<?php
/**
 * ProductApi
 * PHP version 5
 *
 * @category Class
 * @package  ColorMeShop\Swagger
 * @author   Swagger Codegen team
 * @link     https://github.com/swagger-api/swagger-codegen
 */

/**
 * カラーミーショップ API
 *
 * # カラーミーショップ API  ## 利用手順  ### OAuthアプリケーションの登録  デベロッパーアカウントをお持ちでない場合は作成します。[デベロッパー登録ページ](https://api.shop-pro.jp/developers/sign_up)から登録してください。  次に、[登録ページ](https://api.shop-pro.jp/oauth/applications/new)からアプリ登録を行ってください。 スマートフォンのWebViewを利用する場合は、リダイレクトURIに`urn:ietf:wg:oauth:2.0:oob`を入力してください。  ### 認可  カラーミーショップアカウントの認証ページを開きます。認証ページのURLは、`https://api.shop-pro.jp/oauth/authorize`に必要なパラメータをつけたものです。  |パラメータ名|値| |---|---| |`client_id`|アプリ詳細画面で確認できるクライアントID| |`response_type`|\"code\"を指定| |`scope`| 別表参照| |`redirect_uri`|アプリ登録時に入力したリダイレクトURI|  `scope`は、以下のうち、アプリが利用したい機能をスペース区切りで指定してください。  |スコープ|機能| |---|---| |`read_products`|商品データの参照| |`write_products`|在庫データの更新| |`read_sales`|受注・顧客データの参照| |`write_sales`|受注データの更新| |`read_shop_coupons`|ショップクーポンの参照|  以下のようなURLとなります。  ``` https://api.shop-pro.jp/oauth/authorize?client_id=CLIENT_ID&redirect_uri=REDIRECT_URI&response_type=code&scope=read_products%20write_products ```  初めてこのページを訪れる場合は、カラーミーショップアカウントのログインIDとパスワードの入力を求められます。  ログイン後の認証ページでアプリとの連携が承認された場合は、`code`というクエリパラメータに認可コードが付与されます。承認がキャンセルされた、またはエラーが起きた場合は、 `error`パラメータにエラーの内容を表す文字列が与えられます。  アプリ登録時のリダイレクトURIに`urn:ietf:wg:oauth:2.0:oob`を指定した場合は、以下のようなURLにリダイレクトされ、 認可コードがURLの末尾に付与されます。  ``` https://api.shop-pro.jp/oauth/authorize/AUTH_CODE ```  認可コードの有効期限は発行から10分間です。  ### 認可コードをアクセストークンに交換  以下のパラメータを付けて、`https://api.shop-pro.jp/oauth/token`へリクエストを送ります。  |パラメータ名|値| |---|---| |`client_id`|アプリ詳細画面に表示されているクライアントID| |`client_secret`|アプリ詳細画面に表示されているクライアントシークレット| |`code`|取得した認可コード| |`grant_type`|\"authorization_code\"を指定| |`redirect_uri`|アプリ登録時に入力したリダイレクトURI|  curlによるリクエストの例を以下に示します。 ```console $ curl -X POST \\   -d'client_id=CLIENT_ID' \\   -d'client_secret=CLIENT_SECRET' \\   -d'code=CODE' \\   -d'grant_type=authorization_code'   \\   -d'redirect_uri=REDIRECT_URI'  \\   'https://api.shop-pro.jp/oauth/token' ```  リクエストが成功すると、以下のようなJSONが返却されます  ```json {   \"access_token\": \"d461ab8XXXXXXXXXXXXXXXXXXXXXXXXX\",   \"token_type\": \"bearer\",   \"scope\": \"read_products write_products\" } ```  アクセストークンに有効期限はありませんが、[許可済みアプリ一覧画面](https://admin.shop-pro.jp/?mode=app_use_lst)から失効させることができます。なお、同じ認可コードをアクセストークンに交換できるのは1度だけです。  ### APIの利用  取得したアクセストークンは、Authorizationヘッダに入れて使用します。以下にショップ情報を取得する例を示します。  ```console $ curl -H 'Authorization: Bearer d461ab8XXXXXXXXXXXXXXXXXXXXXXXXX' https://api.shop-pro.jp/v1/shop.json ```  ## エラー  カラーミーショップAPIでは、以下の形式の配列でエラーを表現します。  - `code` エラーコード - `message` エラーメッセージ - `status` ステータスコード  ```json {   \"errors\": [     {       \"code\": 404100,       \"message\": \"レコードが見つかりませんでした。\",       \"status\": 404     }   ] } ```  ## 都道府県コードについて APIを利用して都道府県コードを更新したり、レスポンスを参照される際には以下の表を参考にしてください。  <details>   <summary>都道府県コード一覧</summary>    |id|都道府県|   |---|---|   |1|北海道|   |2|青森県|   |3|岩手県|   |4|秋田県|   |5|宮城県|   |6|山形県|   |7|福島県|   |8|茨城県|   |9|栃木県|   |10|群馬県|   |11|埼玉県|   |12|千葉県|   |13|東京都|   |14|神奈川県|   |15|新潟県|   |16|福井県|   |17|石川県|   |18|富山県|   |19|静岡県|   |20|山梨県|   |21|長野県|   |22|愛知県|   |23|岐阜県|   |24|三重県|   |25|和歌山県|   |26|滋賀県|   |27|奈良県|   |28|京都府|   |29|大阪府|   |30|兵庫県|   |31|岡山県|   |32|広島県|   |33|鳥取県|   |34|島根県|   |35|山口県|   |36|香川県|   |37|徳島県|   |38|愛媛県|   |39|高知県|   |40|福岡県|   |41|佐賀県|   |42|長崎県|   |43|大分県|   |44|熊本県|   |45|宮崎県|   |46|鹿児島県|   |47|沖縄県|   |48|海外|  </details>
 *
 * OpenAPI spec version: 1.0.0
 * 
 * Generated by: https://github.com/swagger-api/swagger-codegen.git
 * Swagger Codegen version: 3.0.27
 */
/**
 * NOTE: This class is auto generated by the swagger code generator program.
 * https://github.com/swagger-api/swagger-codegen
 * Do not edit the class manually.
 */

namespace ColorMeShop\Swagger\Api;

use GuzzleHttp\Client;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Psr7\MultipartStream;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\RequestOptions;
use ColorMeShop\Swagger\ApiException;
use ColorMeShop\Swagger\Configuration;
use ColorMeShop\Swagger\HeaderSelector;
use ColorMeShop\Swagger\ObjectSerializer;

/**
 * ProductApi Class Doc Comment
 *
 * @category Class
 * @package  ColorMeShop\Swagger
 * @author   Swagger Codegen team
 * @link     https://github.com/swagger-api/swagger-codegen
 */
class ProductApi
{
    /**
     * @var ClientInterface
     */
    protected $client;

    /**
     * @var Configuration
     */
    protected $config;

    /**
     * @var HeaderSelector
     */
    protected $headerSelector;

    /**
     * @param ClientInterface $client
     * @param Configuration   $config
     * @param HeaderSelector  $selector
     */
    public function __construct(
        ClientInterface $client = null,
        Configuration $config = null,
        HeaderSelector $selector = null
    ) {
        $this->client = $client ?: new Client();
        $this->config = $config ?: new Configuration();
        $this->headerSelector = $selector ?: new HeaderSelector();
    }

    /**
     * @return Configuration
     */
    public function getConfig()
    {
        return $this->config;
    }

    /**
     * Operation deleteProductPickup
     *
     * おすすめ商品情報の削除
     *
     * @param  int $product_id 商品ID (required)
     * @param  int $pickup_type おすすめ商品情報種別（0:おすすめ商品, 1:売れ筋商品, 3:新着商品, 4:イチオシ商品） (required)
     *
     * @throws \ColorMeShop\Swagger\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return \ColorMeShop\Swagger\Model\InlineResponse20011
     */
    public function deleteProductPickup($product_id, $pickup_type)
    {
        list($response) = $this->deleteProductPickupWithHttpInfo($product_id, $pickup_type);
        return $response;
    }

    /**
     * Operation deleteProductPickupWithHttpInfo
     *
     * おすすめ商品情報の削除
     *
     * @param  int $product_id 商品ID (required)
     * @param  int $pickup_type おすすめ商品情報種別（0:おすすめ商品, 1:売れ筋商品, 3:新着商品, 4:イチオシ商品） (required)
     *
     * @throws \ColorMeShop\Swagger\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \ColorMeShop\Swagger\Model\InlineResponse20011, HTTP status code, HTTP response headers (array of strings)
     */
    public function deleteProductPickupWithHttpInfo($product_id, $pickup_type)
    {
        $returnType = '\ColorMeShop\Swagger\Model\InlineResponse20011';
        $request = $this->deleteProductPickupRequest($product_id, $pickup_type);

        try {
            $options = $this->createHttpClientOption();
            try {
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
                );
            }

            $statusCode = $response->getStatusCode();

            if ($statusCode < 200 || $statusCode > 299) {
                throw new ApiException(
                    sprintf(
                        '[%d] Error connecting to the API (%s)',
                        $statusCode,
                        $request->getUri()
                    ),
                    $statusCode,
                    $response->getHeaders(),
                    $response->getBody()
                );
            }

            $responseBody = $response->getBody();
            if ($returnType === '\SplFileObject') {
                $content = $responseBody; //stream goes to serializer
            } else {
                $content = $responseBody->getContents();
                if (!in_array($returnType, ['string','integer','bool'])) {
                    $content = json_decode($content);
                }
            }

            return [
                ObjectSerializer::deserialize($content, $returnType, []),
                $response->getStatusCode(),
                $response->getHeaders()
            ];

        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ColorMeShop\Swagger\Model\InlineResponse20011',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
            }
            throw $e;
        }
    }

    /**
     * Operation deleteProductPickupAsync
     *
     * おすすめ商品情報の削除
     *
     * @param  int $product_id 商品ID (required)
     * @param  int $pickup_type おすすめ商品情報種別（0:おすすめ商品, 1:売れ筋商品, 3:新着商品, 4:イチオシ商品） (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function deleteProductPickupAsync($product_id, $pickup_type)
    {
        return $this->deleteProductPickupAsyncWithHttpInfo($product_id, $pickup_type)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation deleteProductPickupAsyncWithHttpInfo
     *
     * おすすめ商品情報の削除
     *
     * @param  int $product_id 商品ID (required)
     * @param  int $pickup_type おすすめ商品情報種別（0:おすすめ商品, 1:売れ筋商品, 3:新着商品, 4:イチオシ商品） (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function deleteProductPickupAsyncWithHttpInfo($product_id, $pickup_type)
    {
        $returnType = '\ColorMeShop\Swagger\Model\InlineResponse20011';
        $request = $this->deleteProductPickupRequest($product_id, $pickup_type);

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    $responseBody = $response->getBody();
                    if ($returnType === '\SplFileObject') {
                        $content = $responseBody; //stream goes to serializer
                    } else {
                        $content = $responseBody->getContents();
                        if ($returnType !== 'string') {
                            $content = json_decode($content);
                        }
                    }

                    return [
                        ObjectSerializer::deserialize($content, $returnType, []),
                        $response->getStatusCode(),
                        $response->getHeaders()
                    ];
                },
                function ($exception) {
                    $response = $exception->getResponse();
                    $statusCode = $response->getStatusCode();
                    throw new ApiException(
                        sprintf(
                            '[%d] Error connecting to the API (%s)',
                            $statusCode,
                            $exception->getRequest()->getUri()
                        ),
                        $statusCode,
                        $response->getHeaders(),
                        $response->getBody()
                    );
                }
            );
    }

    /**
     * Create request for operation 'deleteProductPickup'
     *
     * @param  int $product_id 商品ID (required)
     * @param  int $pickup_type おすすめ商品情報種別（0:おすすめ商品, 1:売れ筋商品, 3:新着商品, 4:イチオシ商品） (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    protected function deleteProductPickupRequest($product_id, $pickup_type)
    {
        // verify the required parameter 'product_id' is set
        if ($product_id === null || (is_array($product_id) && count($product_id) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $product_id when calling deleteProductPickup'
            );
        }
        // verify the required parameter 'pickup_type' is set
        if ($pickup_type === null || (is_array($pickup_type) && count($pickup_type) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $pickup_type when calling deleteProductPickup'
            );
        }

        $resourcePath = '/v1/products/{product_id}/pickups/{pickup_type}';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;


        // path params
        if ($product_id !== null) {
            $resourcePath = str_replace(
                '{' . 'product_id' . '}',
                ObjectSerializer::toPathValue($product_id),
                $resourcePath
            );
        }
        // path params
        if ($pickup_type !== null) {
            $resourcePath = str_replace(
                '{' . 'pickup_type' . '}',
                ObjectSerializer::toPathValue($pickup_type),
                $resourcePath
            );
        }

        // body params
        $_tempBody = null;

        if ($multipart) {
            $headers = $this->headerSelector->selectHeadersForMultipart(
                ['application/json']
            );
        } else {
            $headers = $this->headerSelector->selectHeaders(
                ['application/json'],
                []
            );
        }

        // for model (json/xml)
        if (isset($_tempBody)) {
            // $_tempBody is the method argument, if present
            $httpBody = $_tempBody;
            // \stdClass has no __toString(), so we should encode it manually
            if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') {
                $httpBody = \GuzzleHttp\json_encode($httpBody);
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $multipartContents[] = [
                        'name' => $formParamName,
                        'contents' => $formParamValue
                    ];
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);

            } elseif ($headers['Content-Type'] === 'application/json') {
                $httpBody = \GuzzleHttp\json_encode($formParams);

            } else {
                // for HTTP post (form)
                $httpBody = \GuzzleHttp\Psr7\build_query($formParams);
            }
        }

        // this endpoint requires OAuth (access token)
        if ($this->config->getAccessToken() !== null) {
            $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
        }

        $defaultHeaders = [];
        if ($this->config->getUserAgent()) {
            $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
        }

        $headers = array_merge(
            $defaultHeaders,
            $headerParams,
            $headers
        );

        $query = \GuzzleHttp\Psr7\build_query($queryParams);
        return new Request(
            'DELETE',
            $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation getProduct
     *
     * 商品データの取得
     *
     * @param  int $product_id 商品ID (required)
     *
     * @throws \ColorMeShop\Swagger\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return \ColorMeShop\Swagger\Model\InlineResponse2009
     */
    public function getProduct($product_id)
    {
        list($response) = $this->getProductWithHttpInfo($product_id);
        return $response;
    }

    /**
     * Operation getProductWithHttpInfo
     *
     * 商品データの取得
     *
     * @param  int $product_id 商品ID (required)
     *
     * @throws \ColorMeShop\Swagger\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \ColorMeShop\Swagger\Model\InlineResponse2009, HTTP status code, HTTP response headers (array of strings)
     */
    public function getProductWithHttpInfo($product_id)
    {
        $returnType = '\ColorMeShop\Swagger\Model\InlineResponse2009';
        $request = $this->getProductRequest($product_id);

        try {
            $options = $this->createHttpClientOption();
            try {
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
                );
            }

            $statusCode = $response->getStatusCode();

            if ($statusCode < 200 || $statusCode > 299) {
                throw new ApiException(
                    sprintf(
                        '[%d] Error connecting to the API (%s)',
                        $statusCode,
                        $request->getUri()
                    ),
                    $statusCode,
                    $response->getHeaders(),
                    $response->getBody()
                );
            }

            $responseBody = $response->getBody();
            if ($returnType === '\SplFileObject') {
                $content = $responseBody; //stream goes to serializer
            } else {
                $content = $responseBody->getContents();
                if (!in_array($returnType, ['string','integer','bool'])) {
                    $content = json_decode($content);
                }
            }

            return [
                ObjectSerializer::deserialize($content, $returnType, []),
                $response->getStatusCode(),
                $response->getHeaders()
            ];

        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ColorMeShop\Swagger\Model\InlineResponse2009',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
            }
            throw $e;
        }
    }

    /**
     * Operation getProductAsync
     *
     * 商品データの取得
     *
     * @param  int $product_id 商品ID (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function getProductAsync($product_id)
    {
        return $this->getProductAsyncWithHttpInfo($product_id)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation getProductAsyncWithHttpInfo
     *
     * 商品データの取得
     *
     * @param  int $product_id 商品ID (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function getProductAsyncWithHttpInfo($product_id)
    {
        $returnType = '\ColorMeShop\Swagger\Model\InlineResponse2009';
        $request = $this->getProductRequest($product_id);

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    $responseBody = $response->getBody();
                    if ($returnType === '\SplFileObject') {
                        $content = $responseBody; //stream goes to serializer
                    } else {
                        $content = $responseBody->getContents();
                        if ($returnType !== 'string') {
                            $content = json_decode($content);
                        }
                    }

                    return [
                        ObjectSerializer::deserialize($content, $returnType, []),
                        $response->getStatusCode(),
                        $response->getHeaders()
                    ];
                },
                function ($exception) {
                    $response = $exception->getResponse();
                    $statusCode = $response->getStatusCode();
                    throw new ApiException(
                        sprintf(
                            '[%d] Error connecting to the API (%s)',
                            $statusCode,
                            $exception->getRequest()->getUri()
                        ),
                        $statusCode,
                        $response->getHeaders(),
                        $response->getBody()
                    );
                }
            );
    }

    /**
     * Create request for operation 'getProduct'
     *
     * @param  int $product_id 商品ID (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    protected function getProductRequest($product_id)
    {
        // verify the required parameter 'product_id' is set
        if ($product_id === null || (is_array($product_id) && count($product_id) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $product_id when calling getProduct'
            );
        }

        $resourcePath = '/v1/products/{product_id}';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;


        // path params
        if ($product_id !== null) {
            $resourcePath = str_replace(
                '{' . 'product_id' . '}',
                ObjectSerializer::toPathValue($product_id),
                $resourcePath
            );
        }

        // body params
        $_tempBody = null;

        if ($multipart) {
            $headers = $this->headerSelector->selectHeadersForMultipart(
                ['application/json']
            );
        } else {
            $headers = $this->headerSelector->selectHeaders(
                ['application/json'],
                []
            );
        }

        // for model (json/xml)
        if (isset($_tempBody)) {
            // $_tempBody is the method argument, if present
            $httpBody = $_tempBody;
            // \stdClass has no __toString(), so we should encode it manually
            if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') {
                $httpBody = \GuzzleHttp\json_encode($httpBody);
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $multipartContents[] = [
                        'name' => $formParamName,
                        'contents' => $formParamValue
                    ];
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);

            } elseif ($headers['Content-Type'] === 'application/json') {
                $httpBody = \GuzzleHttp\json_encode($formParams);

            } else {
                // for HTTP post (form)
                $httpBody = \GuzzleHttp\Psr7\build_query($formParams);
            }
        }

        // this endpoint requires OAuth (access token)
        if ($this->config->getAccessToken() !== null) {
            $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
        }

        $defaultHeaders = [];
        if ($this->config->getUserAgent()) {
            $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
        }

        $headers = array_merge(
            $defaultHeaders,
            $headerParams,
            $headers
        );

        $query = \GuzzleHttp\Psr7\build_query($queryParams);
        return new Request(
            'GET',
            $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation getProductVariants
     *
     * 商品オプション一覧の取得
     *
     * @param  int $product_id 商品ID (required)
     * @param  string $model_number 型番で部分一致検索 (optional)
     * @param  string $fields レスポンスJSONのキーをカンマ区切りで指定 (optional)
     * @param  int $limit レスポンスの件数を指定。指定がない場合は10。最大50 (optional)
     * @param  int $offset 指定した数値+1件目以降のデータを返す (optional)
     *
     * @throws \ColorMeShop\Swagger\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return \ColorMeShop\Swagger\Model\InlineResponse20010
     */
    public function getProductVariants($product_id, $model_number = null, $fields = null, $limit = null, $offset = null)
    {
        list($response) = $this->getProductVariantsWithHttpInfo($product_id, $model_number, $fields, $limit, $offset);
        return $response;
    }

    /**
     * Operation getProductVariantsWithHttpInfo
     *
     * 商品オプション一覧の取得
     *
     * @param  int $product_id 商品ID (required)
     * @param  string $model_number 型番で部分一致検索 (optional)
     * @param  string $fields レスポンスJSONのキーをカンマ区切りで指定 (optional)
     * @param  int $limit レスポンスの件数を指定。指定がない場合は10。最大50 (optional)
     * @param  int $offset 指定した数値+1件目以降のデータを返す (optional)
     *
     * @throws \ColorMeShop\Swagger\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \ColorMeShop\Swagger\Model\InlineResponse20010, HTTP status code, HTTP response headers (array of strings)
     */
    public function getProductVariantsWithHttpInfo($product_id, $model_number = null, $fields = null, $limit = null, $offset = null)
    {
        $returnType = '\ColorMeShop\Swagger\Model\InlineResponse20010';
        $request = $this->getProductVariantsRequest($product_id, $model_number, $fields, $limit, $offset);

        try {
            $options = $this->createHttpClientOption();
            try {
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
                );
            }

            $statusCode = $response->getStatusCode();

            if ($statusCode < 200 || $statusCode > 299) {
                throw new ApiException(
                    sprintf(
                        '[%d] Error connecting to the API (%s)',
                        $statusCode,
                        $request->getUri()
                    ),
                    $statusCode,
                    $response->getHeaders(),
                    $response->getBody()
                );
            }

            $responseBody = $response->getBody();
            if ($returnType === '\SplFileObject') {
                $content = $responseBody; //stream goes to serializer
            } else {
                $content = $responseBody->getContents();
                if (!in_array($returnType, ['string','integer','bool'])) {
                    $content = json_decode($content);
                }
            }

            return [
                ObjectSerializer::deserialize($content, $returnType, []),
                $response->getStatusCode(),
                $response->getHeaders()
            ];

        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ColorMeShop\Swagger\Model\InlineResponse20010',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
            }
            throw $e;
        }
    }

    /**
     * Operation getProductVariantsAsync
     *
     * 商品オプション一覧の取得
     *
     * @param  int $product_id 商品ID (required)
     * @param  string $model_number 型番で部分一致検索 (optional)
     * @param  string $fields レスポンスJSONのキーをカンマ区切りで指定 (optional)
     * @param  int $limit レスポンスの件数を指定。指定がない場合は10。最大50 (optional)
     * @param  int $offset 指定した数値+1件目以降のデータを返す (optional)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function getProductVariantsAsync($product_id, $model_number = null, $fields = null, $limit = null, $offset = null)
    {
        return $this->getProductVariantsAsyncWithHttpInfo($product_id, $model_number, $fields, $limit, $offset)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation getProductVariantsAsyncWithHttpInfo
     *
     * 商品オプション一覧の取得
     *
     * @param  int $product_id 商品ID (required)
     * @param  string $model_number 型番で部分一致検索 (optional)
     * @param  string $fields レスポンスJSONのキーをカンマ区切りで指定 (optional)
     * @param  int $limit レスポンスの件数を指定。指定がない場合は10。最大50 (optional)
     * @param  int $offset 指定した数値+1件目以降のデータを返す (optional)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function getProductVariantsAsyncWithHttpInfo($product_id, $model_number = null, $fields = null, $limit = null, $offset = null)
    {
        $returnType = '\ColorMeShop\Swagger\Model\InlineResponse20010';
        $request = $this->getProductVariantsRequest($product_id, $model_number, $fields, $limit, $offset);

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    $responseBody = $response->getBody();
                    if ($returnType === '\SplFileObject') {
                        $content = $responseBody; //stream goes to serializer
                    } else {
                        $content = $responseBody->getContents();
                        if ($returnType !== 'string') {
                            $content = json_decode($content);
                        }
                    }

                    return [
                        ObjectSerializer::deserialize($content, $returnType, []),
                        $response->getStatusCode(),
                        $response->getHeaders()
                    ];
                },
                function ($exception) {
                    $response = $exception->getResponse();
                    $statusCode = $response->getStatusCode();
                    throw new ApiException(
                        sprintf(
                            '[%d] Error connecting to the API (%s)',
                            $statusCode,
                            $exception->getRequest()->getUri()
                        ),
                        $statusCode,
                        $response->getHeaders(),
                        $response->getBody()
                    );
                }
            );
    }

    /**
     * Create request for operation 'getProductVariants'
     *
     * @param  int $product_id 商品ID (required)
     * @param  string $model_number 型番で部分一致検索 (optional)
     * @param  string $fields レスポンスJSONのキーをカンマ区切りで指定 (optional)
     * @param  int $limit レスポンスの件数を指定。指定がない場合は10。最大50 (optional)
     * @param  int $offset 指定した数値+1件目以降のデータを返す (optional)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    protected function getProductVariantsRequest($product_id, $model_number = null, $fields = null, $limit = null, $offset = null)
    {
        // verify the required parameter 'product_id' is set
        if ($product_id === null || (is_array($product_id) && count($product_id) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $product_id when calling getProductVariants'
            );
        }

        $resourcePath = '/v1/products/{product_id}/variants';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // query params
        if ($model_number !== null) {
            $queryParams['model_number'] = ObjectSerializer::toQueryValue($model_number, null);
        }
        // query params
        if ($fields !== null) {
            $queryParams['fields'] = ObjectSerializer::toQueryValue($fields, null);
        }
        // query params
        if ($limit !== null) {
            $queryParams['limit'] = ObjectSerializer::toQueryValue($limit, null);
        }
        // query params
        if ($offset !== null) {
            $queryParams['offset'] = ObjectSerializer::toQueryValue($offset, null);
        }

        // path params
        if ($product_id !== null) {
            $resourcePath = str_replace(
                '{' . 'product_id' . '}',
                ObjectSerializer::toPathValue($product_id),
                $resourcePath
            );
        }

        // body params
        $_tempBody = null;

        if ($multipart) {
            $headers = $this->headerSelector->selectHeadersForMultipart(
                ['application/json']
            );
        } else {
            $headers = $this->headerSelector->selectHeaders(
                ['application/json'],
                []
            );
        }

        // for model (json/xml)
        if (isset($_tempBody)) {
            // $_tempBody is the method argument, if present
            $httpBody = $_tempBody;
            // \stdClass has no __toString(), so we should encode it manually
            if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') {
                $httpBody = \GuzzleHttp\json_encode($httpBody);
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $multipartContents[] = [
                        'name' => $formParamName,
                        'contents' => $formParamValue
                    ];
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);

            } elseif ($headers['Content-Type'] === 'application/json') {
                $httpBody = \GuzzleHttp\json_encode($formParams);

            } else {
                // for HTTP post (form)
                $httpBody = \GuzzleHttp\Psr7\build_query($formParams);
            }
        }

        // this endpoint requires OAuth (access token)
        if ($this->config->getAccessToken() !== null) {
            $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
        }

        $defaultHeaders = [];
        if ($this->config->getUserAgent()) {
            $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
        }

        $headers = array_merge(
            $defaultHeaders,
            $headerParams,
            $headers
        );

        $query = \GuzzleHttp\Psr7\build_query($queryParams);
        return new Request(
            'GET',
            $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation getProducts
     *
     * 商品一覧の取得
     *
     * @param  string $ids 商品IDで検索。カンマ区切りにすることで複数検索が可能 (optional)
     * @param  int $category_id_big 大カテゴリーIDで検索 (optional)
     * @param  int $category_id_small 小カテゴリーIDで検索 (optional)
     * @param  int $group_ids グループIDで検索。カンマ区切りにすることで複数検索が可能 (optional)
     * @param  string $model_number 型番で部分一致検索 (optional)
     * @param  string $name 商品名で部分一致検索 (optional)
     * @param  string $display_state 掲載設定で検索  - &#x60;showing&#x60;: 掲載状態 - &#x60;hidden&#x60;: 非掲載状態 - &#x60;showing_for_members&#x60;: 会員にのみ掲載 - &#x60;sale_for_members&#x60;: 掲載状態だが購入は会員のみ可能 (optional)
     * @param  int $stocks 在庫管理している商品のうち、在庫数が指定した数値以下の商品を検索。オプションごとに在庫管理している商品は、オプションごとの在庫数で検索される (optional)
     * @param  bool $stock_managed &#x60;true&#x60;の場合、在庫管理している商品を検索 (optional)
     * @param  bool $recent_zero_stocks &#x60;true&#x60; の場合、過去1週間以内に更新された商品から検索 (optional)
     * @param  string $make_date_min 指定日時以降に作成された商品から検索 (optional)
     * @param  string $make_date_max 指定日時以前に作成された商品から検索 (optional)
     * @param  string $update_date_min 指定日時以降に更新された商品から検索 (optional)
     * @param  string $update_date_max 指定日時以前に更新された商品から検索 (optional)
     * @param  string $fields レスポンスJSONのキーをカンマ区切りで指定 (optional)
     * @param  int $limit レスポンスの件数を指定。指定がない場合は10。最大50 (optional)
     * @param  int $offset 指定した数値+1件目以降のデータを返す (optional)
     *
     * @throws \ColorMeShop\Swagger\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return \ColorMeShop\Swagger\Model\InlineResponse2008
     */
    public function getProducts($ids = null, $category_id_big = null, $category_id_small = null, $group_ids = null, $model_number = null, $name = null, $display_state = null, $stocks = null, $stock_managed = null, $recent_zero_stocks = null, $make_date_min = null, $make_date_max = null, $update_date_min = null, $update_date_max = null, $fields = null, $limit = null, $offset = null)
    {
        list($response) = $this->getProductsWithHttpInfo($ids, $category_id_big, $category_id_small, $group_ids, $model_number, $name, $display_state, $stocks, $stock_managed, $recent_zero_stocks, $make_date_min, $make_date_max, $update_date_min, $update_date_max, $fields, $limit, $offset);
        return $response;
    }

    /**
     * Operation getProductsWithHttpInfo
     *
     * 商品一覧の取得
     *
     * @param  string $ids 商品IDで検索。カンマ区切りにすることで複数検索が可能 (optional)
     * @param  int $category_id_big 大カテゴリーIDで検索 (optional)
     * @param  int $category_id_small 小カテゴリーIDで検索 (optional)
     * @param  int $group_ids グループIDで検索。カンマ区切りにすることで複数検索が可能 (optional)
     * @param  string $model_number 型番で部分一致検索 (optional)
     * @param  string $name 商品名で部分一致検索 (optional)
     * @param  string $display_state 掲載設定で検索  - &#x60;showing&#x60;: 掲載状態 - &#x60;hidden&#x60;: 非掲載状態 - &#x60;showing_for_members&#x60;: 会員にのみ掲載 - &#x60;sale_for_members&#x60;: 掲載状態だが購入は会員のみ可能 (optional)
     * @param  int $stocks 在庫管理している商品のうち、在庫数が指定した数値以下の商品を検索。オプションごとに在庫管理している商品は、オプションごとの在庫数で検索される (optional)
     * @param  bool $stock_managed &#x60;true&#x60;の場合、在庫管理している商品を検索 (optional)
     * @param  bool $recent_zero_stocks &#x60;true&#x60; の場合、過去1週間以内に更新された商品から検索 (optional)
     * @param  string $make_date_min 指定日時以降に作成された商品から検索 (optional)
     * @param  string $make_date_max 指定日時以前に作成された商品から検索 (optional)
     * @param  string $update_date_min 指定日時以降に更新された商品から検索 (optional)
     * @param  string $update_date_max 指定日時以前に更新された商品から検索 (optional)
     * @param  string $fields レスポンスJSONのキーをカンマ区切りで指定 (optional)
     * @param  int $limit レスポンスの件数を指定。指定がない場合は10。最大50 (optional)
     * @param  int $offset 指定した数値+1件目以降のデータを返す (optional)
     *
     * @throws \ColorMeShop\Swagger\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \ColorMeShop\Swagger\Model\InlineResponse2008, HTTP status code, HTTP response headers (array of strings)
     */
    public function getProductsWithHttpInfo($ids = null, $category_id_big = null, $category_id_small = null, $group_ids = null, $model_number = null, $name = null, $display_state = null, $stocks = null, $stock_managed = null, $recent_zero_stocks = null, $make_date_min = null, $make_date_max = null, $update_date_min = null, $update_date_max = null, $fields = null, $limit = null, $offset = null)
    {
        $returnType = '\ColorMeShop\Swagger\Model\InlineResponse2008';
        $request = $this->getProductsRequest($ids, $category_id_big, $category_id_small, $group_ids, $model_number, $name, $display_state, $stocks, $stock_managed, $recent_zero_stocks, $make_date_min, $make_date_max, $update_date_min, $update_date_max, $fields, $limit, $offset);

        try {
            $options = $this->createHttpClientOption();
            try {
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
                );
            }

            $statusCode = $response->getStatusCode();

            if ($statusCode < 200 || $statusCode > 299) {
                throw new ApiException(
                    sprintf(
                        '[%d] Error connecting to the API (%s)',
                        $statusCode,
                        $request->getUri()
                    ),
                    $statusCode,
                    $response->getHeaders(),
                    $response->getBody()
                );
            }

            $responseBody = $response->getBody();
            if ($returnType === '\SplFileObject') {
                $content = $responseBody; //stream goes to serializer
            } else {
                $content = $responseBody->getContents();
                if (!in_array($returnType, ['string','integer','bool'])) {
                    $content = json_decode($content);
                }
            }

            return [
                ObjectSerializer::deserialize($content, $returnType, []),
                $response->getStatusCode(),
                $response->getHeaders()
            ];

        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ColorMeShop\Swagger\Model\InlineResponse2008',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
            }
            throw $e;
        }
    }

    /**
     * Operation getProductsAsync
     *
     * 商品一覧の取得
     *
     * @param  string $ids 商品IDで検索。カンマ区切りにすることで複数検索が可能 (optional)
     * @param  int $category_id_big 大カテゴリーIDで検索 (optional)
     * @param  int $category_id_small 小カテゴリーIDで検索 (optional)
     * @param  int $group_ids グループIDで検索。カンマ区切りにすることで複数検索が可能 (optional)
     * @param  string $model_number 型番で部分一致検索 (optional)
     * @param  string $name 商品名で部分一致検索 (optional)
     * @param  string $display_state 掲載設定で検索  - &#x60;showing&#x60;: 掲載状態 - &#x60;hidden&#x60;: 非掲載状態 - &#x60;showing_for_members&#x60;: 会員にのみ掲載 - &#x60;sale_for_members&#x60;: 掲載状態だが購入は会員のみ可能 (optional)
     * @param  int $stocks 在庫管理している商品のうち、在庫数が指定した数値以下の商品を検索。オプションごとに在庫管理している商品は、オプションごとの在庫数で検索される (optional)
     * @param  bool $stock_managed &#x60;true&#x60;の場合、在庫管理している商品を検索 (optional)
     * @param  bool $recent_zero_stocks &#x60;true&#x60; の場合、過去1週間以内に更新された商品から検索 (optional)
     * @param  string $make_date_min 指定日時以降に作成された商品から検索 (optional)
     * @param  string $make_date_max 指定日時以前に作成された商品から検索 (optional)
     * @param  string $update_date_min 指定日時以降に更新された商品から検索 (optional)
     * @param  string $update_date_max 指定日時以前に更新された商品から検索 (optional)
     * @param  string $fields レスポンスJSONのキーをカンマ区切りで指定 (optional)
     * @param  int $limit レスポンスの件数を指定。指定がない場合は10。最大50 (optional)
     * @param  int $offset 指定した数値+1件目以降のデータを返す (optional)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function getProductsAsync($ids = null, $category_id_big = null, $category_id_small = null, $group_ids = null, $model_number = null, $name = null, $display_state = null, $stocks = null, $stock_managed = null, $recent_zero_stocks = null, $make_date_min = null, $make_date_max = null, $update_date_min = null, $update_date_max = null, $fields = null, $limit = null, $offset = null)
    {
        return $this->getProductsAsyncWithHttpInfo($ids, $category_id_big, $category_id_small, $group_ids, $model_number, $name, $display_state, $stocks, $stock_managed, $recent_zero_stocks, $make_date_min, $make_date_max, $update_date_min, $update_date_max, $fields, $limit, $offset)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation getProductsAsyncWithHttpInfo
     *
     * 商品一覧の取得
     *
     * @param  string $ids 商品IDで検索。カンマ区切りにすることで複数検索が可能 (optional)
     * @param  int $category_id_big 大カテゴリーIDで検索 (optional)
     * @param  int $category_id_small 小カテゴリーIDで検索 (optional)
     * @param  int $group_ids グループIDで検索。カンマ区切りにすることで複数検索が可能 (optional)
     * @param  string $model_number 型番で部分一致検索 (optional)
     * @param  string $name 商品名で部分一致検索 (optional)
     * @param  string $display_state 掲載設定で検索  - &#x60;showing&#x60;: 掲載状態 - &#x60;hidden&#x60;: 非掲載状態 - &#x60;showing_for_members&#x60;: 会員にのみ掲載 - &#x60;sale_for_members&#x60;: 掲載状態だが購入は会員のみ可能 (optional)
     * @param  int $stocks 在庫管理している商品のうち、在庫数が指定した数値以下の商品を検索。オプションごとに在庫管理している商品は、オプションごとの在庫数で検索される (optional)
     * @param  bool $stock_managed &#x60;true&#x60;の場合、在庫管理している商品を検索 (optional)
     * @param  bool $recent_zero_stocks &#x60;true&#x60; の場合、過去1週間以内に更新された商品から検索 (optional)
     * @param  string $make_date_min 指定日時以降に作成された商品から検索 (optional)
     * @param  string $make_date_max 指定日時以前に作成された商品から検索 (optional)
     * @param  string $update_date_min 指定日時以降に更新された商品から検索 (optional)
     * @param  string $update_date_max 指定日時以前に更新された商品から検索 (optional)
     * @param  string $fields レスポンスJSONのキーをカンマ区切りで指定 (optional)
     * @param  int $limit レスポンスの件数を指定。指定がない場合は10。最大50 (optional)
     * @param  int $offset 指定した数値+1件目以降のデータを返す (optional)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function getProductsAsyncWithHttpInfo($ids = null, $category_id_big = null, $category_id_small = null, $group_ids = null, $model_number = null, $name = null, $display_state = null, $stocks = null, $stock_managed = null, $recent_zero_stocks = null, $make_date_min = null, $make_date_max = null, $update_date_min = null, $update_date_max = null, $fields = null, $limit = null, $offset = null)
    {
        $returnType = '\ColorMeShop\Swagger\Model\InlineResponse2008';
        $request = $this->getProductsRequest($ids, $category_id_big, $category_id_small, $group_ids, $model_number, $name, $display_state, $stocks, $stock_managed, $recent_zero_stocks, $make_date_min, $make_date_max, $update_date_min, $update_date_max, $fields, $limit, $offset);

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    $responseBody = $response->getBody();
                    if ($returnType === '\SplFileObject') {
                        $content = $responseBody; //stream goes to serializer
                    } else {
                        $content = $responseBody->getContents();
                        if ($returnType !== 'string') {
                            $content = json_decode($content);
                        }
                    }

                    return [
                        ObjectSerializer::deserialize($content, $returnType, []),
                        $response->getStatusCode(),
                        $response->getHeaders()
                    ];
                },
                function ($exception) {
                    $response = $exception->getResponse();
                    $statusCode = $response->getStatusCode();
                    throw new ApiException(
                        sprintf(
                            '[%d] Error connecting to the API (%s)',
                            $statusCode,
                            $exception->getRequest()->getUri()
                        ),
                        $statusCode,
                        $response->getHeaders(),
                        $response->getBody()
                    );
                }
            );
    }

    /**
     * Create request for operation 'getProducts'
     *
     * @param  string $ids 商品IDで検索。カンマ区切りにすることで複数検索が可能 (optional)
     * @param  int $category_id_big 大カテゴリーIDで検索 (optional)
     * @param  int $category_id_small 小カテゴリーIDで検索 (optional)
     * @param  int $group_ids グループIDで検索。カンマ区切りにすることで複数検索が可能 (optional)
     * @param  string $model_number 型番で部分一致検索 (optional)
     * @param  string $name 商品名で部分一致検索 (optional)
     * @param  string $display_state 掲載設定で検索  - &#x60;showing&#x60;: 掲載状態 - &#x60;hidden&#x60;: 非掲載状態 - &#x60;showing_for_members&#x60;: 会員にのみ掲載 - &#x60;sale_for_members&#x60;: 掲載状態だが購入は会員のみ可能 (optional)
     * @param  int $stocks 在庫管理している商品のうち、在庫数が指定した数値以下の商品を検索。オプションごとに在庫管理している商品は、オプションごとの在庫数で検索される (optional)
     * @param  bool $stock_managed &#x60;true&#x60;の場合、在庫管理している商品を検索 (optional)
     * @param  bool $recent_zero_stocks &#x60;true&#x60; の場合、過去1週間以内に更新された商品から検索 (optional)
     * @param  string $make_date_min 指定日時以降に作成された商品から検索 (optional)
     * @param  string $make_date_max 指定日時以前に作成された商品から検索 (optional)
     * @param  string $update_date_min 指定日時以降に更新された商品から検索 (optional)
     * @param  string $update_date_max 指定日時以前に更新された商品から検索 (optional)
     * @param  string $fields レスポンスJSONのキーをカンマ区切りで指定 (optional)
     * @param  int $limit レスポンスの件数を指定。指定がない場合は10。最大50 (optional)
     * @param  int $offset 指定した数値+1件目以降のデータを返す (optional)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    protected function getProductsRequest($ids = null, $category_id_big = null, $category_id_small = null, $group_ids = null, $model_number = null, $name = null, $display_state = null, $stocks = null, $stock_managed = null, $recent_zero_stocks = null, $make_date_min = null, $make_date_max = null, $update_date_min = null, $update_date_max = null, $fields = null, $limit = null, $offset = null)
    {

        $resourcePath = '/v1/products';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // query params
        if ($ids !== null) {
            $queryParams['ids'] = ObjectSerializer::toQueryValue($ids, null);
        }
        // query params
        if ($category_id_big !== null) {
            $queryParams['category_id_big'] = ObjectSerializer::toQueryValue($category_id_big, null);
        }
        // query params
        if ($category_id_small !== null) {
            $queryParams['category_id_small'] = ObjectSerializer::toQueryValue($category_id_small, null);
        }
        // query params
        if ($group_ids !== null) {
            $queryParams['group_ids'] = ObjectSerializer::toQueryValue($group_ids, null);
        }
        // query params
        if ($model_number !== null) {
            $queryParams['model_number'] = ObjectSerializer::toQueryValue($model_number, null);
        }
        // query params
        if ($name !== null) {
            $queryParams['name'] = ObjectSerializer::toQueryValue($name, null);
        }
        // query params
        if ($display_state !== null) {
            $queryParams['display_state'] = ObjectSerializer::toQueryValue($display_state, null);
        }
        // query params
        if ($stocks !== null) {
            $queryParams['stocks'] = ObjectSerializer::toQueryValue($stocks, null);
        }
        // query params
        if ($stock_managed !== null) {
            $queryParams['stock_managed'] = ObjectSerializer::toQueryValue($stock_managed, null);
        }
        // query params
        if ($recent_zero_stocks !== null) {
            $queryParams['recent_zero_stocks'] = ObjectSerializer::toQueryValue($recent_zero_stocks, null);
        }
        // query params
        if ($make_date_min !== null) {
            $queryParams['make_date_min'] = ObjectSerializer::toQueryValue($make_date_min, 'YYYY-MM-DD | YYYY-MM-DD hh:mm:ss');
        }
        // query params
        if ($make_date_max !== null) {
            $queryParams['make_date_max'] = ObjectSerializer::toQueryValue($make_date_max, 'YYYY-MM-DD | YYYY-MM-DD hh:mm:ss');
        }
        // query params
        if ($update_date_min !== null) {
            $queryParams['update_date_min'] = ObjectSerializer::toQueryValue($update_date_min, 'YYYY-MM-DD | YYYY-MM-DD hh:mm:ss');
        }
        // query params
        if ($update_date_max !== null) {
            $queryParams['update_date_max'] = ObjectSerializer::toQueryValue($update_date_max, 'YYYY-MM-DD | YYYY-MM-DD hh:mm:ss');
        }
        // query params
        if ($fields !== null) {
            $queryParams['fields'] = ObjectSerializer::toQueryValue($fields, null);
        }
        // query params
        if ($limit !== null) {
            $queryParams['limit'] = ObjectSerializer::toQueryValue($limit, null);
        }
        // query params
        if ($offset !== null) {
            $queryParams['offset'] = ObjectSerializer::toQueryValue($offset, null);
        }


        // body params
        $_tempBody = null;

        if ($multipart) {
            $headers = $this->headerSelector->selectHeadersForMultipart(
                ['application/json']
            );
        } else {
            $headers = $this->headerSelector->selectHeaders(
                ['application/json'],
                []
            );
        }

        // for model (json/xml)
        if (isset($_tempBody)) {
            // $_tempBody is the method argument, if present
            $httpBody = $_tempBody;
            // \stdClass has no __toString(), so we should encode it manually
            if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') {
                $httpBody = \GuzzleHttp\json_encode($httpBody);
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $multipartContents[] = [
                        'name' => $formParamName,
                        'contents' => $formParamValue
                    ];
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);

            } elseif ($headers['Content-Type'] === 'application/json') {
                $httpBody = \GuzzleHttp\json_encode($formParams);

            } else {
                // for HTTP post (form)
                $httpBody = \GuzzleHttp\Psr7\build_query($formParams);
            }
        }

        // this endpoint requires OAuth (access token)
        if ($this->config->getAccessToken() !== null) {
            $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
        }

        $defaultHeaders = [];
        if ($this->config->getUserAgent()) {
            $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
        }

        $headers = array_merge(
            $defaultHeaders,
            $headerParams,
            $headers
        );

        $query = \GuzzleHttp\Psr7\build_query($queryParams);
        return new Request(
            'GET',
            $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation postProductPickup
     *
     * おすすめ商品情報の追加
     *
     * @param  \ColorMeShop\Swagger\Model\ProductIdPickupsBody1 $body body (required)
     * @param  int $product_id 商品ID (required)
     *
     * @throws \ColorMeShop\Swagger\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return \ColorMeShop\Swagger\Model\InlineResponse20011
     */
    public function postProductPickup($body, $product_id)
    {
        list($response) = $this->postProductPickupWithHttpInfo($body, $product_id);
        return $response;
    }

    /**
     * Operation postProductPickupWithHttpInfo
     *
     * おすすめ商品情報の追加
     *
     * @param  \ColorMeShop\Swagger\Model\ProductIdPickupsBody1 $body (required)
     * @param  int $product_id 商品ID (required)
     *
     * @throws \ColorMeShop\Swagger\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \ColorMeShop\Swagger\Model\InlineResponse20011, HTTP status code, HTTP response headers (array of strings)
     */
    public function postProductPickupWithHttpInfo($body, $product_id)
    {
        $returnType = '\ColorMeShop\Swagger\Model\InlineResponse20011';
        $request = $this->postProductPickupRequest($body, $product_id);

        try {
            $options = $this->createHttpClientOption();
            try {
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
                );
            }

            $statusCode = $response->getStatusCode();

            if ($statusCode < 200 || $statusCode > 299) {
                throw new ApiException(
                    sprintf(
                        '[%d] Error connecting to the API (%s)',
                        $statusCode,
                        $request->getUri()
                    ),
                    $statusCode,
                    $response->getHeaders(),
                    $response->getBody()
                );
            }

            $responseBody = $response->getBody();
            if ($returnType === '\SplFileObject') {
                $content = $responseBody; //stream goes to serializer
            } else {
                $content = $responseBody->getContents();
                if (!in_array($returnType, ['string','integer','bool'])) {
                    $content = json_decode($content);
                }
            }

            return [
                ObjectSerializer::deserialize($content, $returnType, []),
                $response->getStatusCode(),
                $response->getHeaders()
            ];

        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ColorMeShop\Swagger\Model\InlineResponse20011',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
            }
            throw $e;
        }
    }

    /**
     * Operation postProductPickupAsync
     *
     * おすすめ商品情報の追加
     *
     * @param  \ColorMeShop\Swagger\Model\ProductIdPickupsBody1 $body (required)
     * @param  int $product_id 商品ID (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function postProductPickupAsync($body, $product_id)
    {
        return $this->postProductPickupAsyncWithHttpInfo($body, $product_id)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation postProductPickupAsyncWithHttpInfo
     *
     * おすすめ商品情報の追加
     *
     * @param  \ColorMeShop\Swagger\Model\ProductIdPickupsBody1 $body (required)
     * @param  int $product_id 商品ID (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function postProductPickupAsyncWithHttpInfo($body, $product_id)
    {
        $returnType = '\ColorMeShop\Swagger\Model\InlineResponse20011';
        $request = $this->postProductPickupRequest($body, $product_id);

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    $responseBody = $response->getBody();
                    if ($returnType === '\SplFileObject') {
                        $content = $responseBody; //stream goes to serializer
                    } else {
                        $content = $responseBody->getContents();
                        if ($returnType !== 'string') {
                            $content = json_decode($content);
                        }
                    }

                    return [
                        ObjectSerializer::deserialize($content, $returnType, []),
                        $response->getStatusCode(),
                        $response->getHeaders()
                    ];
                },
                function ($exception) {
                    $response = $exception->getResponse();
                    $statusCode = $response->getStatusCode();
                    throw new ApiException(
                        sprintf(
                            '[%d] Error connecting to the API (%s)',
                            $statusCode,
                            $exception->getRequest()->getUri()
                        ),
                        $statusCode,
                        $response->getHeaders(),
                        $response->getBody()
                    );
                }
            );
    }

    /**
     * Create request for operation 'postProductPickup'
     *
     * @param  \ColorMeShop\Swagger\Model\ProductIdPickupsBody1 $body (required)
     * @param  int $product_id 商品ID (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    protected function postProductPickupRequest($body, $product_id)
    {
        // verify the required parameter 'body' is set
        if ($body === null || (is_array($body) && count($body) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $body when calling postProductPickup'
            );
        }
        // verify the required parameter 'product_id' is set
        if ($product_id === null || (is_array($product_id) && count($product_id) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $product_id when calling postProductPickup'
            );
        }

        $resourcePath = '/v1/products/{product_id}/pickups';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;


        // path params
        if ($product_id !== null) {
            $resourcePath = str_replace(
                '{' . 'product_id' . '}',
                ObjectSerializer::toPathValue($product_id),
                $resourcePath
            );
        }

        // body params
        $_tempBody = null;
        if (isset($body)) {
            $_tempBody = $body;
        }

        if ($multipart) {
            $headers = $this->headerSelector->selectHeadersForMultipart(
                ['application/json']
            );
        } else {
            $headers = $this->headerSelector->selectHeaders(
                ['application/json'],
                ['application/json']
            );
        }

        // for model (json/xml)
        if (isset($_tempBody)) {
            // $_tempBody is the method argument, if present
            $httpBody = $_tempBody;
            // \stdClass has no __toString(), so we should encode it manually
            if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') {
                $httpBody = \GuzzleHttp\json_encode($httpBody);
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $multipartContents[] = [
                        'name' => $formParamName,
                        'contents' => $formParamValue
                    ];
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);

            } elseif ($headers['Content-Type'] === 'application/json') {
                $httpBody = \GuzzleHttp\json_encode($formParams);

            } else {
                // for HTTP post (form)
                $httpBody = \GuzzleHttp\Psr7\build_query($formParams);
            }
        }

        // this endpoint requires OAuth (access token)
        if ($this->config->getAccessToken() !== null) {
            $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
        }

        $defaultHeaders = [];
        if ($this->config->getUserAgent()) {
            $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
        }

        $headers = array_merge(
            $defaultHeaders,
            $headerParams,
            $headers
        );

        $query = \GuzzleHttp\Psr7\build_query($queryParams);
        return new Request(
            'POST',
            $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation postProducts
     *
     * 商品データの追加
     *
     * @param  \ColorMeShop\Swagger\Model\V1ProductsBody $body 商品データ (required)
     *
     * @throws \ColorMeShop\Swagger\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return \ColorMeShop\Swagger\Model\InlineResponse2009
     */
    public function postProducts($body)
    {
        list($response) = $this->postProductsWithHttpInfo($body);
        return $response;
    }

    /**
     * Operation postProductsWithHttpInfo
     *
     * 商品データの追加
     *
     * @param  \ColorMeShop\Swagger\Model\V1ProductsBody $body 商品データ (required)
     *
     * @throws \ColorMeShop\Swagger\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \ColorMeShop\Swagger\Model\InlineResponse2009, HTTP status code, HTTP response headers (array of strings)
     */
    public function postProductsWithHttpInfo($body)
    {
        $returnType = '\ColorMeShop\Swagger\Model\InlineResponse2009';
        $request = $this->postProductsRequest($body);

        try {
            $options = $this->createHttpClientOption();
            try {
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
                );
            }

            $statusCode = $response->getStatusCode();

            if ($statusCode < 200 || $statusCode > 299) {
                throw new ApiException(
                    sprintf(
                        '[%d] Error connecting to the API (%s)',
                        $statusCode,
                        $request->getUri()
                    ),
                    $statusCode,
                    $response->getHeaders(),
                    $response->getBody()
                );
            }

            $responseBody = $response->getBody();
            if ($returnType === '\SplFileObject') {
                $content = $responseBody; //stream goes to serializer
            } else {
                $content = $responseBody->getContents();
                if (!in_array($returnType, ['string','integer','bool'])) {
                    $content = json_decode($content);
                }
            }

            return [
                ObjectSerializer::deserialize($content, $returnType, []),
                $response->getStatusCode(),
                $response->getHeaders()
            ];

        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ColorMeShop\Swagger\Model\InlineResponse2009',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
            }
            throw $e;
        }
    }

    /**
     * Operation postProductsAsync
     *
     * 商品データの追加
     *
     * @param  \ColorMeShop\Swagger\Model\V1ProductsBody $body 商品データ (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function postProductsAsync($body)
    {
        return $this->postProductsAsyncWithHttpInfo($body)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation postProductsAsyncWithHttpInfo
     *
     * 商品データの追加
     *
     * @param  \ColorMeShop\Swagger\Model\V1ProductsBody $body 商品データ (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function postProductsAsyncWithHttpInfo($body)
    {
        $returnType = '\ColorMeShop\Swagger\Model\InlineResponse2009';
        $request = $this->postProductsRequest($body);

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    $responseBody = $response->getBody();
                    if ($returnType === '\SplFileObject') {
                        $content = $responseBody; //stream goes to serializer
                    } else {
                        $content = $responseBody->getContents();
                        if ($returnType !== 'string') {
                            $content = json_decode($content);
                        }
                    }

                    return [
                        ObjectSerializer::deserialize($content, $returnType, []),
                        $response->getStatusCode(),
                        $response->getHeaders()
                    ];
                },
                function ($exception) {
                    $response = $exception->getResponse();
                    $statusCode = $response->getStatusCode();
                    throw new ApiException(
                        sprintf(
                            '[%d] Error connecting to the API (%s)',
                            $statusCode,
                            $exception->getRequest()->getUri()
                        ),
                        $statusCode,
                        $response->getHeaders(),
                        $response->getBody()
                    );
                }
            );
    }

    /**
     * Create request for operation 'postProducts'
     *
     * @param  \ColorMeShop\Swagger\Model\V1ProductsBody $body 商品データ (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    protected function postProductsRequest($body)
    {
        // verify the required parameter 'body' is set
        if ($body === null || (is_array($body) && count($body) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $body when calling postProducts'
            );
        }

        $resourcePath = '/v1/products';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;



        // body params
        $_tempBody = null;
        if (isset($body)) {
            $_tempBody = $body;
        }

        if ($multipart) {
            $headers = $this->headerSelector->selectHeadersForMultipart(
                ['application/json']
            );
        } else {
            $headers = $this->headerSelector->selectHeaders(
                ['application/json'],
                ['application/json']
            );
        }

        // for model (json/xml)
        if (isset($_tempBody)) {
            // $_tempBody is the method argument, if present
            $httpBody = $_tempBody;
            // \stdClass has no __toString(), so we should encode it manually
            if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') {
                $httpBody = \GuzzleHttp\json_encode($httpBody);
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $multipartContents[] = [
                        'name' => $formParamName,
                        'contents' => $formParamValue
                    ];
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);

            } elseif ($headers['Content-Type'] === 'application/json') {
                $httpBody = \GuzzleHttp\json_encode($formParams);

            } else {
                // for HTTP post (form)
                $httpBody = \GuzzleHttp\Psr7\build_query($formParams);
            }
        }

        // this endpoint requires OAuth (access token)
        if ($this->config->getAccessToken() !== null) {
            $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
        }

        $defaultHeaders = [];
        if ($this->config->getUserAgent()) {
            $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
        }

        $headers = array_merge(
            $defaultHeaders,
            $headerParams,
            $headers
        );

        $query = \GuzzleHttp\Psr7\build_query($queryParams);
        return new Request(
            'POST',
            $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation putProductPickup
     *
     * おすすめ商品情報の更新
     *
     * @param  \ColorMeShop\Swagger\Model\ProductIdPickupsBody $body body (required)
     * @param  int $product_id 商品ID (required)
     *
     * @throws \ColorMeShop\Swagger\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return \ColorMeShop\Swagger\Model\InlineResponse20011
     */
    public function putProductPickup($body, $product_id)
    {
        list($response) = $this->putProductPickupWithHttpInfo($body, $product_id);
        return $response;
    }

    /**
     * Operation putProductPickupWithHttpInfo
     *
     * おすすめ商品情報の更新
     *
     * @param  \ColorMeShop\Swagger\Model\ProductIdPickupsBody $body (required)
     * @param  int $product_id 商品ID (required)
     *
     * @throws \ColorMeShop\Swagger\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \ColorMeShop\Swagger\Model\InlineResponse20011, HTTP status code, HTTP response headers (array of strings)
     */
    public function putProductPickupWithHttpInfo($body, $product_id)
    {
        $returnType = '\ColorMeShop\Swagger\Model\InlineResponse20011';
        $request = $this->putProductPickupRequest($body, $product_id);

        try {
            $options = $this->createHttpClientOption();
            try {
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
                );
            }

            $statusCode = $response->getStatusCode();

            if ($statusCode < 200 || $statusCode > 299) {
                throw new ApiException(
                    sprintf(
                        '[%d] Error connecting to the API (%s)',
                        $statusCode,
                        $request->getUri()
                    ),
                    $statusCode,
                    $response->getHeaders(),
                    $response->getBody()
                );
            }

            $responseBody = $response->getBody();
            if ($returnType === '\SplFileObject') {
                $content = $responseBody; //stream goes to serializer
            } else {
                $content = $responseBody->getContents();
                if (!in_array($returnType, ['string','integer','bool'])) {
                    $content = json_decode($content);
                }
            }

            return [
                ObjectSerializer::deserialize($content, $returnType, []),
                $response->getStatusCode(),
                $response->getHeaders()
            ];

        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ColorMeShop\Swagger\Model\InlineResponse20011',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
            }
            throw $e;
        }
    }

    /**
     * Operation putProductPickupAsync
     *
     * おすすめ商品情報の更新
     *
     * @param  \ColorMeShop\Swagger\Model\ProductIdPickupsBody $body (required)
     * @param  int $product_id 商品ID (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function putProductPickupAsync($body, $product_id)
    {
        return $this->putProductPickupAsyncWithHttpInfo($body, $product_id)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation putProductPickupAsyncWithHttpInfo
     *
     * おすすめ商品情報の更新
     *
     * @param  \ColorMeShop\Swagger\Model\ProductIdPickupsBody $body (required)
     * @param  int $product_id 商品ID (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function putProductPickupAsyncWithHttpInfo($body, $product_id)
    {
        $returnType = '\ColorMeShop\Swagger\Model\InlineResponse20011';
        $request = $this->putProductPickupRequest($body, $product_id);

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    $responseBody = $response->getBody();
                    if ($returnType === '\SplFileObject') {
                        $content = $responseBody; //stream goes to serializer
                    } else {
                        $content = $responseBody->getContents();
                        if ($returnType !== 'string') {
                            $content = json_decode($content);
                        }
                    }

                    return [
                        ObjectSerializer::deserialize($content, $returnType, []),
                        $response->getStatusCode(),
                        $response->getHeaders()
                    ];
                },
                function ($exception) {
                    $response = $exception->getResponse();
                    $statusCode = $response->getStatusCode();
                    throw new ApiException(
                        sprintf(
                            '[%d] Error connecting to the API (%s)',
                            $statusCode,
                            $exception->getRequest()->getUri()
                        ),
                        $statusCode,
                        $response->getHeaders(),
                        $response->getBody()
                    );
                }
            );
    }

    /**
     * Create request for operation 'putProductPickup'
     *
     * @param  \ColorMeShop\Swagger\Model\ProductIdPickupsBody $body (required)
     * @param  int $product_id 商品ID (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    protected function putProductPickupRequest($body, $product_id)
    {
        // verify the required parameter 'body' is set
        if ($body === null || (is_array($body) && count($body) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $body when calling putProductPickup'
            );
        }
        // verify the required parameter 'product_id' is set
        if ($product_id === null || (is_array($product_id) && count($product_id) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $product_id when calling putProductPickup'
            );
        }

        $resourcePath = '/v1/products/{product_id}/pickups';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;


        // path params
        if ($product_id !== null) {
            $resourcePath = str_replace(
                '{' . 'product_id' . '}',
                ObjectSerializer::toPathValue($product_id),
                $resourcePath
            );
        }

        // body params
        $_tempBody = null;
        if (isset($body)) {
            $_tempBody = $body;
        }

        if ($multipart) {
            $headers = $this->headerSelector->selectHeadersForMultipart(
                ['application/json']
            );
        } else {
            $headers = $this->headerSelector->selectHeaders(
                ['application/json'],
                ['application/json']
            );
        }

        // for model (json/xml)
        if (isset($_tempBody)) {
            // $_tempBody is the method argument, if present
            $httpBody = $_tempBody;
            // \stdClass has no __toString(), so we should encode it manually
            if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') {
                $httpBody = \GuzzleHttp\json_encode($httpBody);
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $multipartContents[] = [
                        'name' => $formParamName,
                        'contents' => $formParamValue
                    ];
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);

            } elseif ($headers['Content-Type'] === 'application/json') {
                $httpBody = \GuzzleHttp\json_encode($formParams);

            } else {
                // for HTTP post (form)
                $httpBody = \GuzzleHttp\Psr7\build_query($formParams);
            }
        }

        // this endpoint requires OAuth (access token)
        if ($this->config->getAccessToken() !== null) {
            $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
        }

        $defaultHeaders = [];
        if ($this->config->getUserAgent()) {
            $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
        }

        $headers = array_merge(
            $defaultHeaders,
            $headerParams,
            $headers
        );

        $query = \GuzzleHttp\Psr7\build_query($queryParams);
        return new Request(
            'PUT',
            $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation updateProduct
     *
     * 商品データの更新
     *
     * @param  int $product_id 商品ID (required)
     * @param  \ColorMeShop\Swagger\Model\ProductsProductIdBody $body 商品データ (optional)
     *
     * @throws \ColorMeShop\Swagger\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return \ColorMeShop\Swagger\Model\InlineResponse2009
     */
    public function updateProduct($product_id, $body = null)
    {
        list($response) = $this->updateProductWithHttpInfo($product_id, $body);
        return $response;
    }

    /**
     * Operation updateProductWithHttpInfo
     *
     * 商品データの更新
     *
     * @param  int $product_id 商品ID (required)
     * @param  \ColorMeShop\Swagger\Model\ProductsProductIdBody $body 商品データ (optional)
     *
     * @throws \ColorMeShop\Swagger\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \ColorMeShop\Swagger\Model\InlineResponse2009, HTTP status code, HTTP response headers (array of strings)
     */
    public function updateProductWithHttpInfo($product_id, $body = null)
    {
        $returnType = '\ColorMeShop\Swagger\Model\InlineResponse2009';
        $request = $this->updateProductRequest($product_id, $body);

        try {
            $options = $this->createHttpClientOption();
            try {
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
                );
            }

            $statusCode = $response->getStatusCode();

            if ($statusCode < 200 || $statusCode > 299) {
                throw new ApiException(
                    sprintf(
                        '[%d] Error connecting to the API (%s)',
                        $statusCode,
                        $request->getUri()
                    ),
                    $statusCode,
                    $response->getHeaders(),
                    $response->getBody()
                );
            }

            $responseBody = $response->getBody();
            if ($returnType === '\SplFileObject') {
                $content = $responseBody; //stream goes to serializer
            } else {
                $content = $responseBody->getContents();
                if (!in_array($returnType, ['string','integer','bool'])) {
                    $content = json_decode($content);
                }
            }

            return [
                ObjectSerializer::deserialize($content, $returnType, []),
                $response->getStatusCode(),
                $response->getHeaders()
            ];

        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ColorMeShop\Swagger\Model\InlineResponse2009',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
            }
            throw $e;
        }
    }

    /**
     * Operation updateProductAsync
     *
     * 商品データの更新
     *
     * @param  int $product_id 商品ID (required)
     * @param  \ColorMeShop\Swagger\Model\ProductsProductIdBody $body 商品データ (optional)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function updateProductAsync($product_id, $body = null)
    {
        return $this->updateProductAsyncWithHttpInfo($product_id, $body)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation updateProductAsyncWithHttpInfo
     *
     * 商品データの更新
     *
     * @param  int $product_id 商品ID (required)
     * @param  \ColorMeShop\Swagger\Model\ProductsProductIdBody $body 商品データ (optional)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function updateProductAsyncWithHttpInfo($product_id, $body = null)
    {
        $returnType = '\ColorMeShop\Swagger\Model\InlineResponse2009';
        $request = $this->updateProductRequest($product_id, $body);

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    $responseBody = $response->getBody();
                    if ($returnType === '\SplFileObject') {
                        $content = $responseBody; //stream goes to serializer
                    } else {
                        $content = $responseBody->getContents();
                        if ($returnType !== 'string') {
                            $content = json_decode($content);
                        }
                    }

                    return [
                        ObjectSerializer::deserialize($content, $returnType, []),
                        $response->getStatusCode(),
                        $response->getHeaders()
                    ];
                },
                function ($exception) {
                    $response = $exception->getResponse();
                    $statusCode = $response->getStatusCode();
                    throw new ApiException(
                        sprintf(
                            '[%d] Error connecting to the API (%s)',
                            $statusCode,
                            $exception->getRequest()->getUri()
                        ),
                        $statusCode,
                        $response->getHeaders(),
                        $response->getBody()
                    );
                }
            );
    }

    /**
     * Create request for operation 'updateProduct'
     *
     * @param  int $product_id 商品ID (required)
     * @param  \ColorMeShop\Swagger\Model\ProductsProductIdBody $body 商品データ (optional)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    protected function updateProductRequest($product_id, $body = null)
    {
        // verify the required parameter 'product_id' is set
        if ($product_id === null || (is_array($product_id) && count($product_id) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $product_id when calling updateProduct'
            );
        }

        $resourcePath = '/v1/products/{product_id}';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;


        // path params
        if ($product_id !== null) {
            $resourcePath = str_replace(
                '{' . 'product_id' . '}',
                ObjectSerializer::toPathValue($product_id),
                $resourcePath
            );
        }

        // body params
        $_tempBody = null;
        if (isset($body)) {
            $_tempBody = $body;
        }

        if ($multipart) {
            $headers = $this->headerSelector->selectHeadersForMultipart(
                ['application/json']
            );
        } else {
            $headers = $this->headerSelector->selectHeaders(
                ['application/json'],
                ['application/json']
            );
        }

        // for model (json/xml)
        if (isset($_tempBody)) {
            // $_tempBody is the method argument, if present
            $httpBody = $_tempBody;
            // \stdClass has no __toString(), so we should encode it manually
            if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') {
                $httpBody = \GuzzleHttp\json_encode($httpBody);
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $multipartContents[] = [
                        'name' => $formParamName,
                        'contents' => $formParamValue
                    ];
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);

            } elseif ($headers['Content-Type'] === 'application/json') {
                $httpBody = \GuzzleHttp\json_encode($formParams);

            } else {
                // for HTTP post (form)
                $httpBody = \GuzzleHttp\Psr7\build_query($formParams);
            }
        }

        // this endpoint requires OAuth (access token)
        if ($this->config->getAccessToken() !== null) {
            $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
        }

        $defaultHeaders = [];
        if ($this->config->getUserAgent()) {
            $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
        }

        $headers = array_merge(
            $defaultHeaders,
            $headerParams,
            $headers
        );

        $query = \GuzzleHttp\Psr7\build_query($queryParams);
        return new Request(
            'PUT',
            $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Create http client option
     *
     * @throws \RuntimeException on file opening failure
     * @return array of http client options
     */
    protected function createHttpClientOption()
    {
        $options = [];
        if ($this->config->getDebug()) {
            $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a');
            if (!$options[RequestOptions::DEBUG]) {
                throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile());
            }
        }

        return $options;
    }
}
