Skip to content

Commit

Permalink
Merge pull request #202 from aligent/fix/201-creation-of-dynamic-prop…
Browse files Browse the repository at this point in the history
…erties-deprecated-in-php8

Fix/201 creation of dynamic properties deprecated in php8
  • Loading branch information
jswift authored Mar 31, 2023
2 parents 1e71e40 + 5b67398 commit b0b2620
Show file tree
Hide file tree
Showing 33 changed files with 242 additions and 88 deletions.
17 changes: 2 additions & 15 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -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)
7 changes: 7 additions & 0 deletions src/BigCommerce/ResourceModels/Cart/Cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
1 change: 1 addition & 0 deletions src/BigCommerce/ResourceModels/Cart/CartRedirectUrls.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ class CartRedirectUrls extends ResourceModel
{
public string $cart_url;
public string $checkout_url;
public string $embedded_checkout_url;
}
14 changes: 14 additions & 0 deletions src/BigCommerce/ResourceModels/Catalog/Product/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ 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
*/
Expand All @@ -97,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)) {
Expand Down Expand Up @@ -126,5 +139,6 @@ protected function beforeBuildObject(): void
{
$this->buildObjectArray('modifiers', ProductModifier::class);
$this->buildObjectArray('images', ProductImage::class);
$this->buildObjectArray('variants', ProductVariant::class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/BigCommerce/ResourceModels/Channel/Channel.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ class Channel extends ResourceModel
public bool $is_visible;
public string $name;
public string $status;
public bool $is_enabled;
}
3 changes: 3 additions & 0 deletions src/BigCommerce/ResourceModels/Customer/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ class CustomerAddress extends ResourceModel
public string $phone;
public string $address_type;
public int $customer_id;
public ?string $company;
}
1 change: 1 addition & 0 deletions src/BigCommerce/ResourceModels/Order/OrderRefundItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ class OrderRefundItem extends ResourceModel
public ?float $amount;
public ?float $quantity;
public ?string $reason;
public ?float $requested_amount;
}
1 change: 1 addition & 0 deletions src/BigCommerce/ResourceModels/Page/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

class Page extends ResourceModel
{
public int $id;
public string $name;
public ?string $email;
public string $meta_title;
Expand Down
2 changes: 1 addition & 1 deletion src/BigCommerce/ResourceModels/PriceList/PriceList.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
7 changes: 4 additions & 3 deletions src/BigCommerce/ResourceModels/PriceList/PriceListRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 2 additions & 0 deletions src/BigCommerce/ResourceModels/Redirect/Redirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
1 change: 1 addition & 0 deletions src/BigCommerce/ResourceModels/Script/Script.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ class Script extends ResourceModel
public string $api_client_id;
public string $consent_category;
public bool $enabled;
public string $name;
}
3 changes: 3 additions & 0 deletions src/BigCommerce/ResourceModels/Widget/Placement.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
12 changes: 12 additions & 0 deletions src/BigCommerce/ResponseModels/Meta/Links.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace BigCommerce\ApiV3\ResponseModels\Meta;

use BigCommerce\ApiV3\ResourceModels\ResourceModel;

class Links extends ResourceModel
{
public ?string $previous;
public string $current;
public ?string $next;
}
8 changes: 8 additions & 0 deletions src/BigCommerce/ResponseModels/Meta/Pagination.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,12 @@ class Pagination extends ResourceModel
* @var int The total number of pages in the collection
*/
public int $total_pages;

public ?Links $links;

protected function beforeBuildObject(): void
{
self::buildPropertyObject('links', Links::class);
parent::beforeBuildObject();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
8 changes: 8 additions & 0 deletions src/BigCommerceLegacyApi/ResponseModels/Order/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
8 changes: 8 additions & 0 deletions tests/BigCommerce/Api/Catalog/ProductsApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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_modified": "1990-12-30T00:29:23.515Z"
},
{
"permission_set": "read",
Expand All @@ -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_modified": "1990-12-30T00:29:23.515Z"
}
],
"meta": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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_modified": "1990-12-30T00:29:23.515Z"
},
{
"permission_set": "read",
Expand All @@ -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_modified": "1990-12-30T00:29:23.515Z"
}
],
"meta": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
21
],
"brand_id": 36,
"option_set_id": {},
"option_set_id": null,
"option_set_display": "right",
"inventory_level": 0,
"inventory_warning_level": 0,
Expand Down
Loading

0 comments on commit b0b2620

Please sign in to comment.