Skip to content

Commit ff13855

Browse files
authored
Merge pull request #178 from aligent/release/1.10.0
Release/1.10.0
2 parents 1ba118e + 9a18c34 commit ff13855

File tree

10 files changed

+56
-27
lines changed

10 files changed

+56
-27
lines changed

RELEASE_NOTES.md

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
### Fixes
22

3-
- CartsApi Missing Optional Include Parameter #145 (Thanks @jracek-chl)
4-
- ProductModifierValues was missing value data #150. This is a small breaking change
5-
to the [ProductModifierValue](./blob/main/src/BigCommerce/ResourceModels/Catalog/Product/ProductModifierValue.php)
6-
constructor.
3+
- Fix incorrect endpoint and method for Create Redirect Urls (thanks @Mosnar)
4+
- Updated storeinformation controller to match others (thanks @joelreeds)
5+
- Fixed incorrect endpoint on OrdersApi (thanks @simpleapps-io)
6+
- Handle the case of no orders returned in the V2 api causing error. (Issue #161)
7+
- Fix `preorder_release_date` property type (Issue #162)
8+
- Add `page_title` to Brand (Issue #171)
9+
710

811
### New Features
912

10-
- Implement [Site Routes API](https://developer.bigcommerce.com/api-reference/264af6ae04399-get-a-site-s-routes) #144
13+
- Allow overriding of most Guzzle Client defaults, and also set a timeout

src/BigCommerce/Api/Carts/CartRedirectUrlsApi.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@
3131
*/
3232
class CartRedirectUrlsApi extends UuidResourceWithUuidParentApi
3333
{
34-
private const REDIRECT_URL = 'carts/%d/redirect_urls';
34+
private const REDIRECT_URL = 'carts/%s/redirect_urls';
3535

3636
public function create(): CartRedirectUrlsResponse
3737
{
38-
$response = $this->getClient()->getRestClient()->put(
38+
$response = $this->getClient()->getRestClient()->post(
3939
sprintf(self::REDIRECT_URL, $this->getParentUuid())
4040
);
4141

src/BigCommerce/BaseApiClient.php

+22-13
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ abstract class BaseApiClient
1010
public const DEFAULT_HANDLER = 'handler';
1111
public const DEFAULT_BASE_URI = 'base_uri';
1212
public const DEFAULT_HEADERS = 'headers';
13+
public const DEFAULT_TIMEOUT = 'timeout';
1314

1415
private const HEADERS__AUTH_CLIENT = 'X-Auth-Client';
1516
private const HEADERS__AUTH_TOKEN = 'X-Auth-Token';
@@ -29,36 +30,44 @@ abstract class BaseApiClient
2930

3031
private array $debugContainer = [];
3132

33+
private array $defaultClientOptions = [
34+
self::DEFAULT_TIMEOUT => 45,
35+
self::DEFAULT_HEADERS => [
36+
self::HEADERS__CONTENT_TYPE => self::APPLICATION_JSON,
37+
self::HEADERS__ACCEPT => self::APPLICATION_JSON,
38+
]
39+
];
40+
3241
public function __construct(
3342
string $storeHash,
3443
string $clientId,
3544
string $accessToken,
36-
?\GuzzleHttp\Client $client = null
45+
?\GuzzleHttp\Client $client = null,
46+
?array $clientOptions = []
3747
) {
3848
$this->storeHash = $storeHash;
3949
$this->clientId = $clientId;
4050
$this->accessToken = $accessToken;
4151
$this->setBaseUri(sprintf($this->defaultBaseUrl(), $this->storeHash));
4252

43-
$this->client = $client ?? $this->buildDefaultHttpClient();
53+
$this->client = $client ?? $this->buildDefaultHttpClient($clientOptions);
4454
}
4555

46-
private function buildDefaultHttpClient(): \GuzzleHttp\Client
56+
private function buildDefaultHttpClient(array $clientOptions): \GuzzleHttp\Client
4757
{
4858
$history = Middleware::history($this->debugContainer);
4959
$stack = HandlerStack::create();
5060
$stack->push($history);
5161

52-
return new \GuzzleHttp\Client([
53-
self::DEFAULT_HANDLER => $stack,
54-
self::DEFAULT_BASE_URI => $this->getBaseUri(),
55-
self::DEFAULT_HEADERS => [
56-
self::HEADERS__AUTH_CLIENT => $this->clientId,
57-
self::HEADERS__AUTH_TOKEN => $this->accessToken,
58-
self::HEADERS__CONTENT_TYPE => self::APPLICATION_JSON,
59-
self::HEADERS__ACCEPT => self::APPLICATION_JSON,
60-
],
61-
]);
62+
$options = array_merge($this->defaultClientOptions, $clientOptions);
63+
$options[self::DEFAULT_HANDLER] = $stack;
64+
$options[self::DEFAULT_BASE_URI] = $this->getBaseUri();
65+
$options[self::DEFAULT_HEADERS] = array_merge([
66+
self::HEADERS__AUTH_CLIENT => $this->clientId,
67+
self::HEADERS__AUTH_TOKEN => $this->accessToken,
68+
], $options[self::DEFAULT_HEADERS]);
69+
70+
return new \GuzzleHttp\Client($options);
6271
}
6372

6473
public function getBaseUri(): string

src/BigCommerce/ResourceModels/Catalog/Brand/Brand.php

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class Brand extends ResourceModel
1616
public ?string $meta_description;
1717
public string $image_url;
1818
public string $search_keywords;
19+
public string $page_title;
1920

2021
public function __construct(?stdClass $optionObject = null)
2122
{

src/BigCommerce/ResourceModels/Catalog/Product/Product.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class Product extends ResourceModel
6767
public string $date_created;
6868
public string $date_modified;
6969
public int $view_count;
70-
public ?object $preorder_release_date;
70+
public ?string $preorder_release_date;
7171
public string $preorder_message;
7272
public bool $is_preorder_only;
7373
public bool $is_price_hidden;

src/BigCommerceLegacyApi/Api/Orders/OrdersApi.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class OrdersApi extends V2ApiBase
5353

5454
private const ORDERS_ENDPOINT = 'orders';
5555
private const ORDER_ENDPOINT = 'orders/%d';
56-
private const ORDER_COUNT_ENDPOINT = '/orders/count';
56+
private const ORDER_COUNT_ENDPOINT = 'orders/count';
5757

5858
public function singleResourceUrl(): string
5959
{
@@ -86,6 +86,10 @@ public function getAll(array $filters = [], int $page = 1, int $limit = 250): ar
8686
{
8787
$response = $this->getAllResources($filters, $page, $limit);
8888

89+
if ($response->getStatusCode() === 204) {
90+
return [];
91+
}
92+
8993
return array_map(fn($r) => new OrderResponse($r), json_decode($response->getBody()));
9094
}
9195

src/BigCommerceLegacyApi/Api/StoreInformation/StoreInformationApi.php

+12
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,20 @@ class StoreInformationApi extends V2ApiBase
1515
*
1616
* @return StoreInformation
1717
* @throws \GuzzleHttp\Exception\GuzzleException
18+
* @deprecated Replaced by `get()` function.
1819
*/
1920
public function storeInformation(): StoreInformation
21+
{
22+
return $this->get();
23+
}
24+
25+
/**
26+
* Returns metadata about a store.
27+
*
28+
* @return StoreInformation
29+
* @throws \GuzzleHttp\Exception\GuzzleException
30+
*/
31+
public function get(): StoreInformation
2032
{
2133
$response = $this->getClient()->getRestClient()->get(
2234
self::STORE_INFORMATION_ENDPOINT

tests/BigCommerce/responses/catalog__products__174__get.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"date_created": "2018-08-15T14:48:46+00:00",
6060
"date_modified": "2018-09-05T20:42:07+00:00",
6161
"view_count": 10,
62-
"preorder_release_date": {},
62+
"preorder_release_date": "",
6363
"preorder_message": "",
6464
"is_preorder_only": false,
6565
"is_price_hidden": false,

tests/BigCommerce/responses/catalog__products__get_all.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
"date_created": "2018-08-15T14:48:46+00:00",
6161
"date_modified": "2018-09-05T20:42:07+00:00",
6262
"view_count": 10,
63-
"preorder_release_date": {},
63+
"preorder_release_date": null,
6464
"preorder_message": "",
6565
"is_preorder_only": false,
6666
"is_price_hidden": false,
@@ -168,7 +168,7 @@
168168
"date_created": "2018-08-15T14:48:36+00:00",
169169
"date_modified": "2018-08-20T15:11:17+00:00",
170170
"view_count": 21,
171-
"preorder_release_date": {},
171+
"preorder_release_date": "",
172172
"preorder_message": "",
173173
"is_preorder_only": false,
174174
"is_price_hidden": false,

tests/BigCommerceLegacyApi/Api/StoreInformation/StoreInformationApiTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public function testCanGetStoreInformation(): void
1717
{
1818
$this->setReturnData('storeinformation_store.json');
1919

20-
$information = $this->getApi()->storeInformation()->storeInformation();
20+
$information = $this->getApi()->storeInformation()->get();
2121

2222
$this->assertEquals('BigCommerce', $information->name);
2323
$this->assertEquals('my-awesome.store', $information->domain);
@@ -33,7 +33,7 @@ public function testCanGetStoreInformationForStoreWithNoLogo()
3333
//Weird API design means the logo is set to empty array if no logo present
3434
$this->setReturnData('storeinformation_store__no-logo.json');
3535

36-
$information = $this->getApi()->storeInformation()->storeInformation();
36+
$information = $this->getApi()->storeInformation()->get();
3737

3838
$this->assertEquals('MLITest', $information->name);
3939
$this->assertNull($information->logo);

0 commit comments

Comments
 (0)