From b1e2545e092838edc873023aad1eccab99099479 Mon Sep 17 00:00:00 2001 From: Falko Woudstra Date: Thu, 5 May 2022 20:13:12 +0200 Subject: [PATCH 1/3] Improve structure and fix missing quoteId parameter in ApiResourceQuotesShippingmethods@count --- README.md | 34 +- composer.json | 2 +- src/ApiClient.php | 955 +++ src/ApiException.php | 7 + src/ApiResourceAccount.php | 25 + src/ApiResourceAccountMetafields.php | 43 + src/ApiResourceAccountPermissions.php | 25 + src/ApiResourceAccountRatelimit.php | 25 + src/ApiResourceAdditionalcosts.php | 68 + src/ApiResourceAttributes.php | 81 + src/ApiResourceBlogs.php | 81 + src/ApiResourceBlogsArticles.php | 81 + src/ApiResourceBlogsArticlesImage.php | 71 + src/ApiResourceBlogsArticlesTags.php | 67 + src/ApiResourceBlogsComments.php | 81 + src/ApiResourceBlogsTags.php | 81 + src/ApiResourceBrands.php | 81 + src/ApiResourceBrandsImage.php | 71 + src/ApiResourceCatalog.php | 43 + src/ApiResourceCategories.php | 81 + src/ApiResourceCategoriesImage.php | 71 + src/ApiResourceCategoriesProducts.php | 67 + src/ApiResourceCategoriesProductsBulk.php | 29 + src/ApiResourceCheckouts.php | 77 + src/ApiResourceCheckoutsOrder.php | 28 + src/ApiResourceCheckoutsPayment_methods.php | 27 + src/ApiResourceCheckoutsProducts.php | 82 + src/ApiResourceCheckoutsShipment_methods.php | 27 + src/ApiResourceCheckoutsValidate.php | 27 + src/ApiResourceContacts.php | 43 + src/ApiResourceCountries.php | 43 + src/ApiResourceCustomers.php | 81 + src/ApiResourceCustomersLogin.php | 30 + src/ApiResourceCustomersMetafields.php | 86 + src/ApiResourceCustomersTokens.php | 30 + src/ApiResourceDashboard.php | 27 + src/ApiResourceDeliverydates.php | 81 + src/ApiResourceDiscountrules.php | 81 + src/ApiResourceDiscounts.php | 81 + src/ApiResourceEvents.php | 54 + src/ApiResourceExternal_services.php | 67 + src/ApiResourceFiles.php | 100 + src/ApiResourceFilters.php | 81 + src/ApiResourceFiltersValues.php | 86 + src/ApiResourceGroups.php | 81 + src/ApiResourceGroupsCustomers.php | 67 + src/ApiResourceInvoices.php | 57 + src/ApiResourceInvoicesItems.php | 45 + src/ApiResourceInvoicesMetafields.php | 86 + src/ApiResourceLanguages.php | 43 + src/ApiResourceLocations.php | 81 + src/ApiResourceMetafields.php | 81 + src/ApiResourceOrders.php | 57 + src/ApiResourceOrdersCredit.php | 30 + src/ApiResourceOrdersCustomstatuses.php | 81 + src/ApiResourceOrdersEvents.php | 43 + src/ApiResourceOrdersMetafields.php | 86 + src/ApiResourceOrdersProducts.php | 45 + src/ApiResourcePaymentmethods.php | 43 + src/ApiResourceProducts.php | 81 + src/ApiResourceProductsAttributes.php | 78 + src/ApiResourceProductsFiltervalues.php | 65 + src/ApiResourceProductsImages.php | 105 + src/ApiResourceProductsMetafields.php | 86 + src/ApiResourceProductsRelations.php | 86 + src/ApiResourceQuotes.php | 70 + src/ApiResourceQuotesConvert.php | 30 + src/ApiResourceQuotesPaymentmethods.php | 38 + src/ApiResourceQuotesProducts.php | 86 + src/ApiResourceQuotesShippingmethods.php | 39 + src/ApiResourceRedirects.php | 81 + src/ApiResourceReturns.php | 68 + src/ApiResourceReviews.php | 81 + src/ApiResourceSets.php | 81 + src/ApiResourceShipments.php | 57 + src/ApiResourceShipmentsMetafields.php | 86 + src/ApiResourceShipmentsProducts.php | 45 + src/ApiResourceShippingmethods.php | 43 + src/ApiResourceShippingmethodsCountries.php | 45 + src/ApiResourceShippingmethodsValues.php | 45 + src/ApiResourceShop.php | 38 + src/ApiResourceShopCompany.php | 25 + src/ApiResourceShopJavascript.php | 38 + src/ApiResourceShopLimits.php | 25 + src/ApiResourceShopMetafields.php | 81 + src/ApiResourceShopScripts.php | 81 + src/ApiResourceShopSettings.php | 25 + src/ApiResourceShopTracking.php | 81 + src/ApiResourceShopWebsite.php | 25 + src/ApiResourceSubscriptions.php | 81 + src/ApiResourceSuppliers.php | 81 + src/ApiResourceTags.php | 81 + src/ApiResourceTagsProducts.php | 67 + src/ApiResourceTaxes.php | 81 + src/ApiResourceTaxesOverrides.php | 86 + src/ApiResourceTextpages.php | 81 + src/ApiResourceThemeCategories.php | 81 + src/ApiResourceThemeProducts.php | 81 + src/ApiResourceTickets.php | 81 + src/ApiResourceTicketsMessages.php | 86 + src/ApiResourceTime.php | 25 + src/ApiResourceTypes.php | 81 + src/ApiResourceTypesAttributes.php | 67 + src/ApiResourceVariants.php | 81 + src/ApiResourceVariantsBulk.php | 29 + src/ApiResourceVariantsImage.php | 52 + src/ApiResourceVariantsMetafields.php | 86 + src/ApiResourceVariantsMovements.php | 43 + src/ApiResourceWebhooks.php | 81 + src/WebshopappApiClient.php | 7460 ------------------ 110 files changed, 7564 insertions(+), 7478 deletions(-) create mode 100755 src/ApiClient.php create mode 100644 src/ApiException.php create mode 100644 src/ApiResourceAccount.php create mode 100644 src/ApiResourceAccountMetafields.php create mode 100644 src/ApiResourceAccountPermissions.php create mode 100644 src/ApiResourceAccountRatelimit.php create mode 100644 src/ApiResourceAdditionalcosts.php create mode 100644 src/ApiResourceAttributes.php create mode 100644 src/ApiResourceBlogs.php create mode 100644 src/ApiResourceBlogsArticles.php create mode 100644 src/ApiResourceBlogsArticlesImage.php create mode 100644 src/ApiResourceBlogsArticlesTags.php create mode 100644 src/ApiResourceBlogsComments.php create mode 100644 src/ApiResourceBlogsTags.php create mode 100644 src/ApiResourceBrands.php create mode 100644 src/ApiResourceBrandsImage.php create mode 100644 src/ApiResourceCatalog.php create mode 100644 src/ApiResourceCategories.php create mode 100644 src/ApiResourceCategoriesImage.php create mode 100644 src/ApiResourceCategoriesProducts.php create mode 100644 src/ApiResourceCategoriesProductsBulk.php create mode 100644 src/ApiResourceCheckouts.php create mode 100644 src/ApiResourceCheckoutsOrder.php create mode 100644 src/ApiResourceCheckoutsPayment_methods.php create mode 100644 src/ApiResourceCheckoutsProducts.php create mode 100644 src/ApiResourceCheckoutsShipment_methods.php create mode 100644 src/ApiResourceCheckoutsValidate.php create mode 100644 src/ApiResourceContacts.php create mode 100644 src/ApiResourceCountries.php create mode 100644 src/ApiResourceCustomers.php create mode 100644 src/ApiResourceCustomersLogin.php create mode 100644 src/ApiResourceCustomersMetafields.php create mode 100644 src/ApiResourceCustomersTokens.php create mode 100644 src/ApiResourceDashboard.php create mode 100644 src/ApiResourceDeliverydates.php create mode 100644 src/ApiResourceDiscountrules.php create mode 100644 src/ApiResourceDiscounts.php create mode 100644 src/ApiResourceEvents.php create mode 100644 src/ApiResourceExternal_services.php create mode 100644 src/ApiResourceFiles.php create mode 100644 src/ApiResourceFilters.php create mode 100644 src/ApiResourceFiltersValues.php create mode 100644 src/ApiResourceGroups.php create mode 100644 src/ApiResourceGroupsCustomers.php create mode 100644 src/ApiResourceInvoices.php create mode 100644 src/ApiResourceInvoicesItems.php create mode 100644 src/ApiResourceInvoicesMetafields.php create mode 100644 src/ApiResourceLanguages.php create mode 100644 src/ApiResourceLocations.php create mode 100644 src/ApiResourceMetafields.php create mode 100644 src/ApiResourceOrders.php create mode 100644 src/ApiResourceOrdersCredit.php create mode 100644 src/ApiResourceOrdersCustomstatuses.php create mode 100644 src/ApiResourceOrdersEvents.php create mode 100644 src/ApiResourceOrdersMetafields.php create mode 100644 src/ApiResourceOrdersProducts.php create mode 100644 src/ApiResourcePaymentmethods.php create mode 100644 src/ApiResourceProducts.php create mode 100644 src/ApiResourceProductsAttributes.php create mode 100644 src/ApiResourceProductsFiltervalues.php create mode 100644 src/ApiResourceProductsImages.php create mode 100644 src/ApiResourceProductsMetafields.php create mode 100644 src/ApiResourceProductsRelations.php create mode 100644 src/ApiResourceQuotes.php create mode 100644 src/ApiResourceQuotesConvert.php create mode 100644 src/ApiResourceQuotesPaymentmethods.php create mode 100644 src/ApiResourceQuotesProducts.php create mode 100644 src/ApiResourceQuotesShippingmethods.php create mode 100644 src/ApiResourceRedirects.php create mode 100644 src/ApiResourceReturns.php create mode 100644 src/ApiResourceReviews.php create mode 100644 src/ApiResourceSets.php create mode 100644 src/ApiResourceShipments.php create mode 100644 src/ApiResourceShipmentsMetafields.php create mode 100644 src/ApiResourceShipmentsProducts.php create mode 100644 src/ApiResourceShippingmethods.php create mode 100644 src/ApiResourceShippingmethodsCountries.php create mode 100644 src/ApiResourceShippingmethodsValues.php create mode 100644 src/ApiResourceShop.php create mode 100644 src/ApiResourceShopCompany.php create mode 100644 src/ApiResourceShopJavascript.php create mode 100644 src/ApiResourceShopLimits.php create mode 100644 src/ApiResourceShopMetafields.php create mode 100644 src/ApiResourceShopScripts.php create mode 100644 src/ApiResourceShopSettings.php create mode 100644 src/ApiResourceShopTracking.php create mode 100644 src/ApiResourceShopWebsite.php create mode 100644 src/ApiResourceSubscriptions.php create mode 100644 src/ApiResourceSuppliers.php create mode 100644 src/ApiResourceTags.php create mode 100644 src/ApiResourceTagsProducts.php create mode 100644 src/ApiResourceTaxes.php create mode 100644 src/ApiResourceTaxesOverrides.php create mode 100644 src/ApiResourceTextpages.php create mode 100644 src/ApiResourceThemeCategories.php create mode 100644 src/ApiResourceThemeProducts.php create mode 100644 src/ApiResourceTickets.php create mode 100644 src/ApiResourceTicketsMessages.php create mode 100644 src/ApiResourceTime.php create mode 100644 src/ApiResourceTypes.php create mode 100644 src/ApiResourceTypesAttributes.php create mode 100644 src/ApiResourceVariants.php create mode 100644 src/ApiResourceVariantsBulk.php create mode 100644 src/ApiResourceVariantsImage.php create mode 100644 src/ApiResourceVariantsMetafields.php create mode 100644 src/ApiResourceVariantsMovements.php create mode 100644 src/ApiResourceWebhooks.php delete mode 100755 src/WebshopappApiClient.php diff --git a/README.md b/README.md index e55ff6a..69649c7 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -![Lightspeed eCom](http://developers.seoshop.com/assets/gfx/logo.png) +![Lightspeed eCom](https://developers.lightspeedhq.com/images/new_logo.png) [![Latest Stable Version](http://img.shields.io/packagist/v/seoshop/seoshop-php.svg)](https://packagist.org/packages/seoshop/seoshop-php) [![Latest Unstable Version](http://img.shields.io/packagist/vpre/seoshop/seoshop-php.svg)](https://packagist.org/packages/seoshop/seoshop-php) @@ -7,14 +7,22 @@ # Lightspeed eCom PHP API client This package is a convenience wrapper to communicate with the Lightspeed eCom REST-API. + +## Requirements +To use the Lightspeed eCom PHP API client, the following things are required: + ++ PHP >= 5.4 ++ cURL, JSON, mbstring and FileInfo PHP extensions + + ## Installation -For the installation of the client, there are 2 ways. The composer way is preferable, but not always possible. -### Composer -**Note: From client version 1.9.0 and upward, we will only support PHP 5.4 and above.** +By far the easiest way to install the Lightspeed eCom PHP API client is to require it with [Composer](http://getcomposer.org/doc/00-intro.md). -Include the package in your `composer.json` file -``` json +``` bash +$ composer require seoshop/seoshop-php:^1.9 +``` +```json { "require": { "seoshop/seoshop-php": "^1.9" @@ -22,16 +30,8 @@ Include the package in your `composer.json` file } ``` -...then run `composer update` and load the composer autoloader: - -``` php -shop->get(); ``` diff --git a/composer.json b/composer.json index f2abcfe..57e442b 100644 --- a/composer.json +++ b/composer.json @@ -18,6 +18,6 @@ "ext-fileinfo": "*" }, "autoload": { - "files": ["src/WebshopappApiClient.php"] + "files": ["src/*.php"] } } diff --git a/src/ApiClient.php b/src/ApiClient.php new file mode 100755 index 0000000..a5a2b07 --- /dev/null +++ b/src/ApiClient.php @@ -0,0 +1,955 @@ +setApiServer($apiServer); + $this->setApiKey($apiKey); + $this->setApiSecret($apiSecret); + $this->setApiLanguage($apiLanguage); + + $this->registerResources(); + } + + /** + * @return string + */ + public function getApiLanguage() + { + return $this->apiLanguage; + } + + /** + * @param $apiServer + */ + public function setApiServer($apiServer) + { + $this->apiServer = $apiServer; + } + + /** + * @param $apiKey + */ + public function setApiKey($apiKey) + { + $this->apiKey = $apiKey; + } + + /** + * @return string + */ + public function getApiKey() + { + return $this->apiKey; + } + + /** + * @param $apiSecret + */ + public function setApiSecret($apiSecret) + { + $this->apiSecret = $apiSecret; + } + + /** + * @return string + */ + public function getApiSecret() + { + return $this->apiSecret; + } + + /** + * @param $apiLanguage + */ + public function setApiLanguage($apiLanguage) + { + $this->apiLanguage = $apiLanguage; + } + + /** + * @return string + */ + public function getApiServer() + { + return $this->apiServer; + } + + /** + * @return int + */ + public function getApiCallsMade() + { + return $this->apiCallsMade; + } + + /** + * @param array $responseHeaders + * + * @return void + */ + public function setResponseHeaders($responseHeaders) + { + $this->responseHeaders = $responseHeaders; + } + + /** + * @return array + */ + public function getResponseHeaders() + { + return $this->responseHeaders; + } + + /** + * @throws ApiException + */ + private function checkLoginCredentials() + { + if (strlen($this->getApiKey()) !== 32 || strlen($this->getApiSecret()) !== 32) + { + throw new ApiException('Invalid login credentials.'); + } + if (strlen($this->getApiLanguage()) !== 2) + { + throw new ApiException('Invalid API language.'); + } + } + + private function registerResources() + { + $this->account = new ApiResourceAccount($this); + $this->accountMetafields = new ApiResourceAccountMetafields($this); + $this->accountPermissions = new ApiResourceAccountPermissions($this); + $this->accountRatelimit = new ApiResourceAccountRatelimit($this); + $this->additionalcosts = new ApiResourceAdditionalcosts($this); + $this->attributes = new ApiResourceAttributes($this); + $this->blogs = new ApiResourceBlogs($this); + $this->blogsArticles = new ApiResourceBlogsArticles($this); + $this->blogsArticlesImage = new ApiResourceBlogsArticlesImage($this); + $this->blogsArticlesTags = new ApiResourceBlogsArticlesTags($this); + $this->blogsComments = new ApiResourceBlogsComments($this); + $this->blogsTags = new ApiResourceBlogsTags($this); + $this->brands = new ApiResourceBrands($this); + $this->brandsImage = new ApiResourceBrandsImage($this); + $this->catalog = new ApiResourceCatalog($this); + $this->categories = new ApiResourceCategories($this); + $this->categoriesImage = new ApiResourceCategoriesImage($this); + $this->categoriesProducts = new ApiResourceCategoriesProducts($this); + $this->categoriesProductsBulk = new ApiResourceCategoriesProductsBulk($this); + $this->checkouts = new ApiResourceCheckouts($this); + $this->checkoutsOrder = new ApiResourceCheckoutsOrder($this); + $this->checkoutsPayment_methods = new ApiResourceCheckoutsPayment_methods($this); + $this->checkoutsProducts = new ApiResourceCheckoutsProducts($this); + $this->checkoutsShipment_methods = new ApiResourceCheckoutsShipment_methods($this); + $this->checkoutsValidate = new ApiResourceCheckoutsValidate($this); + $this->contacts = new ApiResourceContacts($this); + $this->countries = new ApiResourceCountries($this); + $this->customers = new ApiResourceCustomers($this); + $this->customersLogin = new ApiResourceCustomersLogin($this); + $this->customersMetafields = new ApiResourceCustomersMetafields($this); + $this->customersTokens = new ApiResourceCustomersTokens($this); + $this->dashboard = new ApiResourceDashboard($this); + $this->deliverydates = new ApiResourceDeliverydates($this); + $this->discountrules = new ApiResourceDiscountrules($this); + $this->discounts = new ApiResourceDiscounts($this); + $this->events = new ApiResourceEvents($this); + $this->external_services = new ApiResourceExternal_services($this); + $this->files = new ApiResourceFiles($this); + $this->filters = new ApiResourceFilters($this); + $this->filtersValues = new ApiResourceFiltersValues($this); + $this->groups = new ApiResourceGroups($this); + $this->groupsCustomers = new ApiResourceGroupsCustomers($this); + $this->invoices = new ApiResourceInvoices($this); + $this->invoicesItems = new ApiResourceInvoicesItems($this); + $this->invoicesMetafields = new ApiResourceInvoicesMetafields($this); + $this->languages = new ApiResourceLanguages($this); + $this->locations = new ApiResourceLocations($this); + $this->metafields = new ApiResourceMetafields($this); + $this->orders = new ApiResourceOrders($this); + $this->ordersCredit = new ApiResourceOrdersCredit($this); + $this->ordersMetafields = new ApiResourceOrdersMetafields($this); + $this->ordersProducts = new ApiResourceOrdersProducts($this); + $this->ordersCustomstatuses = new ApiResourceOrdersCustomstatuses($this); + $this->ordersEvents = new ApiResourceOrdersEvents($this); + $this->paymentmethods = new ApiResourcePaymentmethods($this); + $this->products = new ApiResourceProducts($this); + $this->productsAttributes = new ApiResourceProductsAttributes($this); + $this->productsFiltervalues = new ApiResourceProductsFiltervalues($this); + $this->productsImages = new ApiResourceProductsImages($this); + $this->productsMetafields = new ApiResourceProductsMetafields($this); + $this->productsRelations = new ApiResourceProductsRelations($this); + $this->quotes = new ApiResourceQuotes($this); + $this->quotesConvert = new ApiResourceQuotesConvert($this); + $this->quotesPaymentmethods = new ApiResourceQuotesPaymentmethods($this); + $this->quotesProducts = new ApiResourceQuotesProducts($this); + $this->quotesShippingmethods = new ApiResourceQuotesShippingmethods($this); + $this->redirects = new ApiResourceRedirects($this); + $this->returns = new ApiResourceReturns($this); + $this->reviews = new ApiResourceReviews($this); + $this->sets = new ApiResourceSets($this); + $this->shipments = new ApiResourceShipments($this); + $this->shipmentsMetafields = new ApiResourceShipmentsMetafields($this); + $this->shipmentsProducts = new ApiResourceShipmentsProducts($this); + $this->shippingmethods = new ApiResourceShippingmethods($this); + $this->shippingmethodsCountries = new ApiResourceShippingmethodsCountries($this); + $this->shippingmethodsValues = new ApiResourceShippingmethodsValues($this); + $this->shop = new ApiResourceShop($this); + $this->shopCompany = new ApiResourceShopCompany($this); + $this->shopJavascript = new ApiResourceShopJavascript($this); + $this->shopLimits = new ApiResourceShopLimits($this); + $this->shopMetafields = new ApiResourceShopMetafields($this); + $this->shopScripts = new ApiResourceShopScripts($this); + $this->shopSettings = new ApiResourceShopSettings($this); + $this->shopTracking = new ApiResourceShopTracking($this); + $this->shopWebsite = new ApiResourceShopWebsite($this); + $this->subscriptions = new ApiResourceSubscriptions($this); + $this->suppliers = new ApiResourceSuppliers($this); + $this->tags = new ApiResourceTags($this); + $this->tagsProducts = new ApiResourceTagsProducts($this); + $this->taxes = new ApiResourceTaxes($this); + $this->taxesOverrides = new ApiResourceTaxesOverrides($this); + $this->textpages = new ApiResourceTextpages($this); + $this->themeCategories = new ApiResourceThemeCategories($this); + $this->themeProducts = new ApiResourceThemeProducts($this); + $this->tickets = new ApiResourceTickets($this); + $this->ticketsMessages = new ApiResourceTicketsMessages($this); + $this->time = new ApiResourceTime($this); + $this->types = new ApiResourceTypes($this); + $this->typesAttributes = new ApiResourceTypesAttributes($this); + $this->variants = new ApiResourceVariants($this); + $this->variantsImage = new ApiResourceVariantsImage($this); + $this->variantsMetafields = new ApiResourceVariantsMetafields($this); + $this->variantsBulk = new ApiResourceVariantsBulk($this); + $this->variantsMovements = new ApiResourceVariantsMovements($this); + $this->webhooks = new ApiResourceWebhooks($this); + } + + /** + * @param string $resourceUrl + * @param array $params + * + * @return string + */ + private function getUrl($resourceUrl, $params = null) + { + if ($this->apiServer == 'live') + { + $apiHost = self::SERVER_HOST_LIVE; + } + elseif ($this->apiServer == 'local') + { + $apiHost = self::SERVER_HOST_LOCAL; + } + elseif ($this->apiServer == 'eu1') + { + $apiHost = self::SERVER_EU1_LIVE; + } + elseif ($this->apiServer == 'us1') + { + $apiHost = self::SERVER_US1_LIVE; + } + + $apiHostParts = parse_url($apiHost); + $resourceUrlParts = parse_url($resourceUrl); + + $apiUrl = $apiHostParts['scheme'] . '://' . $this->getApiKey() . ':' . $this->getApiSecret() . '@' . $apiHostParts['host'] . '/'; + if (isset($apiHostParts['path']) && strlen(trim($apiHostParts['path'], '/'))) + { + $apiUrl .= trim($apiHostParts['path'], '/') . '/'; + } + $apiUrl .= $this->getApiLanguage() . '/' . $resourceUrlParts['path'] . '.json'; + + if (isset($resourceUrlParts['query'])) + { + $apiUrl .= '?' . $resourceUrlParts['query']; + } + elseif ($params && is_array($params)) + { + $queryParameters = array(); + + foreach ($params as $key => $value) + { + if (!is_array($value)) + { + $queryParameters[] = $key . '=' . urlencode($value); + } + } + + $queryParameters = implode('&', $queryParameters); + + if (!empty($queryParameters)) + { + $apiUrl .= '?' . $queryParameters; + } + } + + return $apiUrl; + } + + /** + * Invoke the Webshopapp API. + * + * @param string $url The resource url (required) + * @param string $method The http method (default 'get') + * @param array $payload The query/post data + * + * @return mixed The decoded response object + * @throws ApiException + */ + private function sendRequest($url, $method, $payload = null, $options = []) + { + $this->checkLoginCredentials(); + + if ($method == 'post' || $method == 'put') + { + if (!$payload || !is_array($payload)) + { + throw new ApiException(100, 'Invalid payload'); + } + + $multipart = array_key_exists('header', $options); + + $header = $multipart ? $options['header'] : 'application/json'; + + $curlOptions = array( + CURLOPT_URL => $this->getUrl($url), + CURLOPT_CUSTOMREQUEST => strtoupper($method), + CURLOPT_HTTPHEADER => array('Content-Type: ' . $header), + CURLOPT_POST => true, + CURLOPT_POSTFIELDS => $multipart ? $payload : json_encode($payload), + ); + } + elseif ($method == 'delete') + { + $curlOptions = array( + CURLOPT_URL => $this->getUrl($url), + CURLOPT_CUSTOMREQUEST => 'DELETE', + ); + } + else + { + $curlOptions = array( + CURLOPT_URL => $this->getUrl($url, $payload), + ); + } + + $curlOptions += array( + CURLOPT_HEADER => false, + CURLOPT_RETURNTRANSFER => true, + CURLOPT_SSL_VERIFYPEER => false, + CURLOPT_USERAGENT => 'ApiClient/' . self::CLIENT_VERSION . ' (PHP/' . phpversion() . ')', + CURLOPT_SSLVERSION => 6, + ); + + $curlHandle = curl_init(); + + curl_setopt_array($curlHandle, $curlOptions); + + $headers = []; + + curl_setopt($curlHandle, CURLOPT_HEADERFUNCTION, function($curl, $header) use (&$headers) { + $length = strlen($header); + $header = explode(':', $header, 2); + + if (count($header) <= 1) { + return $length; + } + + $header = array_map('trim', $header); + $headers[$header[0]] = $header[1]; + + return $length; + }); + + $responseBody = curl_exec($curlHandle); + + if ($headers) { + $this->setResponseHeaders($headers); + } + + if (curl_errno($curlHandle)) + { + $this->handleCurlError($curlHandle); + } + + $responseBody = json_decode($responseBody, true); + $responseCode = curl_getinfo($curlHandle, CURLINFO_HTTP_CODE); + + curl_close($curlHandle); + + $this->apiCallsMade ++; + + if ($responseCode < 200 || $responseCode > 299 || ($responseBody && array_key_exists('error', $responseBody))) + { + $this->handleResponseError($responseCode, $responseBody); + } + + if ($responseBody && preg_match('/^checkout/i', $url) !== 1) + { + $responseBody = array_shift($responseBody); + } + + return $responseBody; + } + + /** + * @param int $responseCode + * @param array $responseBody + * + * @throws ApiException + */ + private function handleResponseError($responseCode, $responseBody) + { + $errorMessage = 'Unknown error: ' . $responseCode; + + if ($responseBody && array_key_exists('error', $responseBody)) + { + $errorMessage = $responseBody['error']['message']; + } + + throw new ApiException($errorMessage, $responseCode); + } + + /** + * @param resource $curlHandle + * + * @throws ApiException + */ + private function handleCurlError($curlHandle) + { + $errorMessage = 'Curl error: ' . curl_error($curlHandle); + + throw new ApiException($errorMessage, curl_errno($curlHandle)); + } + + /** + * @param string $url + * @param array $payload + * @param array $options + * + * @return array + * @throws ApiException + */ + public function create($url, $payload, $options = []) + { + return $this->sendRequest($url, 'post', $payload, $options); + } + + /** + * @param string $url + * @param array $params + * + * @return array|int + * @throws ApiException + */ + public function read($url, $params = array()) + { + return $this->sendRequest($url, 'get', $params); + } + + /** + * @param string $url + * @param array $payload + * @param array $options + * + * @return array + * @throws ApiException + */ + public function update($url, $payload, $options = []) + { + return $this->sendRequest($url, 'put', $payload, $options); + } + + /** + * @param string $url + * + * @return array + * @throws ApiException + */ + public function delete($url) + { + return $this->sendRequest($url, 'delete'); + } +} diff --git a/src/ApiException.php b/src/ApiException.php new file mode 100644 index 0000000..eaf7353 --- /dev/null +++ b/src/ApiException.php @@ -0,0 +1,7 @@ +client = $client; + } + + /** + * @return array + * @throws ApiException + */ + public function get() + { + return $this->client->read('account'); + } +} \ No newline at end of file diff --git a/src/ApiResourceAccountMetafields.php b/src/ApiResourceAccountMetafields.php new file mode 100644 index 0000000..0a60976 --- /dev/null +++ b/src/ApiResourceAccountMetafields.php @@ -0,0 +1,43 @@ +client = $client; + } + + /** + * @param int $metafieldId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($metafieldId = null, $params = array()) + { + if (!$metafieldId) { + return $this->client->read('account/metafields', $params); + } else { + return $this->client->read('account/metafields/' . $metafieldId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('account/metafields/count', $params); + } +} \ No newline at end of file diff --git a/src/ApiResourceAccountPermissions.php b/src/ApiResourceAccountPermissions.php new file mode 100644 index 0000000..fa24a4d --- /dev/null +++ b/src/ApiResourceAccountPermissions.php @@ -0,0 +1,25 @@ +client = $client; + } + + /** + * @return array + * @throws ApiException + */ + public function get() + { + return $this->client->read('account/permissions'); + } +} \ No newline at end of file diff --git a/src/ApiResourceAccountRatelimit.php b/src/ApiResourceAccountRatelimit.php new file mode 100644 index 0000000..dfe83da --- /dev/null +++ b/src/ApiResourceAccountRatelimit.php @@ -0,0 +1,25 @@ +client = $client; + } + + /** + * @return array + * @throws ApiException + */ + public function get() + { + return $this->client->read('account/ratelimit'); + } +} \ No newline at end of file diff --git a/src/ApiResourceAdditionalcosts.php b/src/ApiResourceAdditionalcosts.php new file mode 100644 index 0000000..f292069 --- /dev/null +++ b/src/ApiResourceAdditionalcosts.php @@ -0,0 +1,68 @@ +client = $client; + } + + /** + * @param int $additionalcostId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($additionalcostId = null, $params = array()) + { + if (!$additionalcostId) { + return $this->client->read('additionalcosts', $params); + } else { + return $this->client->read('additionalcosts/' . $additionalcostId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('additionalcosts/count', $params); + } + + /** + * @param int $additionalcostId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($additionalcostId, $fields) + { + $fields = array('additionalCost' => $fields); + + return $this->client->update('additionalcosts/' . $additionalcostId, $fields); + } + + /** + * @param int $additionalcostId + * + * @return array + * @throws ApiException + */ + public function delete($additionalcostId) + { + return $this->client->delete('additionalcosts/' . $additionalcostId); + } +} \ No newline at end of file diff --git a/src/ApiResourceAttributes.php b/src/ApiResourceAttributes.php new file mode 100644 index 0000000..e83cc8e --- /dev/null +++ b/src/ApiResourceAttributes.php @@ -0,0 +1,81 @@ +client = $client; + } + + /** + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($fields) + { + $fields = array('attribute' => $fields); + + return $this->client->create('attributes', $fields); + } + + /** + * @param int $attributeId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($attributeId = null, $params = array()) + { + if (!$attributeId) { + return $this->client->read('attributes', $params); + } else { + return $this->client->read('attributes/' . $attributeId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('attributes/count', $params); + } + + /** + * @param int $attributeId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($attributeId, $fields) + { + $fields = array('attribute' => $fields); + + return $this->client->update('attributes/' . $attributeId, $fields); + } + + /** + * @param int $attributeId + * + * @return array + * @throws ApiException + */ + public function delete($attributeId) + { + return $this->client->delete('attributes/' . $attributeId); + } +} \ No newline at end of file diff --git a/src/ApiResourceBlogs.php b/src/ApiResourceBlogs.php new file mode 100644 index 0000000..f158db4 --- /dev/null +++ b/src/ApiResourceBlogs.php @@ -0,0 +1,81 @@ +client = $client; + } + + /** + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($fields) + { + $fields = array('blog' => $fields); + + return $this->client->create('blogs', $fields); + } + + /** + * @param int $blogId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($blogId = null, $params = array()) + { + if (!$blogId) { + return $this->client->read('blogs', $params); + } else { + return $this->client->read('blogs/' . $blogId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('blogs/count', $params); + } + + /** + * @param int $blogId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($blogId, $fields) + { + $fields = array('blog' => $fields); + + return $this->client->update('blogs/' . $blogId, $fields); + } + + /** + * @param int $blogId + * + * @return array + * @throws ApiException + */ + public function delete($blogId) + { + return $this->client->delete('blogs/' . $blogId); + } +} \ No newline at end of file diff --git a/src/ApiResourceBlogsArticles.php b/src/ApiResourceBlogsArticles.php new file mode 100644 index 0000000..e677300 --- /dev/null +++ b/src/ApiResourceBlogsArticles.php @@ -0,0 +1,81 @@ +client = $client; + } + + /** + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($fields) + { + $fields = array('blogArticle' => $fields); + + return $this->client->create('blogs/articles', $fields); + } + + /** + * @param int $articleId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($articleId = null, $params = array()) + { + if (!$articleId) { + return $this->client->read('blogs/articles', $params); + } else { + return $this->client->read('blogs/articles/' . $articleId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('blogs/articles/count', $params); + } + + /** + * @param int $articleId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($articleId, $fields) + { + $fields = array('blogArticle' => $fields); + + return $this->client->update('blogs/articles/' . $articleId, $fields); + } + + /** + * @param int $articleId + * + * @return array + * @throws ApiException + */ + public function delete($articleId) + { + return $this->client->delete('blogs/articles/' . $articleId); + } +} \ No newline at end of file diff --git a/src/ApiResourceBlogsArticlesImage.php b/src/ApiResourceBlogsArticlesImage.php new file mode 100644 index 0000000..f1fd1cc --- /dev/null +++ b/src/ApiResourceBlogsArticlesImage.php @@ -0,0 +1,71 @@ +client = $client; + } + + /** + * @param int $articleId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($articleId, $fields) + { + if (strpos($fields['attachment'], 'http') === false) { + try { + $attachment = $fields['attachment']; + + new \SplFileObject($attachment); + + $mimetype = mime_content_type($attachment); + $fields['attachment'] = new \CURLFile($attachment, $mimetype); + + $options = [ + 'header' => 'multipart/form-data' + ]; + + return $this->client->create('blogs/articles/' . $articleId . '/image', $fields, $options); + } catch (\RuntimeException $exception) { + // + } + } + + $fields = array('blogArticleImage' => $fields); + + return $this->client->create('blogs/articles/' . $articleId . '/image', $fields); + } + + /** + * @param int $articleId + * + * @return array + * @throws ApiException + */ + public function get($articleId) + { + return $this->client->read('blogs/articles/' . $articleId . '/image'); + } + + /** + * @param int $articleId + * + * @return array + * @throws ApiException + */ + public function delete($articleId) + { + return $this->client->delete('blogs/articles/' . $articleId . '/image'); + } +} \ No newline at end of file diff --git a/src/ApiResourceBlogsArticlesTags.php b/src/ApiResourceBlogsArticlesTags.php new file mode 100644 index 0000000..63d31fa --- /dev/null +++ b/src/ApiResourceBlogsArticlesTags.php @@ -0,0 +1,67 @@ +client = $client; + } + + /** + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($fields) + { + $fields = array('blogArticleTag' => $fields); + + return $this->client->create('blogs/articles/tags', $fields); + } + + /** + * @param int $relationId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($relationId = null, $params = array()) + { + if (!$relationId) { + return $this->client->read('blogs/articles/tags', $params); + } else { + return $this->client->read('blogs/articles/tags/' . $relationId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('blogs/articles/tags/count', $params); + } + + /** + * @param int $relationId + * + * @return array + * @throws ApiException + */ + public function delete($relationId) + { + return $this->client->delete('blogs/articles/tags/' . $relationId); + } +} \ No newline at end of file diff --git a/src/ApiResourceBlogsComments.php b/src/ApiResourceBlogsComments.php new file mode 100644 index 0000000..da396cc --- /dev/null +++ b/src/ApiResourceBlogsComments.php @@ -0,0 +1,81 @@ +client = $client; + } + + /** + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($fields) + { + $fields = array('blogComment' => $fields); + + return $this->client->create('blogs/comments', $fields); + } + + /** + * @param int $commentId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($commentId = null, $params = array()) + { + if (!$commentId) { + return $this->client->read('blogs/comments', $params); + } else { + return $this->client->read('blogs/comments/' . $commentId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('blogs/comments/count', $params); + } + + /** + * @param int $commentId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($commentId, $fields) + { + $fields = array('blogComment' => $fields); + + return $this->client->update('blogs/comments/' . $commentId, $fields); + } + + /** + * @param int $commentId + * + * @return array + * @throws ApiException + */ + public function delete($commentId) + { + return $this->client->delete('blogs/comments/' . $commentId); + } +} \ No newline at end of file diff --git a/src/ApiResourceBlogsTags.php b/src/ApiResourceBlogsTags.php new file mode 100644 index 0000000..8aa8f17 --- /dev/null +++ b/src/ApiResourceBlogsTags.php @@ -0,0 +1,81 @@ +client = $client; + } + + /** + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($fields) + { + $fields = array('blogTag' => $fields); + + return $this->client->create('blogs/tags', $fields); + } + + /** + * @param int $tagId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($tagId = null, $params = array()) + { + if (!$tagId) { + return $this->client->read('blogs/tags', $params); + } else { + return $this->client->read('blogs/tags/' . $tagId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('blogs/tags/count', $params); + } + + /** + * @param int $tagId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($tagId, $fields) + { + $fields = array('blogTag' => $fields); + + return $this->client->update('blogs/tags/' . $tagId, $fields); + } + + /** + * @param int $tagId + * + * @return array + * @throws ApiException + */ + public function delete($tagId) + { + return $this->client->delete('blogs/tags/' . $tagId); + } +} \ No newline at end of file diff --git a/src/ApiResourceBrands.php b/src/ApiResourceBrands.php new file mode 100644 index 0000000..aba63d4 --- /dev/null +++ b/src/ApiResourceBrands.php @@ -0,0 +1,81 @@ +client = $client; + } + + /** + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($fields) + { + $fields = array('brand' => $fields); + + return $this->client->create('brands', $fields); + } + + /** + * @param int $brandId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($brandId = null, $params = array()) + { + if (!$brandId) { + return $this->client->read('brands', $params); + } else { + return $this->client->read('brands/' . $brandId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('brands/count', $params); + } + + /** + * @param int $brandId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($brandId, $fields) + { + $fields = array('brand' => $fields); + + return $this->client->update('brands/' . $brandId, $fields); + } + + /** + * @param int $brandId + * + * @return array + * @throws ApiException + */ + public function delete($brandId) + { + return $this->client->delete('brands/' . $brandId); + } +} \ No newline at end of file diff --git a/src/ApiResourceBrandsImage.php b/src/ApiResourceBrandsImage.php new file mode 100644 index 0000000..4fc60d5 --- /dev/null +++ b/src/ApiResourceBrandsImage.php @@ -0,0 +1,71 @@ +client = $client; + } + + /** + * @param int $brandId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($brandId, $fields) + { + if (strpos($fields['attachment'], 'http') === false) { + try { + $attachment = $fields['attachment']; + + new \SplFileObject($attachment); + + $mimetype = mime_content_type($attachment); + $fields['attachment'] = new \CURLFile($attachment, $mimetype); + + $options = [ + 'header' => 'multipart/form-data' + ]; + + return $this->client->create('brands/' . $brandId . '/image', $fields, $options); + } catch (\RuntimeException $exception) { + // + } + } + + $fields = array('brandImage' => $fields); + + return $this->client->create('brands/' . $brandId . '/image', $fields); + } + + /** + * @param int $brandId + * + * @return array + * @throws ApiException + */ + public function get($brandId) + { + return $this->client->read('brands/' . $brandId . '/image'); + } + + /** + * @param int $brandId + * + * @return array + * @throws ApiException + */ + public function delete($brandId) + { + return $this->client->delete('brands/' . $brandId . '/image'); + } +} \ No newline at end of file diff --git a/src/ApiResourceCatalog.php b/src/ApiResourceCatalog.php new file mode 100644 index 0000000..e0e2a95 --- /dev/null +++ b/src/ApiResourceCatalog.php @@ -0,0 +1,43 @@ +client = $client; + } + + /** + * @param int $productId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($productId = null, $params = array()) + { + if (!$productId) { + return $this->client->read('catalog', $params); + } else { + return $this->client->read('catalog/' . $productId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('catalog/count', $params); + } +} \ No newline at end of file diff --git a/src/ApiResourceCategories.php b/src/ApiResourceCategories.php new file mode 100644 index 0000000..a4c3d5c --- /dev/null +++ b/src/ApiResourceCategories.php @@ -0,0 +1,81 @@ +client = $client; + } + + /** + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($fields) + { + $fields = array('category' => $fields); + + return $this->client->create('categories', $fields); + } + + /** + * @param int $categoryId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($categoryId = null, $params = array()) + { + if (!$categoryId) { + return $this->client->read('categories', $params); + } else { + return $this->client->read('categories/' . $categoryId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('categories/count', $params); + } + + /** + * @param int $categoryId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($categoryId, $fields) + { + $fields = array('category' => $fields); + + return $this->client->update('categories/' . $categoryId, $fields); + } + + /** + * @param int $categoryId + * + * @return array + * @throws ApiException + */ + public function delete($categoryId) + { + return $this->client->delete('categories/' . $categoryId); + } +} \ No newline at end of file diff --git a/src/ApiResourceCategoriesImage.php b/src/ApiResourceCategoriesImage.php new file mode 100644 index 0000000..66203ea --- /dev/null +++ b/src/ApiResourceCategoriesImage.php @@ -0,0 +1,71 @@ +client = $client; + } + + /** + * @param int $categoryId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($categoryId, $fields) + { + if (strpos($fields['attachment'], 'http') === false) { + try { + $attachment = $fields['attachment']; + + new \SplFileObject($attachment); + + $mimetype = mime_content_type($attachment); + $fields['attachment'] = new \CURLFile($attachment, $mimetype); + + $options = [ + 'header' => 'multipart/form-data' + ]; + + return $this->client->create('categories/' . $categoryId . '/image', $fields, $options); + } catch (\RuntimeException $exception) { + // + } + } + + $fields = array('categoryImage' => $fields); + + return $this->client->create('categories/' . $categoryId . '/image', $fields); + } + + /** + * @param int $categoryId + * + * @return array + * @throws ApiException + */ + public function get($categoryId) + { + return $this->client->read('categories/' . $categoryId . '/image'); + } + + /** + * @param int $categoryId + * + * @return array + * @throws ApiException + */ + public function delete($categoryId) + { + return $this->client->delete('categories/' . $categoryId . '/image'); + } +} \ No newline at end of file diff --git a/src/ApiResourceCategoriesProducts.php b/src/ApiResourceCategoriesProducts.php new file mode 100644 index 0000000..6a3a61a --- /dev/null +++ b/src/ApiResourceCategoriesProducts.php @@ -0,0 +1,67 @@ +client = $client; + } + + /** + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($fields) + { + $fields = array('categoriesProduct' => $fields); + + return $this->client->create('categories/products', $fields); + } + + /** + * @param int $relationId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($relationId = null, $params = array()) + { + if (!$relationId) { + return $this->client->read('categories/products', $params); + } else { + return $this->client->read('categories/products/' . $relationId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('categories/products/count', $params); + } + + /** + * @param int $relationId + * + * @return array + * @throws ApiException + */ + public function delete($relationId) + { + return $this->client->delete('categories/products/' . $relationId); + } +} \ No newline at end of file diff --git a/src/ApiResourceCategoriesProductsBulk.php b/src/ApiResourceCategoriesProductsBulk.php new file mode 100644 index 0000000..465a736 --- /dev/null +++ b/src/ApiResourceCategoriesProductsBulk.php @@ -0,0 +1,29 @@ +client = $client; + } + + /** + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($fields) + { + $fields = array('categoriesProduct' => $fields); + + return $this->client->create('categories/products/bulk', $fields); + } +} \ No newline at end of file diff --git a/src/ApiResourceCheckouts.php b/src/ApiResourceCheckouts.php new file mode 100644 index 0000000..d934e74 --- /dev/null +++ b/src/ApiResourceCheckouts.php @@ -0,0 +1,77 @@ +client = $client; + } + + /** + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($fields) + { + return $this->client->create('checkouts', $fields); + } + + /** + * @param int $checkoutId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($checkoutId = null, $params = array()) + { + if (!$checkoutId) { + return $this->client->read('checkouts', $params); + } else { + return $this->client->read('checkouts/' . $checkoutId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('checkouts/count', $params); + } + + /** + * @param int $checkoutId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($checkoutId, $fields) + { + return $this->client->update('checkouts/' . $checkoutId, $fields); + } + + /** + * @param int $checkoutId + * + * @return array + * @throws ApiException + */ + public function delete($checkoutId) + { + return $this->client->delete('checkouts/' . $checkoutId); + } +} \ No newline at end of file diff --git a/src/ApiResourceCheckoutsOrder.php b/src/ApiResourceCheckoutsOrder.php new file mode 100644 index 0000000..2f2c9ff --- /dev/null +++ b/src/ApiResourceCheckoutsOrder.php @@ -0,0 +1,28 @@ +client = $client; + } + + /** + * @param int $checkoutId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($checkoutId, $fields) + { + return $this->client->create('checkouts/' . $checkoutId . '/order', $fields); + } +} \ No newline at end of file diff --git a/src/ApiResourceCheckoutsPayment_methods.php b/src/ApiResourceCheckoutsPayment_methods.php new file mode 100644 index 0000000..8c81205 --- /dev/null +++ b/src/ApiResourceCheckoutsPayment_methods.php @@ -0,0 +1,27 @@ +client = $client; + } + + /** + * @param int $checkoutId + * + * @return array + * @throws ApiException + */ + public function get($checkoutId) + { + return $this->client->read('checkouts/' . $checkoutId . '/payment_methods'); + } +} \ No newline at end of file diff --git a/src/ApiResourceCheckoutsProducts.php b/src/ApiResourceCheckoutsProducts.php new file mode 100644 index 0000000..c338122 --- /dev/null +++ b/src/ApiResourceCheckoutsProducts.php @@ -0,0 +1,82 @@ +client = $client; + } + + /** + * @param int $checkoutId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($checkoutId, $fields) + { + return $this->client->create('checkouts/' . $checkoutId . '/products', $fields); + } + + /** + * @param int $checkoutId + * @param int $productId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($checkoutId, $productId = null, $params = array()) + { + if (!$productId) { + return $this->client->read('checkouts/' . $checkoutId . '/products', $params); + } else { + return $this->client->read('checkouts/' . $checkoutId . '/products/' . $productId, $params); + } + } + + /** + * @param int $checkoutId + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($checkoutId, $params = array()) + { + return $this->client->read('checkouts/' . $checkoutId . '/products/count', $params); + } + + /** + * @param int $checkoutId + * @param int $productId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($checkoutId, $productId, $fields) + { + return $this->client->update('checkouts/' . $checkoutId . '/products/' . $productId, $fields); + } + + /** + * @param int $checkoutId + * @param int $productId + * + * @return array + * @throws ApiException + */ + public function delete($checkoutId, $productId) + { + return $this->client->delete('checkouts/' . $checkoutId . '/products/' . $productId); + } +} \ No newline at end of file diff --git a/src/ApiResourceCheckoutsShipment_methods.php b/src/ApiResourceCheckoutsShipment_methods.php new file mode 100644 index 0000000..8bded4e --- /dev/null +++ b/src/ApiResourceCheckoutsShipment_methods.php @@ -0,0 +1,27 @@ +client = $client; + } + + /** + * @param int $checkoutId + * + * @return array + * @throws ApiException + */ + public function get($checkoutId) + { + return $this->client->read('checkouts/' . $checkoutId . '/shipment_methods'); + } +} \ No newline at end of file diff --git a/src/ApiResourceCheckoutsValidate.php b/src/ApiResourceCheckoutsValidate.php new file mode 100644 index 0000000..54f727d --- /dev/null +++ b/src/ApiResourceCheckoutsValidate.php @@ -0,0 +1,27 @@ +client = $client; + } + + /** + * @param int $checkoutId + * + * @return array + * @throws ApiException + */ + public function get($checkoutId) + { + return $this->client->read('checkouts/' . $checkoutId . '/validate'); + } +} \ No newline at end of file diff --git a/src/ApiResourceContacts.php b/src/ApiResourceContacts.php new file mode 100644 index 0000000..15e1d53 --- /dev/null +++ b/src/ApiResourceContacts.php @@ -0,0 +1,43 @@ +client = $client; + } + + /** + * @param int $contactId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($contactId = null, $params = array()) + { + if (!$contactId) { + return $this->client->read('contacts', $params); + } else { + return $this->client->read('contacts/' . $contactId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('contacts/count', $params); + } +} \ No newline at end of file diff --git a/src/ApiResourceCountries.php b/src/ApiResourceCountries.php new file mode 100644 index 0000000..e632d7c --- /dev/null +++ b/src/ApiResourceCountries.php @@ -0,0 +1,43 @@ +client = $client; + } + + /** + * @param int $countryId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($countryId = null, $params = array()) + { + if (!$countryId) { + return $this->client->read('countries', $params); + } else { + return $this->client->read('countries/' . $countryId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('countries/count', $params); + } +} \ No newline at end of file diff --git a/src/ApiResourceCustomers.php b/src/ApiResourceCustomers.php new file mode 100644 index 0000000..79f6830 --- /dev/null +++ b/src/ApiResourceCustomers.php @@ -0,0 +1,81 @@ +client = $client; + } + + /** + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($fields) + { + $fields = array('customer' => $fields); + + return $this->client->create('customers', $fields); + } + + /** + * @param int $customerId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($customerId = null, $params = array()) + { + if (!$customerId) { + return $this->client->read('customers', $params); + } else { + return $this->client->read('customers/' . $customerId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('customers/count', $params); + } + + /** + * @param int $customerId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($customerId, $fields) + { + $fields = array('customer' => $fields); + + return $this->client->update('customers/' . $customerId, $fields); + } + + /** + * @param int $customerId + * + * @return array + * @throws ApiException + */ + public function delete($customerId) + { + return $this->client->delete('customers/' . $customerId); + } +} \ No newline at end of file diff --git a/src/ApiResourceCustomersLogin.php b/src/ApiResourceCustomersLogin.php new file mode 100644 index 0000000..e98e2ed --- /dev/null +++ b/src/ApiResourceCustomersLogin.php @@ -0,0 +1,30 @@ +client = $client; + } + + /** + * @param int $customerId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($customerId, $fields) + { + $fields = array('customerLogin' => $fields); + + return $this->client->create('customers/' . $customerId . '/login', $fields); + } +} \ No newline at end of file diff --git a/src/ApiResourceCustomersMetafields.php b/src/ApiResourceCustomersMetafields.php new file mode 100644 index 0000000..b7842a7 --- /dev/null +++ b/src/ApiResourceCustomersMetafields.php @@ -0,0 +1,86 @@ +client = $client; + } + + /** + * @param int $customerId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($customerId, $fields) + { + $fields = array('customerMetafield' => $fields); + + return $this->client->create('customers/' . $customerId . '/metafields', $fields); + } + + /** + * @param int $customerId + * @param int $metafieldId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($customerId, $metafieldId = null, $params = array()) + { + if (!$metafieldId) { + return $this->client->read('customers/' . $customerId . '/metafields', $params); + } else { + return $this->client->read('customers/' . $customerId . '/metafields/' . $metafieldId, $params); + } + } + + /** + * @param int $customerId + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($customerId, $params = array()) + { + return $this->client->read('customers/' . $customerId . '/metafields/count', $params); + } + + /** + * @param int $customerId + * @param int $metafieldId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($customerId, $metafieldId, $fields) + { + $fields = array('customerMetafield' => $fields); + + return $this->client->update('customers/' . $customerId . '/metafields/' . $metafieldId, $fields); + } + + /** + * @param int $customerId + * @param int $metafieldId + * + * @return array + * @throws ApiException + */ + public function delete($customerId, $metafieldId) + { + return $this->client->delete('customers/' . $customerId . '/metafields/' . $metafieldId); + } +} \ No newline at end of file diff --git a/src/ApiResourceCustomersTokens.php b/src/ApiResourceCustomersTokens.php new file mode 100644 index 0000000..0fd42fa --- /dev/null +++ b/src/ApiResourceCustomersTokens.php @@ -0,0 +1,30 @@ +client = $client; + } + + /** + * @param int $customerId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($customerId, $fields) + { + $fields = array('customerToken' => $fields); + + return $this->client->create('customers/' . $customerId . '/tokens', $fields); + } +} \ No newline at end of file diff --git a/src/ApiResourceDashboard.php b/src/ApiResourceDashboard.php new file mode 100644 index 0000000..bce3a2f --- /dev/null +++ b/src/ApiResourceDashboard.php @@ -0,0 +1,27 @@ +client = $client; + } + + /** + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($params = array()) + { + return $this->client->read('dashboard', $params); + } +} \ No newline at end of file diff --git a/src/ApiResourceDeliverydates.php b/src/ApiResourceDeliverydates.php new file mode 100644 index 0000000..b2a7206 --- /dev/null +++ b/src/ApiResourceDeliverydates.php @@ -0,0 +1,81 @@ +client = $client; + } + + /** + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($fields) + { + $fields = array('deliverydate' => $fields); + + return $this->client->create('deliverydates', $fields); + } + + /** + * @param int $deliverydateId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($deliverydateId = null, $params = array()) + { + if (!$deliverydateId) { + return $this->client->read('deliverydates', $params); + } else { + return $this->client->read('deliverydates/' . $deliverydateId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('deliverydates/count', $params); + } + + /** + * @param int $deliverydateId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($deliverydateId, $fields) + { + $fields = array('deliverydate' => $fields); + + return $this->client->update('deliverydates/' . $deliverydateId, $fields); + } + + /** + * @param int $deliverydateId + * + * @return array + * @throws ApiException + */ + public function delete($deliverydateId) + { + return $this->client->delete('deliverydates/' . $deliverydateId); + } +} \ No newline at end of file diff --git a/src/ApiResourceDiscountrules.php b/src/ApiResourceDiscountrules.php new file mode 100644 index 0000000..c63a1d6 --- /dev/null +++ b/src/ApiResourceDiscountrules.php @@ -0,0 +1,81 @@ +client = $client; + } + + /** + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($fields) + { + $fields = array('discountRule' => $fields); + + return $this->client->create('discountrules', $fields); + } + + /** + * @param int $discountruleId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($discountruleId = null, $params = array()) + { + if (!$discountruleId) { + return $this->client->read('discountrules', $params); + } else { + return $this->client->read('discountrules/' . $discountruleId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('discountrules/count', $params); + } + + /** + * @param int $discountruleId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($discountruleId, $fields) + { + $fields = array('discountRule' => $fields); + + return $this->client->update('discountrules/' . $discountruleId, $fields); + } + + /** + * @param int $discountruleId + * + * @return array + * @throws ApiException + */ + public function delete($discountruleId) + { + return $this->client->delete('discountrules/' . $discountruleId); + } +} \ No newline at end of file diff --git a/src/ApiResourceDiscounts.php b/src/ApiResourceDiscounts.php new file mode 100644 index 0000000..ae0f81c --- /dev/null +++ b/src/ApiResourceDiscounts.php @@ -0,0 +1,81 @@ +client = $client; + } + + /** + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($fields) + { + $fields = array('discount' => $fields); + + return $this->client->create('discounts', $fields); + } + + /** + * @param int $discountId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($discountId = null, $params = array()) + { + if (!$discountId) { + return $this->client->read('discounts', $params); + } else { + return $this->client->read('discounts/' . $discountId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('discounts/count', $params); + } + + /** + * @param int $discountId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($discountId, $fields) + { + $fields = array('discount' => $fields); + + return $this->client->update('discounts/' . $discountId, $fields); + } + + /** + * @param int $discountId + * + * @return array + * @throws ApiException + */ + public function delete($discountId) + { + return $this->client->delete('discounts/' . $discountId); + } +} \ No newline at end of file diff --git a/src/ApiResourceEvents.php b/src/ApiResourceEvents.php new file mode 100644 index 0000000..e9ff1e3 --- /dev/null +++ b/src/ApiResourceEvents.php @@ -0,0 +1,54 @@ +client = $client; + } + + /** + * @param int $eventId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($eventId = null, $params = array()) + { + if (!$eventId) { + return $this->client->read('events', $params); + } else { + return $this->client->read('events/' . $eventId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('events/count', $params); + } + + /** + * @param int $eventId + * + * @return array + * @throws ApiException + */ + public function delete($eventId) + { + return $this->client->delete('events/' . $eventId); + } +} \ No newline at end of file diff --git a/src/ApiResourceExternal_services.php b/src/ApiResourceExternal_services.php new file mode 100644 index 0000000..2445b60 --- /dev/null +++ b/src/ApiResourceExternal_services.php @@ -0,0 +1,67 @@ +client = $client; + } + + /** + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($fields) + { + $fields = array('externalService' => $fields); + + return $this->client->create('external_services', $fields); + } + + /** + * @param int $externalserviceId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($externalserviceId = null, $params = array()) + { + if (!$externalserviceId) { + return $this->client->read('external_services', $params); + } else { + return $this->client->read('external_services/' . $externalserviceId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('external_services/count', $params); + } + + /** + * @param int $externalserviceId + * + * @return array + * @throws ApiException + */ + public function delete($externalserviceId) + { + return $this->client->delete('external_services/' . $externalserviceId); + } +} \ No newline at end of file diff --git a/src/ApiResourceFiles.php b/src/ApiResourceFiles.php new file mode 100644 index 0000000..d3e9a27 --- /dev/null +++ b/src/ApiResourceFiles.php @@ -0,0 +1,100 @@ +client = $client; + } + + /** + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($fields) + { + if (strpos($fields['attachment'], 'http') === false) { + try { + $attachment = $fields['attachment']; + + new \SplFileObject($attachment); + + $mimetype = mime_content_type($attachment); + $fields['attachment'] = new \CURLFile($attachment, $mimetype); + + $options = [ + 'header' => 'multipart/form-data' + ]; + + return $this->client->create('files', $fields, $options); + } catch (\RuntimeException $exception) { + // + } + } + + $fields = array('file' => $fields); + + return $this->client->create('files', $fields); + } + + /** + * @param int $fileId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($fileId = null, $params = array()) + { + if (!$fileId) { + return $this->client->read('files', $params); + } else { + return $this->client->read('files/' . $fileId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('files/count', $params); + } + + /** + * @param int $fileId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($fileId, $fields) + { + $fields = array('file' => $fields); + + return $this->client->update('files/' . $fileId, $fields); + } + + /** + * @param int $fileId + * + * @return array + * @throws ApiException + */ + public function delete($fileId) + { + return $this->client->delete('files/' . $fileId); + } +} \ No newline at end of file diff --git a/src/ApiResourceFilters.php b/src/ApiResourceFilters.php new file mode 100644 index 0000000..adc4a3d --- /dev/null +++ b/src/ApiResourceFilters.php @@ -0,0 +1,81 @@ +client = $client; + } + + /** + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($fields) + { + $fields = array('filter' => $fields); + + return $this->client->create('filters', $fields); + } + + /** + * @param int $filterId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($filterId = null, $params = array()) + { + if (!$filterId) { + return $this->client->read('filters', $params); + } else { + return $this->client->read('filters/' . $filterId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('filters/count', $params); + } + + /** + * @param int $filterId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($filterId, $fields) + { + $fields = array('filter' => $fields); + + return $this->client->update('filters/' . $filterId, $fields); + } + + /** + * @param int $filterId + * + * @return array + * @throws ApiException + */ + public function delete($filterId) + { + return $this->client->delete('filters/' . $filterId); + } +} \ No newline at end of file diff --git a/src/ApiResourceFiltersValues.php b/src/ApiResourceFiltersValues.php new file mode 100644 index 0000000..fe8830b --- /dev/null +++ b/src/ApiResourceFiltersValues.php @@ -0,0 +1,86 @@ +client = $client; + } + + /** + * @param int $filterId + * @param int $filterValueId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($filterId, $filterValueId = null, $params = array()) + { + if (!$filterValueId) { + return $this->client->read('filters/' . $filterId . '/values', $params); + } else { + return $this->client->read('filters/' . $filterId . '/values/' . $filterValueId, $params); + } + } + + /** + * @param int $filterId + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($filterId, $params = array()) + { + return $this->client->read('filters/' . $filterId . '/values/count', $params); + } + + /** + * @param int $filterId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($filterId, $fields) + { + $fields = array('filterValue' => $fields); + + return $this->client->create('filters/' . $filterId . '/values', $fields); + } + + /** + * @param int $filterId + * @param int $filterValueId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($filterId, $filterValueId, $fields) + { + $fields = array('filterValue' => $fields); + + return $this->client->update('filters/' . $filterId . '/values/' . $filterValueId, $fields); + } + + /** + * @param int $filterId + * @param int $filterValueId + * + * @return array + * @throws ApiException + */ + public function delete($filterId, $filterValueId) + { + return $this->client->delete('filters/' . $filterId . '/values/' . $filterValueId); + } +} \ No newline at end of file diff --git a/src/ApiResourceGroups.php b/src/ApiResourceGroups.php new file mode 100644 index 0000000..d58fd14 --- /dev/null +++ b/src/ApiResourceGroups.php @@ -0,0 +1,81 @@ +client = $client; + } + + /** + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($fields) + { + $fields = array('group' => $fields); + + return $this->client->create('groups', $fields); + } + + /** + * @param int $groupId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($groupId = null, $params = array()) + { + if (!$groupId) { + return $this->client->read('groups', $params); + } else { + return $this->client->read('groups/' . $groupId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('groups/count', $params); + } + + /** + * @param int $groupId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($groupId, $fields) + { + $fields = array('group' => $fields); + + return $this->client->update('groups/' . $groupId, $fields); + } + + /** + * @param int $groupId + * + * @return array + * @throws ApiException + */ + public function delete($groupId) + { + return $this->client->delete('groups/' . $groupId); + } +} \ No newline at end of file diff --git a/src/ApiResourceGroupsCustomers.php b/src/ApiResourceGroupsCustomers.php new file mode 100644 index 0000000..d76347a --- /dev/null +++ b/src/ApiResourceGroupsCustomers.php @@ -0,0 +1,67 @@ +client = $client; + } + + /** + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($fields) + { + $fields = array('groupsCustomer' => $fields); + + return $this->client->create('groups/customers', $fields); + } + + /** + * @param int $relationId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($relationId = null, $params = array()) + { + if (!$relationId) { + return $this->client->read('groups/customers', $params); + } else { + return $this->client->read('groups/customers/' . $relationId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('groups/customers/count', $params); + } + + /** + * @param int $relationId + * + * @return array + * @throws ApiException + */ + public function delete($relationId) + { + return $this->client->delete('groups/customers/' . $relationId); + } +} \ No newline at end of file diff --git a/src/ApiResourceInvoices.php b/src/ApiResourceInvoices.php new file mode 100644 index 0000000..1fef9aa --- /dev/null +++ b/src/ApiResourceInvoices.php @@ -0,0 +1,57 @@ +client = $client; + } + + /** + * @param int $invoiceId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($invoiceId = null, $params = array()) + { + if (!$invoiceId) { + return $this->client->read('invoices', $params); + } else { + return $this->client->read('invoices/' . $invoiceId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('invoices/count', $params); + } + + /** + * @param int $invoiceId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($invoiceId, $fields) + { + $fields = array('invoice' => $fields); + + return $this->client->update('invoices/' . $invoiceId, $fields); + } +} \ No newline at end of file diff --git a/src/ApiResourceInvoicesItems.php b/src/ApiResourceInvoicesItems.php new file mode 100644 index 0000000..69e893b --- /dev/null +++ b/src/ApiResourceInvoicesItems.php @@ -0,0 +1,45 @@ +client = $client; + } + + /** + * @param int $invoiceId + * @param int $itemId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($invoiceId, $itemId = null, $params = array()) + { + if (!$itemId) { + return $this->client->read('invoices/' . $invoiceId . '/items', $params); + } else { + return $this->client->read('invoices/' . $invoiceId . '/items/' . $itemId, $params); + } + } + + /** + * @param int $invoiceId + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($invoiceId, $params = array()) + { + return $this->client->read('invoices/' . $invoiceId . '/items/count', $params); + } +} \ No newline at end of file diff --git a/src/ApiResourceInvoicesMetafields.php b/src/ApiResourceInvoicesMetafields.php new file mode 100644 index 0000000..ef6da66 --- /dev/null +++ b/src/ApiResourceInvoicesMetafields.php @@ -0,0 +1,86 @@ +client = $client; + } + + /** + * @param int $invoiceId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($invoiceId, $fields) + { + $fields = array('invoiceMetafield' => $fields); + + return $this->client->create('invoices/' . $invoiceId . '/metafields', $fields); + } + + /** + * @param int $invoiceId + * @param int $metafieldId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($invoiceId, $metafieldId = null, $params = array()) + { + if (!$metafieldId) { + return $this->client->read('invoices/' . $invoiceId . '/metafields', $params); + } else { + return $this->client->read('invoices/' . $invoiceId . '/metafields/' . $metafieldId, $params); + } + } + + /** + * @param int $invoiceId + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($invoiceId, $params = array()) + { + return $this->client->read('invoices/' . $invoiceId . '/metafields/count', $params); + } + + /** + * @param int $invoiceId + * @param int $metafieldId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($invoiceId, $metafieldId, $fields) + { + $fields = array('invoiceMetafield' => $fields); + + return $this->client->update('invoices/' . $invoiceId . '/metafields/' . $metafieldId, $fields); + } + + /** + * @param int $invoiceId + * @param int $metafieldId + * + * @return array + * @throws ApiException + */ + public function delete($invoiceId, $metafieldId) + { + return $this->client->delete('invoices/' . $invoiceId . '/metafields/' . $metafieldId); + } +} \ No newline at end of file diff --git a/src/ApiResourceLanguages.php b/src/ApiResourceLanguages.php new file mode 100644 index 0000000..b9a1c8f --- /dev/null +++ b/src/ApiResourceLanguages.php @@ -0,0 +1,43 @@ +client = $client; + } + + /** + * @param int $languageId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($languageId = null, $params = array()) + { + if (!$languageId) { + return $this->client->read('languages', $params); + } else { + return $this->client->read('languages/' . $languageId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('languages/count', $params); + } +} \ No newline at end of file diff --git a/src/ApiResourceLocations.php b/src/ApiResourceLocations.php new file mode 100644 index 0000000..13173a5 --- /dev/null +++ b/src/ApiResourceLocations.php @@ -0,0 +1,81 @@ +client = $client; + } + + /** + * @param int $locationId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($locationId = null, $params = array()) + { + if (!$locationId) { + return $this->client->read('locations', $params); + } else { + return $this->client->read('locations/' . $locationId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('locations/count', $params); + } + + /** + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($fields) + { + $fields = array('locations' => $fields); + + return $this->client->create('locations', $fields); + } + + /** + * @param int $locationId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($locationId, $fields) + { + $fields = array('location' => $fields); + + return $this->client->update('locations/' . $locationId, $fields); + } + + /** + * @param int $locationId + * + * @return array + * @throws ApiException + */ + public function delete($locationId) + { + return $this->client->delete('locations/' . $locationId); + } +} \ No newline at end of file diff --git a/src/ApiResourceMetafields.php b/src/ApiResourceMetafields.php new file mode 100644 index 0000000..0036c3f --- /dev/null +++ b/src/ApiResourceMetafields.php @@ -0,0 +1,81 @@ +client = $client; + } + + /** + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($fields) + { + $fields = array('metafield' => $fields); + + return $this->client->create('metafields', $fields); + } + + /** + * @param int $metafieldId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($metafieldId = null, $params = array()) + { + if (!$metafieldId) { + return $this->client->read('metafields', $params); + } else { + return $this->client->read('metafields/' . $metafieldId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('metafields/count', $params); + } + + /** + * @param int $metafieldId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($metafieldId, $fields) + { + $fields = array('metafield' => $fields); + + return $this->client->update('metafields/' . $metafieldId, $fields); + } + + /** + * @param int $metafieldId + * + * @return array + * @throws ApiException + */ + public function delete($metafieldId) + { + return $this->client->delete('metafields/' . $metafieldId); + } +} \ No newline at end of file diff --git a/src/ApiResourceOrders.php b/src/ApiResourceOrders.php new file mode 100644 index 0000000..ce454b8 --- /dev/null +++ b/src/ApiResourceOrders.php @@ -0,0 +1,57 @@ +client = $client; + } + + /** + * @param int $orderId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($orderId = null, $params = array()) + { + if (!$orderId) { + return $this->client->read('orders', $params); + } else { + return $this->client->read('orders/' . $orderId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('orders/count', $params); + } + + /** + * @param int $orderId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($orderId, $fields) + { + $fields = array('order' => $fields); + + return $this->client->update('orders/' . $orderId, $fields); + } +} \ No newline at end of file diff --git a/src/ApiResourceOrdersCredit.php b/src/ApiResourceOrdersCredit.php new file mode 100644 index 0000000..3ce761c --- /dev/null +++ b/src/ApiResourceOrdersCredit.php @@ -0,0 +1,30 @@ +client = $client; + } + + /** + * @param int $orderId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($orderId, $fields) + { + $fields = array('credit' => $fields); + + return $this->client->create('orders/' . $orderId . '/credit', $fields); + } +} \ No newline at end of file diff --git a/src/ApiResourceOrdersCustomstatuses.php b/src/ApiResourceOrdersCustomstatuses.php new file mode 100644 index 0000000..c3cb804 --- /dev/null +++ b/src/ApiResourceOrdersCustomstatuses.php @@ -0,0 +1,81 @@ +client = $client; + } + + /** + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($fields) + { + $fields = array('customStatus' => $fields); + + return $this->client->create('orders/customstatuses', $fields); + } + + /** + * @param int $customstatusId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($customstatusId = null, $params = array()) + { + if (!$customstatusId) { + return $this->client->read('orders/customstatuses', $params); + } else { + return $this->client->read('orders/customstatuses/' . $customstatusId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('orders/customstatuses/count', $params); + } + + /** + * @param int $customstatusId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($customstatusId, $fields) + { + $fields = array('customStatus' => $fields); + + return $this->client->update('orders/customstatuses/' . $customstatusId, $fields); + } + + /** + * @param int $customstatusId + * + * @return array + * @throws ApiException + */ + public function delete($customstatusId) + { + return $this->client->delete('orders/customstatuses/' . $customstatusId); + } +} \ No newline at end of file diff --git a/src/ApiResourceOrdersEvents.php b/src/ApiResourceOrdersEvents.php new file mode 100644 index 0000000..c73a3c8 --- /dev/null +++ b/src/ApiResourceOrdersEvents.php @@ -0,0 +1,43 @@ +client = $client; + } + + /** + * @param int $eventId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($eventId = null, $params = array()) + { + if (!$eventId) { + return $this->client->read('orders/events', $params); + } else { + return $this->client->read('orders/events/' . $eventId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('orders/events/count', $params); + } +} \ No newline at end of file diff --git a/src/ApiResourceOrdersMetafields.php b/src/ApiResourceOrdersMetafields.php new file mode 100644 index 0000000..a269f08 --- /dev/null +++ b/src/ApiResourceOrdersMetafields.php @@ -0,0 +1,86 @@ +client = $client; + } + + /** + * @param int $orderId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($orderId, $fields) + { + $fields = array('orderMetafield' => $fields); + + return $this->client->create('orders/' . $orderId . '/metafields', $fields); + } + + /** + * @param int $orderId + * @param int $metafieldId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($orderId, $metafieldId = null, $params = array()) + { + if (!$metafieldId) { + return $this->client->read('orders/' . $orderId . '/metafields', $params); + } else { + return $this->client->read('orders/' . $orderId . '/metafields/' . $metafieldId, $params); + } + } + + /** + * @param int $orderId + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($orderId, $params = array()) + { + return $this->client->read('orders/' . $orderId . '/metafields/count', $params); + } + + /** + * @param int $orderId + * @param int $metafieldId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($orderId, $metafieldId, $fields) + { + $fields = array('orderMetafield' => $fields); + + return $this->client->update('orders/' . $orderId . '/metafields/' . $metafieldId, $fields); + } + + /** + * @param int $orderId + * @param int $metafieldId + * + * @return array + * @throws ApiException + */ + public function delete($orderId, $metafieldId) + { + return $this->client->delete('orders/' . $orderId . '/metafields/' . $metafieldId); + } +} \ No newline at end of file diff --git a/src/ApiResourceOrdersProducts.php b/src/ApiResourceOrdersProducts.php new file mode 100644 index 0000000..6e1134f --- /dev/null +++ b/src/ApiResourceOrdersProducts.php @@ -0,0 +1,45 @@ +client = $client; + } + + /** + * @param int $orderId + * @param int $productId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($orderId, $productId = null, $params = array()) + { + if (!$productId) { + return $this->client->read('orders/' . $orderId . '/products', $params); + } else { + return $this->client->read('orders/' . $orderId . '/products/' . $productId, $params); + } + } + + /** + * @param int $orderId + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($orderId, $params = array()) + { + return $this->client->read('orders/' . $orderId . '/products/count', $params); + } +} \ No newline at end of file diff --git a/src/ApiResourcePaymentmethods.php b/src/ApiResourcePaymentmethods.php new file mode 100644 index 0000000..61b8010 --- /dev/null +++ b/src/ApiResourcePaymentmethods.php @@ -0,0 +1,43 @@ +client = $client; + } + + /** + * @param int $paymentmethodId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($paymentmethodId = null, $params = array()) + { + if (!$paymentmethodId) { + return $this->client->read('paymentmethods', $params); + } else { + return $this->client->read('paymentmethods/' . $paymentmethodId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('paymentmethods/count', $params); + } +} \ No newline at end of file diff --git a/src/ApiResourceProducts.php b/src/ApiResourceProducts.php new file mode 100644 index 0000000..9c4f7e9 --- /dev/null +++ b/src/ApiResourceProducts.php @@ -0,0 +1,81 @@ +client = $client; + } + + /** + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($fields) + { + $fields = array('product' => $fields); + + return $this->client->create('products', $fields); + } + + /** + * @param int $productId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($productId = null, $params = array()) + { + if (!$productId) { + return $this->client->read('products', $params); + } else { + return $this->client->read('products/' . $productId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('products/count', $params); + } + + /** + * @param int $productId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($productId, $fields) + { + $fields = array('product' => $fields); + + return $this->client->update('products/' . $productId, $fields); + } + + /** + * @param int $productId + * + * @return array + * @throws ApiException + */ + public function delete($productId) + { + return $this->client->delete('products/' . $productId); + } +} \ No newline at end of file diff --git a/src/ApiResourceProductsAttributes.php b/src/ApiResourceProductsAttributes.php new file mode 100644 index 0000000..77d8b37 --- /dev/null +++ b/src/ApiResourceProductsAttributes.php @@ -0,0 +1,78 @@ +client = $client; + } + + /** + * @param int $productId + * @param int $attributeId Set to null for bulk update. + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($productId, $attributeId, $fields) + { + if (!$attributeId) { + $fields = array('productAttributes' => $fields); + + return $this->client->update('products/' . $productId . '/attributes', $fields); + } else { + $fields = array('productAttribute' => $fields); + + return $this->client->update('products/' . $productId . '/attributes/' . $attributeId, $fields); + } + } + + /** + * @param int $productId + * @param int $attributeId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($productId, $attributeId = null, $params = array()) + { + if (!$attributeId) { + return $this->client->read('products/' . $productId . '/attributes', $params); + } else { + return $this->client->read('products/' . $productId . '/attributes/' . $attributeId, $params); + } + } + + /** + * @param int $productId + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($productId, $params = array()) + { + return $this->client->read('products/' . $productId . '/attributes/count', $params); + } + + /** + * @param int $productId + * @param int $attributeId + * + * @return array + * @throws ApiException + */ + public function delete($productId, $attributeId) + { + return $this->client->delete('products/' . $productId . '/attributes/' . $attributeId); + } +} \ No newline at end of file diff --git a/src/ApiResourceProductsFiltervalues.php b/src/ApiResourceProductsFiltervalues.php new file mode 100644 index 0000000..05598b5 --- /dev/null +++ b/src/ApiResourceProductsFiltervalues.php @@ -0,0 +1,65 @@ +client = $client; + } + + /** + * @param int $productId + * + * @return array + * @throws ApiException + */ + public function get($productId) + { + return $this->client->read('products/' . $productId . '/filtervalues'); + } + + /** + * @param int $productId + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($productId, $params = array()) + { + return $this->client->read('products/' . $productId . '/filtervalues/count', $params); + } + + /** + * @param int $productId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($productId, $fields) + { + $fields = array('productFiltervalue' => $fields); + + return $this->client->create('products/' . $productId . '/filtervalues', $fields); + } + + /** + * @param int $productId + * @param int $filterValueId + * + * @return array + * @throws ApiException + */ + public function delete($productId, $filterValueId) + { + return $this->client->delete('products/' . $productId . '/filtervalues/' . $filterValueId); + } +} \ No newline at end of file diff --git a/src/ApiResourceProductsImages.php b/src/ApiResourceProductsImages.php new file mode 100644 index 0000000..aa38726 --- /dev/null +++ b/src/ApiResourceProductsImages.php @@ -0,0 +1,105 @@ +client = $client; + } + + /** + * @param int $productId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($productId, $fields) + { + if (strpos($fields['attachment'], 'http') === false) { + try { + $attachment = $fields['attachment']; + + new \SplFileObject($attachment); + + $mimetype = mime_content_type($attachment); + $fields['attachment'] = new \CURLFile($attachment, $mimetype); + + $options = [ + 'header' => 'multipart/form-data' + ]; + + return $this->client->create('products/' . $productId . '/images', $fields, $options); + } catch (\RuntimeException $exception) { + // + } + } + + $fields = array('productImage' => $fields); + + return $this->client->create('products/' . $productId . '/images', $fields); + } + + /** + * @param int $productId + * @param int $imageId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($productId, $imageId = null, $params = array()) + { + if (!$imageId) { + return $this->client->read('products/' . $productId . '/images', $params); + } else { + return $this->client->read('products/' . $productId . '/images/' . $imageId, $params); + } + } + + /** + * @param int $productId + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($productId, $params = array()) + { + return $this->client->read('products/' . $productId . '/images/count', $params); + } + + /** + * @param int $productId + * @param int $imageId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($productId, $imageId, $fields) + { + $fields = array('productImage' => $fields); + + return $this->client->update('products/' . $productId . '/images/' . $imageId, $fields); + } + + /** + * @param int $productId + * @param int $imageId + * + * @return array + * @throws ApiException + */ + public function delete($productId, $imageId) + { + return $this->client->delete('products/' . $productId . '/images/' . $imageId); + } +} \ No newline at end of file diff --git a/src/ApiResourceProductsMetafields.php b/src/ApiResourceProductsMetafields.php new file mode 100644 index 0000000..cc8cf52 --- /dev/null +++ b/src/ApiResourceProductsMetafields.php @@ -0,0 +1,86 @@ +client = $client; + } + + /** + * @param int $productId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($productId, $fields) + { + $fields = array('productMetafield' => $fields); + + return $this->client->create('products/' . $productId . '/metafields', $fields); + } + + /** + * @param int $productId + * @param int $metafieldId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($productId, $metafieldId = null, $params = array()) + { + if (!$metafieldId) { + return $this->client->read('products/' . $productId . '/metafields', $params); + } else { + return $this->client->read('products/' . $productId . '/metafields/' . $metafieldId, $params); + } + } + + /** + * @param int $productId + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($productId, $params = array()) + { + return $this->client->read('products/' . $productId . '/metafields/count', $params); + } + + /** + * @param int $productId + * @param int $metafieldId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($productId, $metafieldId, $fields) + { + $fields = array('productMetafield' => $fields); + + return $this->client->update('products/' . $productId . '/metafields/' . $metafieldId, $fields); + } + + /** + * @param int $productId + * @param int $metafieldId + * + * @return array + * @throws ApiException + */ + public function delete($productId, $metafieldId) + { + return $this->client->delete('products/' . $productId . '/metafields/' . $metafieldId); + } +} \ No newline at end of file diff --git a/src/ApiResourceProductsRelations.php b/src/ApiResourceProductsRelations.php new file mode 100644 index 0000000..f5c1d1a --- /dev/null +++ b/src/ApiResourceProductsRelations.php @@ -0,0 +1,86 @@ +client = $client; + } + + /** + * @param int $productId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($productId, $fields) + { + $fields = array('productRelation' => $fields); + + return $this->client->create('products/' . $productId . '/relations', $fields); + } + + /** + * @param int $productId + * @param int $relationId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($productId, $relationId = null, $params = array()) + { + if (!$relationId) { + return $this->client->read('products/' . $productId . '/relations', $params); + } else { + return $this->client->read('products/' . $productId . '/relations/' . $relationId, $params); + } + } + + /** + * @param int $productId + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($productId, $params = array()) + { + return $this->client->read('products/' . $productId . '/relations/count', $params); + } + + /** + * @param int $productId + * @param int $relationId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($productId, $relationId, $fields) + { + $fields = array('productRelation' => $fields); + + return $this->client->update('products/' . $productId . '/relations/' . $relationId, $fields); + } + + /** + * @param int $productId + * @param int $relationId + * + * @return array + * @throws ApiException + */ + public function delete($productId, $relationId) + { + return $this->client->delete('products/' . $productId . '/relations/' . $relationId); + } +} \ No newline at end of file diff --git a/src/ApiResourceQuotes.php b/src/ApiResourceQuotes.php new file mode 100644 index 0000000..43a71c5 --- /dev/null +++ b/src/ApiResourceQuotes.php @@ -0,0 +1,70 @@ +client = $client; + } + + /** + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($fields) + { + $fields = array('quote' => $fields); + + return $this->client->create('quotes', $fields); + } + + /** + * @param int $quoteId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($quoteId = null, $params = array()) + { + if (!$quoteId) { + return $this->client->read('quotes', $params); + } else { + return $this->client->read('quotes/' . $quoteId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('quotes/count', $params); + } + + /** + * @param int $quoteId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($quoteId, $fields) + { + $fields = array('quote' => $fields); + + return $this->client->update('quotes/' . $quoteId, $fields); + } +} \ No newline at end of file diff --git a/src/ApiResourceQuotesConvert.php b/src/ApiResourceQuotesConvert.php new file mode 100644 index 0000000..6f2d528 --- /dev/null +++ b/src/ApiResourceQuotesConvert.php @@ -0,0 +1,30 @@ +client = $client; + } + + /** + * @param int $quoteId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($quoteId, $fields) + { + $fields = array('order' => $fields); + + return $this->client->create('quotes/' . $quoteId . '/convert', $fields); + } +} \ No newline at end of file diff --git a/src/ApiResourceQuotesPaymentmethods.php b/src/ApiResourceQuotesPaymentmethods.php new file mode 100644 index 0000000..9697ddc --- /dev/null +++ b/src/ApiResourceQuotesPaymentmethods.php @@ -0,0 +1,38 @@ +client = $client; + } + + /** + * @param int $quoteId + * + * @return array + * @throws ApiException + */ + public function get($quoteId) + { + return $this->client->read('quotes/' . $quoteId . '/paymentmethods'); + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($quoteId, $params = array()) + { + return $this->client->read('quotes/' . $quoteId . '/paymentmethods/count', $params); + } +} \ No newline at end of file diff --git a/src/ApiResourceQuotesProducts.php b/src/ApiResourceQuotesProducts.php new file mode 100644 index 0000000..554cec9 --- /dev/null +++ b/src/ApiResourceQuotesProducts.php @@ -0,0 +1,86 @@ +client = $client; + } + + /** + * @param int $quoteId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($quoteId, $fields) + { + $fields = array('quoteProduct' => $fields); + + return $this->client->create('quotes/' . $quoteId . '/products', $fields); + } + + /** + * @param int $quoteId + * @param int $productId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($quoteId, $productId = null, $params = array()) + { + if (!$productId) { + return $this->client->read('quotes/' . $quoteId . '/products', $params); + } else { + return $this->client->read('quotes/' . $quoteId . '/products/' . $productId, $params); + } + } + + /** + * @param int $quoteId + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($quoteId, $params = array()) + { + return $this->client->read('quotes/' . $quoteId . '/products/count', $params); + } + + /** + * @param int $quoteId + * @param int $productId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($quoteId, $productId, $fields) + { + $fields = array('quoteProduct' => $fields); + + return $this->client->update('quotes/' . $quoteId . '/products/' . $productId, $fields); + } + + /** + * @param int $quoteId + * @param int $productId + * + * @return array + * @throws ApiException + */ + public function delete($quoteId, $productId) + { + return $this->client->delete('quotes/' . $quoteId . '/products/' . $productId); + } +} \ No newline at end of file diff --git a/src/ApiResourceQuotesShippingmethods.php b/src/ApiResourceQuotesShippingmethods.php new file mode 100644 index 0000000..69ec5fb --- /dev/null +++ b/src/ApiResourceQuotesShippingmethods.php @@ -0,0 +1,39 @@ +client = $client; + } + + /** + * @param int $quoteId + * + * @return array + * @throws ApiException + */ + public function get($quoteId) + { + return $this->client->read('quotes/' . $quoteId . '/shippingmethods'); + } + + /** + * @param int $quoteId + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($quoteId, $params = array()) + { + return $this->client->read('quotes/' . $quoteId . '/shippingmethods/count', $params); + } +} \ No newline at end of file diff --git a/src/ApiResourceRedirects.php b/src/ApiResourceRedirects.php new file mode 100644 index 0000000..4c6da9d --- /dev/null +++ b/src/ApiResourceRedirects.php @@ -0,0 +1,81 @@ +client = $client; + } + + /** + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($fields) + { + $fields = array('redirect' => $fields); + + return $this->client->create('redirects', $fields); + } + + /** + * @param int $redirectId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($redirectId = null, $params = array()) + { + if (!$redirectId) { + return $this->client->read('redirects', $params); + } else { + return $this->client->read('redirects/' . $redirectId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('redirects/count', $params); + } + + /** + * @param int $redirectId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($redirectId, $fields) + { + $fields = array('redirect' => $fields); + + return $this->client->update('redirects/' . $redirectId, $fields); + } + + /** + * @param int $redirectId + * + * @return array + * @throws ApiException + */ + public function delete($redirectId) + { + return $this->client->delete('redirects/' . $redirectId); + } +} \ No newline at end of file diff --git a/src/ApiResourceReturns.php b/src/ApiResourceReturns.php new file mode 100644 index 0000000..b506a2a --- /dev/null +++ b/src/ApiResourceReturns.php @@ -0,0 +1,68 @@ +client = $client; + } + + /** + * @param int $returnId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($returnId = null, $params = array()) + { + if (!$returnId) { + return $this->client->read('returns', $params); + } else { + return $this->client->read('returns/' . $returnId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('returns/count', $params); + } + + /** + * @param int $returnId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($returnId, $fields) + { + $fields = array('return' => $fields); + + return $this->client->update('returns/' . $returnId, $fields); + } + + /** + * @param int $returnId + * + * @return array + * @throws ApiException + */ + public function delete($returnId) + { + return $this->client->delete('returns/' . $returnId); + } +} \ No newline at end of file diff --git a/src/ApiResourceReviews.php b/src/ApiResourceReviews.php new file mode 100644 index 0000000..b25eaa8 --- /dev/null +++ b/src/ApiResourceReviews.php @@ -0,0 +1,81 @@ +client = $client; + } + + /** + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($fields) + { + $fields = array('review' => $fields); + + return $this->client->create('reviews', $fields); + } + + /** + * @param int $reviewId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($reviewId = null, $params = array()) + { + if (!$reviewId) { + return $this->client->read('reviews', $params); + } else { + return $this->client->read('reviews/' . $reviewId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('reviews/count', $params); + } + + /** + * @param int $reviewId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($reviewId, $fields) + { + $fields = array('review' => $fields); + + return $this->client->update('reviews/' . $reviewId, $fields); + } + + /** + * @param int $reviewId + * + * @return array + * @throws ApiException + */ + public function delete($reviewId) + { + return $this->client->delete('reviews/' . $reviewId); + } +} \ No newline at end of file diff --git a/src/ApiResourceSets.php b/src/ApiResourceSets.php new file mode 100644 index 0000000..f5415f8 --- /dev/null +++ b/src/ApiResourceSets.php @@ -0,0 +1,81 @@ +client = $client; + } + + /** + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($fields) + { + $fields = array('set' => $fields); + + return $this->client->create('sets', $fields); + } + + /** + * @param int $setId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($setId = null, $params = array()) + { + if (!$setId) { + return $this->client->read('sets', $params); + } else { + return $this->client->read('sets/' . $setId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('sets/count', $params); + } + + /** + * @param int $setId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($setId, $fields) + { + $fields = array('set' => $fields); + + return $this->client->update('sets/' . $setId, $fields); + } + + /** + * @param int $setId + * + * @return array + * @throws ApiException + */ + public function delete($setId) + { + return $this->client->delete('sets/' . $setId); + } +} \ No newline at end of file diff --git a/src/ApiResourceShipments.php b/src/ApiResourceShipments.php new file mode 100644 index 0000000..793d9c4 --- /dev/null +++ b/src/ApiResourceShipments.php @@ -0,0 +1,57 @@ +client = $client; + } + + /** + * @param int $shipmentId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($shipmentId = null, $params = array()) + { + if (!$shipmentId) { + return $this->client->read('shipments', $params); + } else { + return $this->client->read('shipments/' . $shipmentId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('shipments/count', $params); + } + + /** + * @param int $shipmentId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($shipmentId, $fields) + { + $fields = array('shipment' => $fields); + + return $this->client->update('shipments/' . $shipmentId, $fields); + } +} \ No newline at end of file diff --git a/src/ApiResourceShipmentsMetafields.php b/src/ApiResourceShipmentsMetafields.php new file mode 100644 index 0000000..882cc9a --- /dev/null +++ b/src/ApiResourceShipmentsMetafields.php @@ -0,0 +1,86 @@ +client = $client; + } + + /** + * @param int $shipmentId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($shipmentId, $fields) + { + $fields = array('shipmentMetafield' => $fields); + + return $this->client->create('shipments/' . $shipmentId . '/metafields', $fields); + } + + /** + * @param int $shipmentId + * @param int $metafieldId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($shipmentId, $metafieldId = null, $params = array()) + { + if (!$metafieldId) { + return $this->client->read('shipments/' . $shipmentId . '/metafields', $params); + } else { + return $this->client->read('shipments/' . $shipmentId . '/metafields/' . $metafieldId, $params); + } + } + + /** + * @param int $shipmentId + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($shipmentId, $params = array()) + { + return $this->client->read('shipments/' . $shipmentId . '/metafields/count', $params); + } + + /** + * @param int $shipmentId + * @param int $metafieldId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($shipmentId, $metafieldId, $fields) + { + $fields = array('shipmentMetafield' => $fields); + + return $this->client->update('shipments/' . $shipmentId . '/metafields/' . $metafieldId, $fields); + } + + /** + * @param int $shipmentId + * @param int $metafieldId + * + * @return array + * @throws ApiException + */ + public function delete($shipmentId, $metafieldId) + { + return $this->client->delete('shipments/' . $shipmentId . '/metafields/' . $metafieldId); + } +} \ No newline at end of file diff --git a/src/ApiResourceShipmentsProducts.php b/src/ApiResourceShipmentsProducts.php new file mode 100644 index 0000000..fbe387e --- /dev/null +++ b/src/ApiResourceShipmentsProducts.php @@ -0,0 +1,45 @@ +client = $client; + } + + /** + * @param int $shipmentId + * @param int $productId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($shipmentId, $productId = null, $params = array()) + { + if (!$productId) { + return $this->client->read('shipments/' . $shipmentId . '/products', $params); + } else { + return $this->client->read('shipments/' . $shipmentId . '/products/' . $productId, $params); + } + } + + /** + * @param int $shipmentId + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($shipmentId, $params = array()) + { + return $this->client->read('shipments/' . $shipmentId . '/products/count', $params); + } +} \ No newline at end of file diff --git a/src/ApiResourceShippingmethods.php b/src/ApiResourceShippingmethods.php new file mode 100644 index 0000000..829de28 --- /dev/null +++ b/src/ApiResourceShippingmethods.php @@ -0,0 +1,43 @@ +client = $client; + } + + /** + * @param int $shippingmethodId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($shippingmethodId = null, $params = array()) + { + if (!$shippingmethodId) { + return $this->client->read('shippingmethods', $params); + } else { + return $this->client->read('shippingmethods/' . $shippingmethodId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('shippingmethods/count', $params); + } +} \ No newline at end of file diff --git a/src/ApiResourceShippingmethodsCountries.php b/src/ApiResourceShippingmethodsCountries.php new file mode 100644 index 0000000..7f6f6d5 --- /dev/null +++ b/src/ApiResourceShippingmethodsCountries.php @@ -0,0 +1,45 @@ +client = $client; + } + + /** + * @param int $shippingmethodId + * @param int $countryId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($shippingmethodId, $countryId = null, $params = array()) + { + if (!$countryId) { + return $this->client->read('shippingmethods/' . $shippingmethodId . '/countries', $params); + } else { + return $this->client->read('shippingmethods/' . $shippingmethodId . '/countries/' . $countryId, $params); + } + } + + /** + * @param int $shippingmethodId + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($shippingmethodId, $params = array()) + { + return $this->client->read('shippingmethods/' . $shippingmethodId . '/countries/count', $params); + } +} \ No newline at end of file diff --git a/src/ApiResourceShippingmethodsValues.php b/src/ApiResourceShippingmethodsValues.php new file mode 100644 index 0000000..7b20b23 --- /dev/null +++ b/src/ApiResourceShippingmethodsValues.php @@ -0,0 +1,45 @@ +client = $client; + } + + /** + * @param int $shippingmethodId + * @param int $valueId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($shippingmethodId, $valueId = null, $params = array()) + { + if (!$valueId) { + return $this->client->read('shippingmethods/' . $shippingmethodId . '/values', $params); + } else { + return $this->client->read('shippingmethods/' . $shippingmethodId . '/values/' . $valueId, $params); + } + } + + /** + * @param int $shippingmethodId + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($shippingmethodId, $params = array()) + { + return $this->client->read('shippingmethods/' . $shippingmethodId . '/values/count', $params); + } +} \ No newline at end of file diff --git a/src/ApiResourceShop.php b/src/ApiResourceShop.php new file mode 100644 index 0000000..11e6f31 --- /dev/null +++ b/src/ApiResourceShop.php @@ -0,0 +1,38 @@ +client = $client; + } + + /** + * @return array + * @throws ApiException + */ + public function get() + { + return $this->client->read('shop'); + } + + /** + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($fields) + { + $fields = array('shop' => $fields); + + return $this->client->update('shop', $fields); + } +} \ No newline at end of file diff --git a/src/ApiResourceShopCompany.php b/src/ApiResourceShopCompany.php new file mode 100644 index 0000000..6d68d03 --- /dev/null +++ b/src/ApiResourceShopCompany.php @@ -0,0 +1,25 @@ +client = $client; + } + + /** + * @return array + * @throws ApiException + */ + public function get() + { + return $this->client->read('shop/company'); + } +} \ No newline at end of file diff --git a/src/ApiResourceShopJavascript.php b/src/ApiResourceShopJavascript.php new file mode 100644 index 0000000..a51ae56 --- /dev/null +++ b/src/ApiResourceShopJavascript.php @@ -0,0 +1,38 @@ +client = $client; + } + + /** + * @return array + * @throws ApiException + */ + public function get() + { + return $this->client->read('shop/javascript'); + } + + /** + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($fields) + { + $fields = array('shopJavascript' => $fields); + + return $this->client->update('shop/javascript', $fields); + } +} \ No newline at end of file diff --git a/src/ApiResourceShopLimits.php b/src/ApiResourceShopLimits.php new file mode 100644 index 0000000..a191531 --- /dev/null +++ b/src/ApiResourceShopLimits.php @@ -0,0 +1,25 @@ +client = $client; + } + + /** + * @return array + * @throws ApiException + */ + public function get() + { + return $this->client->read('shop/limits'); + } +} \ No newline at end of file diff --git a/src/ApiResourceShopMetafields.php b/src/ApiResourceShopMetafields.php new file mode 100644 index 0000000..e620419 --- /dev/null +++ b/src/ApiResourceShopMetafields.php @@ -0,0 +1,81 @@ +client = $client; + } + + /** + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($fields) + { + $fields = array('shopMetafield' => $fields); + + return $this->client->create('shop/metafields', $fields); + } + + /** + * @param int $metafieldId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($metafieldId = null, $params = array()) + { + if (!$metafieldId) { + return $this->client->read('shop/metafields', $params); + } else { + return $this->client->read('shop/metafields/' . $metafieldId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('shop/metafields/count', $params); + } + + /** + * @param int $metafieldId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($metafieldId, $fields) + { + $fields = array('shopMetafield' => $fields); + + return $this->client->update('shop/metafields/' . $metafieldId, $fields); + } + + /** + * @param int $metafieldId + * + * @return array + * @throws ApiException + */ + public function delete($metafieldId) + { + return $this->client->delete('shop/metafields/' . $metafieldId); + } +} \ No newline at end of file diff --git a/src/ApiResourceShopScripts.php b/src/ApiResourceShopScripts.php new file mode 100644 index 0000000..b0f5c92 --- /dev/null +++ b/src/ApiResourceShopScripts.php @@ -0,0 +1,81 @@ +client = $client; + } + + /** + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($fields) + { + $fields = array('shopScript' => $fields); + + return $this->client->create('shop/scripts', $fields); + } + + /** + * @param int $scriptId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($scriptId = null, $params = array()) + { + if (!$scriptId) { + return $this->client->read('shop/scripts', $params); + } else { + return $this->client->read('shop/scripts/' . $scriptId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('shop/scripts/count', $params); + } + + /** + * @param int $scriptId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($scriptId, $fields) + { + $fields = array('shopScript' => $fields); + + return $this->client->update('shop/scripts/' . $scriptId, $fields); + } + + /** + * @param int $scriptId + * + * @return array + * @throws ApiException + */ + public function delete($scriptId) + { + return $this->client->delete('shop/scripts/' . $scriptId); + } +} \ No newline at end of file diff --git a/src/ApiResourceShopSettings.php b/src/ApiResourceShopSettings.php new file mode 100644 index 0000000..fb35a89 --- /dev/null +++ b/src/ApiResourceShopSettings.php @@ -0,0 +1,25 @@ +client = $client; + } + + /** + * @return array + * @throws ApiException + */ + public function get() + { + return $this->client->read('shop/settings'); + } +} \ No newline at end of file diff --git a/src/ApiResourceShopTracking.php b/src/ApiResourceShopTracking.php new file mode 100644 index 0000000..bf99de9 --- /dev/null +++ b/src/ApiResourceShopTracking.php @@ -0,0 +1,81 @@ +client = $client; + } + + /** + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($fields) + { + $fields = array('shopTracking' => $fields); + + return $this->client->create('shop/tracking', $fields); + } + + /** + * @param int $trackingId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($trackingId = null, $params = array()) + { + if (!$trackingId) { + return $this->client->read('shop/tracking', $params); + } else { + return $this->client->read('shop/tracking/' . $trackingId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('shop/tracking/count', $params); + } + + /** + * @param int $trackingId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($trackingId, $fields) + { + $fields = array('shopTracking' => $fields); + + return $this->client->update('shop/tracking/' . $trackingId, $fields); + } + + /** + * @param int $trackingId + * + * @return array + * @throws ApiException + */ + public function delete($trackingId) + { + return $this->client->delete('shop/tracking/' . $trackingId); + } +} \ No newline at end of file diff --git a/src/ApiResourceShopWebsite.php b/src/ApiResourceShopWebsite.php new file mode 100644 index 0000000..f9d4e85 --- /dev/null +++ b/src/ApiResourceShopWebsite.php @@ -0,0 +1,25 @@ +client = $client; + } + + /** + * @return array + * @throws ApiException + */ + public function get() + { + return $this->client->read('shop/website'); + } +} \ No newline at end of file diff --git a/src/ApiResourceSubscriptions.php b/src/ApiResourceSubscriptions.php new file mode 100644 index 0000000..81ca873 --- /dev/null +++ b/src/ApiResourceSubscriptions.php @@ -0,0 +1,81 @@ +client = $client; + } + + /** + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($fields) + { + $fields = array('subscription' => $fields); + + return $this->client->create('subscriptions', $fields); + } + + /** + * @param int $subscriptionId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($subscriptionId = null, $params = array()) + { + if (!$subscriptionId) { + return $this->client->read('subscriptions', $params); + } else { + return $this->client->read('subscriptions/' . $subscriptionId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('subscriptions/count', $params); + } + + /** + * @param int $subscriptionId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($subscriptionId, $fields) + { + $fields = array('subscription' => $fields); + + return $this->client->update('subscriptions/' . $subscriptionId, $fields); + } + + /** + * @param int $subscriptionId + * + * @return array + * @throws ApiException + */ + public function delete($subscriptionId) + { + return $this->client->delete('subscriptions/' . $subscriptionId); + } +} \ No newline at end of file diff --git a/src/ApiResourceSuppliers.php b/src/ApiResourceSuppliers.php new file mode 100644 index 0000000..dcb6e8e --- /dev/null +++ b/src/ApiResourceSuppliers.php @@ -0,0 +1,81 @@ +client = $client; + } + + /** + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($fields) + { + $fields = array('supplier' => $fields); + + return $this->client->create('suppliers', $fields); + } + + /** + * @param int $supplierId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($supplierId = null, $params = array()) + { + if (!$supplierId) { + return $this->client->read('suppliers', $params); + } else { + return $this->client->read('suppliers/' . $supplierId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('suppliers/count', $params); + } + + /** + * @param int $supplierId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($supplierId, $fields) + { + $fields = array('supplier' => $fields); + + return $this->client->update('suppliers/' . $supplierId, $fields); + } + + /** + * @param int $supplierId + * + * @return array + * @throws ApiException + */ + public function delete($supplierId) + { + return $this->client->delete('suppliers/' . $supplierId); + } +} \ No newline at end of file diff --git a/src/ApiResourceTags.php b/src/ApiResourceTags.php new file mode 100644 index 0000000..8de33e7 --- /dev/null +++ b/src/ApiResourceTags.php @@ -0,0 +1,81 @@ +client = $client; + } + + /** + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($fields) + { + $fields = array('tag' => $fields); + + return $this->client->create('tags', $fields); + } + + /** + * @param int $tagId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($tagId = null, $params = array()) + { + if (!$tagId) { + return $this->client->read('tags', $params); + } else { + return $this->client->read('tags/' . $tagId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('tags/count', $params); + } + + /** + * @param int $tagId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($tagId, $fields) + { + $fields = array('tag' => $fields); + + return $this->client->update('tags/' . $tagId, $fields); + } + + /** + * @param int $tagId + * + * @return array + * @throws ApiException + */ + public function delete($tagId) + { + return $this->client->delete('tags/' . $tagId); + } +} \ No newline at end of file diff --git a/src/ApiResourceTagsProducts.php b/src/ApiResourceTagsProducts.php new file mode 100644 index 0000000..6e570a7 --- /dev/null +++ b/src/ApiResourceTagsProducts.php @@ -0,0 +1,67 @@ +client = $client; + } + + /** + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($fields) + { + $fields = array('tagsProduct' => $fields); + + return $this->client->create('tags/products', $fields); + } + + /** + * @param int $relationId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($relationId = null, $params = array()) + { + if (!$relationId) { + return $this->client->read('tags/products', $params); + } else { + return $this->client->read('tags/products/' . $relationId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('tags/products/count', $params); + } + + /** + * @param int $relationId + * + * @return array + * @throws ApiException + */ + public function delete($relationId) + { + return $this->client->delete('tags/products/' . $relationId); + } +} \ No newline at end of file diff --git a/src/ApiResourceTaxes.php b/src/ApiResourceTaxes.php new file mode 100644 index 0000000..bf16521 --- /dev/null +++ b/src/ApiResourceTaxes.php @@ -0,0 +1,81 @@ +client = $client; + } + + /** + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($fields) + { + $fields = array('tax' => $fields); + + return $this->client->create('taxes', $fields); + } + + /** + * @param int $taxId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($taxId = null, $params = array()) + { + if (!$taxId) { + return $this->client->read('taxes', $params); + } else { + return $this->client->read('taxes/' . $taxId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('taxes/count', $params); + } + + /** + * @param int $taxId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($taxId, $fields) + { + $fields = array('tax' => $fields); + + return $this->client->update('taxes/' . $taxId, $fields); + } + + /** + * @param int $taxId + * + * @return array + * @throws ApiException + */ + public function delete($taxId) + { + return $this->client->delete('taxes/' . $taxId); + } +} \ No newline at end of file diff --git a/src/ApiResourceTaxesOverrides.php b/src/ApiResourceTaxesOverrides.php new file mode 100644 index 0000000..d68d377 --- /dev/null +++ b/src/ApiResourceTaxesOverrides.php @@ -0,0 +1,86 @@ +client = $client; + } + + /** + * @param int $taxId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($taxId, $fields) + { + $fields = array('taxOverride' => $fields); + + return $this->client->create('taxes/' . $taxId . '/overrides', $fields); + } + + /** + * @param int $taxId + * @param int $taxOverrideId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($taxId, $taxOverrideId = null, $params = array()) + { + if (!$taxOverrideId) { + return $this->client->read('taxes/' . $taxId . '/overrides', $params); + } else { + return $this->client->read('taxes/' . $taxId . '/overrides/' . $taxOverrideId, $params); + } + } + + /** + * @param int $taxId + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($taxId, $params = array()) + { + return $this->client->read('taxes/' . $taxId . '/overrides/count', $params); + } + + /** + * @param int $taxId + * @param int $taxOverrideId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($taxId, $taxOverrideId, $fields) + { + $fields = array('taxOverride' => $fields); + + return $this->client->update('taxes/' . $taxId . '/overrides/' . $taxOverrideId, $fields); + } + + /** + * @param int $taxId + * @param int $taxOverrideId + * + * @return array + * @throws ApiException + */ + public function delete($taxId, $taxOverrideId) + { + return $this->client->delete('taxes/' . $taxId . '/overrides/' . $taxOverrideId); + } +} \ No newline at end of file diff --git a/src/ApiResourceTextpages.php b/src/ApiResourceTextpages.php new file mode 100644 index 0000000..199c7f2 --- /dev/null +++ b/src/ApiResourceTextpages.php @@ -0,0 +1,81 @@ +client = $client; + } + + /** + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($fields) + { + $fields = array('textpage' => $fields); + + return $this->client->create('textpages', $fields); + } + + /** + * @param int $textpageId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($textpageId = null, $params = array()) + { + if (!$textpageId) { + return $this->client->read('textpages', $params); + } else { + return $this->client->read('textpages/' . $textpageId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('textpages/count', $params); + } + + /** + * @param int $textpageId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($textpageId, $fields) + { + $fields = array('textpage' => $fields); + + return $this->client->update('textpages/' . $textpageId, $fields); + } + + /** + * @param int $textpageId + * + * @return array + * @throws ApiException + */ + public function delete($textpageId) + { + return $this->client->delete('textpages/' . $textpageId); + } +} \ No newline at end of file diff --git a/src/ApiResourceThemeCategories.php b/src/ApiResourceThemeCategories.php new file mode 100644 index 0000000..ad59ae7 --- /dev/null +++ b/src/ApiResourceThemeCategories.php @@ -0,0 +1,81 @@ +client = $client; + } + + /** + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($fields) + { + $fields = array('themeCategory' => $fields); + + return $this->client->create('theme/categories', $fields); + } + + /** + * @param int $categoryId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($categoryId = null, $params = array()) + { + if (!$categoryId) { + return $this->client->read('theme/categories', $params); + } else { + return $this->client->read('theme/categories/' . $categoryId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('theme/categories/count', $params); + } + + /** + * @param int $categoryId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($categoryId, $fields) + { + $fields = array('themeCategory' => $fields); + + return $this->client->update('theme/categories/' . $categoryId, $fields); + } + + /** + * @param int $categoryId + * + * @return array + * @throws ApiException + */ + public function delete($categoryId) + { + return $this->client->delete('theme/categories/' . $categoryId); + } +} \ No newline at end of file diff --git a/src/ApiResourceThemeProducts.php b/src/ApiResourceThemeProducts.php new file mode 100644 index 0000000..8914302 --- /dev/null +++ b/src/ApiResourceThemeProducts.php @@ -0,0 +1,81 @@ +client = $client; + } + + /** + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($fields) + { + $fields = array('themeProduct' => $fields); + + return $this->client->create('theme/products', $fields); + } + + /** + * @param int $productId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($productId = null, $params = array()) + { + if (!$productId) { + return $this->client->read('theme/products', $params); + } else { + return $this->client->read('theme/products/' . $productId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('theme/products/count', $params); + } + + /** + * @param int $productId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($productId, $fields) + { + $fields = array('themeProduct' => $fields); + + return $this->client->update('theme/products/' . $productId, $fields); + } + + /** + * @param int $productId + * + * @return array + * @throws ApiException + */ + public function delete($productId) + { + return $this->client->delete('theme/products/' . $productId); + } +} \ No newline at end of file diff --git a/src/ApiResourceTickets.php b/src/ApiResourceTickets.php new file mode 100644 index 0000000..c0d0e0f --- /dev/null +++ b/src/ApiResourceTickets.php @@ -0,0 +1,81 @@ +client = $client; + } + + /** + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($fields) + { + $fields = array('ticket' => $fields); + + return $this->client->create('tickets', $fields); + } + + /** + * @param int $ticketId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($ticketId = null, $params = array()) + { + if (!$ticketId) { + return $this->client->read('tickets', $params); + } else { + return $this->client->read('tickets/' . $ticketId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('tickets/count', $params); + } + + /** + * @param int $ticketId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($ticketId, $fields) + { + $fields = array('ticket' => $fields); + + return $this->client->update('tickets/' . $ticketId, $fields); + } + + /** + * @param int $ticketId + * + * @return array + * @throws ApiException + */ + public function delete($ticketId) + { + return $this->client->delete('tickets/' . $ticketId); + } +} \ No newline at end of file diff --git a/src/ApiResourceTicketsMessages.php b/src/ApiResourceTicketsMessages.php new file mode 100644 index 0000000..a210211 --- /dev/null +++ b/src/ApiResourceTicketsMessages.php @@ -0,0 +1,86 @@ +client = $client; + } + + /** + * @param int $ticketId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($ticketId, $fields) + { + $fields = array('ticketMessage' => $fields); + + return $this->client->create('tickets/' . $ticketId . '/messages', $fields); + } + + /** + * @param int $ticketId + * @param int $messageId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($ticketId, $messageId = null, $params = array()) + { + if (!$messageId) { + return $this->client->read('tickets/' . $ticketId . '/messages', $params); + } else { + return $this->client->read('tickets/' . $ticketId . '/messages/' . $messageId, $params); + } + } + + /** + * @param int $ticketId + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($ticketId, $params = array()) + { + return $this->client->read('tickets/' . $ticketId . '/messages/count', $params); + } + + /** + * @param int $ticketId + * @param int $messageId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($ticketId, $messageId, $fields) + { + $fields = array('ticketMessage' => $fields); + + return $this->client->update('tickets/' . $ticketId . '/messages/' . $messageId, $fields); + } + + /** + * @param int $ticketId + * @param int $messageId + * + * @return array + * @throws ApiException + */ + public function delete($ticketId, $messageId) + { + return $this->client->delete('tickets/' . $ticketId . '/messages/' . $messageId); + } +} \ No newline at end of file diff --git a/src/ApiResourceTime.php b/src/ApiResourceTime.php new file mode 100644 index 0000000..94042f4 --- /dev/null +++ b/src/ApiResourceTime.php @@ -0,0 +1,25 @@ +client = $client; + } + + /** + * @return array + * @throws ApiException + */ + public function get() + { + return $this->client->read('time'); + } +} \ No newline at end of file diff --git a/src/ApiResourceTypes.php b/src/ApiResourceTypes.php new file mode 100644 index 0000000..98f1afa --- /dev/null +++ b/src/ApiResourceTypes.php @@ -0,0 +1,81 @@ +client = $client; + } + + /** + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($fields) + { + $fields = array('type' => $fields); + + return $this->client->create('types', $fields); + } + + /** + * @param int $typeId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($typeId = null, $params = array()) + { + if (!$typeId) { + return $this->client->read('types', $params); + } else { + return $this->client->read('types/' . $typeId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('types/count', $params); + } + + /** + * @param int $typeId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($typeId, $fields) + { + $fields = array('type' => $fields); + + return $this->client->update('types/' . $typeId, $fields); + } + + /** + * @param int $typeId + * + * @return array + * @throws ApiException + */ + public function delete($typeId) + { + return $this->client->delete('types/' . $typeId); + } +} \ No newline at end of file diff --git a/src/ApiResourceTypesAttributes.php b/src/ApiResourceTypesAttributes.php new file mode 100644 index 0000000..67ee318 --- /dev/null +++ b/src/ApiResourceTypesAttributes.php @@ -0,0 +1,67 @@ +client = $client; + } + + /** + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($fields) + { + $fields = array('typesAttribute' => $fields); + + return $this->client->create('types/attributes', $fields); + } + + /** + * @param int $relationId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($relationId = null, $params = array()) + { + if (!$relationId) { + return $this->client->read('types/attributes', $params); + } else { + return $this->client->read('types/attributes/' . $relationId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('types/attributes/count', $params); + } + + /** + * @param int $relationId + * + * @return array + * @throws ApiException + */ + public function delete($relationId) + { + return $this->client->delete('types/attributes/' . $relationId); + } +} \ No newline at end of file diff --git a/src/ApiResourceVariants.php b/src/ApiResourceVariants.php new file mode 100644 index 0000000..421e0a8 --- /dev/null +++ b/src/ApiResourceVariants.php @@ -0,0 +1,81 @@ +client = $client; + } + + /** + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($fields) + { + $fields = array('variant' => $fields); + + return $this->client->create('variants', $fields); + } + + /** + * @param int $variantId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($variantId = null, $params = array()) + { + if (!$variantId) { + return $this->client->read('variants', $params); + } else { + return $this->client->read('variants/' . $variantId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('variants/count', $params); + } + + /** + * @param int $variantId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($variantId, $fields) + { + $fields = array('variant' => $fields); + + return $this->client->update('variants/' . $variantId, $fields); + } + + /** + * @param int $variantId + * + * @return array + * @throws ApiException + */ + public function delete($variantId) + { + return $this->client->delete('variants/' . $variantId); + } +} \ No newline at end of file diff --git a/src/ApiResourceVariantsBulk.php b/src/ApiResourceVariantsBulk.php new file mode 100644 index 0000000..d548e16 --- /dev/null +++ b/src/ApiResourceVariantsBulk.php @@ -0,0 +1,29 @@ +client = $client; + } + + /** + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($fields) + { + $fields = array('variant' => $fields); + + return $this->client->update('variants/bulk', $fields); + } +} \ No newline at end of file diff --git a/src/ApiResourceVariantsImage.php b/src/ApiResourceVariantsImage.php new file mode 100644 index 0000000..422dc23 --- /dev/null +++ b/src/ApiResourceVariantsImage.php @@ -0,0 +1,52 @@ +client = $client; + } + + /** + * @param int $variantId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($variantId, $fields) + { + $fields = array('variantImage' => $fields); + + return $this->client->create('variants/' . $variantId . '/image', $fields); + } + + /** + * @param int $variantId + * + * @return array + * @throws ApiException + */ + public function get($variantId) + { + return $this->client->read('variants/' . $variantId . '/image'); + } + + /** + * @param int $variantId + * + * @return array + * @throws ApiException + */ + public function delete($variantId) + { + return $this->client->delete('variants/' . $variantId . '/image'); + } +} \ No newline at end of file diff --git a/src/ApiResourceVariantsMetafields.php b/src/ApiResourceVariantsMetafields.php new file mode 100644 index 0000000..50f16fd --- /dev/null +++ b/src/ApiResourceVariantsMetafields.php @@ -0,0 +1,86 @@ +client = $client; + } + + /** + * @param int $variantId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($variantId, $fields) + { + $fields = array('variantMetafield' => $fields); + + return $this->client->create('variants/' . $variantId . '/metafields', $fields); + } + + /** + * @param int $variantId + * @param int $metafieldId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($variantId, $metafieldId = null, $params = array()) + { + if (!$metafieldId) { + return $this->client->read('variants/' . $variantId . '/metafields', $params); + } else { + return $this->client->read('variants/' . $variantId . '/metafields/' . $metafieldId, $params); + } + } + + /** + * @param int $variantId + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($variantId, $params = array()) + { + return $this->client->read('variants/' . $variantId . '/metafields/count', $params); + } + + /** + * @param int $variantId + * @param int $metafieldId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($variantId, $metafieldId, $fields) + { + $fields = array('variantMetafield' => $fields); + + return $this->client->update('variants/' . $variantId . '/metafields/' . $metafieldId, $fields); + } + + /** + * @param int $variantId + * @param int $metafieldId + * + * @return array + * @throws ApiException + */ + public function delete($variantId, $metafieldId) + { + return $this->client->delete('variants/' . $variantId . '/metafields/' . $metafieldId); + } +} \ No newline at end of file diff --git a/src/ApiResourceVariantsMovements.php b/src/ApiResourceVariantsMovements.php new file mode 100644 index 0000000..15a532a --- /dev/null +++ b/src/ApiResourceVariantsMovements.php @@ -0,0 +1,43 @@ +client = $client; + } + + /** + * @param int $movementId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($movementId = null, $params = array()) + { + if (!$movementId) { + return $this->client->read('variants/movements', $params); + } else { + return $this->client->read('variants/movements/' . $movementId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('variants/movements/count', $params); + } +} \ No newline at end of file diff --git a/src/ApiResourceWebhooks.php b/src/ApiResourceWebhooks.php new file mode 100644 index 0000000..3db73e6 --- /dev/null +++ b/src/ApiResourceWebhooks.php @@ -0,0 +1,81 @@ +client = $client; + } + + /** + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function create($fields) + { + $fields = array('webhook' => $fields); + + return $this->client->create('webhooks', $fields); + } + + /** + * @param int $webhookId + * @param array $params + * + * @return array + * @throws ApiException + */ + public function get($webhookId = null, $params = array()) + { + if (!$webhookId) { + return $this->client->read('webhooks', $params); + } else { + return $this->client->read('webhooks/' . $webhookId, $params); + } + } + + /** + * @param array $params + * + * @return int + * @throws ApiException + */ + public function count($params = array()) + { + return $this->client->read('webhooks/count', $params); + } + + /** + * @param int $webhookId + * @param array $fields + * + * @return array + * @throws ApiException + */ + public function update($webhookId, $fields) + { + $fields = array('webhook' => $fields); + + return $this->client->update('webhooks/' . $webhookId, $fields); + } + + /** + * @param int $webhookId + * + * @return array + * @throws ApiException + */ + public function delete($webhookId) + { + return $this->client->delete('webhooks/' . $webhookId); + } +} \ No newline at end of file diff --git a/src/WebshopappApiClient.php b/src/WebshopappApiClient.php deleted file mode 100755 index e320db3..0000000 --- a/src/WebshopappApiClient.php +++ /dev/null @@ -1,7460 +0,0 @@ -setApiServer($apiServer); - $this->setApiKey($apiKey); - $this->setApiSecret($apiSecret); - $this->setApiLanguage($apiLanguage); - - $this->registerResources(); - } - - /** - * @return string - */ - public function getApiLanguage() - { - return $this->apiLanguage; - } - - /** - * @param $apiServer - */ - public function setApiServer($apiServer) - { - $this->apiServer = $apiServer; - } - - /** - * @param $apiKey - */ - public function setApiKey($apiKey) - { - $this->apiKey = $apiKey; - } - - /** - * @return string - */ - public function getApiKey() - { - return $this->apiKey; - } - - /** - * @param $apiSecret - */ - public function setApiSecret($apiSecret) - { - $this->apiSecret = $apiSecret; - } - - /** - * @return string - */ - public function getApiSecret() - { - return $this->apiSecret; - } - - /** - * @param $apiLanguage - */ - public function setApiLanguage($apiLanguage) - { - $this->apiLanguage = $apiLanguage; - } - - /** - * @return string - */ - public function getApiServer() - { - return $this->apiServer; - } - - /** - * @return int - */ - public function getApiCallsMade() - { - return $this->apiCallsMade; - } - - /** - * @param array $responseHeaders - * - * @return void - */ - public function setResponseHeaders($responseHeaders) - { - $this->responseHeaders = $responseHeaders; - } - - /** - * @return array - */ - public function getResponseHeaders() - { - return $this->responseHeaders; - } - - /** - * @throws WebshopappApiException - */ - private function checkLoginCredentials() - { - if (strlen($this->getApiKey()) !== 32 || strlen($this->getApiSecret()) !== 32) - { - throw new WebshopappApiException('Invalid login credentials.'); - } - if (strlen($this->getApiLanguage()) !== 2) - { - throw new WebshopappApiException('Invalid API language.'); - } - } - - private function registerResources() - { - $this->account = new WebshopappApiResourceAccount($this); - $this->accountMetafields = new WebshopappApiResourceAccountMetafields($this); - $this->accountPermissions = new WebshopappApiResourceAccountPermissions($this); - $this->accountRatelimit = new WebshopappApiResourceAccountRatelimit($this); - $this->additionalcosts = new WebshopappApiResourceAdditionalcosts($this); - $this->attributes = new WebshopappApiResourceAttributes($this); - $this->blogs = new WebshopappApiResourceBlogs($this); - $this->blogsArticles = new WebshopappApiResourceBlogsArticles($this); - $this->blogsArticlesImage = new WebshopappApiResourceBlogsArticlesImage($this); - $this->blogsArticlesTags = new WebshopappApiResourceBlogsArticlesTags($this); - $this->blogsComments = new WebshopappApiResourceBlogsComments($this); - $this->blogsTags = new WebshopappApiResourceBlogsTags($this); - $this->brands = new WebshopappApiResourceBrands($this); - $this->brandsImage = new WebshopappApiResourceBrandsImage($this); - $this->catalog = new WebshopappApiResourceCatalog($this); - $this->categories = new WebshopappApiResourceCategories($this); - $this->categoriesImage = new WebshopappApiResourceCategoriesImage($this); - $this->categoriesProducts = new WebshopappApiResourceCategoriesProducts($this); - $this->categoriesProductsBulk = new WebshopappApiResourceCategoriesProductsBulk($this); - $this->checkouts = new WebshopappApiResourceCheckouts($this); - $this->checkoutsOrder = new WebshopappApiResourceCheckoutsOrder($this); - $this->checkoutsPayment_methods = new WebshopappApiResourceCheckoutsPayment_methods($this); - $this->checkoutsProducts = new WebshopappApiResourceCheckoutsProducts($this); - $this->checkoutsShipment_methods = new WebshopappApiResourceCheckoutsShipment_methods($this); - $this->checkoutsValidate = new WebshopappApiResourceCheckoutsValidate($this); - $this->contacts = new WebshopappApiResourceContacts($this); - $this->countries = new WebshopappApiResourceCountries($this); - $this->customers = new WebshopappApiResourceCustomers($this); - $this->customersLogin = new WebshopappApiResourceCustomersLogin($this); - $this->customersMetafields = new WebshopappApiResourceCustomersMetafields($this); - $this->customersTokens = new WebshopappApiResourceCustomersTokens($this); - $this->dashboard = new WebshopappApiResourceDashboard($this); - $this->deliverydates = new WebshopappApiResourceDeliverydates($this); - $this->discountrules = new WebshopappApiResourceDiscountrules($this); - $this->discounts = new WebshopappApiResourceDiscounts($this); - $this->events = new WebshopappApiResourceEvents($this); - $this->external_services = new WebshopappApiResourceExternal_services($this); - $this->files = new WebshopappApiResourceFiles($this); - $this->filters = new WebshopappApiResourceFilters($this); - $this->filtersValues = new WebshopappApiResourceFiltersValues($this); - $this->groups = new WebshopappApiResourceGroups($this); - $this->groupsCustomers = new WebshopappApiResourceGroupsCustomers($this); - $this->invoices = new WebshopappApiResourceInvoices($this); - $this->invoicesItems = new WebshopappApiResourceInvoicesItems($this); - $this->invoicesMetafields = new WebshopappApiResourceInvoicesMetafields($this); - $this->languages = new WebshopappApiResourceLanguages($this); - $this->locations = new WebshopappApiResourceLocations($this); - $this->metafields = new WebshopappApiResourceMetafields($this); - $this->orders = new WebshopappApiResourceOrders($this); - $this->ordersCredit = new WebshopappApiResourceOrdersCredit($this); - $this->ordersMetafields = new WebshopappApiResourceOrdersMetafields($this); - $this->ordersProducts = new WebshopappApiResourceOrdersProducts($this); - $this->ordersCustomstatuses = new WebshopappApiResourceOrdersCustomstatuses($this); - $this->ordersEvents = new WebshopappApiResourceOrdersEvents($this); - $this->paymentmethods = new WebshopappApiResourcePaymentmethods($this); - $this->products = new WebshopappApiResourceProducts($this); - $this->productsAttributes = new WebshopappApiResourceProductsAttributes($this); - $this->productsFiltervalues = new WebshopappApiResourceProductsFiltervalues($this); - $this->productsImages = new WebshopappApiResourceProductsImages($this); - $this->productsMetafields = new WebshopappApiResourceProductsMetafields($this); - $this->productsRelations = new WebshopappApiResourceProductsRelations($this); - $this->quotes = new WebshopappApiResourceQuotes($this); - $this->quotesConvert = new WebshopappApiResourceQuotesConvert($this); - $this->quotesPaymentmethods = new WebshopappApiResourceQuotesPaymentmethods($this); - $this->quotesProducts = new WebshopappApiResourceQuotesProducts($this); - $this->quotesShippingmethods = new WebshopappApiResourceQuotesShippingmethods($this); - $this->redirects = new WebshopappApiResourceRedirects($this); - $this->returns = new WebshopappApiResourceReturns($this); - $this->reviews = new WebshopappApiResourceReviews($this); - $this->sets = new WebshopappApiResourceSets($this); - $this->shipments = new WebshopappApiResourceShipments($this); - $this->shipmentsMetafields = new WebshopappApiResourceShipmentsMetafields($this); - $this->shipmentsProducts = new WebshopappApiResourceShipmentsProducts($this); - $this->shippingmethods = new WebshopappApiResourceShippingmethods($this); - $this->shippingmethodsCountries = new WebshopappApiResourceShippingmethodsCountries($this); - $this->shippingmethodsValues = new WebshopappApiResourceShippingmethodsValues($this); - $this->shop = new WebshopappApiResourceShop($this); - $this->shopCompany = new WebshopappApiResourceShopCompany($this); - $this->shopJavascript = new WebshopappApiResourceShopJavascript($this); - $this->shopLimits = new WebshopappApiResourceShopLimits($this); - $this->shopMetafields = new WebshopappApiResourceShopMetafields($this); - $this->shopScripts = new WebshopappApiResourceShopScripts($this); - $this->shopSettings = new WebshopappApiResourceShopSettings($this); - $this->shopTracking = new WebshopappApiResourceShopTracking($this); - $this->shopWebsite = new WebshopappApiResourceShopWebsite($this); - $this->subscriptions = new WebshopappApiResourceSubscriptions($this); - $this->suppliers = new WebshopappApiResourceSuppliers($this); - $this->tags = new WebshopappApiResourceTags($this); - $this->tagsProducts = new WebshopappApiResourceTagsProducts($this); - $this->taxes = new WebshopappApiResourceTaxes($this); - $this->taxesOverrides = new WebshopappApiResourceTaxesOverrides($this); - $this->textpages = new WebshopappApiResourceTextpages($this); - $this->themeCategories = new WebshopappApiResourceThemeCategories($this); - $this->themeProducts = new WebshopappApiResourceThemeProducts($this); - $this->tickets = new WebshopappApiResourceTickets($this); - $this->ticketsMessages = new WebshopappApiResourceTicketsMessages($this); - $this->time = new WebshopappApiResourceTime($this); - $this->types = new WebshopappApiResourceTypes($this); - $this->typesAttributes = new WebshopappApiResourceTypesAttributes($this); - $this->variants = new WebshopappApiResourceVariants($this); - $this->variantsImage = new WebshopappApiResourceVariantsImage($this); - $this->variantsMetafields = new WebshopappApiResourceVariantsMetafields($this); - $this->variantsBulk = new WebshopappApiResourceVariantsBulk($this); - $this->variantsMovements = new WebshopappApiResourceVariantsMovements($this); - $this->webhooks = new WebshopappApiResourceWebhooks($this); - } - - /** - * @param string $resourceUrl - * @param array $params - * - * @return string - */ - private function getUrl($resourceUrl, $params = null) - { - if ($this->apiServer == 'live') - { - $apiHost = self::SERVER_HOST_LIVE; - } - elseif ($this->apiServer == 'local') - { - $apiHost = self::SERVER_HOST_LOCAL; - } - elseif ($this->apiServer == 'eu1') - { - $apiHost = self::SERVER_EU1_LIVE; - } - elseif ($this->apiServer == 'us1') - { - $apiHost = self::SERVER_US1_LIVE; - } - - $apiHostParts = parse_url($apiHost); - $resourceUrlParts = parse_url($resourceUrl); - - $apiUrl = $apiHostParts['scheme'] . '://' . $this->getApiKey() . ':' . $this->getApiSecret() . '@' . $apiHostParts['host'] . '/'; - if (isset($apiHostParts['path']) && strlen(trim($apiHostParts['path'], '/'))) - { - $apiUrl .= trim($apiHostParts['path'], '/') . '/'; - } - $apiUrl .= $this->getApiLanguage() . '/' . $resourceUrlParts['path'] . '.json'; - - if (isset($resourceUrlParts['query'])) - { - $apiUrl .= '?' . $resourceUrlParts['query']; - } - elseif ($params && is_array($params)) - { - $queryParameters = array(); - - foreach ($params as $key => $value) - { - if (!is_array($value)) - { - $queryParameters[] = $key . '=' . urlencode($value); - } - } - - $queryParameters = implode('&', $queryParameters); - - if (!empty($queryParameters)) - { - $apiUrl .= '?' . $queryParameters; - } - } - - return $apiUrl; - } - - /** - * Invoke the Webshopapp API. - * - * @param string $url The resource url (required) - * @param string $method The http method (default 'get') - * @param array $payload The query/post data - * - * @return mixed The decoded response object - * @throws WebshopappApiException - */ - private function sendRequest($url, $method, $payload = null, $options = []) - { - $this->checkLoginCredentials(); - - if ($method == 'post' || $method == 'put') - { - if (!$payload || !is_array($payload)) - { - throw new WebshopAppApiException(100, 'Invalid payload'); - } - - $multipart = array_key_exists('header', $options); - - $header = $multipart ? $options['header'] : 'application/json'; - - $curlOptions = array( - CURLOPT_URL => $this->getUrl($url), - CURLOPT_CUSTOMREQUEST => strtoupper($method), - CURLOPT_HTTPHEADER => array('Content-Type: ' . $header), - CURLOPT_POST => true, - CURLOPT_POSTFIELDS => $multipart ? $payload : json_encode($payload), - ); - } - elseif ($method == 'delete') - { - $curlOptions = array( - CURLOPT_URL => $this->getUrl($url), - CURLOPT_CUSTOMREQUEST => 'DELETE', - ); - } - else - { - $curlOptions = array( - CURLOPT_URL => $this->getUrl($url, $payload), - ); - } - - $curlOptions += array( - CURLOPT_HEADER => false, - CURLOPT_RETURNTRANSFER => true, - CURLOPT_SSL_VERIFYPEER => false, - CURLOPT_USERAGENT => 'WebshopappApiClient/' . self::CLIENT_VERSION . ' (PHP/' . phpversion() . ')', - CURLOPT_SSLVERSION => 6, - ); - - $curlHandle = curl_init(); - - curl_setopt_array($curlHandle, $curlOptions); - - $headers = []; - - curl_setopt($curlHandle, CURLOPT_HEADERFUNCTION, function($curl, $header) use (&$headers) { - $length = strlen($header); - $header = explode(':', $header, 2); - - if (count($header) <= 1) { - return $length; - } - - $header = array_map('trim', $header); - $headers[$header[0]] = $header[1]; - - return $length; - }); - - $responseBody = curl_exec($curlHandle); - - if ($headers) { - $this->setResponseHeaders($headers); - } - - if (curl_errno($curlHandle)) - { - $this->handleCurlError($curlHandle); - } - - $responseBody = json_decode($responseBody, true); - $responseCode = curl_getinfo($curlHandle, CURLINFO_HTTP_CODE); - - curl_close($curlHandle); - - $this->apiCallsMade ++; - - if ($responseCode < 200 || $responseCode > 299 || ($responseBody && array_key_exists('error', $responseBody))) - { - $this->handleResponseError($responseCode, $responseBody); - } - - if ($responseBody && preg_match('/^checkout/i', $url) !== 1) - { - $responseBody = array_shift($responseBody); - } - - return $responseBody; - } - - /** - * @param int $responseCode - * @param array $responseBody - * - * @throws WebshopappApiException - */ - private function handleResponseError($responseCode, $responseBody) - { - $errorMessage = 'Unknown error: ' . $responseCode; - - if ($responseBody && array_key_exists('error', $responseBody)) - { - $errorMessage = $responseBody['error']['message']; - } - - throw new WebshopappApiException($errorMessage, $responseCode); - } - - /** - * @param resource $curlHandle - * - * @throws WebshopappApiException - */ - private function handleCurlError($curlHandle) - { - $errorMessage = 'Curl error: ' . curl_error($curlHandle); - - throw new WebshopappApiException($errorMessage, curl_errno($curlHandle)); - } - - /** - * @param string $url - * @param array $payload - * @param array $options - * - * @return array - * @throws WebshopappApiException - */ - public function create($url, $payload, $options = []) - { - return $this->sendRequest($url, 'post', $payload, $options); - } - - /** - * @param string $url - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function read($url, $params = array()) - { - return $this->sendRequest($url, 'get', $params); - } - - /** - * @param string $url - * @param array $payload - * @param array $options - * - * @return array - * @throws WebshopappApiException - */ - public function update($url, $payload, $options = []) - { - return $this->sendRequest($url, 'put', $payload, $options); - } - - /** - * @param string $url - * - * @return array - * @throws WebshopappApiException - */ - public function delete($url) - { - return $this->sendRequest($url, 'delete'); - } -} - -class WebshopappApiException extends Exception -{ -} - -class WebshopappApiResourceAccount -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @return array - * @throws WebshopappApiException - */ - public function get() - { - return $this->client->read('account'); - } -} - -class WebshopappApiResourceAccountMetafields -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param int $metafieldId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($metafieldId = null, $params = array()) - { - if (!$metafieldId) - { - return $this->client->read('account/metafields', $params); - } - else - { - return $this->client->read('account/metafields/' . $metafieldId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('account/metafields/count', $params); - } -} - -class WebshopappApiResourceAccountPermissions -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @return array - * @throws WebshopappApiException - */ - public function get() - { - return $this->client->read('account/permissions'); - } -} - -class WebshopappApiResourceAccountRatelimit -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @return array - * @throws WebshopappApiException - */ - public function get() - { - return $this->client->read('account/ratelimit'); - } -} - -class WebshopappApiResourceAdditionalcosts -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param int $additionalcostId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($additionalcostId = null, $params = array()) - { - if (!$additionalcostId) - { - return $this->client->read('additionalcosts', $params); - } - else - { - return $this->client->read('additionalcosts/' . $additionalcostId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('additionalcosts/count', $params); - } - - /** - * @param int $additionalcostId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($additionalcostId, $fields) - { - $fields = array('additionalCost' => $fields); - - return $this->client->update('additionalcosts/' . $additionalcostId, $fields); - } - - /** - * @param int $additionalcostId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($additionalcostId) - { - return $this->client->delete('additionalcosts/' . $additionalcostId); - } -} - -class WebshopappApiResourceAttributes -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($fields) - { - $fields = array('attribute' => $fields); - - return $this->client->create('attributes', $fields); - } - - /** - * @param int $attributeId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($attributeId = null, $params = array()) - { - if (!$attributeId) - { - return $this->client->read('attributes', $params); - } - else - { - return $this->client->read('attributes/' . $attributeId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('attributes/count', $params); - } - - /** - * @param int $attributeId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($attributeId, $fields) - { - $fields = array('attribute' => $fields); - - return $this->client->update('attributes/' . $attributeId, $fields); - } - - /** - * @param int $attributeId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($attributeId) - { - return $this->client->delete('attributes/' . $attributeId); - } -} - -class WebshopappApiResourceBlogs -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($fields) - { - $fields = array('blog' => $fields); - - return $this->client->create('blogs', $fields); - } - - /** - * @param int $blogId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($blogId = null, $params = array()) - { - if (!$blogId) - { - return $this->client->read('blogs', $params); - } - else - { - return $this->client->read('blogs/' . $blogId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('blogs/count', $params); - } - - /** - * @param int $blogId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($blogId, $fields) - { - $fields = array('blog' => $fields); - - return $this->client->update('blogs/' . $blogId, $fields); - } - - /** - * @param int $blogId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($blogId) - { - return $this->client->delete('blogs/' . $blogId); - } -} - -class WebshopappApiResourceBlogsArticles -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($fields) - { - $fields = array('blogArticle' => $fields); - - return $this->client->create('blogs/articles', $fields); - } - - /** - * @param int $articleId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($articleId = null, $params = array()) - { - if (!$articleId) - { - return $this->client->read('blogs/articles', $params); - } - else - { - return $this->client->read('blogs/articles/' . $articleId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('blogs/articles/count', $params); - } - - /** - * @param int $articleId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($articleId, $fields) - { - $fields = array('blogArticle' => $fields); - - return $this->client->update('blogs/articles/' . $articleId, $fields); - } - - /** - * @param int $articleId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($articleId) - { - return $this->client->delete('blogs/articles/' . $articleId); - } -} - -class WebshopappApiResourceBlogsArticlesImage -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param int $articleId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($articleId, $fields) - { - if (strpos($fields['attachment'], 'http') === false) { - try { - $attachment = $fields['attachment']; - - new SplFileObject($attachment); - - $mimetype = mime_content_type($attachment); - $fields['attachment'] = new CURLFile($attachment, $mimetype); - - $options = [ - 'header' => 'multipart/form-data' - ]; - - return $this->client->create('blogs/articles/' . $articleId . '/image', $fields, $options); - } catch (RuntimeException $exception) { - // - } - } - - $fields = array('blogArticleImage' => $fields); - - return $this->client->create('blogs/articles/' . $articleId . '/image', $fields); - } - - /** - * @param int $articleId - * - * @return array - * @throws WebshopappApiException - */ - public function get($articleId) - { - return $this->client->read('blogs/articles/' . $articleId . '/image'); - } - - /** - * @param int $articleId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($articleId) - { - return $this->client->delete('blogs/articles/' . $articleId . '/image'); - } -} - -class WebshopappApiResourceBlogsArticlesTags -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($fields) - { - $fields = array('blogArticleTag' => $fields); - - return $this->client->create('blogs/articles/tags', $fields); - } - - /** - * @param int $relationId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($relationId = null, $params = array()) - { - if (!$relationId) - { - return $this->client->read('blogs/articles/tags', $params); - } - else - { - return $this->client->read('blogs/articles/tags/' . $relationId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('blogs/articles/tags/count', $params); - } - - /** - * @param int $relationId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($relationId) - { - return $this->client->delete('blogs/articles/tags/' . $relationId); - } -} - -class WebshopappApiResourceBlogsComments -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($fields) - { - $fields = array('blogComment' => $fields); - - return $this->client->create('blogs/comments', $fields); - } - - /** - * @param int $commentId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($commentId = null, $params = array()) - { - if (!$commentId) - { - return $this->client->read('blogs/comments', $params); - } - else - { - return $this->client->read('blogs/comments/' . $commentId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('blogs/comments/count', $params); - } - - /** - * @param int $commentId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($commentId, $fields) - { - $fields = array('blogComment' => $fields); - - return $this->client->update('blogs/comments/' . $commentId, $fields); - } - - /** - * @param int $commentId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($commentId) - { - return $this->client->delete('blogs/comments/' . $commentId); - } -} - -class WebshopappApiResourceBlogsTags -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($fields) - { - $fields = array('blogTag' => $fields); - - return $this->client->create('blogs/tags', $fields); - } - - /** - * @param int $tagId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($tagId = null, $params = array()) - { - if (!$tagId) - { - return $this->client->read('blogs/tags', $params); - } - else - { - return $this->client->read('blogs/tags/' . $tagId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('blogs/tags/count', $params); - } - - /** - * @param int $tagId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($tagId, $fields) - { - $fields = array('blogTag' => $fields); - - return $this->client->update('blogs/tags/' . $tagId, $fields); - } - - /** - * @param int $tagId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($tagId) - { - return $this->client->delete('blogs/tags/' . $tagId); - } -} - -class WebshopappApiResourceBrands -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($fields) - { - $fields = array('brand' => $fields); - - return $this->client->create('brands', $fields); - } - - /** - * @param int $brandId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($brandId = null, $params = array()) - { - if (!$brandId) - { - return $this->client->read('brands', $params); - } - else - { - return $this->client->read('brands/' . $brandId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('brands/count', $params); - } - - /** - * @param int $brandId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($brandId, $fields) - { - $fields = array('brand' => $fields); - - return $this->client->update('brands/' . $brandId, $fields); - } - - /** - * @param int $brandId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($brandId) - { - return $this->client->delete('brands/' . $brandId); - } -} - -class WebshopappApiResourceBrandsImage -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param int $brandId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($brandId, $fields) - { - if (strpos($fields['attachment'], 'http') === false) { - try { - $attachment = $fields['attachment']; - - new SplFileObject($attachment); - - $mimetype = mime_content_type($attachment); - $fields['attachment'] = new CURLFile($attachment, $mimetype); - - $options = [ - 'header' => 'multipart/form-data' - ]; - - return $this->client->create('brands/' . $brandId . '/image', $fields, $options); - } catch (RuntimeException $exception) { - // - } - } - - $fields = array('brandImage' => $fields); - - return $this->client->create('brands/' . $brandId . '/image', $fields); - } - - /** - * @param int $brandId - * - * @return array - * @throws WebshopappApiException - */ - public function get($brandId) - { - return $this->client->read('brands/' . $brandId . '/image'); - } - - /** - * @param int $brandId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($brandId) - { - return $this->client->delete('brands/' . $brandId . '/image'); - } -} - -class WebshopappApiResourceCatalog -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param int $productId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($productId = null, $params = array()) - { - if (!$productId) - { - return $this->client->read('catalog', $params); - } - else - { - return $this->client->read('catalog/' . $productId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('catalog/count', $params); - } -} - -class WebshopappApiResourceCategories -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($fields) - { - $fields = array('category' => $fields); - - return $this->client->create('categories', $fields); - } - - /** - * @param int $categoryId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($categoryId = null, $params = array()) - { - if (!$categoryId) - { - return $this->client->read('categories', $params); - } - else - { - return $this->client->read('categories/' . $categoryId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('categories/count', $params); - } - - /** - * @param int $categoryId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($categoryId, $fields) - { - $fields = array('category' => $fields); - - return $this->client->update('categories/' . $categoryId, $fields); - } - - /** - * @param int $categoryId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($categoryId) - { - return $this->client->delete('categories/' . $categoryId); - } -} - -class WebshopappApiResourceCategoriesImage -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param int $categoryId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($categoryId, $fields) - { - if (strpos($fields['attachment'], 'http') === false) { - try { - $attachment = $fields['attachment']; - - new SplFileObject($attachment); - - $mimetype = mime_content_type($attachment); - $fields['attachment'] = new CURLFile($attachment, $mimetype); - - $options = [ - 'header' => 'multipart/form-data' - ]; - - return $this->client->create('categories/' . $categoryId . '/image', $fields, $options); - } catch (RuntimeException $exception) { - // - } - } - - $fields = array('categoryImage' => $fields); - - return $this->client->create('categories/' . $categoryId . '/image', $fields); - } - - /** - * @param int $categoryId - * - * @return array - * @throws WebshopappApiException - */ - public function get($categoryId) - { - return $this->client->read('categories/' . $categoryId . '/image'); - } - - /** - * @param int $categoryId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($categoryId) - { - return $this->client->delete('categories/' . $categoryId . '/image'); - } -} - -class WebshopappApiResourceCategoriesProducts -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($fields) - { - $fields = array('categoriesProduct' => $fields); - - return $this->client->create('categories/products', $fields); - } - - /** - * @param int $relationId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($relationId = null, $params = array()) - { - if (!$relationId) - { - return $this->client->read('categories/products', $params); - } - else - { - return $this->client->read('categories/products/' . $relationId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('categories/products/count', $params); - } - - /** - * @param int $relationId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($relationId) - { - return $this->client->delete('categories/products/' . $relationId); - } -} - -class WebshopappApiResourceCategoriesProductsBulk -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($fields) - { - $fields = array('categoriesProduct' => $fields); - - return $this->client->create('categories/products/bulk', $fields); - } -} - -class WebshopappApiResourceCheckouts -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($fields) - { - return $this->client->create('checkouts', $fields); - } - - /** - * @param int $checkoutId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($checkoutId = null, $params = array()) - { - if (!$checkoutId) - { - return $this->client->read('checkouts', $params); - } - else - { - return $this->client->read('checkouts/' . $checkoutId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('checkouts/count', $params); - } - - /** - * @param int $checkoutId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($checkoutId, $fields) - { - return $this->client->update('checkouts/' . $checkoutId, $fields); - } - - /** - * @param int $checkoutId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($checkoutId) - { - return $this->client->delete('checkouts/' . $checkoutId); - } -} - -class WebshopappApiResourceCheckoutsOrder -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param int $checkoutId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($checkoutId, $fields) - { - return $this->client->create('checkouts/' . $checkoutId . '/order', $fields); - } -} - -class WebshopappApiResourceCheckoutsPayment_methods -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param int $checkoutId - * - * @return array - * @throws WebshopappApiException - */ - public function get($checkoutId) - { - return $this->client->read('checkouts/' . $checkoutId . '/payment_methods'); - } -} - -class WebshopappApiResourceCheckoutsProducts -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param int $checkoutId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($checkoutId, $fields) - { - return $this->client->create('checkouts/' . $checkoutId . '/products', $fields); - } - - /** - * @param int $checkoutId - * @param int $productId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($checkoutId, $productId = null, $params = array()) - { - if (!$productId) - { - return $this->client->read('checkouts/' . $checkoutId . '/products', $params); - } - else - { - return $this->client->read('checkouts/' . $checkoutId . '/products/' . $productId, $params); - } - } - - /** - * @param int $checkoutId - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($checkoutId, $params = array()) - { - return $this->client->read('checkouts/' . $checkoutId . '/products/count', $params); - } - - /** - * @param int $checkoutId - * @param int $productId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($checkoutId, $productId, $fields) - { - return $this->client->update('checkouts/' . $checkoutId . '/products/' . $productId, $fields); - } - - /** - * @param int $checkoutId - * @param int $productId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($checkoutId, $productId) - { - return $this->client->delete('checkouts/' . $checkoutId . '/products/' . $productId); - } -} - -class WebshopappApiResourceCheckoutsShipment_methods -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param int $checkoutId - * - * @return array - * @throws WebshopappApiException - */ - public function get($checkoutId) - { - return $this->client->read('checkouts/' . $checkoutId . '/shipment_methods'); - } -} - -class WebshopappApiResourceCheckoutsValidate -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param int $checkoutId - * - * @return array - * @throws WebshopappApiException - */ - public function get($checkoutId) - { - return $this->client->read('checkouts/' . $checkoutId . '/validate'); - } -} - -class WebshopappApiResourceContacts -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param int $contactId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($contactId = null, $params = array()) - { - if (!$contactId) - { - return $this->client->read('contacts', $params); - } - else - { - return $this->client->read('contacts/' . $contactId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('contacts/count', $params); - } -} - -class WebshopappApiResourceCountries -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param int $countryId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($countryId = null, $params = array()) - { - if (!$countryId) - { - return $this->client->read('countries', $params); - } - else - { - return $this->client->read('countries/' . $countryId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('countries/count', $params); - } -} - -class WebshopappApiResourceCustomers -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($fields) - { - $fields = array('customer' => $fields); - - return $this->client->create('customers', $fields); - } - - /** - * @param int $customerId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($customerId = null, $params = array()) - { - if (!$customerId) - { - return $this->client->read('customers', $params); - } - else - { - return $this->client->read('customers/' . $customerId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('customers/count', $params); - } - - /** - * @param int $customerId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($customerId, $fields) - { - $fields = array('customer' => $fields); - - return $this->client->update('customers/' . $customerId, $fields); - } - - /** - * @param int $customerId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($customerId) - { - return $this->client->delete('customers/' . $customerId); - } -} - -class WebshopappApiResourceCustomersLogin -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param int $customerId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($customerId, $fields) - { - $fields = array('customerLogin' => $fields); - - return $this->client->create('customers/' . $customerId . '/login', $fields); - } -} - -class WebshopappApiResourceCustomersMetafields -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param int $customerId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($customerId, $fields) - { - $fields = array('customerMetafield' => $fields); - - return $this->client->create('customers/' . $customerId . '/metafields', $fields); - } - - /** - * @param int $customerId - * @param int $metafieldId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($customerId, $metafieldId = null, $params = array()) - { - if (!$metafieldId) - { - return $this->client->read('customers/' . $customerId . '/metafields', $params); - } - else - { - return $this->client->read('customers/' . $customerId . '/metafields/' . $metafieldId, $params); - } - } - - /** - * @param int $customerId - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($customerId, $params = array()) - { - return $this->client->read('customers/' . $customerId . '/metafields/count', $params); - } - - /** - * @param int $customerId - * @param int $metafieldId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($customerId, $metafieldId, $fields) - { - $fields = array('customerMetafield' => $fields); - - return $this->client->update('customers/' . $customerId . '/metafields/' . $metafieldId, $fields); - } - - /** - * @param int $customerId - * @param int $metafieldId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($customerId, $metafieldId) - { - return $this->client->delete('customers/' . $customerId . '/metafields/' . $metafieldId); - } -} - -class WebshopappApiResourceCustomersTokens -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param int $customerId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($customerId, $fields) - { - $fields = array('customerToken' => $fields); - - return $this->client->create('customers/' . $customerId . '/tokens', $fields); - } -} - -class WebshopappApiResourceDashboard -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($params = array()) - { - return $this->client->read('dashboard', $params); - } -} - -class WebshopappApiResourceDeliverydates -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($fields) - { - $fields = array('deliverydate' => $fields); - - return $this->client->create('deliverydates', $fields); - } - - /** - * @param int $deliverydateId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($deliverydateId = null, $params = array()) - { - if (!$deliverydateId) - { - return $this->client->read('deliverydates', $params); - } - else - { - return $this->client->read('deliverydates/' . $deliverydateId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('deliverydates/count', $params); - } - - /** - * @param int $deliverydateId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($deliverydateId, $fields) - { - $fields = array('deliverydate' => $fields); - - return $this->client->update('deliverydates/' . $deliverydateId, $fields); - } - - /** - * @param int $deliverydateId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($deliverydateId) - { - return $this->client->delete('deliverydates/' . $deliverydateId); - } -} - -class WebshopappApiResourceDiscountrules -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($fields) - { - $fields = array('discountRule' => $fields); - - return $this->client->create('discountrules', $fields); - } - - /** - * @param int $discountruleId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($discountruleId = null, $params = array()) - { - if (!$discountruleId) - { - return $this->client->read('discountrules', $params); - } - else - { - return $this->client->read('discountrules/' . $discountruleId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('discountrules/count', $params); - } - - /** - * @param int $discountruleId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($discountruleId, $fields) - { - $fields = array('discountRule' => $fields); - - return $this->client->update('discountrules/' . $discountruleId, $fields); - } - - /** - * @param int $discountruleId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($discountruleId) - { - return $this->client->delete('discountrules/' . $discountruleId); - } -} - -class WebshopappApiResourceDiscounts -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($fields) - { - $fields = array('discount' => $fields); - - return $this->client->create('discounts', $fields); - } - - /** - * @param int $discountId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($discountId = null, $params = array()) - { - if (!$discountId) - { - return $this->client->read('discounts', $params); - } - else - { - return $this->client->read('discounts/' . $discountId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('discounts/count', $params); - } - - /** - * @param int $discountId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($discountId, $fields) - { - $fields = array('discount' => $fields); - - return $this->client->update('discounts/' . $discountId, $fields); - } - - /** - * @param int $discountId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($discountId) - { - return $this->client->delete('discounts/' . $discountId); - } -} - -class WebshopappApiResourceEvents -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param int $eventId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($eventId = null, $params = array()) - { - if (!$eventId) - { - return $this->client->read('events', $params); - } - else - { - return $this->client->read('events/' . $eventId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('events/count', $params); - } - - /** - * @param int $eventId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($eventId) - { - return $this->client->delete('events/' . $eventId); - } -} - -class WebshopappApiResourceExternal_services -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($fields) - { - $fields = array('externalService' => $fields); - - return $this->client->create('external_services', $fields); - } - - /** - * @param int $externalserviceId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($externalserviceId = null, $params = array()) - { - if (!$externalserviceId) - { - return $this->client->read('external_services', $params); - } - else - { - return $this->client->read('external_services/' . $externalserviceId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('external_services/count', $params); - } - - /** - * @param int $externalserviceId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($externalserviceId) - { - return $this->client->delete('external_services/' . $externalserviceId); - } -} - -class WebshopappApiResourceFiles -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($fields) - { - if (strpos($fields['attachment'], 'http') === false) { - try { - $attachment = $fields['attachment']; - - new SplFileObject($attachment); - - $mimetype = mime_content_type($attachment); - $fields['attachment'] = new CURLFile($attachment, $mimetype); - - $options = [ - 'header' => 'multipart/form-data' - ]; - - return $this->client->create('files', $fields, $options); - } catch (RuntimeException $exception) { - // - } - } - - $fields = array('file' => $fields); - - return $this->client->create('files', $fields); - } - - /** - * @param int $fileId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($fileId = null, $params = array()) - { - if (!$fileId) - { - return $this->client->read('files', $params); - } - else - { - return $this->client->read('files/' . $fileId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('files/count', $params); - } - - /** - * @param int $fileId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($fileId, $fields) - { - $fields = array('file' => $fields); - - return $this->client->update('files/' . $fileId, $fields); - } - - /** - * @param int $fileId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($fileId) - { - return $this->client->delete('files/' . $fileId); - } -} - -class WebshopappApiResourceFilters -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($fields) - { - $fields = array('filter' => $fields); - - return $this->client->create('filters', $fields); - } - - /** - * @param int $filterId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($filterId = null, $params = array()) - { - if (!$filterId) - { - return $this->client->read('filters', $params); - } - else - { - return $this->client->read('filters/' . $filterId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('filters/count', $params); - } - - /** - * @param int $filterId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($filterId, $fields) - { - $fields = array('filter' => $fields); - - return $this->client->update('filters/' . $filterId, $fields); - } - - /** - * @param int $filterId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($filterId) - { - return $this->client->delete('filters/' . $filterId); - } -} - -class WebshopappApiResourceFiltersValues -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param int $filterId - * @param int $filterValueId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($filterId, $filterValueId = null, $params = array()) - { - if (!$filterValueId) - { - return $this->client->read('filters/' . $filterId . '/values', $params); - } - else - { - return $this->client->read('filters/' . $filterId . '/values/' . $filterValueId, $params); - } - } - - /** - * @param int $filterId - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($filterId, $params = array()) - { - return $this->client->read('filters/' . $filterId . '/values/count', $params); - } - - /** - * @param int $filterId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($filterId, $fields) - { - $fields = array('filterValue' => $fields); - - return $this->client->create('filters/' . $filterId . '/values', $fields); - } - - /** - * @param int $filterId - * @param int $filterValueId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($filterId, $filterValueId, $fields) - { - $fields = array('filterValue' => $fields); - - return $this->client->update('filters/' . $filterId . '/values/' . $filterValueId, $fields); - } - - /** - * @param int $filterId - * @param int $filterValueId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($filterId, $filterValueId) - { - return $this->client->delete('filters/' . $filterId . '/values/' . $filterValueId); - } -} - -class WebshopappApiResourceGroups -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($fields) - { - $fields = array('group' => $fields); - - return $this->client->create('groups', $fields); - } - - /** - * @param int $groupId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($groupId = null, $params = array()) - { - if (!$groupId) - { - return $this->client->read('groups', $params); - } - else - { - return $this->client->read('groups/' . $groupId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('groups/count', $params); - } - - /** - * @param int $groupId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($groupId, $fields) - { - $fields = array('group' => $fields); - - return $this->client->update('groups/' . $groupId, $fields); - } - - /** - * @param int $groupId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($groupId) - { - return $this->client->delete('groups/' . $groupId); - } -} - -class WebshopappApiResourceGroupsCustomers -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($fields) - { - $fields = array('groupsCustomer' => $fields); - - return $this->client->create('groups/customers', $fields); - } - - /** - * @param int $relationId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($relationId = null, $params = array()) - { - if (!$relationId) - { - return $this->client->read('groups/customers', $params); - } - else - { - return $this->client->read('groups/customers/' . $relationId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('groups/customers/count', $params); - } - - /** - * @param int $relationId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($relationId) - { - return $this->client->delete('groups/customers/' . $relationId); - } -} - -class WebshopappApiResourceInvoices -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param int $invoiceId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($invoiceId = null, $params = array()) - { - if (!$invoiceId) - { - return $this->client->read('invoices', $params); - } - else - { - return $this->client->read('invoices/' . $invoiceId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('invoices/count', $params); - } - - /** - * @param int $invoiceId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($invoiceId, $fields) - { - $fields = array('invoice' => $fields); - - return $this->client->update('invoices/' . $invoiceId, $fields); - } -} - -class WebshopappApiResourceInvoicesItems -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param int $invoiceId - * @param int $itemId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($invoiceId, $itemId = null, $params = array()) - { - if (!$itemId) - { - return $this->client->read('invoices/' . $invoiceId . '/items', $params); - } - else - { - return $this->client->read('invoices/' . $invoiceId . '/items/' . $itemId, $params); - } - } - - /** - * @param int $invoiceId - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($invoiceId, $params = array()) - { - return $this->client->read('invoices/' . $invoiceId . '/items/count', $params); - } -} - -class WebshopappApiResourceInvoicesMetafields -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param int $invoiceId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($invoiceId, $fields) - { - $fields = array('invoiceMetafield' => $fields); - - return $this->client->create('invoices/' . $invoiceId . '/metafields', $fields); - } - - /** - * @param int $invoiceId - * @param int $metafieldId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($invoiceId, $metafieldId = null, $params = array()) - { - if (!$metafieldId) - { - return $this->client->read('invoices/' . $invoiceId . '/metafields', $params); - } - else - { - return $this->client->read('invoices/' . $invoiceId . '/metafields/' . $metafieldId, $params); - } - } - - /** - * @param int $invoiceId - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($invoiceId, $params = array()) - { - return $this->client->read('invoices/' . $invoiceId . '/metafields/count', $params); - } - - /** - * @param int $invoiceId - * @param int $metafieldId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($invoiceId, $metafieldId, $fields) - { - $fields = array('invoiceMetafield' => $fields); - - return $this->client->update('invoices/' . $invoiceId . '/metafields/' . $metafieldId, $fields); - } - - /** - * @param int $invoiceId - * @param int $metafieldId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($invoiceId, $metafieldId) - { - return $this->client->delete('invoices/' . $invoiceId . '/metafields/' . $metafieldId); - } -} - -class WebshopappApiResourceLanguages -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param int $languageId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($languageId = null, $params = array()) - { - if (!$languageId) - { - return $this->client->read('languages', $params); - } - else - { - return $this->client->read('languages/' . $languageId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('languages/count', $params); - } -} - -class WebshopappApiResourceLocations -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param int $locationId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($locationId = null, $params = array()) - { - if (!$locationId) - { - return $this->client->read('locations', $params); - } - else - { - return $this->client->read('locations/' . $locationId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('locations/count', $params); - } - - /** - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($fields) - { - $fields = array('locations' => $fields); - - return $this->client->create('locations', $fields); - } - - /** - * @param int $locationId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($locationId, $fields) - { - $fields = array('location' => $fields); - - return $this->client->update('locations/' . $locationId, $fields); - } - - /** - * @param int $locationId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($locationId) - { - return $this->client->delete('locations/' . $locationId); - } -} - -class WebshopappApiResourceMetafields -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($fields) - { - $fields = array('metafield' => $fields); - - return $this->client->create('metafields', $fields); - } - - /** - * @param int $metafieldId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($metafieldId = null, $params = array()) - { - if (!$metafieldId) - { - return $this->client->read('metafields', $params); - } - else - { - return $this->client->read('metafields/' . $metafieldId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('metafields/count', $params); - } - - /** - * @param int $metafieldId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($metafieldId, $fields) - { - $fields = array('metafield' => $fields); - - return $this->client->update('metafields/' . $metafieldId, $fields); - } - - /** - * @param int $metafieldId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($metafieldId) - { - return $this->client->delete('metafields/' . $metafieldId); - } -} - -class WebshopappApiResourceOrders -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param int $orderId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($orderId = null, $params = array()) - { - if (!$orderId) - { - return $this->client->read('orders', $params); - } - else - { - return $this->client->read('orders/' . $orderId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('orders/count', $params); - } - - /** - * @param int $orderId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($orderId, $fields) - { - $fields = array('order' => $fields); - - return $this->client->update('orders/' . $orderId, $fields); - } -} - -class WebshopappApiResourceOrdersCredit -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param int $orderId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($orderId, $fields) - { - $fields = array('credit' => $fields); - - return $this->client->create('orders/' . $orderId . '/credit', $fields); - } -} - -class WebshopappApiResourceOrdersMetafields -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param int $orderId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($orderId, $fields) - { - $fields = array('orderMetafield' => $fields); - - return $this->client->create('orders/' . $orderId . '/metafields', $fields); - } - - /** - * @param int $orderId - * @param int $metafieldId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($orderId, $metafieldId = null, $params = array()) - { - if (!$metafieldId) - { - return $this->client->read('orders/' . $orderId . '/metafields', $params); - } - else - { - return $this->client->read('orders/' . $orderId . '/metafields/' . $metafieldId, $params); - } - } - - /** - * @param int $orderId - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($orderId, $params = array()) - { - return $this->client->read('orders/' . $orderId . '/metafields/count', $params); - } - - /** - * @param int $orderId - * @param int $metafieldId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($orderId, $metafieldId, $fields) - { - $fields = array('orderMetafield' => $fields); - - return $this->client->update('orders/' . $orderId . '/metafields/' . $metafieldId, $fields); - } - - /** - * @param int $orderId - * @param int $metafieldId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($orderId, $metafieldId) - { - return $this->client->delete('orders/' . $orderId . '/metafields/' . $metafieldId); - } -} - -class WebshopappApiResourceOrdersProducts -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param int $orderId - * @param int $productId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($orderId, $productId = null, $params = array()) - { - if (!$productId) - { - return $this->client->read('orders/' . $orderId . '/products', $params); - } - else - { - return $this->client->read('orders/' . $orderId . '/products/' . $productId, $params); - } - } - - /** - * @param int $orderId - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($orderId, $params = array()) - { - return $this->client->read('orders/' . $orderId . '/products/count', $params); - } -} - -class WebshopappApiResourceOrdersCustomstatuses -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($fields) - { - $fields = array('customStatus' => $fields); - - return $this->client->create('orders/customstatuses', $fields); - } - - /** - * @param int $customstatusId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($customstatusId = null, $params = array()) - { - if (!$customstatusId) - { - return $this->client->read('orders/customstatuses', $params); - } - else - { - return $this->client->read('orders/customstatuses/' . $customstatusId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('orders/customstatuses/count', $params); - } - - /** - * @param int $customstatusId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($customstatusId, $fields) - { - $fields = array('customStatus' => $fields); - - return $this->client->update('orders/customstatuses/' . $customstatusId, $fields); - } - - /** - * @param int $customstatusId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($customstatusId) - { - return $this->client->delete('orders/customstatuses/' . $customstatusId); - } -} - -class WebshopappApiResourceOrdersEvents -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param int $eventId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($eventId = null, $params = array()) - { - if (!$eventId) - { - return $this->client->read('orders/events', $params); - } - else - { - return $this->client->read('orders/events/' . $eventId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('orders/events/count', $params); - } -} - -class WebshopappApiResourcePaymentmethods -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param int $paymentmethodId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($paymentmethodId = null, $params = array()) - { - if (!$paymentmethodId) - { - return $this->client->read('paymentmethods', $params); - } - else - { - return $this->client->read('paymentmethods/' . $paymentmethodId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('paymentmethods/count', $params); - } -} - -class WebshopappApiResourceProducts -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($fields) - { - $fields = array('product' => $fields); - - return $this->client->create('products', $fields); - } - - /** - * @param int $productId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($productId = null, $params = array()) - { - if (!$productId) - { - return $this->client->read('products', $params); - } - else - { - return $this->client->read('products/' . $productId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('products/count', $params); - } - - /** - * @param int $productId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($productId, $fields) - { - $fields = array('product' => $fields); - - return $this->client->update('products/' . $productId, $fields); - } - - /** - * @param int $productId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($productId) - { - return $this->client->delete('products/' . $productId); - } -} - -class WebshopappApiResourceProductsAttributes -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param int $productId - * @param int $attributeId Set to null for bulk update. - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($productId, $attributeId, $fields) - { - if (!$attributeId) - { - $fields = array('productAttributes' => $fields); - - return $this->client->update('products/' . $productId . '/attributes', $fields); - } - else - { - $fields = array('productAttribute' => $fields); - - return $this->client->update('products/' . $productId . '/attributes/' . $attributeId, $fields); - } - } - - /** - * @param int $productId - * @param int $attributeId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($productId, $attributeId = null, $params = array()) - { - if (!$attributeId) - { - return $this->client->read('products/' . $productId . '/attributes', $params); - } - else - { - return $this->client->read('products/' . $productId . '/attributes/' . $attributeId, $params); - } - } - - /** - * @param int $productId - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($productId, $params = array()) - { - return $this->client->read('products/' . $productId . '/attributes/count', $params); - } - - /** - * @param int $productId - * @param int $attributeId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($productId, $attributeId) - { - return $this->client->delete('products/' . $productId . '/attributes/' . $attributeId); - } -} - -class WebshopappApiResourceProductsFiltervalues -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param int $productId - * - * @return array - * @throws WebshopappApiException - */ - public function get($productId) - { - return $this->client->read('products/' . $productId . '/filtervalues'); - } - - /** - * @param int $productId - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($productId, $params = array()) - { - return $this->client->read('products/' . $productId . '/filtervalues/count', $params); - } - - /** - * @param int $productId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($productId, $fields) - { - $fields = array('productFiltervalue' => $fields); - - return $this->client->create('products/' . $productId . '/filtervalues', $fields); - } - - /** - * @param int $productId - * @param int $filterValueId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($productId, $filterValueId) - { - return $this->client->delete('products/' . $productId . '/filtervalues/' . $filterValueId); - } -} - -class WebshopappApiResourceProductsImages -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param int $productId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($productId, $fields) - { - if (strpos($fields['attachment'], 'http') === false) { - try { - $attachment = $fields['attachment']; - - new SplFileObject($attachment); - - $mimetype = mime_content_type($attachment); - $fields['attachment'] = new CURLFile($attachment, $mimetype); - - $options = [ - 'header' => 'multipart/form-data' - ]; - - return $this->client->create('products/' . $productId . '/images', $fields, $options); - } catch (RuntimeException $exception) { - // - } - } - - $fields = array('productImage' => $fields); - - return $this->client->create('products/' . $productId . '/images', $fields); - } - - /** - * @param int $productId - * @param int $imageId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($productId, $imageId = null, $params = array()) - { - if (!$imageId) - { - return $this->client->read('products/' . $productId . '/images', $params); - } - else - { - return $this->client->read('products/' . $productId . '/images/' . $imageId, $params); - } - } - - /** - * @param int $productId - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($productId, $params = array()) - { - return $this->client->read('products/' . $productId . '/images/count', $params); - } - - /** - * @param int $productId - * @param int $imageId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($productId, $imageId, $fields) - { - $fields = array('productImage' => $fields); - - return $this->client->update('products/' . $productId . '/images/' . $imageId, $fields); - } - - /** - * @param int $productId - * @param int $imageId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($productId, $imageId) - { - return $this->client->delete('products/' . $productId . '/images/' . $imageId); - } -} - -class WebshopappApiResourceProductsMetafields -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param int $productId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($productId, $fields) - { - $fields = array('productMetafield' => $fields); - - return $this->client->create('products/' . $productId . '/metafields', $fields); - } - - /** - * @param int $productId - * @param int $metafieldId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($productId, $metafieldId = null, $params = array()) - { - if (!$metafieldId) - { - return $this->client->read('products/' . $productId . '/metafields', $params); - } - else - { - return $this->client->read('products/' . $productId . '/metafields/' . $metafieldId, $params); - } - } - - /** - * @param int $productId - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($productId, $params = array()) - { - return $this->client->read('products/' . $productId . '/metafields/count', $params); - } - - /** - * @param int $productId - * @param int $metafieldId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($productId, $metafieldId, $fields) - { - $fields = array('productMetafield' => $fields); - - return $this->client->update('products/' . $productId . '/metafields/' . $metafieldId, $fields); - } - - /** - * @param int $productId - * @param int $metafieldId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($productId, $metafieldId) - { - return $this->client->delete('products/' . $productId . '/metafields/' . $metafieldId); - } -} - -class WebshopappApiResourceProductsRelations -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param int $productId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($productId, $fields) - { - $fields = array('productRelation' => $fields); - - return $this->client->create('products/' . $productId . '/relations', $fields); - } - - /** - * @param int $productId - * @param int $relationId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($productId, $relationId = null, $params = array()) - { - if (!$relationId) - { - return $this->client->read('products/' . $productId . '/relations', $params); - } - else - { - return $this->client->read('products/' . $productId . '/relations/' . $relationId, $params); - } - } - - /** - * @param int $productId - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($productId, $params = array()) - { - return $this->client->read('products/' . $productId . '/relations/count', $params); - } - - /** - * @param int $productId - * @param int $relationId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($productId, $relationId, $fields) - { - $fields = array('productRelation' => $fields); - - return $this->client->update('products/' . $productId . '/relations/' . $relationId, $fields); - } - - /** - * @param int $productId - * @param int $relationId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($productId, $relationId) - { - return $this->client->delete('products/' . $productId . '/relations/' . $relationId); - } -} - -class WebshopappApiResourceQuotes -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($fields) - { - $fields = array('quote' => $fields); - - return $this->client->create('quotes', $fields); - } - - /** - * @param int $quoteId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($quoteId = null, $params = array()) - { - if (!$quoteId) - { - return $this->client->read('quotes', $params); - } - else - { - return $this->client->read('quotes/' . $quoteId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('quotes/count', $params); - } - - /** - * @param int $quoteId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($quoteId, $fields) - { - $fields = array('quote' => $fields); - - return $this->client->update('quotes/' . $quoteId, $fields); - } -} - -class WebshopappApiResourceQuotesConvert -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param int $quoteId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($quoteId, $fields) - { - $fields = array('order' => $fields); - - return $this->client->create('quotes/' . $quoteId . '/convert', $fields); - } -} - -class WebshopappApiResourceQuotesPaymentmethods -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param int $quoteId - * - * @return array - * @throws WebshopappApiException - */ - public function get($quoteId) - { - return $this->client->read('quotes/' . $quoteId . '/paymentmethods'); - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('quotes/' . $quoteId . '/paymentmethods/count', $params); - } -} - -class WebshopappApiResourceQuotesProducts -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param int $quoteId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($quoteId, $fields) - { - $fields = array('quoteProduct' => $fields); - - return $this->client->create('quotes/' . $quoteId . '/products', $fields); - } - - /** - * @param int $quoteId - * @param int $productId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($quoteId, $productId = null, $params = array()) - { - if (!$productId) - { - return $this->client->read('quotes/' . $quoteId . '/products', $params); - } - else - { - return $this->client->read('quotes/' . $quoteId . '/products/' . $productId, $params); - } - } - - /** - * @param int $quoteId - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($quoteId, $params = array()) - { - return $this->client->read('quotes/' . $quoteId . '/products/count', $params); - } - - /** - * @param int $quoteId - * @param int $productId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($quoteId, $productId, $fields) - { - $fields = array('quoteProduct' => $fields); - - return $this->client->update('quotes/' . $quoteId . '/products/' . $productId, $fields); - } - - /** - * @param int $quoteId - * @param int $productId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($quoteId, $productId) - { - return $this->client->delete('quotes/' . $quoteId . '/products/' . $productId); - } -} - -class WebshopappApiResourceQuotesShippingmethods -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param int $quoteId - * - * @return array - * @throws WebshopappApiException - */ - public function get($quoteId) - { - return $this->client->read('quotes/' . $quoteId . '/shippingmethods'); - } - - /** - * @param int $quoteId - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($quoteId, $params = array()) - { - return $this->client->read('quotes/' . $quoteId . '/shippingmethods/count', $params); - } -} - -class WebshopappApiResourceRedirects -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($fields) - { - $fields = array('redirect' => $fields); - - return $this->client->create('redirects', $fields); - } - - /** - * @param int $redirectId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($redirectId = null, $params = array()) - { - if (!$redirectId) - { - return $this->client->read('redirects', $params); - } - else - { - return $this->client->read('redirects/' . $redirectId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('redirects/count', $params); - } - - /** - * @param int $redirectId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($redirectId, $fields) - { - $fields = array('redirect' => $fields); - - return $this->client->update('redirects/' . $redirectId, $fields); - } - - /** - * @param int $redirectId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($redirectId) - { - return $this->client->delete('redirects/' . $redirectId); - } -} - -class WebshopappApiResourceReturns -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param int $returnId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($returnId = null, $params = array()) - { - if (!$returnId) - { - return $this->client->read('returns', $params); - } - else - { - return $this->client->read('returns/' . $returnId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('returns/count', $params); - } - - /** - * @param int $returnId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($returnId, $fields) - { - $fields = array('return' => $fields); - - return $this->client->update('returns/' . $returnId, $fields); - } - - /** - * @param int $returnId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($returnId) - { - return $this->client->delete('returns/' . $returnId); - } -} - -class WebshopappApiResourceReviews -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($fields) - { - $fields = array('review' => $fields); - - return $this->client->create('reviews', $fields); - } - - /** - * @param int $reviewId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($reviewId = null, $params = array()) - { - if (!$reviewId) - { - return $this->client->read('reviews', $params); - } - else - { - return $this->client->read('reviews/' . $reviewId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('reviews/count', $params); - } - - /** - * @param int $reviewId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($reviewId, $fields) - { - $fields = array('review' => $fields); - - return $this->client->update('reviews/' . $reviewId, $fields); - } - - /** - * @param int $reviewId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($reviewId) - { - return $this->client->delete('reviews/' . $reviewId); - } -} - -class WebshopappApiResourceSets -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($fields) - { - $fields = array('set' => $fields); - - return $this->client->create('sets', $fields); - } - - /** - * @param int $setId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($setId = null, $params = array()) - { - if (!$setId) - { - return $this->client->read('sets', $params); - } - else - { - return $this->client->read('sets/' . $setId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('sets/count', $params); - } - - /** - * @param int $setId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($setId, $fields) - { - $fields = array('set' => $fields); - - return $this->client->update('sets/' . $setId, $fields); - } - - /** - * @param int $setId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($setId) - { - return $this->client->delete('sets/' . $setId); - } -} - -class WebshopappApiResourceShipments -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param int $shipmentId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($shipmentId = null, $params = array()) - { - if (!$shipmentId) - { - return $this->client->read('shipments', $params); - } - else - { - return $this->client->read('shipments/' . $shipmentId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('shipments/count', $params); - } - - /** - * @param int $shipmentId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($shipmentId, $fields) - { - $fields = array('shipment' => $fields); - - return $this->client->update('shipments/' . $shipmentId, $fields); - } -} - -class WebshopappApiResourceShipmentsMetafields -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param int $shipmentId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($shipmentId, $fields) - { - $fields = array('shipmentMetafield' => $fields); - - return $this->client->create('shipments/' . $shipmentId . '/metafields', $fields); - } - - /** - * @param int $shipmentId - * @param int $metafieldId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($shipmentId, $metafieldId = null, $params = array()) - { - if (!$metafieldId) - { - return $this->client->read('shipments/' . $shipmentId . '/metafields', $params); - } - else - { - return $this->client->read('shipments/' . $shipmentId . '/metafields/' . $metafieldId, $params); - } - } - - /** - * @param int $shipmentId - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($shipmentId, $params = array()) - { - return $this->client->read('shipments/' . $shipmentId . '/metafields/count', $params); - } - - /** - * @param int $shipmentId - * @param int $metafieldId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($shipmentId, $metafieldId, $fields) - { - $fields = array('shipmentMetafield' => $fields); - - return $this->client->update('shipments/' . $shipmentId . '/metafields/' . $metafieldId, $fields); - } - - /** - * @param int $shipmentId - * @param int $metafieldId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($shipmentId, $metafieldId) - { - return $this->client->delete('shipments/' . $shipmentId . '/metafields/' . $metafieldId); - } -} - -class WebshopappApiResourceShipmentsProducts -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param int $shipmentId - * @param int $productId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($shipmentId, $productId = null, $params = array()) - { - if (!$productId) - { - return $this->client->read('shipments/' . $shipmentId . '/products', $params); - } - else - { - return $this->client->read('shipments/' . $shipmentId . '/products/' . $productId, $params); - } - } - - /** - * @param int $shipmentId - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($shipmentId, $params = array()) - { - return $this->client->read('shipments/' . $shipmentId . '/products/count', $params); - } -} - -class WebshopappApiResourceShippingmethods -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param int $shippingmethodId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($shippingmethodId = null, $params = array()) - { - if (!$shippingmethodId) - { - return $this->client->read('shippingmethods', $params); - } - else - { - return $this->client->read('shippingmethods/' . $shippingmethodId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('shippingmethods/count', $params); - } -} - -class WebshopappApiResourceShippingmethodsCountries -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param int $shippingmethodId - * @param int $countryId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($shippingmethodId, $countryId = null, $params = array()) - { - if (!$countryId) - { - return $this->client->read('shippingmethods/' . $shippingmethodId . '/countries', $params); - } - else - { - return $this->client->read('shippingmethods/' . $shippingmethodId . '/countries/' . $countryId, $params); - } - } - - /** - * @param int $shippingmethodId - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($shippingmethodId, $params = array()) - { - return $this->client->read('shippingmethods/' . $shippingmethodId . '/countries/count', $params); - } -} - -class WebshopappApiResourceShippingmethodsValues -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param int $shippingmethodId - * @param int $valueId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($shippingmethodId, $valueId = null, $params = array()) - { - if (!$valueId) - { - return $this->client->read('shippingmethods/' . $shippingmethodId . '/values', $params); - } - else - { - return $this->client->read('shippingmethods/' . $shippingmethodId . '/values/' . $valueId, $params); - } - } - - /** - * @param int $shippingmethodId - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($shippingmethodId, $params = array()) - { - return $this->client->read('shippingmethods/' . $shippingmethodId . '/values/count', $params); - } -} - -class WebshopappApiResourceShop -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @return array - * @throws WebshopappApiException - */ - public function get() - { - return $this->client->read('shop'); - } - - /** - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($fields) - { - $fields = array('shop' => $fields); - - return $this->client->update('shop', $fields); - } -} - -class WebshopappApiResourceShopCompany -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @return array - * @throws WebshopappApiException - */ - public function get() - { - return $this->client->read('shop/company'); - } -} - -class WebshopappApiResourceShopJavascript -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @return array - * @throws WebshopappApiException - */ - public function get() - { - return $this->client->read('shop/javascript'); - } - - /** - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($fields) - { - $fields = array('shopJavascript' => $fields); - - return $this->client->update('shop/javascript', $fields); - } -} - -class WebshopappApiResourceShopLimits -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @return array - * @throws WebshopappApiException - */ - public function get() - { - return $this->client->read('shop/limits'); - } -} - -class WebshopappApiResourceShopMetafields -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($fields) - { - $fields = array('shopMetafield' => $fields); - - return $this->client->create('shop/metafields', $fields); - } - - /** - * @param int $metafieldId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($metafieldId = null, $params = array()) - { - if (!$metafieldId) - { - return $this->client->read('shop/metafields', $params); - } - else - { - return $this->client->read('shop/metafields/' . $metafieldId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('shop/metafields/count', $params); - } - - /** - * @param int $metafieldId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($metafieldId, $fields) - { - $fields = array('shopMetafield' => $fields); - - return $this->client->update('shop/metafields/' . $metafieldId, $fields); - } - - /** - * @param int $metafieldId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($metafieldId) - { - return $this->client->delete('shop/metafields/' . $metafieldId); - } -} - -class WebshopappApiResourceShopScripts -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($fields) - { - $fields = array('shopScript' => $fields); - - return $this->client->create('shop/scripts', $fields); - } - - /** - * @param int $scriptId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($scriptId = null, $params = array()) - { - if (!$scriptId) - { - return $this->client->read('shop/scripts', $params); - } - else - { - return $this->client->read('shop/scripts/' . $scriptId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('shop/scripts/count', $params); - } - - /** - * @param int $scriptId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($scriptId, $fields) - { - $fields = array('shopScript' => $fields); - - return $this->client->update('shop/scripts/' . $scriptId, $fields); - } - - /** - * @param int $scriptId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($scriptId) - { - return $this->client->delete('shop/scripts/' . $scriptId); - } -} - -class WebshopappApiResourceShopSettings -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @return array - * @throws WebshopappApiException - */ - public function get() - { - return $this->client->read('shop/settings'); - } -} - -class WebshopappApiResourceShopTracking -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($fields) - { - $fields = array('shopTracking' => $fields); - - return $this->client->create('shop/tracking', $fields); - } - - /** - * @param int $trackingId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($trackingId = null, $params = array()) - { - if (!$trackingId) - { - return $this->client->read('shop/tracking', $params); - } - else - { - return $this->client->read('shop/tracking/' . $trackingId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('shop/tracking/count', $params); - } - - /** - * @param int $trackingId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($trackingId, $fields) - { - $fields = array('shopTracking' => $fields); - - return $this->client->update('shop/tracking/' . $trackingId, $fields); - } - - /** - * @param int $trackingId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($trackingId) - { - return $this->client->delete('shop/tracking/' . $trackingId); - } -} - -class WebshopappApiResourceShopWebsite -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @return array - * @throws WebshopappApiException - */ - public function get() - { - return $this->client->read('shop/website'); - } -} - -class WebshopappApiResourceSubscriptions -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($fields) - { - $fields = array('subscription' => $fields); - - return $this->client->create('subscriptions', $fields); - } - - /** - * @param int $subscriptionId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($subscriptionId = null, $params = array()) - { - if (!$subscriptionId) - { - return $this->client->read('subscriptions', $params); - } - else - { - return $this->client->read('subscriptions/' . $subscriptionId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('subscriptions/count', $params); - } - - /** - * @param int $subscriptionId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($subscriptionId, $fields) - { - $fields = array('subscription' => $fields); - - return $this->client->update('subscriptions/' . $subscriptionId, $fields); - } - - /** - * @param int $subscriptionId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($subscriptionId) - { - return $this->client->delete('subscriptions/' . $subscriptionId); - } -} - -class WebshopappApiResourceSuppliers -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($fields) - { - $fields = array('supplier' => $fields); - - return $this->client->create('suppliers', $fields); - } - - /** - * @param int $supplierId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($supplierId = null, $params = array()) - { - if (!$supplierId) - { - return $this->client->read('suppliers', $params); - } - else - { - return $this->client->read('suppliers/' . $supplierId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('suppliers/count', $params); - } - - /** - * @param int $supplierId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($supplierId, $fields) - { - $fields = array('supplier' => $fields); - - return $this->client->update('suppliers/' . $supplierId, $fields); - } - - /** - * @param int $supplierId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($supplierId) - { - return $this->client->delete('suppliers/' . $supplierId); - } -} - -class WebshopappApiResourceTags -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($fields) - { - $fields = array('tag' => $fields); - - return $this->client->create('tags', $fields); - } - - /** - * @param int $tagId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($tagId = null, $params = array()) - { - if (!$tagId) - { - return $this->client->read('tags', $params); - } - else - { - return $this->client->read('tags/' . $tagId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('tags/count', $params); - } - - /** - * @param int $tagId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($tagId, $fields) - { - $fields = array('tag' => $fields); - - return $this->client->update('tags/' . $tagId, $fields); - } - - /** - * @param int $tagId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($tagId) - { - return $this->client->delete('tags/' . $tagId); - } -} - -class WebshopappApiResourceTagsProducts -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($fields) - { - $fields = array('tagsProduct' => $fields); - - return $this->client->create('tags/products', $fields); - } - - /** - * @param int $relationId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($relationId = null, $params = array()) - { - if (!$relationId) - { - return $this->client->read('tags/products', $params); - } - else - { - return $this->client->read('tags/products/' . $relationId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('tags/products/count', $params); - } - - /** - * @param int $relationId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($relationId) - { - return $this->client->delete('tags/products/' . $relationId); - } -} - -class WebshopappApiResourceTaxes -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($fields) - { - $fields = array('tax' => $fields); - - return $this->client->create('taxes', $fields); - } - - /** - * @param int $taxId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($taxId = null, $params = array()) - { - if (!$taxId) - { - return $this->client->read('taxes', $params); - } - else - { - return $this->client->read('taxes/' . $taxId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('taxes/count', $params); - } - - /** - * @param int $taxId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($taxId, $fields) - { - $fields = array('tax' => $fields); - - return $this->client->update('taxes/' . $taxId, $fields); - } - - /** - * @param int $taxId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($taxId) - { - return $this->client->delete('taxes/' . $taxId); - } -} - -class WebshopappApiResourceTaxesOverrides -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param int $taxId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($taxId, $fields) - { - $fields = array('taxOverride' => $fields); - - return $this->client->create('taxes/' . $taxId . '/overrides', $fields); - } - - /** - * @param int $taxId - * @param int $taxOverrideId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($taxId, $taxOverrideId = null, $params = array()) - { - if (!$taxOverrideId) - { - return $this->client->read('taxes/' . $taxId . '/overrides', $params); - } - else - { - return $this->client->read('taxes/' . $taxId . '/overrides/' . $taxOverrideId, $params); - } - } - - /** - * @param int $taxId - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($taxId, $params = array()) - { - return $this->client->read('taxes/' . $taxId . '/overrides/count', $params); - } - - /** - * @param int $taxId - * @param int $taxOverrideId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($taxId, $taxOverrideId, $fields) - { - $fields = array('taxOverride' => $fields); - - return $this->client->update('taxes/' . $taxId . '/overrides/' . $taxOverrideId, $fields); - } - - /** - * @param int $taxId - * @param int $taxOverrideId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($taxId, $taxOverrideId) - { - return $this->client->delete('taxes/' . $taxId . '/overrides/' . $taxOverrideId); - } -} - -class WebshopappApiResourceTextpages -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($fields) - { - $fields = array('textpage' => $fields); - - return $this->client->create('textpages', $fields); - } - - /** - * @param int $textpageId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($textpageId = null, $params = array()) - { - if (!$textpageId) - { - return $this->client->read('textpages', $params); - } - else - { - return $this->client->read('textpages/' . $textpageId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('textpages/count', $params); - } - - /** - * @param int $textpageId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($textpageId, $fields) - { - $fields = array('textpage' => $fields); - - return $this->client->update('textpages/' . $textpageId, $fields); - } - - /** - * @param int $textpageId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($textpageId) - { - return $this->client->delete('textpages/' . $textpageId); - } -} - -class WebshopappApiResourceThemeCategories -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($fields) - { - $fields = array('themeCategory' => $fields); - - return $this->client->create('theme/categories', $fields); - } - - /** - * @param int $categoryId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($categoryId = null, $params = array()) - { - if (!$categoryId) - { - return $this->client->read('theme/categories', $params); - } - else - { - return $this->client->read('theme/categories/' . $categoryId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('theme/categories/count', $params); - } - - /** - * @param int $categoryId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($categoryId, $fields) - { - $fields = array('themeCategory' => $fields); - - return $this->client->update('theme/categories/' . $categoryId, $fields); - } - - /** - * @param int $categoryId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($categoryId) - { - return $this->client->delete('theme/categories/' . $categoryId); - } -} - -class WebshopappApiResourceThemeProducts -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($fields) - { - $fields = array('themeProduct' => $fields); - - return $this->client->create('theme/products', $fields); - } - - /** - * @param int $productId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($productId = null, $params = array()) - { - if (!$productId) - { - return $this->client->read('theme/products', $params); - } - else - { - return $this->client->read('theme/products/' . $productId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('theme/products/count', $params); - } - - /** - * @param int $productId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($productId, $fields) - { - $fields = array('themeProduct' => $fields); - - return $this->client->update('theme/products/' . $productId, $fields); - } - - /** - * @param int $productId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($productId) - { - return $this->client->delete('theme/products/' . $productId); - } -} - -class WebshopappApiResourceTickets -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($fields) - { - $fields = array('ticket' => $fields); - - return $this->client->create('tickets', $fields); - } - - /** - * @param int $ticketId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($ticketId = null, $params = array()) - { - if (!$ticketId) - { - return $this->client->read('tickets', $params); - } - else - { - return $this->client->read('tickets/' . $ticketId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('tickets/count', $params); - } - - /** - * @param int $ticketId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($ticketId, $fields) - { - $fields = array('ticket' => $fields); - - return $this->client->update('tickets/' . $ticketId, $fields); - } - - /** - * @param int $ticketId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($ticketId) - { - return $this->client->delete('tickets/' . $ticketId); - } -} - -class WebshopappApiResourceTicketsMessages -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param int $ticketId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($ticketId, $fields) - { - $fields = array('ticketMessage' => $fields); - - return $this->client->create('tickets/' . $ticketId . '/messages', $fields); - } - - /** - * @param int $ticketId - * @param int $messageId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($ticketId, $messageId = null, $params = array()) - { - if (!$messageId) - { - return $this->client->read('tickets/' . $ticketId . '/messages', $params); - } - else - { - return $this->client->read('tickets/' . $ticketId . '/messages/' . $messageId, $params); - } - } - - /** - * @param int $ticketId - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($ticketId, $params = array()) - { - return $this->client->read('tickets/' . $ticketId . '/messages/count', $params); - } - - /** - * @param int $ticketId - * @param int $messageId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($ticketId, $messageId, $fields) - { - $fields = array('ticketMessage' => $fields); - - return $this->client->update('tickets/' . $ticketId . '/messages/' . $messageId, $fields); - } - - /** - * @param int $ticketId - * @param int $messageId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($ticketId, $messageId) - { - return $this->client->delete('tickets/' . $ticketId . '/messages/' . $messageId); - } -} - -class WebshopappApiResourceTime -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @return array - * @throws WebshopappApiException - */ - public function get() - { - return $this->client->read('time'); - } -} - -class WebshopappApiResourceTypes -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($fields) - { - $fields = array('type' => $fields); - - return $this->client->create('types', $fields); - } - - /** - * @param int $typeId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($typeId = null, $params = array()) - { - if (!$typeId) - { - return $this->client->read('types', $params); - } - else - { - return $this->client->read('types/' . $typeId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('types/count', $params); - } - - /** - * @param int $typeId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($typeId, $fields) - { - $fields = array('type' => $fields); - - return $this->client->update('types/' . $typeId, $fields); - } - - /** - * @param int $typeId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($typeId) - { - return $this->client->delete('types/' . $typeId); - } -} - -class WebshopappApiResourceTypesAttributes -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($fields) - { - $fields = array('typesAttribute' => $fields); - - return $this->client->create('types/attributes', $fields); - } - - /** - * @param int $relationId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($relationId = null, $params = array()) - { - if (!$relationId) - { - return $this->client->read('types/attributes', $params); - } - else - { - return $this->client->read('types/attributes/' . $relationId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('types/attributes/count', $params); - } - - /** - * @param int $relationId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($relationId) - { - return $this->client->delete('types/attributes/' . $relationId); - } -} - -class WebshopappApiResourceVariants -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($fields) - { - $fields = array('variant' => $fields); - - return $this->client->create('variants', $fields); - } - - /** - * @param int $variantId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($variantId = null, $params = array()) - { - if (!$variantId) - { - return $this->client->read('variants', $params); - } - else - { - return $this->client->read('variants/' . $variantId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('variants/count', $params); - } - - /** - * @param int $variantId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($variantId, $fields) - { - $fields = array('variant' => $fields); - - return $this->client->update('variants/' . $variantId, $fields); - } - - /** - * @param int $variantId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($variantId) - { - return $this->client->delete('variants/' . $variantId); - } -} - -class WebshopappApiResourceVariantsImage -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param int $variantId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($variantId, $fields) - { - $fields = array('variantImage' => $fields); - - return $this->client->create('variants/' . $variantId . '/image', $fields); - } - - /** - * @param int $variantId - * - * @return array - * @throws WebshopappApiException - */ - public function get($variantId) - { - return $this->client->read('variants/' . $variantId . '/image'); - } - - /** - * @param int $variantId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($variantId) - { - return $this->client->delete('variants/' . $variantId . '/image'); - } -} - -class WebshopappApiResourceVariantsMetafields -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param int $variantId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($variantId, $fields) - { - $fields = array('variantMetafield' => $fields); - - return $this->client->create('variants/' . $variantId . '/metafields', $fields); - } - - /** - * @param int $variantId - * @param int $metafieldId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($variantId, $metafieldId = null, $params = array()) - { - if (!$metafieldId) - { - return $this->client->read('variants/' . $variantId . '/metafields', $params); - } - else - { - return $this->client->read('variants/' . $variantId . '/metafields/' . $metafieldId, $params); - } - } - - /** - * @param int $variantId - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($variantId, $params = array()) - { - return $this->client->read('variants/' . $variantId . '/metafields/count', $params); - } - - /** - * @param int $variantId - * @param int $metafieldId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($variantId, $metafieldId, $fields) - { - $fields = array('variantMetafield' => $fields); - - return $this->client->update('variants/' . $variantId . '/metafields/' . $metafieldId, $fields); - } - - /** - * @param int $variantId - * @param int $metafieldId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($variantId, $metafieldId) - { - return $this->client->delete('variants/' . $variantId . '/metafields/' . $metafieldId); - } -} - -class WebshopappApiResourceVariantsBulk -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($fields) - { - $fields = array('variant' => $fields); - - return $this->client->update('variants/bulk', $fields); - } -} - -class WebshopappApiResourceVariantsMovements -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param int $movementId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($movementId = null, $params = array()) - { - if (!$movementId) - { - return $this->client->read('variants/movements', $params); - } - else - { - return $this->client->read('variants/movements/' . $movementId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('variants/movements/count', $params); - } -} - -class WebshopappApiResourceWebhooks -{ - /** - * @var WebshopappApiClient - */ - private $client; - - public function __construct(WebshopappApiClient $client) - { - $this->client = $client; - } - - /** - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function create($fields) - { - $fields = array('webhook' => $fields); - - return $this->client->create('webhooks', $fields); - } - - /** - * @param int $webhookId - * @param array $params - * - * @return array - * @throws WebshopappApiException - */ - public function get($webhookId = null, $params = array()) - { - if (!$webhookId) - { - return $this->client->read('webhooks', $params); - } - else - { - return $this->client->read('webhooks/' . $webhookId, $params); - } - } - - /** - * @param array $params - * - * @return int - * @throws WebshopappApiException - */ - public function count($params = array()) - { - return $this->client->read('webhooks/count', $params); - } - - /** - * @param int $webhookId - * @param array $fields - * - * @return array - * @throws WebshopappApiException - */ - public function update($webhookId, $fields) - { - $fields = array('webhook' => $fields); - - return $this->client->update('webhooks/' . $webhookId, $fields); - } - - /** - * @param int $webhookId - * - * @return array - * @throws WebshopappApiException - */ - public function delete($webhookId) - { - return $this->client->delete('webhooks/' . $webhookId); - } -} From f3ec64bc21685ae37a5ea9adda519819bfab3174 Mon Sep 17 00:00:00 2001 From: Falko Woudstra Date: Thu, 5 May 2022 20:16:21 +0200 Subject: [PATCH 2/3] Small fixes --- README.md | 4 ++-- src/ApiClient.php | 2 +- src/ApiException.php | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 69649c7..795abe2 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ git clone https://github.com/SEOshop/API-PHP-Client And include the class in your project ``` php -require_once '/path/to/ApiClient.php'; +require_once '/path/to/lightspeed-php-sdk/src/ApiClient.php'; ``` ## Usage @@ -49,7 +49,7 @@ There are a lot of API resources that are accessible through this client. You ca shop->get(); ``` diff --git a/src/ApiClient.php b/src/ApiClient.php index a5a2b07..7ed0ac9 100755 --- a/src/ApiClient.php +++ b/src/ApiClient.php @@ -3,7 +3,7 @@ namespace Lightspeed; /** - * The Webshopapp Api Client Class + * The Lightspeed Api Client Class */ class ApiClient { diff --git a/src/ApiException.php b/src/ApiException.php index eaf7353..4129280 100644 --- a/src/ApiException.php +++ b/src/ApiException.php @@ -4,4 +4,5 @@ class ApiException extends \Exception { + // } \ No newline at end of file From ba2e4475d0853453d04b3dd1af7ca8b745ac9641 Mon Sep 17 00:00:00 2001 From: Falko Woudstra Date: Thu, 5 May 2022 20:32:09 +0200 Subject: [PATCH 3/3] Fix autoloading --- composer.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 57e442b..e47e0d0 100644 --- a/composer.json +++ b/composer.json @@ -18,6 +18,8 @@ "ext-fileinfo": "*" }, "autoload": { - "files": ["src/*.php"] + "psr-4": { + "Lightspeed\\": "src/" + } } }