Skip to content

Commit 01484e8

Browse files
authored
Merge pull request #133 from aligent/fix/store-information-no-logo
Fix/store information no logo
2 parents ee781db + 37485a9 commit 01484e8

File tree

3 files changed

+87
-1
lines changed

3 files changed

+87
-1
lines changed

src/BigCommerceLegacyApi/ResourceModels/StoreInformation/StoreInformation.php

+10-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace BigCommerce\ApiV2\ResourceModels\StoreInformation;
44

55
use BigCommerce\ApiV3\ResourceModels\ResourceModel;
6+
use stdClass;
67

78
class StoreInformation extends ResourceModel
89
{
@@ -37,8 +38,16 @@ class StoreInformation extends ResourceModel
3738
public string $plan_name;
3839
public string $plan_level;
3940
public string $industry;
40-
public object $logo;
41+
public ?object $logo;
4142
public string $is_price_entered_with_tax;
4243
public array $active_comparison_modules;
4344
public object $features;
45+
46+
public function __construct(?stdClass $optionObject = null)
47+
{
48+
if (isset($optionObject->logo) && is_array($optionObject->logo)) {
49+
$optionObject->logo = null;
50+
}
51+
parent::__construct($optionObject);
52+
}
4453
}

tests/BigCommerceLegacyApi/Api/StoreInformation/StoreInformationApiTest.php

+16
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,21 @@ public function testCanGetStoreInformation(): void
2121

2222
$this->assertEquals('BigCommerce', $information->name);
2323
$this->assertEquals('my-awesome.store', $information->domain);
24+
$this->assertEquals(
25+
'https://cdn8.bigcommerce.com/s-{store_hash}/product_images/'
26+
. 'screen_shot_2018-05-15_at_12.22.26_pm__05547_1529512135.png',
27+
$information->logo->url
28+
);
29+
}
30+
31+
public function testCanGetStoreInformationForStoreWithNoLogo()
32+
{
33+
//Weird API design means the logo is set to empty array if no logo present
34+
$this->setReturnData('storeinformation_store__no-logo.json');
35+
36+
$information = $this->getApi()->storeInformation()->storeInformation();
37+
38+
$this->assertEquals('MLITest', $information->name);
39+
$this->assertNull($information->logo);
2440
}
2541
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
"id": "amkfvuhbq3",
3+
"account_uuid": "b73387ce-abxc-4e78-8b82-9b1d06f19ea2",
4+
"domain": "mlitest.mybigcommerce.com",
5+
"secure_url": "https://mli.mybigcommerce.com",
6+
"control_panel_base_url": "https://store-ioufvuhbq5.mybigcommerce.com",
7+
"status": "prelaunch",
8+
"name": "MLITest",
9+
"first_name": "Jarrod",
10+
"last_name": "Swift",
11+
"address": "",
12+
"country": "Australia",
13+
"country_code": "AU",
14+
"phone": "",
15+
"admin_email": "[email protected]",
16+
"order_email": "[email protected]",
17+
"favicon_url": "https://cdn11.bigcommerce.com/r-8e9780100977368b96291d000214555c233b72c/img/bc_favicon.ico",
18+
"timezone": {
19+
"name": "Europe/London",
20+
"raw_offset": 0,
21+
"dst_offset": 0,
22+
"dst_correction": false,
23+
"date_format": {
24+
"display": "jS M Y",
25+
"export": "jS M Y",
26+
"extended_display": "jS M Y @ g:i A"
27+
}
28+
},
29+
"language": "en",
30+
"currency": "AUD",
31+
"currency_symbol": "$",
32+
"decimal_separator": ".",
33+
"thousands_separator": ",",
34+
"decimal_places": 2,
35+
"currency_symbol_location": "left",
36+
"weight_units": "KGS",
37+
"dimension_units": "Centimeters",
38+
"dimension_decimal_places": 2,
39+
"dimension_decimal_token": ".",
40+
"dimension_thousands_token": ",",
41+
"plan_name": "Partner Sandbox",
42+
"plan_level": "Sandbox Store",
43+
"plan_is_trial": false,
44+
"industry": "Animals & Pet Supplies",
45+
"logo": [],
46+
"is_price_entered_with_tax": true,
47+
"store_id": 1002483486,
48+
"default_site_id": 1000,
49+
"default_channel_id": 1,
50+
"active_comparison_modules": [],
51+
"features": {
52+
"stencil_enabled": true,
53+
"sitewidehttps_enabled": true,
54+
"facebook_catalog_id": "",
55+
"checkout_type": "optimized",
56+
"wishlists_enabled": true,
57+
"graphql_storefront_api_enabled": true,
58+
"shopper_consent_tracking_enabled": false,
59+
"multi_storefront_enabled": true
60+
}
61+
}

0 commit comments

Comments
 (0)