From 37613bed793cc77950602f279aa5d3dd9e38389f Mon Sep 17 00:00:00 2001 From: Patrick Rodacker Date: Mon, 26 Aug 2019 10:56:32 +0200 Subject: [PATCH 1/2] update readme to include information about client implementation --- README.md | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index aac5101f..c04e631c 100644 --- a/README.md +++ b/README.md @@ -9,13 +9,23 @@ - PHP >= 7.1 (extension requirements in composer.json). ## Installation -Use [composer](https://getcomposer.org/?target=_blank) to install the package +The sdk uses the [httplug](http://docs.php-http.org/en/latest/httplug/introduction.html) library for the http client implementation, +so you will need to install a library that provides the virtual `php-http/client-implementation` composer package, e.g. `php-http/guzzle6-adapter`. + +Use [composer](https://getcomposer.org/?target=_blank) to install a http client of your choice + +```bash +$ composer require php-http/guzzle6-adapter +``` + +and the sdk itself: + ```bash $ composer require starweb/shop-api-sdk ``` # Documentation -The Starweb Shop API SDK uses an auto generated client +The Starweb Shop API SDK uses an auto generated client based on [Jane](https://jane.readthedocs.io/) at its core. # Issues Please use the [issue tracker](https://github.com/starweb/shop-api-sdk-php/issues?target=_blank) if you find any issues. From 4d418d6aec0514368a913ab8021b5c0db67f24f9 Mon Sep 17 00:00:00 2001 From: Patrick Rodacker Date: Tue, 27 Aug 2019 08:30:43 +0200 Subject: [PATCH 2/2] adds example how to create the sdk and call operations on the client --- README.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/README.md b/README.md index c04e631c..23f85b56 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,33 @@ $ composer require starweb/shop-api-sdk # Documentation The Starweb Shop API SDK uses an auto generated client based on [Jane](https://jane.readthedocs.io/) at its core. +All you need to get started with the sdk is to create an instance of [`ClientCredentials`](src/Api/Authentication/ClientCredentials.php) passing your client id and client secret to the constructor. +Together with your APIs base url you can than use the static factory method to create the sdk: + + $credentials = new ClientCredentials('my-client-id', 'my-client-secret'); + $starweb = Starweb::create($credentials, 'https://my-shop.starwebserver.se/api/v2'); + +**Make sure to store your credentials in a secure way**. We recommend using environment variables. + +Once you have the sdk created you can get the client and start using it: + + // get the client from the sdk + $client = $starweb->getClient(); + + // fetch products + $products = $client->listProducts(); + + /** + * @see \Starweb\Api\Generated\Model\ProductModelCollection + * @see \Starweb\Api\Generated\Model\ProductModel + */ + foreach($products->getData() as $product) { + $categories = $product->getCategories(); + } + + // get a single product + $product = $client->getProduct(123); + # Issues Please use the [issue tracker](https://github.com/starweb/shop-api-sdk-php/issues?target=_blank) if you find any issues.