Passed
Push — master ( 485566...57f584 )
by Ro Kleine
03:17
created

ManagesFulfillments::rescheduleFulfillmentOrder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 2
c 1
b 0
f 1
nc 1
nop 2
dl 0
loc 5
rs 10
1
<?php
2
3
namespace Signifly\Shopify\REST\Actions;
4
5
use Illuminate\Support\Collection;
6
use Signifly\Shopify\REST\Resources\ApiResource;
7
use Signifly\Shopify\Shopify;
8
9
/** @mixin Shopify */
10
trait ManagesFulfillments
11
{
12
    public function getOrderFulfillmentsCount($orderId, array $params = []): int
13
    {
14
        return $this->getResourceCount('fulfillments', $params, ['orders', $orderId]);
0 ignored issues
show
Bug introduced by
It seems like getResourceCount() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

14
        return $this->/** @scrutinizer ignore-call */ getResourceCount('fulfillments', $params, ['orders', $orderId]);
Loading history...
15
    }
16
17
    public function getOrderFulfillments($orderId, array $params = []): Collection
18
    {
19
        return $this->getResources('fulfillments', $params, ['orders', $orderId]);
0 ignored issues
show
Bug introduced by
It seems like getResources() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

19
        return $this->/** @scrutinizer ignore-call */ getResources('fulfillments', $params, ['orders', $orderId]);
Loading history...
20
    }
21
22
    public function getOrderFulfillment($orderId, $fulfillmentId): ApiResource
23
    {
24
        return $this->getResource('fulfillments', $fulfillmentId, ['orders', $orderId]);
0 ignored issues
show
Bug introduced by
It seems like getResource() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

24
        return $this->/** @scrutinizer ignore-call */ getResource('fulfillments', $fulfillmentId, ['orders', $orderId]);
Loading history...
25
    }
26
27
    public function createFulfillment(array $data): ApiResource
28
    {
29
        return $this->createResource('fulfillments', $data);
0 ignored issues
show
Bug introduced by
It seems like createResource() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

29
        return $this->/** @scrutinizer ignore-call */ createResource('fulfillments', $data);
Loading history...
30
    }
31
32
    public function updateOrderFulfillment($orderId, $fulfillmentId, array $data): ApiResource
33
    {
34
        return $this->updateResource('fulfillments', $fulfillmentId, $data, ['orders', $orderId]);
0 ignored issues
show
Bug introduced by
It seems like updateResource() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

34
        return $this->/** @scrutinizer ignore-call */ updateResource('fulfillments', $fulfillmentId, $data, ['orders', $orderId]);
Loading history...
35
    }
36
37
    public function updateTrackingForFulfillment($fulfillmentId, array $data): ApiResource
38
    {
39
        $response = $this->post("fulfillments/{$fulfillmentId}/update_tracking.json", $data);
0 ignored issues
show
Bug introduced by
It seems like post() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

39
        /** @scrutinizer ignore-call */ 
40
        $response = $this->post("fulfillments/{$fulfillmentId}/update_tracking.json", $data);
Loading history...
40
41
        return new ApiResource($response['fulfillment'], $this);
42
    }
43
44
    public function completeOrderFulfillment($orderId, $fulfillmentId): ApiResource
45
    {
46
        $response = $this->post("orders/{$orderId}/fulfillments/{$fulfillmentId}/complete.json");
47
48
        return new ApiResource($response['fulfillment'], $this);
49
    }
50
51
    public function openOrderFulfillment($orderId, $fulfillmentId): ApiResource
52
    {
53
        $response = $this->post("orders/{$orderId}/fulfillments/{$fulfillmentId}/open.json");
54
55
        return new ApiResource($response['fulfillment'], $this);
56
    }
57
58
    public function cancelOrderFulfillment($orderId, $fulfillmentId): ApiResource
59
    {
60
        $response = $this->post("orders/{$orderId}/fulfillments/{$fulfillmentId}/cancel.json");
61
62
        return new ApiResource($response['fulfillment'], $this);
63
    }
64
65
    public function cancelFulfillment($fulfillmentId): ApiResource
66
    {
67
        $response = $this->post("fulfillments/{$fulfillmentId}/cancel.json");
68
69
        return new ApiResource($response['fulfillment'], $this);
70
    }
71
72
    public function getFulfillmentOrderFulfillments($fulfillmentOrderId, array $params = []): Collection
73
    {
74
        return $this->getResources('fulfillments', $params, ['fulfillment_orders', $fulfillmentOrderId]);
75
    }
76
77
    public function getOrderFulfillmentEvents($orderId, $fulfillmentId, array $params = []): Collection
78
    {
79
        return $this->getResources('events', $params, ['orders', $orderId, 'fulfillments', $fulfillmentId]);
80
    }
81
82
    public function getOrderFulfillmentEvent($orderId, $fulfillmentId, $eventId): ApiResource
83
    {
84
        return $this->getResource('events', $eventId, ['orders', $orderId, 'fulfillments', $fulfillmentId]);
85
    }
86
87
    public function createOrderFulfillmentEvent($orderId, $fulfillmentId, array $data): ApiResource
88
    {
89
        return $this->createResource('events', $data, ['orders', $orderId, 'fulfillments', $fulfillmentId]);
90
    }
91
92
    public function deleteOrderFulfillmentEvent($orderId, $fulfillmentId, $eventId): void
93
    {
94
        $this->deleteResource('events', $eventId, ['orders', $orderId, 'fulfillments', $fulfillmentId]);
0 ignored issues
show
Bug introduced by
It seems like deleteResource() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

94
        $this->/** @scrutinizer ignore-call */ 
95
               deleteResource('events', $eventId, ['orders', $orderId, 'fulfillments', $fulfillmentId]);
Loading history...
95
    }
96
97
    public function getOrderFulfillmentOrders($orderId, array $params = []): Collection
98
    {
99
        return $this->getResources('fulfillment_orders', $params, ['orders', $orderId]);
100
    }
101
102
    public function getFulfillmentOrder($fulfillmentOrderId): ApiResource
103
    {
104
        return $this->getResource('fulfillment_orders', $fulfillmentOrderId);
105
    }
106
107
    public function cancelFulfillmentOrder($fulfillmentOrderId): ApiResource
108
    {
109
        $response = $this->post("fulfillment_orders/{$fulfillmentOrderId}/cancel.json");
110
111
        return new ApiResource($response['fulfillment_order'], $this);
112
    }
113
114
    public function closeFulfillmentOrder($fulfillmentOrderId, array $data): ApiResource
115
    {
116
        $response = $this->post("fulfillment_orders/{$fulfillmentOrderId}/close.json", [
117
            'fulfillment_order' => $data,
118
        ]);
119
120
        return new ApiResource($response['fulfillment_order'], $this);
121
    }
122
123
    public function moveFulfillmentOrder($fulfillmentOrderId, array $data): ApiResource
124
    {
125
        $response = $this->post("fulfillment_orders/{$fulfillmentOrderId}/close.json", [
126
            'fulfillment_order' => $data,
127
        ]);
128
129
        return new ApiResource($response['fulfillment_order'], $this);
130
    }
131
132
    public function getFulfillmentOrderLocationsForMove($fulfillmentOrderId, array $params = []): Collection
133
    {
134
        return $this->getResources('locations_for_move', $params, ['fulfillment_orders', $fulfillmentOrderId]);
135
    }
136
137
    public function sendFulfillmentOrderFulfillmentRequest($fulfillmentOrderId, array $data = []): ApiResource
138
    {
139
        $response = $this->post("fulfillment_orders/{$fulfillmentOrderId}/fulfillment_request.json", [
140
            'fulfillment_request' => $data,
141
        ]);
142
143
        return new ApiResource($response['original_fulfillment_order'], $this);
144
    }
145
146
    public function acceptFulfillmentOrderFulfillmentRequest($fulfillmentOrderId, array $data = []): ApiResource
147
    {
148
        $response = $this->post("fulfillment_orders/{$fulfillmentOrderId}/fulfillment_request/accept.json", [
149
            'fulfillment_request' => $data,
150
        ]);
151
152
        return new ApiResource($response['fulfillment_order'], $this);
153
    }
154
155
    public function rejectFulfillmentOrderFulfillmentRequest($fulfillmentOrderId, array $data = []): ApiResource
156
    {
157
        $response = $this->post("fulfillment_orders/{$fulfillmentOrderId}/fulfillment_request/reject.json", [
158
            'fulfillment_request' => $data,
159
        ]);
160
161
        return new ApiResource($response['fulfillment_order'], $this);
162
    }
163
164
    public function createFulfillmentService(array $data): ApiResource
165
    {
166
        return $this->createResource('fulfillment_services', $data);
167
    }
168
169
    public function getFulfillmentServices(array $params = []): Collection
170
    {
171
        return $this->getResources('fulfillment_services', $params);
172
    }
173
174
    public function getFulfillmentService($fulfillmentServiceId): ApiResource
175
    {
176
        return $this->getResource('fulfillment_services', $fulfillmentServiceId);
177
    }
178
179
    public function updateFulfillmentService($fulfillmentServiceId, array $data): ApiResource
180
    {
181
        return $this->updateResource('fulfillment_services', $fulfillmentServiceId, $data);
182
    }
183
184
    public function deleteFulfillmentService($fulfillmentServiceId): void
185
    {
186
        $this->deleteResource('fulfillment_services', $fulfillmentServiceId);
187
    }
188
189
    public function createCarrierService(array $data): ApiResource
190
    {
191
        return $this->createResource('carrier_services', $data);
192
    }
193
194
    public function getCarrierServices(array $params = []): Collection
195
    {
196
        return $this->getResources('carrier_services', $params);
197
    }
198
199
    public function getCarrierService($carrierServiceId): ApiResource
200
    {
201
        return $this->getResource('carrier_services', $carrierServiceId);
202
    }
203
204
    public function updateCarrierService($carrierServiceId, array $data): ApiResource
205
    {
206
        return $this->updateResource('carrier_services', $carrierServiceId, $data);
207
    }
208
209
    public function deleteCarrierService($carrierServiceId): void
210
    {
211
        $this->deleteResource('carrier_services', $carrierServiceId);
212
    }
213
214
    public function sendFulfillmentOrderCancellationRequest($fulfillmentOrderId, array $data = []): ApiResource
215
    {
216
        $response = $this->post("fulfillment_orders/{$fulfillmentOrderId}/cancellation_request.json", [
217
            'cancellation_request' => $data,
218
        ]);
219
220
        return new ApiResource($response['fulfillment_order'], $this);
221
    }
222
223
    public function acceptFulfillmentOrderCancellationRequest($fulfillmentOrderId, array $data = []): ApiResource
224
    {
225
        $response = $this->post("fulfillment_orders/{$fulfillmentOrderId}/cancellation_request/accept.json", [
226
            'cancellation_request' => $data,
227
        ]);
228
229
        return new ApiResource($response['fulfillment_order'], $this);
230
    }
231
232
    public function rejectFulfillmentOrderCancellationRequest($fulfillmentOrderId, array $data = []): ApiResource
233
    {
234
        $response = $this->post("fulfillment_orders/{$fulfillmentOrderId}/cancellation_request/reject.json", [
235
            'cancellation_request' => $data,
236
        ]);
237
238
        return new ApiResource($response['fulfillment_order'], $this);
239
    }
240
241
    public function getAssignedFulfillmentOrders(string $assignmentStatus, array $locationIds): Collection
242
    {
243
        $response = $this->get('assigned_fulfillment_orders.json', [
0 ignored issues
show
Bug introduced by
It seems like get() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

243
        /** @scrutinizer ignore-call */ 
244
        $response = $this->get('assigned_fulfillment_orders.json', [
Loading history...
244
            'assignment_status' => $assignmentStatus,
245
            'location_ids%5B%5D' => $locationIds,
246
        ]);
247
248
        return $this->transformCollection($response['fulfillment_orders'], ApiResource::class);
0 ignored issues
show
Bug introduced by
It seems like transformCollection() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

248
        return $this->/** @scrutinizer ignore-call */ transformCollection($response['fulfillment_orders'], ApiResource::class);
Loading history...
249
    }
250
251
    public function holdFulfillmentOrder($fulfillmentOrderId, array $data): ApiResource
252
    {
253
        $response = $this->post("fulfillment_orders/{$fulfillmentOrderId}/hold.json", [
254
            'fulfillment_hold' => $data,
255
        ]);
256
257
        return new ApiResource($response['fulfillment_order'], $this);
258
    }
259
260
    public function openFulfillmentOrder($fulfillmentOrderId): ApiResource
261
    {
262
        $response = $this->post("fulfillment_orders/{$fulfillmentOrderId}/close.json");
263
264
        return new ApiResource($response['fulfillment_order'], $this);
265
    }
266
267
    public function releaseHoldFulfillmentOrder($fulfillmentOrderId): ApiResource
268
    {
269
        $response = $this->post("fulfillment_orders/{$fulfillmentOrderId}/release_hold.json");
270
271
        return new ApiResource($response['fulfillment_order'], $this);
272
    }
273
274
    public function rescheduleFulfillmentOrder($fulfillmentOrderId, $data): ApiResource
275
    {
276
        $response = $this->post("fulfillment_orders/{$fulfillmentOrderId}/reschedule.json", $data);
277
278
        return new ApiResource($response['fulfillment_order'], $this);
279
    }
280
281
    public function setFulfillmentOrdersDeadline(array $fulfillmentOrderIds, $fulfillmentDeadline): bool
282
    {
283
        $response = $this->post("fulfillment_orders/set_fulfillment_orders_deadline.json", [
0 ignored issues
show
Unused Code introduced by
The assignment to $response is dead and can be removed.
Loading history...
284
            'fulfillment_order_ids' => $fulfillmentOrderIds,
285
            'fulfillment_deadline' => $fulfillmentDeadline,
286
        ]);
287
288
        return true;
289
    }
290
291
}
292