@@ 91-106 (lines=16) @@ | ||
88 | * |
|
89 | * @return array|bool |
|
90 | */ |
|
91 | public function updateCustomer(string $customerId, array $data) |
|
92 | { |
|
93 | $response = $this->sendRequest('PUT', sprintf('customers/%s', $customerId), ['content-type' => 'application/json'], json_encode($data)); |
|
94 | ||
95 | $result = $this->processResponse($response); |
|
96 | ||
97 | if ($result['code'] == '0') { |
|
98 | $customer = $result['customer']; |
|
99 | ||
100 | $this->deleteCustomerCache($customer); |
|
101 | ||
102 | return $customer; |
|
103 | } else { |
|
104 | return false; |
|
105 | } |
|
106 | } |
|
107 | ||
108 | /** |
|
109 | * @param array $customer |
|
@@ 127-140 (lines=14) @@ | ||
124 | * |
|
125 | * @return array|bool |
|
126 | */ |
|
127 | public function createCustomer(array $data) |
|
128 | { |
|
129 | $response = $this->sendRequest('POST', 'customers', ['content-type' => 'application/json'], json_encode($data)); |
|
130 | ||
131 | $result = $this->processResponse($response); |
|
132 | ||
133 | if ($result['code'] == '0') { |
|
134 | $customer = $result['customer']; |
|
135 | ||
136 | return $customer; |
|
137 | } else { |
|
138 | return false; |
|
139 | } |
|
140 | } |
|
141 | } |
|
142 |