From 53a2b12402bc5c589a668e8dd308d79257b24732 Mon Sep 17 00:00:00 2001 From: Greg Mayes Date: Mon, 14 Sep 2020 08:48:08 +0100 Subject: [PATCH] Product entity now supports deleted_at property --- docs/api/products/details.md | 3 +- docs/api/products/list.md | 3 +- src/Entities/Product.php | 72 +++++++++++++++++++++--------------- 3 files changed, 46 insertions(+), 32 deletions(-) diff --git a/docs/api/products/details.md b/docs/api/products/details.md index c413ee1..6d252a6 100644 --- a/docs/api/products/details.md +++ b/docs/api/products/details.md @@ -93,7 +93,8 @@ Expected response: "meta_title": null, "subtitle": null, "seo_description": null, - "keywords": null + "keywords": null, + "deleted_at": null }, "meta": null } diff --git a/docs/api/products/list.md b/docs/api/products/list.md index 781cacc..320fd8d 100644 --- a/docs/api/products/list.md +++ b/docs/api/products/list.md @@ -37,7 +37,8 @@ Expected response: "name": "quis quod nihil", "sku": "9100067798573", "catalogue_reference": "PP-12345", - "thumbnail": "<...>/images\/image-placeholder.svg" + "thumbnail": "<...>/images\/image-placeholder.svg", + "deleted_at": null } ], "first_page_url": "<...>/api\/products?page=1", diff --git a/src/Entities/Product.php b/src/Entities/Product.php index 237f0c2..4153065 100644 --- a/src/Entities/Product.php +++ b/src/Entities/Product.php @@ -5,36 +5,37 @@ use Optimus\Constants\EndpointType; /** - * @property-read int $id - * @property-read string $supplier - * @property-read string $thumbnail - * @property-read string $name - * @property-read string $sku - * @property-read string $reference - * @property-read string $catalogue_reference - * @property-read string $description - * @property-read bool $is_eco_product - * @property-read string $information_eco_product - * @property-read string $information_print_specification - * @property-read string $information_web_link - * @property-read string $information_web_link_description - * @property-read string $information_catalogue_description - * @property-read string $information_colours - * @property-read string $information_packaging - * @property-read string $information_express_delivery - * @property-read int $lead_time_standard - * @property-read int $lead_time_express - * @property-read bool $is_lead_time_express_chargable - * @property-read int $maximum_number_of_colours - * @property-read string $slug - * @property-read string $title - * @property-read string $meta_title - * @property-read string $subtitle - * @property-read string $seo_description - * @property-read string $keywords - * @property-read Category[] $categories - * @property-read Media[] $media - * @property-read Pricing[] $pricing + * @property-read int $id + * @property-read string $supplier + * @property-read string $thumbnail + * @property-read string $name + * @property-read string $sku + * @property-read string $reference + * @property-read string $catalogue_reference + * @property-read string $description + * @property-read bool $is_eco_product + * @property-read string $information_eco_product + * @property-read string $information_print_specification + * @property-read string $information_web_link + * @property-read string $information_web_link_description + * @property-read string $information_catalogue_description + * @property-read string $information_colours + * @property-read string $information_packaging + * @property-read string $information_express_delivery + * @property-read int $lead_time_standard + * @property-read int $lead_time_express + * @property-read bool $is_lead_time_express_chargable + * @property-read int $maximum_number_of_colours + * @property-read string $slug + * @property-read string $title + * @property-read string $meta_title + * @property-read string $subtitle + * @property-read string $seo_description + * @property-read string $keywords + * @property-read Category[] $categories + * @property-read Media[] $media + * @property-read Pricing[] $pricing + * @property-read string|null $deleted_at */ class Product extends AbstractEntity { @@ -74,4 +75,15 @@ public function pricing() { return Pricing::class; } + + /** + * Returns whether the product has been + * soft-deleted from Optimus + * + * @return bool + */ + public function isArchived() + { + return $this->deleted_at !== null; + } }