/*
 * Selling Partner API for Product Type Definitions
 * The Selling Partner API for Product Type Definitions provides programmatic access to attribute and data requirements for product types in the Amazon catalog. Use this API to return the JSON Schema for a product type that you can then use with other Selling Partner APIs, such as the Selling Partner API for Listings Items, the Selling Partner API for Catalog Items, and the Selling Partner API for Feeds (for JSON-based listing feeds).  For more information, see the [Product Type Definitions API Use Case Guide](doc:product-type-api-use-case-guide).
 *
 * OpenAPI spec version: 2020-09-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 { ProductTypeVersion } from "./ProductTypeVersion.js";
import { PropertyGroup } from "./PropertyGroup.js";
import { SchemaLink } from "./SchemaLink.js";

/**
 * The ProductTypeDefinition model module.
 * @module definitionsProductTypes_2020-09-01/js-client.definitionsProductTypes_2020-09-01.model/ProductTypeDefinition
 * @version 2020-09-01
 */
export class ProductTypeDefinition {
  /**
   * Constructs a new <code>ProductTypeDefinition</code>.
   * A product type definition represents the attributes and data requirements for a product type in the Amazon catalog. Product type definitions are used interchangeably between the Selling Partner API for Listings Items, Selling Partner API for Catalog Items, and JSON-based listings feeds in the Selling Partner API for Feeds.
   * @alias module:definitionsProductTypes_2020-09-01/js-client.definitionsProductTypes_2020-09-01.model/ProductTypeDefinition
   * @class
   * @param schema {module:definitionsProductTypes_2020-09-01/js-client.definitionsProductTypes_2020-09-01.model/SchemaLink} Link to schema describing the attributes and requirements for the product type.
   * @param requirements {module:definitionsProductTypes_2020-09-01/js-client.definitionsProductTypes_2020-09-01.model/ProductTypeDefinition.RequirementsEnum} Name of the requirements set represented in this product type definition.
   * @param requirementsEnforced {module:definitionsProductTypes_2020-09-01/js-client.definitionsProductTypes_2020-09-01.model/ProductTypeDefinition.RequirementsEnforcedEnum} Identifies if the required attributes for a requirements set are enforced by the product type definition schema. Non-enforced requirements enable structural validation of individual attributes without all of the required attributes being present (such as for partial updates).
   * @param propertyGroups {Object.<String, module:definitionsProductTypes_2020-09-01/js-client.definitionsProductTypes_2020-09-01.model/PropertyGroup>} Mapping of property group names to property groups. Property groups represent logical groupings of schema properties that can be used for display or informational purposes.
   * @param locale {String} Locale of the display elements contained in the product type definition.
   * @param marketplaceIds {Array.<String>} Amazon marketplace identifiers for which the product type definition is applicable.
   * @param productType {String} The name of the Amazon product type that this product type definition applies to.
   * @param productTypeVersion {module:definitionsProductTypes_2020-09-01/js-client.definitionsProductTypes_2020-09-01.model/ProductTypeVersion} The version details for the Amazon product type.
   */
  constructor(
    schema,
    requirements,
    requirementsEnforced,
    propertyGroups,
    locale,
    marketplaceIds,
    productType,
    productTypeVersion,
  ) {
    this.schema = schema;
    this.requirements = requirements;
    this.requirementsEnforced = requirementsEnforced;
    this.propertyGroups = propertyGroups;
    this.locale = locale;
    this.marketplaceIds = marketplaceIds;
    this.productType = productType;
    this.productTypeVersion = productTypeVersion;
  }

  /**
   * Constructs a <code>ProductTypeDefinition</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:definitionsProductTypes_2020-09-01/js-client.definitionsProductTypes_2020-09-01.model/ProductTypeDefinition} obj Optional instance to populate.
   * @return {module:definitionsProductTypes_2020-09-01/js-client.definitionsProductTypes_2020-09-01.model/ProductTypeDefinition} The populated <code>ProductTypeDefinition</code> instance.
   */
  static constructFromObject(data, obj) {
    if (data) {
      obj = obj || new ProductTypeDefinition();
      if (data.hasOwnProperty("metaSchema"))
        obj.metaSchema = SchemaLink.constructFromObject(data["metaSchema"]);
      if (data.hasOwnProperty("schema"))
        obj.schema = SchemaLink.constructFromObject(data["schema"]);
      if (data.hasOwnProperty("requirements"))
        obj.requirements = ApiClient.convertToType(
          data["requirements"],
          "String",
        );
      if (data.hasOwnProperty("requirementsEnforced"))
        obj.requirementsEnforced = ApiClient.convertToType(
          data["requirementsEnforced"],
          "String",
        );
      if (data.hasOwnProperty("propertyGroups"))
        obj.propertyGroups = ApiClient.convertToType(data["propertyGroups"], {
          String: PropertyGroup,
        });
      if (data.hasOwnProperty("locale"))
        obj.locale = ApiClient.convertToType(data["locale"], "String");
      if (data.hasOwnProperty("marketplaceIds"))
        obj.marketplaceIds = ApiClient.convertToType(data["marketplaceIds"], [
          "String",
        ]);
      if (data.hasOwnProperty("productType"))
        obj.productType = ApiClient.convertToType(
          data["productType"],
          "String",
        );
      if (data.hasOwnProperty("productTypeVersion"))
        obj.productTypeVersion = ProductTypeVersion.constructFromObject(
          data["productTypeVersion"],
        );
    }
    return obj;
  }
}

/**
 * Link to meta-schema describing the vocabulary used by the product type schema.
 * @member {module:definitionsProductTypes_2020-09-01/js-client.definitionsProductTypes_2020-09-01.model/SchemaLink} metaSchema
 */
ProductTypeDefinition.prototype.metaSchema = undefined;

/**
 * Link to schema describing the attributes and requirements for the product type.
 * @member {module:definitionsProductTypes_2020-09-01/js-client.definitionsProductTypes_2020-09-01.model/SchemaLink} schema
 */
ProductTypeDefinition.prototype.schema = undefined;

/**
 * Allowed values for the <code>requirements</code> property.
 * @enum {String}
 * @readonly
 */
ProductTypeDefinition.RequirementsEnum = {
  /**
   * value: "LISTING"
   * @const
   */
  LISTING: "LISTING",

  /**
   * value: "LISTING_PRODUCT_ONLY"
   * @const
   */
  LISTING_PRODUCT_ONLY: "LISTING_PRODUCT_ONLY",

  /**
   * value: "LISTING_OFFER_ONLY"
   * @const
   */
  LISTING_OFFER_ONLY: "LISTING_OFFER_ONLY",
};

/**
 * Name of the requirements set represented in this product type definition.
 * @member {module:definitionsProductTypes_2020-09-01/js-client.definitionsProductTypes_2020-09-01.model/ProductTypeDefinition.RequirementsEnum} requirements
 */
ProductTypeDefinition.prototype.requirements = undefined;

/**
 * Allowed values for the <code>requirementsEnforced</code> property.
 * @enum {String}
 * @readonly
 */
ProductTypeDefinition.RequirementsEnforcedEnum = {
  /**
   * value: "ENFORCED"
   * @const
   */
  ENFORCED: "ENFORCED",

  /**
   * value: "NOT_ENFORCED"
   * @const
   */
  NOT_ENFORCED: "NOT_ENFORCED",
};

/**
 * Identifies if the required attributes for a requirements set are enforced by the product type definition schema. Non-enforced requirements enable structural validation of individual attributes without all of the required attributes being present (such as for partial updates).
 * @member {module:definitionsProductTypes_2020-09-01/js-client.definitionsProductTypes_2020-09-01.model/ProductTypeDefinition.RequirementsEnforcedEnum} requirementsEnforced
 */
ProductTypeDefinition.prototype.requirementsEnforced = undefined;

/**
 * Mapping of property group names to property groups. Property groups represent logical groupings of schema properties that can be used for display or informational purposes.
 * @member {Object.<String, module:definitionsProductTypes_2020-09-01/js-client.definitionsProductTypes_2020-09-01.model/PropertyGroup>} propertyGroups
 */
ProductTypeDefinition.prototype.propertyGroups = undefined;

/**
 * Locale of the display elements contained in the product type definition.
 * @member {String} locale
 */
ProductTypeDefinition.prototype.locale = undefined;

/**
 * Amazon marketplace identifiers for which the product type definition is applicable.
 * @member {Array.<String>} marketplaceIds
 */
ProductTypeDefinition.prototype.marketplaceIds = undefined;

/**
 * The name of the Amazon product type that this product type definition applies to.
 * @member {String} productType
 */
ProductTypeDefinition.prototype.productType = undefined;

/**
 * The version details for the Amazon product type.
 * @member {module:definitionsProductTypes_2020-09-01/js-client.definitionsProductTypes_2020-09-01.model/ProductTypeVersion} productTypeVersion
 */
ProductTypeDefinition.prototype.productTypeVersion = undefined;
