protected function syncFavouriteList() { if (!isset($this->params['customer_token'])) { throw new ShopgateLibraryException(ShopgateLibraryException::PLUGIN_NO_CUSTOMER_TOKEN); } if (empty($this->params['items'])) { $this->params['items'] = array(); // a hack because there is no "empty array" representation in POST } if (empty($this->response)) { $this->response = new ShopgatePluginApiResponseAppJson($this->trace_id); } $syncItems = array(); foreach ($this->params['items'] as $syncItem) { if (!isset($syncItem['item_number'])) { throw new ShopgateLibraryException(ShopgateLibraryException::PLUGIN_API_WRONG_ITEM_FORMAT, 'missing required param "item_number"'); } if (!isset($syncItem['status'])) { throw new ShopgateLibraryException(ShopgateLibraryException::PLUGIN_API_WRONG_ITEM_FORMAT, 'missing required param "status"'); } $syncItems[] = new ShopgateSyncItem($syncItem); } $updatedSyncItems = $this->plugin->syncFavouriteList($this->params['customer_token'], $syncItems); if (!is_array($updatedSyncItems)) { throw new ShopgateLibraryException(ShopgateLibraryException::PLUGIN_API_WRONG_RESPONSE_FORMAT, 'Plugin Response: ' . var_export($updatedSyncItems, true)); } $resItems = array(); foreach ($updatedSyncItems as $updatedSyncItem) { if (!$updatedSyncItem instanceof ShopgateSyncItem) { throw new ShopgateLibraryException(ShopgateLibraryException::PLUGIN_API_WRONG_RESPONSE_FORMAT, 'Plugin Response: ' . var_export($updatedSyncItem, true)); } $resItem = $updatedSyncItem->toArray(); unset($resItem['status']); $resItems[] = $resItem; } $this->responseData['items'] = $resItems; }