1 <?php
2 namespace MailChimp\Ecommerce;
3
4 use MailChimp\MailChimp as MailChimp;
5 use MailChimp\Ecommerce\Carts as Carts;
6 use MailChimp\Ecommerce\Customers as Customers;
7 use MailChimp\Ecommerce\Orders as Orders;
8 use MailChimp\Ecommerce\Products as Products;
9
10 class Ecommerce extends MailChimp
11 {
12
13 14 15 16 17 18
19 public function getStores(array $query = [] )
20 {
21 return self::execute("GET", "ecommerce/stores", $query);
22 }
23
24 25 26 27 28 29 30
31 public function getStore($store_id, array $query = [] )
32 {
33 return self::execute("GET", "ecommerce/stores/{$store_id}", $query);
34 }
35
36 37 38 39 40 41 42 43 44 45
46 public function addStore($store_id, $list_id, $name, $currency_code, array $optional_settings = null)
47 {
48 $optional_fields = ["platform", "domain", "email_address", "money_format", "primary_locale", "timezone", "phone", "address"];
49
50 $data = [
51 "id" => $store_id,
52 "list_id" => $list_id,
53 "name" => $name,
54 "currency_code" => $currency_code
55 ];
56
57
58 if (isset($optional_settings)) {
59 $data = array_merge($data, self::optionalFields($optional_fields, $optional_settings));
60 }
61 return self::execute("POST", "ecommerce/stores", $data);
62 }
63
64 65 66 67 68 69
70 public function updateStore($store_id, array $data = [])
71 {
72 return self::execute("PATCH", "ecommerce/stores/{$store_id}", $data);
73 }
74
75 76 77 78 79
80 public function deleteStore($store_id)
81 {
82 return self::execute("DELETE", "ecommerce/stores/{$store_id}");
83 }
84
85 86 87
88
89 90 91 92
93 public function carts()
94 {
95 return new Carts;
96 }
97
98 99 100 101
102 public function customers()
103 {
104 return new Customers;
105 }
106
107 108 109 110
111 public function orders()
112 {
113 return new Orders;
114 }
115
116 117 118 119
120 public function products()
121 {
122 return new Products;
123 }
124
125 }
126