Code Duplication    Length = 9-14 lines in 14 locations

src/Endpoint/Customer.php 1 location

@@ 31-42 (lines=12) @@
28
     * @param string $email
29
     * @return array
30
     */
31
    public function getCustomerByEmail(string $email) : array
32
    {
33
        Assert::that($email)->email();
34
35
        return (array)$this->master->doRequest(
36
            'GET',
37
            sprintf('/admin/WEBAPI/Endpoints/v1_0/CustomerService/{KEY}/GetCustomerByEmail?email=%s', rawurlencode($email))
38
        );
39
    }
40
    
41
    /**
42
     * @see https://shoppartner.dandomain.dk/dokumentation/api-documentation/customer/#General_Online_Reference
43
     *
44
     * @param  \DateTimeInterface $date
45
     * @return array      

src/Endpoint/Product.php 1 location

@@ 88-98 (lines=11) @@
85
     * @param array $context
86
     * @return array
87
     */
88
    public function getProductByMetadata(string $productNumber, array $context) : array
89
    {
90
        Assert::that($productNumber)->minLength(1, 'The length of $productNumber has to be > 0');
91
        Assert::that($context)->notEmpty();
92
93
        return (array)$this->master->doRequest(
94
            'POST',
95
            sprintf('/admin/WEBAPI/Endpoints/v1_0/ProductService/{KEY}/%s', rawurlencode($productNumber)),
96
            $context
97
        );
98
    }
99
100
    /**
101
     * @see http://4221117.shop53.dandomain.dk/admin/webapi/endpoints/v1_0/ProductService/help/operations/GetProductsInCategoryByMetadata

src/Endpoint/ProductData.php 9 locations

@@ 13-21 (lines=9) @@
10
     * @param string $productNumber
11
     * @return array
12
     */
13
    public function getDataProduct(string $productNumber) : array
14
    {
15
        Assert::that($productNumber)->minLength(1, 'The length of $productNumber has to be > 0');
16
17
        return (array)$this->master->doRequest(
18
            'GET',
19
            sprintf('/admin/WEBAPI/Endpoints/v1_0/ProductDataService/{KEY}/%s', rawurlencode($productNumber))
20
        );
21
    }
22
23
    /**
24
     * @param int $categoryId
@@ 41-49 (lines=9) @@
38
     * @param string $barCode
39
     * @return array
40
     */
41
    public function getDataProductsByBarcode(string $barCode) : array
42
    {
43
        Assert::that($barCode)->minLength(1, 'The length of $barCode has to be > 0');
44
45
        return (array)$this->master->doRequest(
46
            'GET',
47
            sprintf('/admin/WEBAPI/Endpoints/v1_0/ProductDataService/{KEY}/ByBarcode/%s', rawurlencode($barCode))
48
        );
49
    }
50
51
    /**
52
     * @param \DateTimeInterface $date
@@ 121-129 (lines=9) @@
118
     * @param int $stockCount
119
     * @return bool
120
     */
121
    public function setStockCount(string $productNumber, int $stockCount) : bool
122
    {
123
        Assert::that($productNumber)->minLength(1, 'The length of $productNumber has to be > 0');
124
125
        return (bool)$this->master->doRequest(
126
            'PUT',
127
            sprintf('/admin/WEBAPI/Endpoints/v1_0/ProductDataService/{KEY}/SetStockCount/%s/%d', rawurlencode($productNumber), $stockCount)
128
        );
129
    }
130
131
    /**
132
     * Will return the stock count for the specified product number
@@ 262-270 (lines=9) @@
259
     * @param string $productNumber
260
     * @return boolean
261
     */
262
    public function deleteProduct(string $productNumber) : bool
263
    {
264
        Assert::that($productNumber)->minLength(1, 'The length of $productNumber has to be > 0');
265
266
        return (bool)$this->master->doRequest(
267
            'DELETE',
268
            sprintf('/admin/WEBAPI/Endpoints/v1_0/ProductDataService/{KEY}/%s', rawurlencode($productNumber))
269
        );
270
    }
271
272
    /**
273
     * @param array|\stdClass $category
@@ 314-323 (lines=10) @@
311
     * @param array|\stdClass $product
312
     * @return array
313
     */
314
    public function updateProduct(string $productNumber, $product) : array
315
    {
316
        Assert::that($productNumber)->minLength(1, 'The length of $productNumber has to be > 0');
317
318
        return (array)$this->master->doRequest(
319
            'PUT',
320
            sprintf('/admin/WEBAPI/Endpoints/v1_0/ProductDataService/{KEY}/%s', rawurlencode($productNumber)),
321
            $product
322
        );
323
    }
324
325
    /**
326
     * @param string $productNumber
@@ 330-340 (lines=11) @@
327
     * @param KeyValueCollection $keyValueCollection
328
     * @return array
329
     */
330
    public function patchProduct(string $productNumber, KeyValueCollection $keyValueCollection) : array
331
    {
332
        Assert::that($productNumber)->minLength(1, 'The length of $productNumber has to be > 0');
333
        Assert::that($keyValueCollection->count())->greaterThan(0);
334
335
        return (array)$this->master->doRequest(
336
            'PATCH',
337
            sprintf('/admin/WEBAPI/Endpoints/v1_0/ProductDataService/{KEY}/%s', rawurlencode($productNumber)),
338
            $keyValueCollection->get()
339
        );
340
    }
341
342
    /**
343
     * @param string $productNumber
@@ 347-356 (lines=10) @@
344
     * @param array|\stdClass $price
345
     * @return array
346
     */
347
    public function createPrice(string $productNumber, $price) : array
348
    {
349
        Assert::that($productNumber)->minLength(1, 'The length of $productNumber has to be > 0');
350
351
        return (array)$this->master->doRequest(
352
            'POST',
353
            sprintf('/admin/WEBAPI/Endpoints/v1_0/ProductDataService/{KEY}/%s/Prices', rawurlencode($productNumber)),
354
            $price
355
        );
356
    }
357
358
    /**
359
     * @param string $productNumber
@@ 363-372 (lines=10) @@
360
     * @param array|\stdClass $price
361
     * @return bool
362
     */
363
    public function deletePrice(string $productNumber, $price) : bool
364
    {
365
        Assert::that($productNumber)->minLength(1, 'The length of $productNumber has to be > 0');
366
367
        return (bool)$this->master->doRequest(
368
            'DELETE',
369
            sprintf('/admin/WEBAPI/Endpoints/v1_0/ProductDataService/{KEY}/%s/Prices', rawurlencode($productNumber)),
370
            $price
371
        );
372
    }
373
374
    /**
375
     * @param string $productNumber
@@ 378-386 (lines=9) @@
375
     * @param string $productNumber
376
     * @return array
377
     */
378
    public function getPricesForProduct(string $productNumber) : array
379
    {
380
        Assert::that($productNumber)->minLength(1, 'The length of $productNumber has to be > 0');
381
382
        return (array)$this->master->doRequest(
383
            'GET',
384
            sprintf('/admin/WEBAPI/Endpoints/v1_0/ProductDataService/{KEY}/%s/Prices/List', rawurlencode($productNumber))
385
        );
386
    }
387
388
    /**
389
     * @param int $siteId

src/Endpoint/Order.php 2 locations

@@ 155-168 (lines=14) @@
152
     * @param string $comment
153
     * @return bool
154
     */
155
    public function setOrderComment(int $orderId, string $comment) : bool
156
    {
157
        Assert::that($orderId)->greaterThan(0, 'The $orderId has to be positive');
158
        Assert::that($comment)->minLength(1, 'The length of $comment has to be > 0');
159
160
        return (bool)$this->master->doRequest(
161
            'PUT',
162
            sprintf(
163
                '/admin/WEBAPI/Endpoints/v1_0/OrderService/{KEY}/SetOrderComment/%d?comment=%s',
164
                $orderId,
165
                rawurlencode($comment)
166
            )
167
        );
168
    }
169
170
    /**
171
     * @param int $orderId
@@ 191-204 (lines=14) @@
188
     * @param string $trackingNumber
189
     * @return bool
190
     */
191
    public function setTrackNumber(int $orderId, string $trackingNumber) : bool
192
    {
193
        Assert::that($orderId)->greaterThan(0, 'The $orderId has to be positive');
194
        Assert::that($trackingNumber)->minLength(1, 'The length of $trackingNumber has to be > 0');
195
196
        return (bool)$this->master->doRequest(
197
            'PUT',
198
            sprintf(
199
                '/admin/WEBAPI/Endpoints/v1_0/OrderService/{KEY}/SetTrackNumber/%d?tracknumber=%s',
200
                $orderId,
201
                rawurlencode($trackingNumber)
202
            )
203
        );
204
    }
205
206
    /******************
207
     * Helper methods *

src/Endpoint/ProductTag.php 1 location

@@ 102-111 (lines=10) @@
99
     * @param int $tagValueId
100
     * @return bool
101
     */
102
    public function assignTagValueToProduct(string $productNumber, int $tagValueId) : bool
103
    {
104
        Assert::that($productNumber)->minLength(1, 'The length of $productNumber has to be > 0');
105
        Assert::that($tagValueId)->greaterThan(0, '$tagValueId has to be positive');
106
107
        return (bool)$this->master->doRequest(
108
            'PUT',
109
            sprintf('/admin/WEBAPI/Endpoints/v1_0/ProductTagService/{KEY}/AssignTagValueToProduct/%s/%d', rawurlencode($productNumber), $tagValueId)
110
        );
111
    }
112
}
113