Total Complexity | 5 |
Total Lines | 90 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
5 | trait Products |
||
6 | { |
||
7 | /** |
||
8 | * Create a new product. |
||
9 | * |
||
10 | * @param string $product_family_id |
||
11 | * @param array $data |
||
12 | * |
||
13 | * @return array |
||
14 | */ |
||
15 | public function product_create(string $product_family_id, array $data): array |
||
16 | { |
||
17 | $this->apiEndPoint = "/product_families/{$product_family_id}/products.json"; |
||
18 | |||
19 | $this->verb = 'post'; |
||
20 | |||
21 | $this->options['json'] = [ |
||
|
|||
22 | 'product' => $data, |
||
23 | ]; |
||
24 | |||
25 | return $this->doChargifyRequest(); |
||
26 | } |
||
27 | |||
28 | /** |
||
29 | * Get product details. |
||
30 | * |
||
31 | * @param string $product_id |
||
32 | * |
||
33 | * @return array |
||
34 | */ |
||
35 | public function product_details(string $product_id): array |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * Get product details via API Handle. |
||
46 | * |
||
47 | * @param string $handle |
||
48 | * |
||
49 | * @return array |
||
50 | */ |
||
51 | public function product_details_by_handle(string $handle): array |
||
52 | { |
||
53 | $this->apiEndPoint = "/products/handle/{$handle}.json"; |
||
54 | |||
55 | $this->verb = 'get'; |
||
56 | |||
57 | return $this->doChargifyRequest(); |
||
58 | } |
||
59 | |||
60 | /** |
||
61 | * Update product details. |
||
62 | * |
||
63 | * @param string $product_id |
||
64 | * @param array $data |
||
65 | * |
||
66 | * @return array |
||
67 | */ |
||
68 | public function product_update(string $product_id, array $data): array |
||
69 | { |
||
70 | $this->apiEndPoint = "/products/{$product_id}.json"; |
||
71 | |||
72 | $this->verb = 'put'; |
||
73 | |||
74 | $this->options['json'] = [ |
||
75 | 'product' => $data, |
||
76 | ]; |
||
77 | |||
78 | return $this->doChargifyRequest(); |
||
79 | } |
||
80 | |||
81 | /** |
||
82 | * Archive a product. |
||
83 | * |
||
84 | * @param string $product_id |
||
85 | * |
||
86 | * @return array |
||
87 | */ |
||
88 | public function product_archive(string $product_id): array |
||
95 | } |
||
96 | } |
||
97 |