Skip to content

Commit

Permalink
Update to v2.0.0 (#49)
Browse files Browse the repository at this point in the history
* Refactored the structure and rewrote the unit tests (#35)

* Added phpstan for static code analysis (#36)

Added phpstan for static code analysis

* Updated the min. PHP Version to 7.3 and updated updated the PHPUnit package (#37)

* Copyright updated and php constraints updated

* Changelog updated

* Changed the required PHP CPU architecture to 64bit

* Updated the CHANGELOG.md

* Updated Guzzle to v7.4.0 and psr/log to v1.1.0 (#48)

* Updated Guzzle to v7.4.0 and psr/log to v1.1.0

* Renamed BillbeeClient to CustomClient

* Updated the API endpoint and added the Changelog entry

* Merge master in 2.0.0 (#50)

* Update usage_without_composer.md

* URL encode path parameters

* Added missing mappings and a patch function (#40)

Added:
- `Client::patchAddress()`
- Mapping for `Address::$id`
- Mapping for `Order::$payments`
- `Payment` model

* Update CHANGELOG.md

Co-authored-by: fkunz <[email protected]>

* Merge remote-tracking branch 'origin/master' into 2.0.0

# Conflicts:
#	CHANGELOG.md
#	src/Client.php

Co-authored-by: fkunz <[email protected]>
  • Loading branch information
devtronic and fkunz authored Oct 28, 2021
1 parent 2df7c16 commit 07409bc
Show file tree
Hide file tree
Showing 132 changed files with 4,383 additions and 3,134 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
program.php
output.log
/doc/*
!/doc/sami.php
/.php_cs.cache
/.phpunit.result.cache
45 changes: 36 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## v2.0.0 (28 Oct 2021)

- Updated guzzlehttp/guzzle to V7.4.0
- Updated psr/log to 1.1.0
- Updated the Billbee API Endpoint

## v1.9.0 (1 Jun 2021)

New Features:
Expand All @@ -12,19 +18,42 @@ New Features:
## v1.8.3 (4 May 2021)

Bugfixes
- URL encode the `$extRef` in `getOrderByOrderNumber` and the `$externalId` in `getOrderByPartner` before sending the request to the API.
- URL encode the `$extRef` in `getOrderByOrderNumber` and the `$externalId` in `getOrderByPartner` before sending the request to the API.

## v2.0.0-RC3 (21 Apr 2021)

Changed the required PHP CPU architecture to 64bit

## v2.0.0-RC2 (15 Mar 2021)

Updated from master

## v1.8.2 (15 Mar 2021)

Bugfixes
- SoldAmount fixed ([PR #39](https://github.com/billbeeio/billbee-php-sdk/pull/39))

## v2.0.0-RC1 (22 Feb 2021)

_See [UPGRADE.md](UPGRADE.md) for migration details._

New Features
- PHP 8 added to composer.json

Misc:
- Copyright updated ([PR #34](https://github.com/billbeeio/billbee-php-sdk/pull/34))
- Added phpstan for static code analysis ([PR #36](https://github.com/billbeeio/billbee-php-sdk/pull/36))

Breaking changes:
- The code has been reorganized. The client does not implement the endpoints directly anymore. ([PR #35](https://github.com/billbeeio/billbee-php-sdk/pull/35))
-Updated the min. PHP Version to 7.3 ([PR #37](https://github.com/billbeeio/billbee-php-sdk/pull/37))

## v1.8.1 (22 Feb 2021)

New Features
- PHP 8 added to composer.json

## 1.8.0 (9 Dec 2019)
## v1.8.0 (9 Dec 2019)

New features:
- `DELETE /api/v1/products/{id}` added. (`Client::deleteProduct($id)`) ([PR #31](https://github.com/billbeeio/billbee-php-sdk/pull/31))
Expand All @@ -33,11 +62,11 @@ New features:
- `Product::$widthCm`
- `Product::$lengthCm`
- `Product::$heightCm`
- `Product::$billOfMaterial`
- `Product::$billOfMaterial`
- `GET /api/v1/products/PatchableFields` added. (`Client::getPatchableProductFields()`) ([PR #33](https://github.com/billbeeio/billbee-php-sdk/pull/33))
- `PATCH /api/v1/products/{id}` added. (`Client::patchProduct($productId, $model)`) ([PR #33](https://github.com/billbeeio/billbee-php-sdk/pull/33))

## 1.7.0 (15 Nov 2019)
## v1.7.0 (15 Nov 2019)
New features:
- `GET /api/v1/cloudstorages` added. (`Client::getCloudStorages()`) ([PR #18](https://github.com/billbeeio/billbee-php-sdk/pull/18))
- `GET /api/v1/products/category` added. (`Client::getCategories()`) ([PR #19](https://github.com/billbeeio/billbee-php-sdk/pull/19))
Expand All @@ -55,15 +84,15 @@ Misc:
- Added a code documentation generator ([PR #24](https://github.com/billbeeio/billbee-php-sdk/pull/24))
- Fixed code style ([PR #24](https://github.com/billbeeio/billbee-php-sdk/pull/24))

## 1.6.2 (16 Sep 2019)
## v1.6.2 (16 Sep 2019)

New features:
- Added the `SoldProduct` model which is used in `OrderItem::$product`

Bug Fixes:
- Added a mapping for `Order::$paymentTransactionId` and `Order::$deliverySourceCountryCode`

## 1.6.1 (24 Jul 2019)
## v1.6.1 (24 Jul 2019)

Bug Fixes:
- Fixed `use-before-initialize` bug in the `Client::__construct` ([PR #15](https://github.com/billbeeio/billbee-php-sdk/pull/15))
Expand Down Expand Up @@ -121,7 +150,7 @@ General:

## v1.1.4 (23 Aug 2018)

- `articleTitleSource` and `excludeTags` arguments added to `getOrders()` ([PR #5](https://github.com/billbeeio/billbee-php-sdk/pull/5))
- `articleTitleSource` and `excludeTags` arguments added to `getOrders()` ([PR #5](https://github.com/billbeeio/billbee-php-sdk/pull/5))
- `AutosubtractReservedAmount` parameter added to stock model
- Customer Endpoints implemented
- Links updated from `app01.billbee.de` to `app.billbee.io`
Expand All @@ -131,8 +160,6 @@ General:
- Code folding optimized
- Imports optimized



## v1.1.3 (20 Aug 2018)
- `/api/v1/products/custom-fields` endpoints added
- `/api/v1/webhooks` endpoints added
Expand Down
34 changes: 21 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,34 @@ $ composer require billbee/billbee-api
## Usage

Simply instantiate a client object for accessing the api:

```php
<?php

use BillbeeDe\BillbeeAPI\Client;

$user = 'Your Billbee username';
$apiPassword = 'Your Billbee API Password'; // https://app.billbee.io/de/settings/api
$apiKey = 'Your Billbee API Key';

$client = new \BillbeeDe\BillbeeAPI\Client($user, $apiPassword, $apiKey);
$client = new Client($user, $apiPassword, $apiKey);
```

## Example: Retrieve a list of products

```php
<?php

use BillbeeDe\BillbeeAPI\Client;

$user = 'Your Billbee username';
$apiPassword = 'Your Billbee API Password'; // https://app.billbee.io/de/settings/api
$apiKey = 'Your Billbee API Key';

$client = new \BillbeeDe\BillbeeAPI\Client($user, $apiPassword, $apiKey);
$client = new Client($user, $apiPassword, $apiKey);

/** @var \BillbeeDe\BillbeeAPI\Response\GetProductsResponse $productsResponse */
$productsResponse = $client->getProducts($page = 1, $pageSize = 10);
$productsResponse = $client->products()->getProducts($page = 1, $pageSize = 10);

/** @var \BillbeeDe\BillbeeAPI\Model\Product $product */
foreach ($productsResponse->data as $product) {
Expand All @@ -56,35 +62,37 @@ foreach ($productsResponse->data as $product) {
```

## Example: Batch requests
```php

```php
<?php

use BillbeeDe\BillbeeAPI\Client;
use BillbeeDe\BillbeeAPI\Response;

$user = 'Your Billbee username';
$apiPassword = 'Your Billbee API Password'; // https://app.billbee.io/de/settings/api
$apiKey = 'Your Billbee API Key';

$client = new \BillbeeDe\BillbeeAPI\Client($user, $apiPassword, $apiKey);
$client->useBatching = true; # Enable batching
$client = new Client($user, $apiPassword, $apiKey);
$client->enableBatchMode();

$client->getProducts(1, 1); # Adds the request to the batch pool / returns null
$client->getOrders(1, 1); # Adds the request to the batch pool / returns null
$client->getEvents(1, 1); # Adds the request to the batch pool / returns null
$client->products()->getProducts(1, 1); # Adds the request to the batch pool / returns null
$client->orders()->getOrders(1, 1); # Adds the request to the batch pool / returns null
$client->events()->getEvents(1, 1); # Adds the request to the batch pool / returns null

$results = $client->executeBatch(); # Results contain all responses in the added order

/** @var \BillbeeDe\BillbeeAPI\Response\GetProductsResponse $productsResult */
/** @var Response\GetProductsResponse $productsResult */
$productsResult = $results[0];

/** @var \BillbeeDe\BillbeeAPI\Response\GetOrdersResponse $ordersResult */
/** @var Response\GetOrdersResponse $ordersResult */
$ordersResult = $results[1];

/** @var \BillbeeDe\BillbeeAPI\Response\GetEventsResponse $eventsResult */
/** @var Response\GetEventsResponse $eventsResult */
$eventsResult = $results[2];
```

## Testing
Clone the repository, copy the `test_config.dist.yml` to `test_config.yml` and fill it.
Run `phpunit`

## Contributing
Expand Down
100 changes: 100 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Migration Guide

## Minimum PHP Version
Since PHP 5.6 - PHP 7.1 isn't supported anymore and the PHP 7.2 Security support ends in Nov 2020 the minimal PHP Version
was increased to 7.3.

## `Client::$useBatching`

This field was made private. The Client itself implements the `\BillbeeDe\BillbeeAPI\BatchClientInterface`. Use the
following methods for migration

- `BatchClientInterface::enableBatchMode()`
- `BatchClientInterface::disableBatchMode()`
- `BatchClientInterface::isBatchModeEnabled()`

## Endpoints

The client does not implement the request actions anymore. Instead, we provide "Endpoints" which groups the requests by
its topic. This change was made for testing purposes.

### `Client::cloudStorages()` (`CloudStorageEndpoint`)
Former methods:
- `Client::getCloudStorages()`

### `Client::customers()` (`CustomersEndpoint`)
Former methods:
- `Client::getCustomers()`
- `Client::getCustomer()`
- `Client::getCustomerAddresses()`
- `Client::getCustomerAddress()`
- `Client::getCustomerOrders()`
- `Client::createCustomer()`
- `Client::updateCustomer()`

### `Client::events()` (`EventsEndpoint`)
Former methods:
- `Client::getEvents()`

### `Client::invoices()` (`InvoiceEndpoint`)
Former methods:
- `Client::getInvoices()`

### `Client::layouts()` (`LayoutsEndpoint`)
Former methods:
- `Client::getLayouts()`

### `Client::orders()` (`OrdersEndpoint`)
Former methods:
- `Client::getOrders()`
- `Client::getPatchableFields()`
- `Client::getOrder()`
- `Client::getOrderByOrderNumber()`
- `Client::getOrderByPartner()`
- `Client::createOrder()`
- `Client::addOrderTags()`
- `Client::addOrderShipment()`
- `Client::createDeliveryNote()`
- `Client::createInvoice()`
- `Client::sendMessage()`
- `Client::setOrderTags()`
- `Client::setOrderState()`
- `Client::patchOrder()`

### `Client::productCustomFields()` (`ProductCustomFieldsEndpoint`)
Former methods:
- `Client::getCustomFieldDefinitions()`
- `Client::getCustomFieldDefinition()`

### `Client::products()` (`ProductsEndpoint`)
Former methods:
- `Client::updateStock()`
- `Client::updateStockMultiple()`
- `Client::updateStockCode()`
- `Client::createProduct()`
- `Client::patchProduct()`
- `Client::deleteProduct()`

### `Client::provisioning()` (`ProvisioningEndpoint`)
Former methods:
- `Client::getTermsInfo()`

### `Client::search()` (`SearchEndpoint`)
Former methods:
- `Client::search()`

### `Client::shipments()` (`ShipmentsEndpoint`)
Former methods:
- `Client::getShippingProviders()`
- `Client::shipWithLabel()`

### `Client::webHooks()` (`WebHooksEndpoint`)
Former methods:
- `Client::getWebHooks()`
- `Client::getWebHook()`
- `Client::getWebHookFilters()`
- `Client::createWebHook()`
- `Client::updateWebHook()`
- `Client::deleteAllWebHooks()`
- `Client::deleteWebHookById()`
- `Client::deleteWebHook()`
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
"description": "The official Billbee API SDK for PHP",
"type": "library",
"require": {
"php": "5.6.* || ^7.0 || ^8.0",
"php-64bit": "^7.3 || ^8.0",
"ext-curl": "*",
"ext-json": "*",
"mintware-de/data-model-mapper": "^1.0",
"mintware-de/dmm-json": "^1.0",
"guzzlehttp/guzzle": "^6.3",
"psr/log": "^1.0"
"guzzlehttp/guzzle": "^7.4.0",
"psr/log": "^1.1.0"
},
"require-dev": {
"phpunit/phpunit": "~5.7",
"symfony/yaml": "~3.3",
"friendsofphp/php-cs-fixer": "^2.15"
"phpunit/phpunit": "^9.4.1",
"friendsofphp/php-cs-fixer": "^2.15",
"phpstan/phpstan": "^0.12.49"
},
"license": "MIT",
"authors": [
Expand All @@ -35,7 +35,7 @@
"php-cs-fixer fix ./src/ --using-cache=no --rules=@PSR2",
"php-cs-fixer fix ./tests/ --using-cache=no --rules=@PSR2"
],
"generate-doc": "sami update doc/sami.php"
"analyse": "phpstan analyse"
},
"archive": {
"exclude": [
Expand Down
54 changes: 0 additions & 54 deletions doc/sami.php

This file was deleted.

Loading

0 comments on commit 07409bc

Please sign in to comment.