| @@ 57-73 (lines=17) @@ | ||
| 54 | * @var Order $order |
|
| 55 | * @throws \Exception |
|
| 56 | */ |
|
| 57 | public function create(Order $order) |
|
| 58 | { |
|
| 59 | $method = RequestTypes::$POST; |
|
| 60 | $resource = '/orders'; |
|
| 61 | ||
| 62 | $this->generateBody($order); |
|
| 63 | $this->addCustomer($order); |
|
| 64 | $this->addAddress($order->getCustomer(), $order->getShippingAddress(), 'shipping_address'); |
|
| 65 | $this->addAddress($order->getCustomer(), $order->getBillingAddress(), 'billing_address'); |
|
| 66 | $this->addOrderLines($order); |
|
| 67 | ||
| 68 | try { |
|
| 69 | $this->mailChimp->doRequest($method, $this->body, $resource); |
|
| 70 | } catch (\Exception $e) { |
|
| 71 | throw $e; |
|
| 72 | } |
|
| 73 | } |
|
| 74 | ||
| 75 | /** |
|
| 76 | * Edit an order in MailChimp |
|
| @@ 81-97 (lines=17) @@ | ||
| 78 | * @var Order $order |
|
| 79 | * @throws \Exception |
|
| 80 | */ |
|
| 81 | public function edit(Order $order) |
|
| 82 | { |
|
| 83 | $method = RequestTypes::$PATCH; |
|
| 84 | $resource = '/orders/'.$order->getId(); |
|
| 85 | ||
| 86 | $this->generateBody($order, false); |
|
| 87 | $this->addCustomer($order); |
|
| 88 | $this->addAddress($order->getCustomer(), $order->getShippingAddress(), 'shipping_address'); |
|
| 89 | $this->addAddress($order->getCustomer(), $order->getBillingAddress(), 'billing_address'); |
|
| 90 | $this->addOrderLines($order); |
|
| 91 | ||
| 92 | try { |
|
| 93 | $this->mailChimp->doRequest($method, $this->body, $resource); |
|
| 94 | } catch (\Exception $e) { |
|
| 95 | throw $e; |
|
| 96 | } |
|
| 97 | } |
|
| 98 | ||
| 99 | /** |
|
| 100 | * Read orders from MailChimp |
|