Skip to content

Commit

Permalink
1) Fixed bug: user meant to be 'user' at create_user api method
Browse files Browse the repository at this point in the history
2) change build target destination to base dir to prevent exception in case download dir doesn't exist
3) Add option to set api and secret, which come in hand in case we create a user.
4) Add minimum requirments for using this library, was checked by CompatInfo lib.
  • Loading branch information
alonbr committed Jul 7, 2013
1 parent 4339e71 commit 034c8a8
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 9 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
/nbproject
/downloads
.DS_Store
.buildpath
.project
.settings/
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ yotpo-php

A PHP interface to the YOTPO API


## Requirements

* YOTPO API requires PHP 5.3.0 (or later).

## Installation

Add this line to your application's Gemfile:
Expand Down
2 changes: 1 addition & 1 deletion build
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function exit_unless($condition, $msg = null) {
echo "Building Yotpo Phar... ";
$base_dir = dirname(__FILE__);
$source_dir = $base_dir . '/src/Yotpo';
$phar_path = $base_dir . '/downloads/yotpo.phar';
$phar_path = $base_dir . '/yotpo.phar';
echo $phar_path;
$phar = new Phar($phar_path, 0, 'yotpo.phar');
$stub = <<<HEREDOC
Expand Down
24 changes: 16 additions & 8 deletions src/Yotpo/Yotpo.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,9 @@ class Yotpo {
protected static $app_key, $secret, $base_uri = 'https://api.yotpo.com';

public function __construct($app_key = null, $secret = null, $base_uri = null) {
if ($app_key != null) {
self::$app_key = $app_key;
}

if ($secret != null) {
self::$secret = $secret;
}
$this->set_app_key($app_key);

$this->set_secret($secret);

if ($base_uri != null) {
self::$base_uri = $base_uri;
Expand Down Expand Up @@ -86,7 +82,7 @@ public function create_user(array $user_hash) {
'callback_url' => $user_hash['callback_url'],
'url' => $user_hash['url']
);
return $this->post('/users', array(user => $user));
return $this->post('/users', array('user' => $user));
}

public function get_oauth_token(array $credentials_hash = array()) {
Expand Down Expand Up @@ -247,6 +243,18 @@ public function get_product_bottom_line(array $request_hash) {
return $this->get("/products/$app_key/$product_id/bottomline");
}

public function set_app_key($app_key) {
if ($app_key != null) {
self::$app_key = $app_key;
}
}

public function set_secret($secret) {
if ($secret != null) {
self::$secret = $secret;
}
}

protected function get_app_key($hash){
if(!is_null($hash) && !empty($hash) && array_key_exists('app_key', $hash)){
return $hash['app_key'];
Expand Down
Binary file added yotpo.phar
Binary file not shown.

0 comments on commit 034c8a8

Please sign in to comment.