/*
 * Selling Partner API for Catalog Items
 * The Selling Partner API for Catalog Items provides programmatic access to information about items in the Amazon catalog.  For more information, refer to the [Catalog Items API Use Case Guide](doc:catalog-items-api-v2022-04-01-use-case-guide).
 *
 * OpenAPI spec version: 2022-04-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 { Item } from "./Item.js";
import { Pagination } from "./Pagination.js";
import { Refinements } from "./Refinements.js";

/**
 * The ItemSearchResults model module.
 * @module catalogItems_2022-04-01/js-client.catalogItems_2022-04-01.model/ItemSearchResults
 * @version 2022-04-01
 */
export class ItemSearchResults {
  /**
   * Constructs a new <code>ItemSearchResults</code>.
   * Items in the Amazon catalog and search related metadata.
   * @alias module:catalogItems_2022-04-01/js-client.catalogItems_2022-04-01.model/ItemSearchResults
   * @class
   * @param numberOfResults {Number} For `identifiers`-based searches, the total number of Amazon catalog items found. For `keywords`-based searches, the estimated total number of Amazon catalog items matched by the search query (only results up to the page count limit will be returned per request regardless of the number found).  Note: The maximum number of items (ASINs) that can be returned and paged through is 1000.
   * @param pagination {module:catalogItems_2022-04-01/js-client.catalogItems_2022-04-01.model/Pagination} If available, the `nextToken` and/or `previousToken` values required to return paginated results.
   * @param refinements {module:catalogItems_2022-04-01/js-client.catalogItems_2022-04-01.model/Refinements} Search refinements for `keywords`-based searches.
   * @param items {Array.<module:catalogItems_2022-04-01/js-client.catalogItems_2022-04-01.model/Item>} A list of items from the Amazon catalog.
   */
  constructor(numberOfResults, pagination, refinements, items) {
    this.numberOfResults = numberOfResults;
    this.pagination = pagination;
    this.refinements = refinements;
    this.items = items;
  }

  /**
   * Constructs a <code>ItemSearchResults</code> from a plain JavaScript object, optionally creating a new instance.
   * Copies all relevant properties from <code>data</code> to <code>obj</code> if supplied or a new instance if not.
   * @param {Object} data The plain JavaScript object bearing properties of interest.
   * @param {module:catalogItems_2022-04-01/js-client.catalogItems_2022-04-01.model/ItemSearchResults} obj Optional instance to populate.
   * @return {module:catalogItems_2022-04-01/js-client.catalogItems_2022-04-01.model/ItemSearchResults} The populated <code>ItemSearchResults</code> instance.
   */
  static constructFromObject(data, obj) {
    if (data) {
      obj = obj || new ItemSearchResults();
      if (data.hasOwnProperty("numberOfResults"))
        obj.numberOfResults = ApiClient.convertToType(
          data["numberOfResults"],
          "Number",
        );
      if (data.hasOwnProperty("pagination"))
        obj.pagination = Pagination.constructFromObject(data["pagination"]);
      if (data.hasOwnProperty("refinements"))
        obj.refinements = Refinements.constructFromObject(data["refinements"]);
      if (data.hasOwnProperty("items"))
        obj.items = ApiClient.convertToType(data["items"], [Item]);
    }
    return obj;
  }
}

/**
 * For `identifiers`-based searches, the total number of Amazon catalog items found. For `keywords`-based searches, the estimated total number of Amazon catalog items matched by the search query (only results up to the page count limit will be returned per request regardless of the number found).  Note: The maximum number of items (ASINs) that can be returned and paged through is 1000.
 * @member {Number} numberOfResults
 */
ItemSearchResults.prototype.numberOfResults = undefined;

/**
 * If available, the `nextToken` and/or `previousToken` values required to return paginated results.
 * @member {module:catalogItems_2022-04-01/js-client.catalogItems_2022-04-01.model/Pagination} pagination
 */
ItemSearchResults.prototype.pagination = undefined;

/**
 * Search refinements for `keywords`-based searches.
 * @member {module:catalogItems_2022-04-01/js-client.catalogItems_2022-04-01.model/Refinements} refinements
 */
ItemSearchResults.prototype.refinements = undefined;

/**
 * A list of items from the Amazon catalog.
 * @member {Array.<module:catalogItems_2022-04-01/js-client.catalogItems_2022-04-01.model/Item>} items
 */
ItemSearchResults.prototype.items = undefined;
