1 <?php
2 namespace MailChimp\Ecommerce;
3
4 class Customers extends Ecommerce
5 {
6
7 8 9 10 11 12 13
14 public function getCustomers($store_id, array $query = [])
15 {
16 return self::execute("GET", "ecommerce/stores/{$store_id}/customers", $query);
17 }
18
19 20 21 22 23 24 25 26
27 public function getCustomer($store_id, $customer_id, array $query = [])
28 {
29 return self::execute("GET", "ecommerce/stores/{$store_id}/customers/{$customer_id}", $query);
30 }
31
32 33 34 35 36 37 38 39 40 41
42 public function addCustomer($store_id, $customer_id, $email_address, $opt_in_status, array $optional_settings = null)
43 {
44 $optional_fields = ["company", "first_name", "last_name", "orders_count", "vendor", "total_spent", "address"];
45
46 $data = array(
47 "id" => $customer_id,
48 "email_address" => $email_address,
49 "opt_in_status" => $opt_in_status
50 );
51
52
53 if (isset($optional_settings)) {
54 $data = array_merge($data, self::optionalFields($optional_fields, $optional_settings));
55 }
56
57 return self::execute("POST", "ecommerce/stores/{$store_id}/customers/", $data);
58 }
59
60 61 62 63 64 65 66 67
68 public function updateCustomer($store_id, $customer_id, array $data = [] )
69 {
70 return self::execute("PATCH", "ecommerce/stores/{$store_id}/customers/{$customer_id}", $data);
71 }
72
73 74 75 76 77 78 79 80
81 public function upsertCustomer($store_id, $customer_id, array $data = [] )
82 {
83 return self::execute("PUT", "ecommerce/stores/{$store_id}/customers/{$customer_id}", $data);
84 }
85
86 87 88 89 90 91
92 public function deleteCustomer($store_id, $customer_id)
93 {
94 return self::execute("DELETE", "ecommerce/stores/{$store_id}/customers/{$customer_id}");
95 }
96
97
98 }
99