forked from voucherifyio/voucherify-php-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Customer.php
68 lines (59 loc) · 1.58 KB
/
Customer.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
namespace Voucherify;
class Customer extends VoucherifyRequest {
/**
* Customer constructor.
*
* @param string $apiID
* @param string $apiKey
*/
public function __construct($apiID, $apiKey) {
parent::__construct($apiID, $apiKey);
}
/**
* @param Customer $customer
*
* Create customer.
*
* @throws Voucherify\ClientException
*/
public function create($customer) {
return $this->apiRequest("POST", "/customers/", NULL, $customer);
}
/**
* @param string $customerId
*
* Get customer details
*
* @throws Voucherify\ClientException
*/
public function get($customerId) {
return $this->apiRequest("GET", "/customers/" . urlencode($customerId), NULL, NULL);
}
/**
* @param array|stdClass $customer Object with customer fields for update
*
* Update customer
*
* @throws Voucherify\ClientException
*/
public function update($customer) {
$customerId = "";
if (is_array($customer)) {
$customerId = $customer['id'];
} elseif (is_object($customer)) {
$customerId = $customer->id;
}
return $this->apiRequest("PUT", "/customers/" . urlencode($customerId), NULL, $customer);
}
/**
* @param $customerId Customer ID to delete
*
* Delete customer
*
* @throws Voucherify\ClientException
*/
public function delete($customerId) {
return $this->apiRequest("DELETE", "/customers/" . urlencode($customerId), NULL, NULL);
}
}