Skip to content

Commit

Permalink
Product entity now supports deleted_at property
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Mayes committed Sep 14, 2020
1 parent 5ffa5bf commit 53a2b12
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 32 deletions.
3 changes: 2 additions & 1 deletion docs/api/products/details.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ Expected response:
"meta_title": null,
"subtitle": null,
"seo_description": null,
"keywords": null
"keywords": null,
"deleted_at": null
},
"meta": null
}
Expand Down
3 changes: 2 additions & 1 deletion docs/api/products/list.md
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
72 changes: 42 additions & 30 deletions src/Entities/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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;
}
}

0 comments on commit 53a2b12

Please sign in to comment.