From 170bc1ecada43d83e42183f4384826c694323940 Mon Sep 17 00:00:00 2001 From: Jarrod Swift Date: Fri, 31 Mar 2023 14:03:04 +1030 Subject: [PATCH 1/4] Fix unspecified properties in resource classes Fix mistake in metafields response data #201 --- .../Catalog/Product/Product.php | 2 + .../StoreInformation/StoreInformation.php | 5 ++ .../ResponseModels/Order/Order.php | 8 ++ .../ResponseModels/Order/OrderProduct.php | 9 +++ .../Api/Catalog/ProductsApiTest.php | 8 ++ ...alog__brands__11__metafields__get_all.json | 8 +- ..._categories__111__metafields__get_all.json | 8 +- .../responses/catalog__products__77__get.json | 80 +++++++++++++++++++ .../orders__1__metafields__get_all.json | 8 +- 9 files changed, 124 insertions(+), 12 deletions(-) create mode 100644 tests/BigCommerce/responses/catalog__products__77__get.json diff --git a/src/BigCommerce/ResourceModels/Catalog/Product/Product.php b/src/BigCommerce/ResourceModels/Catalog/Product/Product.php index f37b30fe..176d4303 100644 --- a/src/BigCommerce/ResourceModels/Catalog/Product/Product.php +++ b/src/BigCommerce/ResourceModels/Catalog/Product/Product.php @@ -81,6 +81,8 @@ class Product extends ResourceModel public bool $open_graph_use_image; public int $reviews_rating_sum; public int $total_sold; + + /** * @var CustomField[]|null */ diff --git a/src/BigCommerceLegacyApi/ResourceModels/StoreInformation/StoreInformation.php b/src/BigCommerceLegacyApi/ResourceModels/StoreInformation/StoreInformation.php index 8aa9feb0..08971bf4 100644 --- a/src/BigCommerceLegacyApi/ResourceModels/StoreInformation/StoreInformation.php +++ b/src/BigCommerceLegacyApi/ResourceModels/StoreInformation/StoreInformation.php @@ -42,6 +42,11 @@ class StoreInformation extends ResourceModel public string $is_price_entered_with_tax; public array $active_comparison_modules; public object $features; + public int $default_channel_id; + public int $default_site_id; + public int $store_id; + public bool $plan_is_trial; + public string $account_uuid; public function __construct(?stdClass $optionObject = null) { diff --git a/src/BigCommerceLegacyApi/ResponseModels/Order/Order.php b/src/BigCommerceLegacyApi/ResponseModels/Order/Order.php index 3aa33598..93d854ed 100644 --- a/src/BigCommerceLegacyApi/ResponseModels/Order/Order.php +++ b/src/BigCommerceLegacyApi/ResponseModels/Order/Order.php @@ -59,6 +59,7 @@ class Order extends ResourceModel public string $handling_cost_ex_tax; public string $handling_cost_inc_tax; public string $ip_address; + public string $ip_address_v6; public bool $is_deleted; public int $items_shipped; public int $items_total; @@ -77,6 +78,13 @@ class Order extends ResourceModel public string $total_inc_tax; public string $wrapping_cost_ex_tax; public string $wrapping_cost_inc_tax; + public string $custom_status; + public string $total_tax; + public ?string $credit_card_type; + public ?string $external_merchant_id; + public string $store_default_currency_code; + public string $store_default_to_transactional_exchange_rate; + public function __construct(?stdClass $optionObject = null) diff --git a/src/BigCommerceLegacyApi/ResponseModels/Order/OrderProduct.php b/src/BigCommerceLegacyApi/ResponseModels/Order/OrderProduct.php index b5fd98eb..50acaca8 100644 --- a/src/BigCommerceLegacyApi/ResponseModels/Order/OrderProduct.php +++ b/src/BigCommerceLegacyApi/ResponseModels/Order/OrderProduct.php @@ -52,6 +52,15 @@ class OrderProduct extends \BigCommerce\ApiV3\ResourceModels\ResourceModel public ?string $upc; public ?int $variant_id; public string $name_merchant; + public int $product_id; + public string $base_total; + public string $total_ex_tax; + public string $total_inc_tax; + public string $total_tax; + public string $quantity_refunded; + public string $refund_amount; + public string $fulfillment_source; + public array $configurable_fields; public function __construct(?stdClass $optionObject = null) { diff --git a/tests/BigCommerce/Api/Catalog/ProductsApiTest.php b/tests/BigCommerce/Api/Catalog/ProductsApiTest.php index 1c9682b1..e1f4760e 100644 --- a/tests/BigCommerce/Api/Catalog/ProductsApiTest.php +++ b/tests/BigCommerce/Api/Catalog/ProductsApiTest.php @@ -35,6 +35,14 @@ public function testCanGetProduct(): void $this->assertEquals('include_fields=weight%2Cwidth', $this->getLastRequest()->getUri()->getQuery()); } + public function testCanGetProductWithoutError(): void + { + $this->setReturnData('catalog__products__77__get.json'); + $product = $this->getApi()->catalog()->product(77)->get()->getProduct(); + $this->assertEquals(77, $product->id); + $this->assertEquals('SLCTBS', $product->sku); + } + public function testCanGetAllPagesForProducts(): void { $this->setReturnData('catalog__products__get_all.json'); diff --git a/tests/BigCommerce/responses/catalog__brands__11__metafields__get_all.json b/tests/BigCommerce/responses/catalog__brands__11__metafields__get_all.json index ca27ae24..af7f0eaa 100644 --- a/tests/BigCommerce/responses/catalog__brands__11__metafields__get_all.json +++ b/tests/BigCommerce/responses/catalog__brands__11__metafields__get_all.json @@ -9,8 +9,8 @@ "resource_type": "brand", "resource_id": 111, "id": 6, - "created_at": "1973-01-20T21:34:57.903Z", - "updated_at": "1990-12-30T00:29:23.515Z" + "date_created": "1973-01-20T21:34:57.903Z", + "date_updated": "1990-12-30T00:29:23.515Z" }, { "permission_set": "read", @@ -21,8 +21,8 @@ "resource_type": "brand", "resource_id": 111, "id": 6, - "created_at": "1973-01-20T21:34:57.903Z", - "updated_at": "1990-12-30T00:29:23.515Z" + "date_created": "1973-01-20T21:34:57.903Z", + "date_updated": "1990-12-30T00:29:23.515Z" } ], "meta": { diff --git a/tests/BigCommerce/responses/catalog__categories__111__metafields__get_all.json b/tests/BigCommerce/responses/catalog__categories__111__metafields__get_all.json index ca27ae24..af7f0eaa 100644 --- a/tests/BigCommerce/responses/catalog__categories__111__metafields__get_all.json +++ b/tests/BigCommerce/responses/catalog__categories__111__metafields__get_all.json @@ -9,8 +9,8 @@ "resource_type": "brand", "resource_id": 111, "id": 6, - "created_at": "1973-01-20T21:34:57.903Z", - "updated_at": "1990-12-30T00:29:23.515Z" + "date_created": "1973-01-20T21:34:57.903Z", + "date_updated": "1990-12-30T00:29:23.515Z" }, { "permission_set": "read", @@ -21,8 +21,8 @@ "resource_type": "brand", "resource_id": 111, "id": 6, - "created_at": "1973-01-20T21:34:57.903Z", - "updated_at": "1990-12-30T00:29:23.515Z" + "date_created": "1973-01-20T21:34:57.903Z", + "date_updated": "1990-12-30T00:29:23.515Z" } ], "meta": { diff --git a/tests/BigCommerce/responses/catalog__products__77__get.json b/tests/BigCommerce/responses/catalog__products__77__get.json new file mode 100644 index 00000000..eeb5d8f3 --- /dev/null +++ b/tests/BigCommerce/responses/catalog__products__77__get.json @@ -0,0 +1,80 @@ +{ + "data": { + "id": 77, + "name": "[Sample] Fog Linen Chambray Towel - Beige Stripe", + "type": "physical", + "sku": "SLCTBS", + "description": "

The perfect beach towel: thin, lightweight and highly absorbent. Crafted by Fog Linen in Japan using soft Lithuanian linen, each towel rolls up for compact stowaway. Dry off after a refreshing dip in the ocean and stretch out on it for a sun bath. The thinness ensures a quick dry so you can have it rolled back up in your bag without soaking your belongings.

\n

Measures 75 x 145 cm/29.5 x 57 in

\n

100% Linen

", + "weight": 1, + "width": 0, + "depth": 0, + "height": 0, + "price": 49, + "cost_price": 0, + "retail_price": 0, + "sale_price": 0, + "map_price": 0, + "tax_class_id": 0, + "product_tax_code": "", + "calculated_price": 49, + "categories": [ + 18, + 23 + ], + "brand_id": 70, + "option_set_id": 18, + "option_set_display": "right", + "inventory_level": 0, + "inventory_warning_level": 0, + "inventory_tracking": "none", + "reviews_rating_sum": 0, + "reviews_count": 0, + "total_sold": 4, + "fixed_cost_shipping_price": 0, + "is_free_shipping": false, + "is_visible": true, + "is_featured": false, + "related_products": [ + -1 + ], + "warranty": "", + "bin_picking_number": "", + "layout_file": "product.html", + "upc": "", + "mpn": "", + "gtin": "", + "search_keywords": "", + "availability": "available", + "availability_description": "", + "gift_wrapping_options_type": "any", + "gift_wrapping_options_list": [], + "sort_order": 0, + "condition": "New", + "is_condition_shown": false, + "order_quantity_minimum": 0, + "order_quantity_maximum": 0, + "page_title": "", + "meta_keywords": [], + "meta_description": "", + "date_created": "2015-07-03T17:57:10+00:00", + "date_modified": "2022-03-29T22:55:46+00:00", + "view_count": 79, + "preorder_release_date": null, + "preorder_message": "", + "is_preorder_only": false, + "is_price_hidden": false, + "price_hidden_label": "", + "custom_url": { + "url": "/fog-linen-chambray-towel-beige-stripe/", + "is_customized": false + }, + "base_variant_id": null, + "open_graph_type": "product", + "open_graph_title": "", + "open_graph_description": "", + "open_graph_use_meta_description": true, + "open_graph_use_product_name": true, + "open_graph_use_image": true + }, + "meta": {} +} \ No newline at end of file diff --git a/tests/BigCommerce/responses/orders__1__metafields__get_all.json b/tests/BigCommerce/responses/orders__1__metafields__get_all.json index ae88af35..7ece5332 100644 --- a/tests/BigCommerce/responses/orders__1__metafields__get_all.json +++ b/tests/BigCommerce/responses/orders__1__metafields__get_all.json @@ -9,8 +9,8 @@ "resource_type": "brand", "resource_id": 1, "id": 6, - "created_at": "1973-01-20T21:34:57.903Z", - "updated_at": "1990-12-30T00:29:23.515Z" + "date_created": "1973-01-20T21:34:57.903Z", + "date_updated": "1990-12-30T00:29:23.515Z" }, { "permission_set": "read", @@ -21,8 +21,8 @@ "resource_type": "order", "resource_id": 1, "id": 6, - "created_at": "1973-01-20T21:34:57.903Z", - "updated_at": "1990-12-30T00:29:23.515Z" + "date_created": "1973-01-20T21:34:57.903Z", + "date_updated": "1990-12-30T00:29:23.515Z" } ], "meta": { From 7aa3e14d0206ed07a3412ac2437cb3ba16a71052 Mon Sep 17 00:00:00 2001 From: Jarrod Swift Date: Fri, 31 Mar 2023 14:32:30 +1030 Subject: [PATCH 2/4] Fix tests and resource classes for missing or typo'd properties #201 --- .../Catalog/Product/Product.php | 14 +++- .../Catalog/Product/ProductVariant.php | 2 + .../Catalog/Product/ProductVideo.php | 2 +- .../ResourceModels/Channel/Channel.php | 1 + .../ResourceModels/Customer/Customer.php | 3 + .../Customer/CustomerAddress.php | 1 + .../ResourceModels/Order/OrderRefundItem.php | 1 + src/BigCommerce/ResourceModels/Page/Page.php | 1 + .../ResourceModels/PriceList/PriceList.php | 2 +- .../PriceList/PriceListRecord.php | 7 +- .../ResourceModels/Redirect/Redirect.php | 2 + .../ResourceModels/Script/Script.php | 1 + .../ResourceModels/Widget/Placement.php | 3 + src/BigCommerce/ResponseModels/Meta/Links.php | 12 +++ .../ResponseModels/Meta/Pagination.php | 8 ++ ...alog__brands__11__metafields__get_all.json | 4 +- ..._categories__111__metafields__get_all.json | 4 +- .../catalog__products__174__get.json | 2 +- .../responses/catalog__products__get_all.json | 9 +- .../responses/customers__get_all.json | 2 +- .../orders__1__metafields__get_all.json | 4 +- ...ice_lists__3__records__by_variant_388.json | 6 +- .../price_lists__3__records__get_all.json | 84 +++++++++---------- ...cords__by_variant__356__currency__eur.json | 6 +- .../BigCommerce/responses/sites__get_all.json | 2 +- 25 files changed, 115 insertions(+), 68 deletions(-) create mode 100644 src/BigCommerce/ResponseModels/Meta/Links.php diff --git a/src/BigCommerce/ResourceModels/Catalog/Product/Product.php b/src/BigCommerce/ResourceModels/Catalog/Product/Product.php index 176d4303..6c98df79 100644 --- a/src/BigCommerce/ResourceModels/Catalog/Product/Product.php +++ b/src/BigCommerce/ResourceModels/Catalog/Product/Product.php @@ -81,7 +81,13 @@ class Product extends ResourceModel public bool $open_graph_use_image; public int $reviews_rating_sum; public int $total_sold; - + public int $reviews_count; + public ?int $option_set_id; + public ?float $calculated_price; + public ?string $option_set_display; + public string $product_tax_code; + public int $tax_class_id; + public ?float $map_price; /** * @var CustomField[]|null @@ -99,6 +105,11 @@ class Product extends ResourceModel */ public ?array $images; + /** + * @var ProductVariant[]|null + */ + public ?array $variants; + public function __construct(?stdClass $optionObject = null) { if (!is_null($optionObject)) { @@ -128,5 +139,6 @@ protected function beforeBuildObject(): void { $this->buildObjectArray('modifiers', ProductModifier::class); $this->buildObjectArray('images', ProductImage::class); + $this->buildObjectArray('variants', ProductVariant::class); } } diff --git a/src/BigCommerce/ResourceModels/Catalog/Product/ProductVariant.php b/src/BigCommerce/ResourceModels/Catalog/Product/ProductVariant.php index 0b9f31c1..42bd7f40 100644 --- a/src/BigCommerce/ResourceModels/Catalog/Product/ProductVariant.php +++ b/src/BigCommerce/ResourceModels/Catalog/Product/ProductVariant.php @@ -12,6 +12,7 @@ class ProductVariant extends ResourceModel public ?int $sku_id; public ?float $price; public ?float $calculated_price; + public ?float $map_price; public ?float $sale_price; public ?float $retail_price; public ?float $weight; @@ -31,4 +32,5 @@ class ProductVariant extends ResourceModel public int $inventory_warning_level; public string $bin_picking_number; public array $option_values; + public float $calculated_weight; } diff --git a/src/BigCommerce/ResourceModels/Catalog/Product/ProductVideo.php b/src/BigCommerce/ResourceModels/Catalog/Product/ProductVideo.php index 917b4f93..d9533461 100644 --- a/src/BigCommerce/ResourceModels/Catalog/Product/ProductVideo.php +++ b/src/BigCommerce/ResourceModels/Catalog/Product/ProductVideo.php @@ -10,7 +10,7 @@ class ProductVideo extends ResourceModel public string $title; public string $description; - public int $sort_oder; + public int $sort_order; public string $type; public string $video_id; public int $id; diff --git a/src/BigCommerce/ResourceModels/Channel/Channel.php b/src/BigCommerce/ResourceModels/Channel/Channel.php index e4ebd80e..8dd2159b 100644 --- a/src/BigCommerce/ResourceModels/Channel/Channel.php +++ b/src/BigCommerce/ResourceModels/Channel/Channel.php @@ -44,4 +44,5 @@ class Channel extends ResourceModel public bool $is_visible; public string $name; public string $status; + public bool $is_enabled; } diff --git a/src/BigCommerce/ResourceModels/Customer/Customer.php b/src/BigCommerce/ResourceModels/Customer/Customer.php index 5c5d1a84..58a2a785 100644 --- a/src/BigCommerce/ResourceModels/Customer/Customer.php +++ b/src/BigCommerce/ResourceModels/Customer/Customer.php @@ -32,6 +32,9 @@ class Customer extends ResourceModel public ?array $store_credit_amounts; public ?int $origin_channel_id; public ?array $channel_ids; + public ?string $registration_ip_address; + public string $date_created; + public string $date_modified; /** * @var CustomerAddress[] diff --git a/src/BigCommerce/ResourceModels/Customer/CustomerAddress.php b/src/BigCommerce/ResourceModels/Customer/CustomerAddress.php index ebd9488a..0b7bb70f 100644 --- a/src/BigCommerce/ResourceModels/Customer/CustomerAddress.php +++ b/src/BigCommerce/ResourceModels/Customer/CustomerAddress.php @@ -17,4 +17,5 @@ class CustomerAddress extends ResourceModel public string $phone; public string $address_type; public int $customer_id; + public ?string $company; } diff --git a/src/BigCommerce/ResourceModels/Order/OrderRefundItem.php b/src/BigCommerce/ResourceModels/Order/OrderRefundItem.php index 72bb2e1a..1598aebf 100644 --- a/src/BigCommerce/ResourceModels/Order/OrderRefundItem.php +++ b/src/BigCommerce/ResourceModels/Order/OrderRefundItem.php @@ -16,4 +16,5 @@ class OrderRefundItem extends ResourceModel public ?float $amount; public ?float $quantity; public ?string $reason; + public ?float $requested_amount; } diff --git a/src/BigCommerce/ResourceModels/Page/Page.php b/src/BigCommerce/ResourceModels/Page/Page.php index 0f1fe82b..ba58c289 100644 --- a/src/BigCommerce/ResourceModels/Page/Page.php +++ b/src/BigCommerce/ResourceModels/Page/Page.php @@ -6,6 +6,7 @@ class Page extends ResourceModel { + public int $id; public string $name; public ?string $email; public string $meta_title; diff --git a/src/BigCommerce/ResourceModels/PriceList/PriceList.php b/src/BigCommerce/ResourceModels/PriceList/PriceList.php index e90b25c7..b299800a 100644 --- a/src/BigCommerce/ResourceModels/PriceList/PriceList.php +++ b/src/BigCommerce/ResourceModels/PriceList/PriceList.php @@ -9,6 +9,6 @@ class PriceList extends ResourceModel public int $id; public string $name; public string $date_created; - public string $data_modified; + public string $date_modified; public bool $active; } diff --git a/src/BigCommerce/ResourceModels/PriceList/PriceListRecord.php b/src/BigCommerce/ResourceModels/PriceList/PriceListRecord.php index 8e842035..8c3874a2 100644 --- a/src/BigCommerce/ResourceModels/PriceList/PriceListRecord.php +++ b/src/BigCommerce/ResourceModels/PriceList/PriceListRecord.php @@ -8,13 +8,14 @@ class PriceListRecord extends ResourceModel { public int $price_list_id; public int $variant_id; - public float $price; - public object $sale_price; - public object $map_price; + public ?float $price; + public ?float $sale_price; + public ?float $map_price; public float $calculated_price; public string $date_created; public string $date_modified; public string $currency; public int $product_id; public array $bulk_pricing_tiers; + public ?float $retail_price; } diff --git a/src/BigCommerce/ResourceModels/Redirect/Redirect.php b/src/BigCommerce/ResourceModels/Redirect/Redirect.php index f9853f86..82f3b356 100644 --- a/src/BigCommerce/ResourceModels/Redirect/Redirect.php +++ b/src/BigCommerce/ResourceModels/Redirect/Redirect.php @@ -29,6 +29,8 @@ class Redirect extends ResourceModel public string $from_path; public int $site_id; public RedirectTo $to; + public int $id; + public string $to_url; public function __construct(?stdClass $optionObject = null) { diff --git a/src/BigCommerce/ResourceModels/Script/Script.php b/src/BigCommerce/ResourceModels/Script/Script.php index b7f22c73..b6c791c0 100644 --- a/src/BigCommerce/ResourceModels/Script/Script.php +++ b/src/BigCommerce/ResourceModels/Script/Script.php @@ -29,4 +29,5 @@ class Script extends ResourceModel public string $api_client_id; public string $consent_category; public bool $enabled; + public string $name; } diff --git a/src/BigCommerce/ResourceModels/Widget/Placement.php b/src/BigCommerce/ResourceModels/Widget/Placement.php index 473c15b7..5f7fc885 100644 --- a/src/BigCommerce/ResourceModels/Widget/Placement.php +++ b/src/BigCommerce/ResourceModels/Widget/Placement.php @@ -17,6 +17,9 @@ class Placement extends ResourceModel public int $sort_order; public string $region; public ?Widget $widget; + public string $date_created; + public string $date_modified; + public string $uuid; public function __construct(?stdClass $optionObject = null) { diff --git a/src/BigCommerce/ResponseModels/Meta/Links.php b/src/BigCommerce/ResponseModels/Meta/Links.php new file mode 100644 index 00000000..103c6a9e --- /dev/null +++ b/src/BigCommerce/ResponseModels/Meta/Links.php @@ -0,0 +1,12 @@ + Date: Fri, 31 Mar 2023 14:39:44 +1030 Subject: [PATCH 3/4] Fix Cart and CartRedirectUrl properties #201 --- src/BigCommerce/ResourceModels/Cart/Cart.php | 7 +++++++ src/BigCommerce/ResourceModels/Cart/CartRedirectUrls.php | 1 + 2 files changed, 8 insertions(+) diff --git a/src/BigCommerce/ResourceModels/Cart/Cart.php b/src/BigCommerce/ResourceModels/Cart/Cart.php index cfa8a56e..179ad487 100644 --- a/src/BigCommerce/ResourceModels/Cart/Cart.php +++ b/src/BigCommerce/ResourceModels/Cart/Cart.php @@ -22,4 +22,11 @@ class Cart extends ResourceModel public string $updated_time; public int $channel_id; public string $locale; + public ?CartRedirectUrls $redirect_urls; + + protected function beforeBuildObject(): void + { + parent::beforeBuildObject(); + self::buildPropertyObject('redirect_urls', CartRedirectUrls::class); + } } diff --git a/src/BigCommerce/ResourceModels/Cart/CartRedirectUrls.php b/src/BigCommerce/ResourceModels/Cart/CartRedirectUrls.php index 66326047..5c6891bd 100644 --- a/src/BigCommerce/ResourceModels/Cart/CartRedirectUrls.php +++ b/src/BigCommerce/ResourceModels/Cart/CartRedirectUrls.php @@ -8,4 +8,5 @@ class CartRedirectUrls extends ResourceModel { public string $cart_url; public string $checkout_url; + public string $embedded_checkout_url; } From 5b67398c5dcc8cb4dab9ba7bdcc4887041f7b5ef Mon Sep 17 00:00:00 2001 From: Jarrod Swift Date: Fri, 31 Mar 2023 14:41:25 +1030 Subject: [PATCH 4/4] Update release notes #201 --- RELEASE_NOTES.md | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 7b3f737b..2f4c74a2 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,16 +1,3 @@ -This release adds support for a number of new and extended BigCommerce V3 API endpoints. - -### New Features - -- Implement the [System Logs](https://developer.bigcommerce.com/api-reference/6908d02370409-get-system-logs) - endpoint (#185) -- Implement the [Pages](https://developer.bigcommerce.com/api-reference/d74089ee212a2-delete-pages) API (#184) -- Implement extra Customer V3 endpoints (#181): - - [Get stored instruments](https://developer.bigcommerce.com/api-reference/b735a25b3a0b8-get-stored-instruments) - - [Customer Settings](https://developer.bigcommerce.com/api-reference/0c31a6d25e5ea-get-customer-settings) - - [Customer Settings per Channel](https://developer.bigcommerce.com/api-reference/d5e66c45b0415-get-customer-settings-per-channel) - - [Validate credentials](https://developer.bigcommerce.com/api-reference/3d731215a3dcb-validate-a-customer-credentials) -- Add the ability to send and receive Images via the Product API, not just the Product Images api (#175) -- Implement the [Wishlists](https://developer.bigcommerce.com/api-reference/03d6065d6f6e5-wishlist) API (#186) - +### Fixes +- Many deprecation notices for PHP 8.2 about creation of dynamic properties (#201) \ No newline at end of file