/*
 * Selling Partner API for Listings Restrictions
 * The Selling Partner API for Listings Restrictions provides programmatic access to restrictions on Amazon catalog listings.  For more information, see the [Listings Restrictions API Use Case Guide](doc:listings-restrictions-api-v2021-08-01-use-case-guide).
 *
 * OpenAPI spec version: 2021-08-01
 *
 * NOTE: This class is auto generated by the swagger code generator program.
 * https://github.com/swagger-api/swagger-codegen.git
 *
 * Swagger Codegen version: 2.4.9
 *
 * Do not edit the class manually.
 *
 */

import { ApiClient } from "../ApiClient.js";
import { ErrorList } from "../js-client.listingsRestrictions_2021-08-01.model/ErrorList.js";
import { RestrictionList } from "../js-client.listingsRestrictions_2021-08-01.model/RestrictionList.js";
import { HEADER_DATA } from "../../constants/global";

/**
 * Listings service.
 * @module listingsRestrictions_2021-08-01/js-client.listingsRestrictions_2021-08-01.api/ListingsApi
 * @version 2021-08-01
 */
export class ListingsApi {
  /**
   * Constructs a new ListingsApi.
   * @alias module:listingsRestrictions_2021-08-01/js-client.listingsRestrictions_2021-08-01.api/ListingsApi
   * @class
   * @param {module:listingsRestrictions_2021-08-01/ApiClient} [apiClient] Optional API client implementation to use,
   * default to {@link module:listingsRestrictions_2021-08-01/ApiClient#instance} if unspecified.
   */
  constructor(apiClient) {
    this.apiClient = apiClient || ApiClient.instance;
  }

  /**
   * Returns listing restrictions for an item in the Amazon Catalog.   **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 5 | 10 |  The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values then those shown here. For more information, see [Usage Plans and Rate Limits in the Selling Partner API](doc:usage-plans-and-rate-limits-in-the-sp-api).
   * @param {String} asin The Amazon Standard Identification Number (ASIN) of the item.
   * @param {String} sellerId A selling partner identifier, such as a merchant account.
   * @param {Array.<String>} marketplaceIds A comma-delimited list of Amazon marketplace identifiers for the request.
   * @param {Object} opts Optional parameters
   * @param {module:listingsRestrictions_2021-08-01/js-client.listingsRestrictions_2021-08-01.model/String} opts.conditionType The condition used to filter restrictions.
   * @param {String} opts.reasonLocale A locale for reason text localization. When not provided, the default language code of the first marketplace is used. Examples: \"en_US\", \"fr_CA\", \"fr_FR\". Localized messages default to \"en_US\" when a localization is not available in the specified locale.
   * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:listingsRestrictions_2021-08-01/js-client.listingsRestrictions_2021-08-01.model/RestrictionList} and HTTP response
   */
  getListingsRestrictionsWithHttpInfo(asin, sellerId, marketplaceIds, opts) {
    opts = opts || {};
    let postBody = null;

    // verify the required parameter 'asin' is set
    if (asin === undefined || asin === null) {
      throw new Error(
        "Missing the required parameter 'asin' when calling getListingsRestrictions",
      );
    }

    // verify the required parameter 'sellerId' is set
    if (sellerId === undefined || sellerId === null) {
      throw new Error(
        "Missing the required parameter 'sellerId' when calling getListingsRestrictions",
      );
    }

    // verify the required parameter 'marketplaceIds' is set
    if (marketplaceIds === undefined || marketplaceIds === null) {
      throw new Error(
        "Missing the required parameter 'marketplaceIds' when calling getListingsRestrictions",
      );
    }

    let pathParams = {};
    let queryParams = {
      asin: asin,
      conditionType: opts["conditionType"],
      sellerId: sellerId,
      marketplaceIds: this.apiClient.buildCollectionParam(
        marketplaceIds,
        "csv",
      ),
      reasonLocale: opts["reasonLocale"],
    };
    let headerParams = HEADER_DATA;
    let formParams = {};

    let contentTypes = ["application/json"];
    let accepts = ["application/json"];
    let returnType = RestrictionList;

    return this.apiClient.callApi(
      "/listings/2021-08-01/restrictions",
      "GET",
      pathParams,
      queryParams,
      headerParams,
      formParams,
      postBody,
      contentTypes,
      accepts,
      returnType,
    );
  }

  /**
   * Returns listing restrictions for an item in the Amazon Catalog.   **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 5 | 10 |  The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values then those shown here. For more information, see [Usage Plans and Rate Limits in the Selling Partner API](doc:usage-plans-and-rate-limits-in-the-sp-api).
   * @param {String} asin The Amazon Standard Identification Number (ASIN) of the item.
   * @param {String} sellerId A selling partner identifier, such as a merchant account.
   * @param {Array.<String>} marketplaceIds A comma-delimited list of Amazon marketplace identifiers for the request.
   * @param {Object} opts Optional parameters
   * @param {module:listingsRestrictions_2021-08-01/js-client.listingsRestrictions_2021-08-01.model/String} opts.conditionType The condition used to filter restrictions.
   * @param {String} opts.reasonLocale A locale for reason text localization. When not provided, the default language code of the first marketplace is used. Examples: \"en_US\", \"fr_CA\", \"fr_FR\". Localized messages default to \"en_US\" when a localization is not available in the specified locale.
   * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:listingsRestrictions_2021-08-01/js-client.listingsRestrictions_2021-08-01.model/RestrictionList}
   */
  getListingsRestrictions(asin, sellerId, marketplaceIds, opts) {
    return this.getListingsRestrictionsWithHttpInfo(
      asin,
      sellerId,
      marketplaceIds,
      opts,
    ).then(function (response_and_data) {
      return response_and_data.data;
    });
  }
}
