@@ 7-117 (lines=111) @@ | ||
4 | ||
5 | use Codexshaper\WooCommerce\Traits\QueryBuilderTrait; |
|
6 | ||
7 | class Note extends BaseModel |
|
8 | { |
|
9 | use QueryBuilderTrait; |
|
10 | ||
11 | protected $endpoint; |
|
12 | ||
13 | /** |
|
14 | * Retrieve all Items. |
|
15 | * |
|
16 | * @param int $order_id |
|
17 | * @param array $options |
|
18 | * |
|
19 | * @return array |
|
20 | */ |
|
21 | protected function all($order_id, $options = []) |
|
22 | { |
|
23 | $this->endpoint = "orders/{$order_id}/notes"; |
|
24 | ||
25 | return self::all($options); |
|
26 | } |
|
27 | ||
28 | /** |
|
29 | * Retrieve single Item. |
|
30 | * |
|
31 | * @param int $order_id |
|
32 | * @param int $note_id |
|
33 | * @param array $options |
|
34 | * |
|
35 | * @return object |
|
36 | */ |
|
37 | protected function find($order_id, $note_id, $options = []) |
|
38 | { |
|
39 | $this->endpoint = "orders/{$order_id}/notes"; |
|
40 | ||
41 | return self::find($note_id, $options); |
|
42 | } |
|
43 | ||
44 | /** |
|
45 | * Create new Item. |
|
46 | * |
|
47 | * @param int $order_id |
|
48 | * @param array $data |
|
49 | * |
|
50 | * @return object |
|
51 | */ |
|
52 | protected function create($order_id, $data) |
|
53 | { |
|
54 | $this->endpoint = "orders/{$order_id}/notes"; |
|
55 | ||
56 | return self::create($data); |
|
57 | } |
|
58 | ||
59 | /** |
|
60 | * Destroy Item. |
|
61 | * |
|
62 | * @param int $order_id |
|
63 | * @param int $note_id |
|
64 | * @param array $options |
|
65 | * |
|
66 | * @return object |
|
67 | */ |
|
68 | protected function delete($order_id, $note_id, $options = []) |
|
69 | { |
|
70 | $this->endpoint = "orders/{$order_id}/notes"; |
|
71 | ||
72 | return self::delete($note_id, $options); |
|
73 | } |
|
74 | ||
75 | /** |
|
76 | * Paginate results. |
|
77 | * |
|
78 | * @param int $per_page |
|
79 | * @param int $current_page |
|
80 | * |
|
81 | * @return array |
|
82 | */ |
|
83 | protected function paginate( |
|
84 | $order_id, |
|
85 | $per_page = 10, |
|
86 | $current_page = 1, |
|
87 | $options = [] |
|
88 | ) { |
|
89 | $this->endpoint = "orders/{$order_id}/notes"; |
|
90 | ||
91 | return self::paginate($per_page, $current_page, $options); |
|
92 | } |
|
93 | ||
94 | /** |
|
95 | * Count all results. |
|
96 | * |
|
97 | * @return int |
|
98 | */ |
|
99 | protected function count($order_id) |
|
100 | { |
|
101 | $this->endpoint = "orders/{$order_id}/notes"; |
|
102 | ||
103 | return self::count(); |
|
104 | } |
|
105 | ||
106 | /** |
|
107 | * Store data. |
|
108 | * |
|
109 | * @return array |
|
110 | */ |
|
111 | public function save($order_id) |
|
112 | { |
|
113 | $this->endpoint = "orders/{$order_id}/notes"; |
|
114 | ||
115 | return self::save(); |
|
116 | } |
|
117 | } |
|
118 |
@@ 7-117 (lines=111) @@ | ||
4 | ||
5 | use Codexshaper\WooCommerce\Traits\QueryBuilderTrait; |
|
6 | ||
7 | class Refund extends BaseModel |
|
8 | { |
|
9 | use QueryBuilderTrait; |
|
10 | ||
11 | protected $endpoint; |
|
12 | ||
13 | /** |
|
14 | * Retrieve all Items. |
|
15 | * |
|
16 | * @param int $order_id |
|
17 | * @param array $options |
|
18 | * |
|
19 | * @return array |
|
20 | */ |
|
21 | protected function all($order_id, $options = []) |
|
22 | { |
|
23 | $this->endpoint = "orders/{$order_id}/refunds"; |
|
24 | ||
25 | return self::all($options); |
|
26 | } |
|
27 | ||
28 | /** |
|
29 | * Retrieve single Item. |
|
30 | * |
|
31 | * @param int $order_id |
|
32 | * @param int $refund_id |
|
33 | * @param array $options |
|
34 | * |
|
35 | * @return object |
|
36 | */ |
|
37 | protected function find($order_id, $refund_id, $options = []) |
|
38 | { |
|
39 | $this->endpoint = "orders/{$order_id}/refunds"; |
|
40 | ||
41 | return self::find($refund_id, $options); |
|
42 | } |
|
43 | ||
44 | /** |
|
45 | * Create new Item. |
|
46 | * |
|
47 | * @param int $order_id |
|
48 | * @param array $data |
|
49 | * |
|
50 | * @return object |
|
51 | */ |
|
52 | protected function create($order_id, $data) |
|
53 | { |
|
54 | $this->endpoint = "orders/{$order_id}/refunds"; |
|
55 | ||
56 | return self::create($data); |
|
57 | } |
|
58 | ||
59 | /** |
|
60 | * Destroy Item. |
|
61 | * |
|
62 | * @param int $order_id |
|
63 | * @param int $refund_id |
|
64 | * @param array $options |
|
65 | * |
|
66 | * @return object |
|
67 | */ |
|
68 | protected function delete($order_id, $refund_id, $options = []) |
|
69 | { |
|
70 | $this->endpoint = "orders/{$order_id}/refunds"; |
|
71 | ||
72 | return self::delete($refund_id, $options); |
|
73 | } |
|
74 | ||
75 | /** |
|
76 | * Paginate results. |
|
77 | * |
|
78 | * @param int $per_page |
|
79 | * @param int $current_page |
|
80 | * |
|
81 | * @return array |
|
82 | */ |
|
83 | protected function paginate( |
|
84 | $order_id, |
|
85 | $per_page = 10, |
|
86 | $current_page = 1, |
|
87 | $options = [] |
|
88 | ) { |
|
89 | $this->endpoint = "orders/{$order_id}/refunds"; |
|
90 | ||
91 | return self::paginate($per_page, $current_page, $options); |
|
92 | } |
|
93 | ||
94 | /** |
|
95 | * Count all results. |
|
96 | * |
|
97 | * @return int |
|
98 | */ |
|
99 | protected function count($order_id) |
|
100 | { |
|
101 | $this->endpoint = "orders/{$order_id}/refunds"; |
|
102 | ||
103 | return self::count(); |
|
104 | } |
|
105 | ||
106 | /** |
|
107 | * Store data. |
|
108 | * |
|
109 | * @return array |
|
110 | */ |
|
111 | public function save($order_id) |
|
112 | { |
|
113 | $this->endpoint = "orders/{$order_id}/refunds"; |
|
114 | ||
115 | return self::save(); |
|
116 | } |
|
117 | } |
|
118 |
@@ 8-121 (lines=114) @@ | ||
5 | use Codexshaper\WooCommerce\Facades\WooCommerce; |
|
6 | use Codexshaper\WooCommerce\Traits\QueryBuilderTrait; |
|
7 | ||
8 | class ShippingZone extends BaseModel |
|
9 | { |
|
10 | use QueryBuilderTrait; |
|
11 | ||
12 | protected $endpoint = 'shipping/zones'; |
|
13 | ||
14 | /** |
|
15 | * Retrieve all Items. |
|
16 | * |
|
17 | * @param int $id |
|
18 | * @param array $options |
|
19 | * |
|
20 | * @return array |
|
21 | */ |
|
22 | protected function getLocations($id, $options = []) |
|
23 | { |
|
24 | $this->endpoint = "shipping/zones/{$id}/locations"; |
|
25 | ||
26 | return self::all($options); |
|
27 | } |
|
28 | ||
29 | /** |
|
30 | * Update Existing Item. |
|
31 | * |
|
32 | * @param int $id |
|
33 | * @param array $data |
|
34 | * |
|
35 | * @return object |
|
36 | */ |
|
37 | protected function updateLocations($id, $data = []) |
|
38 | { |
|
39 | $this->endpoint = "shipping/zones/{$id}/locations"; |
|
40 | ||
41 | return WooCommerce::update($this->endpoint, $data); |
|
42 | } |
|
43 | ||
44 | /** |
|
45 | * Create new Item. |
|
46 | * |
|
47 | * @param int $id |
|
48 | * @param array $data |
|
49 | * |
|
50 | * @return object |
|
51 | */ |
|
52 | protected function addShippingZoneMethod($id, $data) |
|
53 | { |
|
54 | $this->endpoint = "shipping/zones/{$id}/methods"; |
|
55 | ||
56 | return self::create($data); |
|
57 | } |
|
58 | ||
59 | /** |
|
60 | * Retrieve single Item. |
|
61 | * |
|
62 | * @param int $zone_id |
|
63 | * @param int $id |
|
64 | * @param array $options |
|
65 | * |
|
66 | * @return object |
|
67 | */ |
|
68 | protected function getShippingZoneMethod($zone_id, $id, $options = []) |
|
69 | { |
|
70 | $this->endpoint = "shipping/zones/{$zone_id}/methods"; |
|
71 | ||
72 | return self::find($id, $options); |
|
73 | } |
|
74 | ||
75 | /** |
|
76 | * Retrieve all Items. |
|
77 | * |
|
78 | * @param int $id |
|
79 | * @param array $options |
|
80 | * |
|
81 | * @return array |
|
82 | */ |
|
83 | protected function getShippingZoneMethods($id, $options = []) |
|
84 | { |
|
85 | $this->endpoint = "shipping/zones/{$id}/methods"; |
|
86 | ||
87 | return self::all($options); |
|
88 | } |
|
89 | ||
90 | /** |
|
91 | * Update Existing Item. |
|
92 | * |
|
93 | * @param int $zone_id |
|
94 | * @param int $id |
|
95 | * @param array $data |
|
96 | * |
|
97 | * @return object |
|
98 | */ |
|
99 | protected function updateShippingZoneMethod($zone_id, $id, $data = []) |
|
100 | { |
|
101 | $this->endpoint = "shipping/zones/{$zone_id}/methods"; |
|
102 | ||
103 | return self::update($id, $data); |
|
104 | } |
|
105 | ||
106 | /** |
|
107 | * Destroy Item. |
|
108 | * |
|
109 | * @param int $zone_id |
|
110 | * @param int $id |
|
111 | * @param array $options |
|
112 | * |
|
113 | * @return object |
|
114 | */ |
|
115 | protected function deleteShippingZoneMethod($zone_id, $id, $options = []) |
|
116 | { |
|
117 | $this->endpoint = "shipping/zones/{$zone_id}/methods"; |
|
118 | ||
119 | return self::delete($id, $options); |
|
120 | } |
|
121 | } |
|
122 |