| @@ 49-68 (lines=20) @@ | ||
| 46 | * |
|
| 47 | * @var Product $product |
|
| 48 | */ |
|
| 49 | public function create(Product $product) |
|
| 50 | { |
|
| 51 | $method = RequestTypes::$POST; |
|
| 52 | $resource = '/products'; |
|
| 53 | ||
| 54 | $body = [ |
|
| 55 | 'id' => strval($product->getId()), |
|
| 56 | 'title' => strval($product->getTitle()), |
|
| 57 | 'handle' => strval($product->getHandle()), |
|
| 58 | 'url' => strval($product->getUrl()), |
|
| 59 | 'description' => strval($product->getDescription()), |
|
| 60 | 'type' => strval($product->getType()), |
|
| 61 | 'vendor' => strval($product->getVendor()), |
|
| 62 | 'image_url' => strval($product->getImageUrl()) |
|
| 63 | ]; |
|
| 64 | ||
| 65 | $this->addProductVariants($product, $body); |
|
| 66 | ||
| 67 | $this->mailChimp->doRequest($method, $body, $resource); |
|
| 68 | } |
|
| 69 | ||
| 70 | /** |
|
| 71 | * Edit a product in MailChimp |
|
| @@ 75-93 (lines=19) @@ | ||
| 72 | * |
|
| 73 | * @var Product $product |
|
| 74 | */ |
|
| 75 | public function edit(Product $product) |
|
| 76 | { |
|
| 77 | $method = RequestTypes::$PATCH; |
|
| 78 | $resource = '/products/'.$product->getId(); |
|
| 79 | ||
| 80 | $body = [ |
|
| 81 | 'title' => strval($product->getTitle()), |
|
| 82 | 'handle' => strval($product->getHandle()), |
|
| 83 | 'url' => strval($product->getUrl()), |
|
| 84 | 'description' => strval($product->getDescription()), |
|
| 85 | 'type' => strval($product->getType()), |
|
| 86 | 'vendor' => strval($product->getVendor()), |
|
| 87 | 'image_url' => strval($product->getImageUrl()) |
|
| 88 | ]; |
|
| 89 | ||
| 90 | $this->addProductVariants($product, $body); |
|
| 91 | ||
| 92 | $this->mailChimp->doRequest($method, $body, $resource); |
|
| 93 | } |
|
| 94 | ||
| 95 | /** |
|
| 96 | * Read products from MailChimp |
|