1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Srmklive\Chargify\Traits\ChargifyAPI; |
4
|
|
|
|
5
|
|
|
trait ProductsPricePoints |
6
|
|
|
{ |
7
|
|
|
/** |
8
|
|
|
* Create a product price point. |
9
|
|
|
* |
10
|
|
|
* @param string $product_id |
11
|
|
|
* @param array $data |
12
|
|
|
* |
13
|
|
|
* @return array |
14
|
|
|
* |
15
|
|
|
* @link https://reference.chargify.com/v1/products-price-points/create-a-product-price-point |
16
|
|
|
*/ |
17
|
|
|
public function product_price_point_create(string $product_id, array $data): array |
18
|
|
|
{ |
19
|
|
|
$this->apiEndPoint = "/products/{$product_id}/price_points.json"; |
20
|
|
|
|
21
|
|
|
$this->verb = 'post'; |
22
|
|
|
|
23
|
|
|
$this->options['json'] = [ |
|
|
|
|
24
|
|
|
'price_point' => $data, |
25
|
|
|
]; |
26
|
|
|
|
27
|
|
|
return $this->doChargifyRequest(); |
|
|
|
|
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Update a product price point. |
32
|
|
|
* |
33
|
|
|
* @param string $product_id |
34
|
|
|
* @param string $price_point_id |
35
|
|
|
* @param array $data |
36
|
|
|
* |
37
|
|
|
* @return array |
38
|
|
|
* |
39
|
|
|
* @link https://reference.chargify.com/v1/products-price-points/update-a-product-price-point |
40
|
|
|
*/ |
41
|
|
|
public function product_price_point_update(string $product_id, string $price_point_id, array $data): array |
42
|
|
|
{ |
43
|
|
|
$this->apiEndPoint = "/products/{$product_id}/price_points/{$price_point_id}.json"; |
44
|
|
|
|
45
|
|
|
$this->verb = 'put'; |
46
|
|
|
|
47
|
|
|
$this->options['json'] = [ |
|
|
|
|
48
|
|
|
'price_point' => $data, |
49
|
|
|
]; |
50
|
|
|
|
51
|
|
|
return $this->doChargifyRequest(); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Get a product price point details. |
56
|
|
|
* |
57
|
|
|
* @param string $product_id |
58
|
|
|
* @param string $price_point_id |
59
|
|
|
* |
60
|
|
|
* @return array |
61
|
|
|
* |
62
|
|
|
* @link https://reference.chargify.com/v1/products-price-points/read-a-product-price-point |
63
|
|
|
*/ |
64
|
|
|
public function product_price_point_details(string $product_id, string $price_point_id): array |
65
|
|
|
{ |
66
|
|
|
$this->apiEndPoint = "/products/{$product_id}/price_points/{$price_point_id}.json"; |
67
|
|
|
|
68
|
|
|
$this->verb = 'get'; |
69
|
|
|
|
70
|
|
|
return $this->doChargifyRequest(); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* Get list of product price points. |
75
|
|
|
* |
76
|
|
|
* @param string $product_id |
77
|
|
|
* |
78
|
|
|
* @return array |
79
|
|
|
* |
80
|
|
|
* @link https://reference.chargify.com/v1/products-price-points/read-product-price-points |
81
|
|
|
*/ |
82
|
|
|
public function product_price_point_list(string $product_id): array |
83
|
|
|
{ |
84
|
|
|
$this->apiEndPoint = "/products/{$product_id}/price_points.json"; |
85
|
|
|
|
86
|
|
|
$this->verb = 'get'; |
87
|
|
|
|
88
|
|
|
return $this->doChargifyRequest(); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* Un-archive a product price point. |
93
|
|
|
* |
94
|
|
|
* @param string $product_id |
95
|
|
|
* @param string $price_point_id |
96
|
|
|
* |
97
|
|
|
* @return array |
98
|
|
|
* |
99
|
|
|
* @link https://reference.chargify.com/v1/products-price-points/unarchive-a-product-point |
100
|
|
|
*/ |
101
|
|
|
public function product_price_point_unarchive(string $product_id, string $price_point_id): array |
102
|
|
|
{ |
103
|
|
|
$this->apiEndPoint = "/products/{$product_id}/price_points/{$price_point_id}/unarchive.json"; |
104
|
|
|
|
105
|
|
|
$this->verb = 'patch'; |
106
|
|
|
|
107
|
|
|
return $this->doChargifyRequest(); |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* Delete a product price point. |
112
|
|
|
* |
113
|
|
|
* @param string $product_id |
114
|
|
|
* @param string $price_point_id |
115
|
|
|
* |
116
|
|
|
* @return array |
117
|
|
|
* |
118
|
|
|
* @link https://reference.chargify.com/v1/products-price-points/delete-a-product-price-point |
119
|
|
|
*/ |
120
|
|
|
public function product_price_point_delete(string $product_id, string $price_point_id): array |
121
|
|
|
{ |
122
|
|
|
$this->apiEndPoint = "/products/{$product_id}/price_points/{$price_point_id}.json"; |
123
|
|
|
|
124
|
|
|
$this->verb = 'delete'; |
125
|
|
|
|
126
|
|
|
return $this->doChargifyRequest(); |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* Set a product price point as default. |
131
|
|
|
* |
132
|
|
|
* @param string $product_id |
133
|
|
|
* @param string $price_point_id |
134
|
|
|
* |
135
|
|
|
* @return array |
136
|
|
|
* |
137
|
|
|
* @link https://reference.chargify.com/v1/products-price-points/promote-a-product-price-point-to-default |
138
|
|
|
*/ |
139
|
|
|
public function product_price_point_default(string $product_id, string $price_point_id): array |
140
|
|
|
{ |
141
|
|
|
$this->apiEndPoint = "/products/{$product_id}/price_points/{$price_point_id}/default.json"; |
142
|
|
|
|
143
|
|
|
$this->verb = 'patch'; |
144
|
|
|
|
145
|
|
|
return $this->doChargifyRequest(); |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* Create product price points in bulk. |
150
|
|
|
* |
151
|
|
|
* @param string $product_id |
152
|
|
|
* @param array $data |
153
|
|
|
* |
154
|
|
|
* @return array |
155
|
|
|
* |
156
|
|
|
* @link https://reference.chargify.com/v1/products-price-points/bulk-create-product-price-points |
157
|
|
|
*/ |
158
|
|
|
public function product_price_points_bulk_create(string $product_id, array $data): array |
159
|
|
|
{ |
160
|
|
|
$this->apiEndPoint = "/products/{$product_id}/price_points/bulk.json"; |
161
|
|
|
|
162
|
|
|
$this->verb = 'post'; |
163
|
|
|
|
164
|
|
|
$this->options['json'] = [ |
|
|
|
|
165
|
|
|
'price_points' => $data, |
166
|
|
|
]; |
167
|
|
|
|
168
|
|
|
return $this->doChargifyRequest(); |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
/** |
172
|
|
|
* Add currency pricing for a product price point. |
173
|
|
|
* |
174
|
|
|
* @param string $price_point_id |
175
|
|
|
* @param array $data |
176
|
|
|
* |
177
|
|
|
* @return array |
178
|
|
|
* |
179
|
|
|
* @link https://reference.chargify.com/v1/products-price-points/create-currency-prices |
180
|
|
|
*/ |
181
|
|
|
public function product_price_point_create_currency_prices(string $price_point_id, array $data): array |
182
|
|
|
{ |
183
|
|
|
$this->apiEndPoint = "/product_price_points/{$price_point_id}/currency_prices.json"; |
184
|
|
|
|
185
|
|
|
$this->verb = 'post'; |
186
|
|
|
|
187
|
|
|
$this->options['json'] = [ |
|
|
|
|
188
|
|
|
'currency_prices' => $data, |
189
|
|
|
]; |
190
|
|
|
|
191
|
|
|
return $this->doChargifyRequest(); |
192
|
|
|
} |
193
|
|
|
|
194
|
|
|
/** |
195
|
|
|
* Update currency pricing for a product price point. |
196
|
|
|
* |
197
|
|
|
* @param string $price_point_id |
198
|
|
|
* @param array $data |
199
|
|
|
* |
200
|
|
|
* @return array |
201
|
|
|
* |
202
|
|
|
* @link https://reference.chargify.com/v1/products-price-points/update-currency-prices |
203
|
|
|
*/ |
204
|
|
|
public function product_price_point_update_currency_prices(string $price_point_id, array $data): array |
205
|
|
|
{ |
206
|
|
|
$this->apiEndPoint = "/product_price_points/{$price_point_id}/currency_prices.json"; |
207
|
|
|
|
208
|
|
|
$this->verb = 'put'; |
209
|
|
|
|
210
|
|
|
$this->options['json'] = [ |
|
|
|
|
211
|
|
|
'currency_prices' => $data, |
212
|
|
|
]; |
213
|
|
|
|
214
|
|
|
return $this->doChargifyRequest(); |
215
|
|
|
} |
216
|
|
|
} |
217
|
|
|
|