Completed
Push — master ( 3b1bc5...165104 )
by Joachim
06:51 queued 23s
created

Customer::getCustomerByEmail()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 9
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 9
loc 9
ccs 0
cts 5
cp 0
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 1
crap 2
1
<?php
2
namespace Loevgaard\Dandomain\Api\Endpoint;
3
4
use Assert\Assert;
5
6
class Customer extends Endpoint
7
{
8
9
    /**
10
     * @see https://shoppartner.dandomain.dk/dokumentation/api-documentation/customer/#GetCustomer_GET
11
     *
12
     * @param int $customerId
13
     * @return array
14
     */
15 3 View Code Duplication
    public function getCustomer(int $customerId) : array
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
16
    {
17 3
        Assert::that($customerId)->greaterThan(0, 'The $customerId has to be positive');
18
19 2
        return (array)$this->master->doRequest(
20 2
            'GET',
21 2
            sprintf('/admin/WEBAPI/Endpoints/v1_0/CustomerService/{KEY}/%d', $customerId)
22
        );
23
    }
24
25
    /**
26
     * @see https://shoppartner.dandomain.dk/dokumentation/api-documentation/customer/#GetCustomerByEmail_GET
27
     *
28
     * @param string $email
29
     * @return array
30
     */
31 View Code Duplication
    public function getCustomerByEmail(string $email) : array
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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      
46
     */
47
    public function createdSince(\DateTimeInterface $date) : array
48
    {
49
        return (array)$this->master->doRequest(
50
            'GET',
51
            sprintf('/admin/WEBAPI/Endpoints/v1_0/CustomerService/{KEY}/CreatedSince?date=%s', $date->format('Y-m-d\TH:i:s'))
52
        );
53
    }
54
55
    /**
56
     * @see https://shoppartner.dandomain.dk/dokumentation/api-documentation/customer/#CreateCustomer_POST
57
     *
58
     * @param array|\stdClass $customer
59
     * @return array
60
     */
61
    public function createCustomer($customer) : array
62
    {
63
        return (array)$this->master->doRequest('POST', '/admin/WEBAPI/Endpoints/v1_0/CustomerService/{KEY}', $customer);
64
    }
65
66
    /**
67
     * @see https://shoppartner.dandomain.dk/dokumentation/api-documentation/customer/#UpdateCustomer_PUT
68
     *
69
     * @param int $customerId
70
     * @param array|\stdClass $customer
71
     * @return array
72
     */
73 View Code Duplication
    public function updateCustomer(int $customerId, $customer) : array
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
74
    {
75
        Assert::that($customerId)->greaterThan(0, 'The $customerId has to be positive');
76
77
        return (array)$this->master->doRequest(
78
            'PUT',
79
            sprintf('/admin/WEBAPI/Endpoints/v1_0/CustomerService/{KEY}/%d', $customerId),
80
            $customer
81
        );
82
    }
83
84
    /**
85
     * @see https://shoppartner.dandomain.dk/dokumentation/api-documentation/customer/#DeleteCustomer_DELETE
86
     *
87
     * @param int $customerId
88
     * @return boolean
89
     */
90 View Code Duplication
    public function deleteCustomer(int $customerId) : bool
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
91
    {
92
        Assert::that($customerId)->greaterThan(0, 'The $customerId has to be positive');
93
94
        return (bool)$this->master->doRequest(
95
            'DELETE',
96
            sprintf(
97
                '/admin/WEBAPI/Endpoints/v1_0/CustomerService/{KEY}/%d',
98
                $customerId
99
            )
100
        );
101
    }
102
103
    /**
104
     * @see https://shoppartner.dandomain.dk/dokumentation/api-documentation/customer/#GetCustomerGroups_GET
105
     *
106
     * @return array
107
     */
108
    public function getCustomerGroups() : array
109
    {
110
        return (array)$this->master->doRequest(
111
            'GET',
112
            '/admin/WEBAPI/Endpoints/v1_0/CustomerService/{KEY}/CustomerGroup'
113
        );
114
    }
115
116
    /**
117
     * @see https://shoppartner.dandomain.dk/dokumentation/api-documentation/customer/#UpdateCustomerDiscountPOST
118
     *
119
     * @param int $customerId
120
     * @param array|\stdClass $customerDiscount
121
     * @return array
122
     */
123 View Code Duplication
    public function updateCustomerDiscount(int $customerId, $customerDiscount) : array
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
124
    {
125
        Assert::that($customerId)->greaterThan(0, 'The $customerId has to be positive');
126
127
        return (array)$this->master->doRequest(
128
            'POST',
129
            sprintf('/admin/WEBAPI/Endpoints/v1_0/CustomerService/{KEY}/UpdateCustomerDiscount/%d', $customerId),
130
            $customerDiscount
131
        );
132
    }
133
134
    /**
135
     * @see https://shoppartner.dandomain.dk/dokumentation/api-documentation/customer/#GetCustomerDiscountGET
136
     *
137
     * @param int $customerId
138
     * @return array
139
     */
140 View Code Duplication
    public function getCustomerDiscount(int $customerId) : array
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
141
    {
142
        Assert::that($customerId)->greaterThan(0, 'The $customerId has to be positive');
143
144
        return (array)$this->master->doRequest(
145
            'GET',
146
            sprintf(
147
                '/admin/WEBAPI/Endpoints/v1_0/CustomerService/{KEY}/GetCustomerDiscount/%d',
148
                $customerId
149
            )
150
        );
151
    }
152
}
153