|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Codexshaper\WooCommerce\Models; |
| 4 | + |
| 5 | +use Codexshaper\WooCommerce\Facades\Query; |
| 6 | +use Codexshaper\WooCommerce\Traits\QueryBuilderTrait; |
| 7 | + |
| 8 | +class Subscription extends BaseModel |
| 9 | +{ |
| 10 | + use QueryBuilderTrait; |
| 11 | + |
| 12 | + protected $endpoint = 'subscriptions'; |
| 13 | + |
| 14 | + /** |
| 15 | + * Retrieve all notes. |
| 16 | + * |
| 17 | + * @param int $subscription_id |
| 18 | + * @param array $options |
| 19 | + * |
| 20 | + * @return array |
| 21 | + */ |
| 22 | + protected function notes($subscription_id, $options = []) |
| 23 | + { |
| 24 | + return Query::init() |
| 25 | + ->setEndpoint("subscriptions/{$subscription_id}/notes") |
| 26 | + ->all($options); |
| 27 | + } |
| 28 | + |
| 29 | + /** |
| 30 | + * Retreive a note. |
| 31 | + * |
| 32 | + * @param int $subscription_id |
| 33 | + * @param int $note_id |
| 34 | + * @param array $options |
| 35 | + * |
| 36 | + * @return object |
| 37 | + */ |
| 38 | + protected function note($subscription_id, $note_id, $options = []) |
| 39 | + { |
| 40 | + return Query::init() |
| 41 | + ->setEndpoint("subscriptions/{$subscription_id}/notes") |
| 42 | + ->find($note_id, $options); |
| 43 | + } |
| 44 | + |
| 45 | + /** |
| 46 | + * Create a note. |
| 47 | + * |
| 48 | + * @param int $subscription_id |
| 49 | + * @param array $data |
| 50 | + * |
| 51 | + * @return object |
| 52 | + */ |
| 53 | + protected function createNote($subscription_id, $data = []) |
| 54 | + { |
| 55 | + return Query::init() |
| 56 | + ->setEndpoint("subscriptions/{$subscription_id}/notes") |
| 57 | + ->create($data); |
| 58 | + } |
| 59 | + |
| 60 | + /** |
| 61 | + * Delete a note. |
| 62 | + * |
| 63 | + * @param int $subscription_id |
| 64 | + * @param int $note_id |
| 65 | + * @param array $options |
| 66 | + * |
| 67 | + * @return object |
| 68 | + */ |
| 69 | + protected function deleteNote($subscription_id, $note_id, $options = []) |
| 70 | + { |
| 71 | + return Query::init() |
| 72 | + ->setEndpoint("subscriptions/{$subscription_id}/notes") |
| 73 | + ->delete($note_id, $options); |
| 74 | + } |
| 75 | + |
| 76 | + /** |
| 77 | + * Retrieve all orders for the subscription. |
| 78 | + * |
| 79 | + * @param int $subscription_id |
| 80 | + * @param array $options |
| 81 | + * |
| 82 | + * @return array |
| 83 | + */ |
| 84 | + protected function orders($subscription_id, $options = []) |
| 85 | + { |
| 86 | + return Query::init() |
| 87 | + ->setEndpoint("subscriptions/{$subscription_id}/orders") |
| 88 | + ->all($options); |
| 89 | + } |
| 90 | +} |
0 commit comments