Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix vendor dependency #5

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
15 changes: 15 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
build:
environment:
php:
version: 5.4 # Common versions: 5.4, 5.5, 5.6, 7.0 or hhvm
tests:
override:
-
command: 'phpunit -c tests/phpunit.xml --coverage-clover=clover.xml'
coverage:
file: 'clover.xml'
format: 'php-clover'
checks:
php:
custom_coding_standard:
ruleset_path: 'ruleset.xml'
19 changes: 10 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
language: php
php:
- 5.5
- 5.4
- 5.3
- 5.4
- 5.5
- 5.6
- 7
- hhvm
- nightly

matrix:
allow_failures:
- php: 5.5
- php: 7
- php: hhvm
- php: nightly

before_script:
- curl -s http://getcomposer.org/installer | php
- php composer.phar update --no-interaction --dev

script:
- mkdir -p build/logs
- php vendor/bin/phpunit -c tests/phpunit.xml

after_script:
- php vendor/bin/coveralls
# or enable logging
# - php vendor/bin/coveralls -v
- vendor/bin/phpcs --standard=ruleset.xml --runtime-set ignore_warnings_on_exit 1 src
76 changes: 39 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ A PHP interface to the YOTPO API

First clone the repository:

git clone git@github.com:YotpoLtd/yotpo-php.git
git clone https://github.com/YotpoLtd/yotpo-php.git

Then download and install the composer dependencies:

Expand All @@ -24,38 +24,42 @@ Then download and install the composer dependencies:
First [register your application with Yotpo][register]
Then copy and past the app_key and secret

```php
include "yotpo-php/bootstrap.php";
```php5
// Require composer autoloader
require 'vendor/autoload.php';

use Yotpo\Yotpo;
$ak = "APP_KEY";
$st = "SECRET";
$yotpo = new \Yotpo\Yotpo($ak, $st);
$yotpo = new Yotpo($ak, $st);
```
That's it, you are ready.

Now lets make some public calls to our api. Public calls only require you to use a valid app_key.
That's it, you are ready.

Now lets make some public calls to our api. Public calls only require you to use a valid app_key.

Creating your first review using the API

```php
```php5
$yotpo->create_review(array(
'app_key' => $ak,
'product_id' => "BLABLA",
'shop_domain' => "omri.co",
'product_title' => "pt",
'product_description' => "pd",
'product_url' => "http://google.com/?q=myproducturl",
'product_image_url' => "https://www.google.com/images/srpr/logo4w.png",
'user_display_name' => "MOSHE5656",
'user_email' => '[email protected]',
'review_body' => "this is my review body",
'review_title' => "my review title" ,
'review_score' => 5
'app_key' => $ak,
'product_id' => "BLABLA",
'shop_domain' => "omri.co",
'product_title' => "pt",
'product_description' => "pd",
'product_url' => "http://google.com/?q=myproducturl",
'product_image_url' => "https://www.google.com/images/srpr/logo4w.png",
'user_display_name' => "MOSHE5656",
'user_email' => '[email protected]',
'review_body' => "this is my review body",
'review_title' => "my review title",
'review_score' => 5
));
```

and now lets retrieve all the reviews of our product BLABLA

```php
```php5

$response = $yotpo->get_product_reviews(array('app_key' => $ak, 'product_id' => "BLABLA"));

Expand All @@ -65,7 +69,7 @@ echo $response->response->reviews[0]->score;

getting the bottom line of product BLABLA

```php
```php5
$response = $yotpo->get_product_bottom_line(array('app_key' => $ak, 'product_id' => "BLABLA"));

echo $response->response->bottomline->average_score;
Expand All @@ -76,42 +80,40 @@ Now lets try something a little bit more complicated. Lets try to create a purch

For that we will need to go through Yotpo authenticaton process, provide an app_key and secret, and return to get the utoken. The utoken will allow us to make authenticated API calls.

```php

```php5
// retrieving the utoken - will be valid for 24 hours
$credentials = $yotpo->get_oauth_token();
$utoken = $credentials->access_token;

// first creating the products that are in the order, notice that the key of the product hash is the product_sku
$products = array(
"BLABLA1" => array(
'url' => "http://shop.yotpo.com/products/amazing-yotpo-poster",
'name' => "Yotpo Amazing Poster",
'image_url' => "http://cdn.shopify.com/s/files/1/0098/1912/products/qa2_medium.png?41",
'description' => "this is the most awesome poster in the world!",
'url' => "http://shop.yotpo.com/products/amazing-yotpo-poster",
'name' => "Yotpo Amazing Poster",
'image_url' => "http://cdn.shopify.com/s/files/1/0098/1912/products/qa2_medium.png?41",
'description' => "this is the most awesome poster in the world!",
'price' => "100"
)
);


//now we will create a purchase using this the token we have received in the previous step
$response = $yotpo->create_purchase(array( 'app_key' => $ak,
'utoken' => $utoken,
'email' => "[email protected]",
'customer_name' => "bob",
'order_id' => "13444",
'platform' => "Shopify",
'order_date' => "2013-05-28",
'products' => $products,
$response = $yotpo->create_purchase(array( 'app_key' => $ak,
'utoken' => $utoken,
'email' => "[email protected]",
'customer_name' => "bob",
'order_id' => "13444",
'platform' => "Shopify",
'order_date' => "2013-05-28",
'products' => $products,
'currency_iso' => "USD"
));


```

We can pull all the purchases of a certain account to make sure that the previous calls has worked

```php
```php5
$response = $yotpo->get_purchases(array('app_key' => $ak, 'utoken' => $utoken, 'since_date' => "2013-05-26"));
echo $response->response->total_purchases;
```
Expand Down
4 changes: 0 additions & 4 deletions bootstrap.php

This file was deleted.

8 changes: 3 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"keywords": ["rest", "yotpo"],
"homepage": "https://www.yotpo.com",
"license": "MIT",
"version": "0.0.1",
"authors": [
{
"name": "Vladislav Shub",
Expand All @@ -15,15 +14,14 @@
"require": {
"php": ">=5.3.2",
"nategood/httpful": "*"

},
"require-dev": {
"satooshi/php-coveralls": "dev-master",
"phpunit/phpunit": "3.7.*@dev"
"squizlabs/php_codesniffer": "2.*",
"phpunit/phpunit": "4.8.*"
},
"autoload": {
"psr-0": {
"Yotpo": "src/"
}
}
}
}
9 changes: 9 additions & 0 deletions ruleset.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0"?>
<!--suppress XmlUnboundNsPrefix -->
<ruleset name="PHP-SDK">
<description>The QuickPay ruleset based on the PSR-2 coding standard.</description>
<rule ref="PSR2"/>
<rule ref="PSR1.Methods.CamelCapsMethodName.NotCamelCaps">
<severity>0</severity>
</rule>
</ruleset>
67 changes: 0 additions & 67 deletions src/Yotpo/Bootstrap.php

This file was deleted.

Loading