-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit cdcd626
Showing
69 changed files
with
2,919 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
; This file is for unifying the coding style for different editors and IDEs. | ||
; More information at http://editorconfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
indent_size = 4 | ||
indent_style = space | ||
end_of_line = lf | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Path-based git attributes | ||
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html | ||
|
||
# Ignore all test and documentation with "export-ignore". | ||
/.editorconfig export-ignore | ||
/.gitattributes export-ignore | ||
/.gitignore export-ignore | ||
/.scrutinizer.yml export-ignore | ||
/.styleci.yml export-ignore | ||
/.travis.yml export-ignore | ||
/PULL_REQUEST_TEMPLATE.md export-ignore | ||
/ISSUE_TEMPLATE.md export-ignore | ||
/phpcs.xml.dist export-ignore | ||
/phpunit.xml.dist export-ignore | ||
/tests export-ignore | ||
/docs export-ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
build | ||
composer.lock | ||
vendor | ||
phpcs.xml | ||
phpunit.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
build: | ||
nodes: | ||
analysis: | ||
project_setup: | ||
override: true | ||
tests: | ||
override: [php-scrutinizer-run] | ||
|
||
filter: | ||
excluded_paths: [tests/*] | ||
|
||
checks: | ||
php: | ||
remove_extra_empty_lines: true | ||
remove_php_closing_tag: true | ||
remove_trailing_whitespace: true | ||
fix_use_statements: | ||
remove_unused: true | ||
preserve_multiple: false | ||
preserve_blanklines: true | ||
order_alphabetically: true | ||
fix_php_opening_tag: true | ||
fix_linefeed: true | ||
fix_line_ending: true | ||
fix_identation_4spaces: true | ||
fix_doc_comments: true | ||
|
||
tools: | ||
external_code_coverage: | ||
timeout: 600 | ||
runs: 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
dist: trusty | ||
language: php | ||
|
||
php: | ||
- 7.3 | ||
|
||
# This triggers builds to run on the new TravisCI infrastructure. | ||
# See: http://docs.travis-ci.com/user/workers/container-based-infrastructure/ | ||
sudo: false | ||
|
||
## Cache composer | ||
cache: | ||
directories: | ||
- $HOME/.composer/cache | ||
|
||
matrix: | ||
include: | ||
- php: 7.1 | ||
env: 'COMPOSER_FLAGS="--prefer-stable --prefer-lowest"' | ||
|
||
before_script: | ||
- travis_retry composer update ${COMPOSER_FLAGS} --no-interaction --prefer-dist | ||
|
||
script: | ||
- vendor/bin/phpcs --standard=psr2 src/ | ||
- vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover | ||
|
||
after_script: | ||
- | | ||
if [[ "$TRAVIS_PHP_VERSION" != 'hhvm' ]]; then | ||
wget https://scrutinizer-ci.com/ocular.phar | ||
php ocular.phar code-coverage:upload --format=php-clover coverage.clover | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Bol.com Retailer API client for PHP | ||
|
||
This is an open source PHP client for the [Bol.com Retailer API](https://developers.bol.com/newretailerapiv3/). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{ | ||
"name": "picqer/bol-retailer-php-client", | ||
"type": "library", | ||
"description": "Bol.com Retailer API client", | ||
"keywords": [ | ||
"picqer", | ||
"bol-retailer-php-client" | ||
], | ||
"homepage": "https://github.com/picqer/bol-retailer-php-client", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Ramon Kleiss", | ||
"email": "[email protected]", | ||
"homepage": "https://picqer.com", | ||
"role": "Developer" | ||
} | ||
], | ||
"require": { | ||
"php": "~7.1", | ||
"ext-json": "^1.5", | ||
"guzzlehttp/guzzle": "^6.3" | ||
}, | ||
"require-dev": { | ||
"phpstan/phpstan": "^0.11.12", | ||
"phpunit/phpunit": ">=7.0", | ||
"squizlabs/php_codesniffer": "^3.0" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Picqer\\BolRetailer\\": "src" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"Picqer\\BolRetailer\\Tests\\": "tests" | ||
} | ||
}, | ||
"scripts": { | ||
"test": "phpunit", | ||
"check-style": "phpcs src tests", | ||
"fix-style": "phpcbf src tests" | ||
}, | ||
"extra": { | ||
"branch-alias": { | ||
"dev-master": "1.0-dev" | ||
} | ||
}, | ||
"config": { | ||
"sort-packages": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
require_once __DIR__ . '/../vendor/autoload.php'; | ||
|
||
// The first thing you need to do is set the authentication credentials | ||
// of the client otherwise any calls to the Bol.com API will fail. | ||
|
||
Picqer\BolRetailer\Client::setDemoMode(true); | ||
Picqer\BolRetailer\Client::setCredentials( | ||
getenv('CLIENT_ID'), | ||
getenv('CLIENT_SECRET') | ||
); | ||
|
||
// You can fetch all orders by using the `Order::all` method. | ||
// This method return reduced order instances (`Picqer/BolRetailer/Model/ReducedOrder`) | ||
// that contain less information than an order fetched by its identifier. That | ||
// is why we loop over the orders after fetching them. | ||
// | ||
// It is not recommended to do this in production because it will cause you | ||
// to hit the rate limits really fast. For more information about rate | ||
// limiting, see: https://api.bol.com/retailer/public/conventions/index.html | ||
|
||
$reducedOrders = Picqer\BolRetailer\Order::all(); | ||
|
||
foreach ($reducedOrders as $reducedOrder) { | ||
$order = Picqer\BolRetailer\Order::get($reducedOrder->orderId); | ||
|
||
printf( | ||
"Ordered by \"%s %s\":\n", | ||
$order->customerDetails->billingDetails->firstName, | ||
$order->customerDetails->billingDetails->surName | ||
); | ||
|
||
foreach ($order->orderItems as $orderItem) { | ||
printf( | ||
"\t%s:\t%s (%dx) à € %.2f\n", | ||
$orderItem->orderItemId, | ||
$orderItem->title, | ||
$orderItem->quantity, | ||
$orderItem->offerPrice | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
require_once __DIR__ . '/../vendor/autoload.php'; | ||
|
||
// The first thing you need to do is set the authentication credentials | ||
// of the client otherwise any calls to the Bol.com API will fail. | ||
|
||
Picqer\BolRetailer\Client::setDemoMode(true); | ||
Picqer\BolRetailer\Client::setCredentials( | ||
getenv('CLIENT_ID'), | ||
getenv('CLIENT_SECRET') | ||
); | ||
|
||
// Next thing: we need to fetch an order to create a shipment for. | ||
$order = Picqer\BolRetailer\Order::get('1043946570'); | ||
|
||
$processStatus = Picqer\BolRetailer\Shipment::create($order->orderItems[0], [ | ||
'transport' => [ | ||
'transporterCode' => 'TNT', | ||
'trackAndTrace' => '3SBOL0987654321' | ||
] | ||
]); | ||
|
||
// You can now choose to wait until the process completes: | ||
// | ||
// ```php | ||
// $processStatus->waitUntilComplete(20, 3); | ||
// ``` | ||
// | ||
// Since the demo API of Bol.com does not support dynamic process statuses, we will not wait. | ||
|
||
printf("Waiting for process with ID \"%s\"\n", $processStatus->id); | ||
|
||
// You can also opt to create a shipment for an entire order. This will return an array of `ProcessStatus` objects. | ||
|
||
$processStatuses = Picqer\BolRetailer\Shipment::createForOrder($order, [ | ||
'transport' => [ | ||
'transporterCode' => 'TNT', | ||
'trackAndTrace' => '3SBOL0987654321' | ||
] | ||
]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
require_once __DIR__ . '/../vendor/autoload.php'; | ||
|
||
// The first thing you need to do is set the authentication credentials | ||
// of the client otherwise any calls to the Bol.com API will fail. | ||
|
||
Picqer\BolRetailer\Client::setDemoMode(true); | ||
Picqer\BolRetailer\Client::setCredentials( | ||
getenv('CLIENT_ID'), | ||
getenv('CLIENT_SECRET') | ||
); | ||
|
||
// We can create a new offer by using the `Offer::create` method | ||
|
||
$offer = Picqer\BolRetailer\Offer::create([ | ||
"ean" => "0000007740404", | ||
"condition" => [ | ||
"name" => "AS_NEW", | ||
"category" => "SECONDHAND", | ||
"comment" => "Heeft een koffie vlek op de kaft." | ||
], | ||
"referenceCode" => "REF12345", | ||
"onHoldByRetailer" => false, | ||
"unknownProductTitle" => "Unknown Product Title", | ||
"pricing" => [ | ||
"bundlePrices" => [ | ||
[ | ||
"quantity" => 1, | ||
"price" => 9.99 | ||
] | ||
] | ||
], | ||
"stock" => [ | ||
"amount" => 6, | ||
"managedByRetailer" => false | ||
], | ||
"fulfilment" => [ | ||
"type" => "FBR", | ||
"deliveryCode" => "24uurs-23" | ||
] | ||
]); | ||
|
||
// You can use the update method to update offers. This will return a process status because it runs asynchronously. | ||
// To update the stock level of an offer, you can use the `updateStock` method. | ||
|
||
$offer = Picqer\BolRetailer\Offer::get('13722de8-8182-d161-5422-4a0a1caab5c8'); | ||
$processStatus = $offer->updateStock(5, true); | ||
|
||
// Wait until the process is complete. | ||
// $processStatus->waitUntilComplete(); | ||
|
||
// And refresh the offer model | ||
$offer->refresh(); | ||
printf("Current stock level: %d\n", $offer->stock->amount); | ||
|
||
// And you can also delete an offer. | ||
$offer->delete(); | ||
|
||
// And finally, to get an offer by its ID you can do the same as with orders | ||
$offer = Picqer\BolRetailer\Offer::get('13722de8-8182-d161-5422-4a0a1caab5c8'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0"?> | ||
<ruleset name="bol-retailer-php-client"> | ||
<description>The coding standard of bol-retailer-php-client package</description> | ||
<arg value="p" /> | ||
|
||
<config name="ignore_warnings_on_exit" value="1" /> | ||
<config name="ignore_errors_on_exit" value="1" /> | ||
|
||
<arg name="colors" /> | ||
<arg value="s" /> | ||
|
||
<!-- Use the PSR2 Standard--> | ||
<rule ref="PSR2" /> | ||
</ruleset> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit bootstrap="vendor/autoload.php" | ||
backupGlobals="false" | ||
backupStaticAttributes="false" | ||
colors="true" | ||
verbose="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false"> | ||
<testsuites> | ||
<testsuite name="picqer Test Suite"> | ||
<directory>tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
<filter> | ||
<whitelist> | ||
<directory suffix=".php">src/</directory> | ||
</whitelist> | ||
</filter> | ||
<logging> | ||
<log type="junit" target="build/report.junit.xml"/> | ||
<log type="coverage-html" target="build/coverage"/> | ||
<log type="coverage-text" target="build/coverage.txt"/> | ||
<log type="coverage-clover" target="build/logs/clover.xml"/> | ||
</logging> | ||
</phpunit> |
Oops, something went wrong.