square-connect
Version:
JavaScript client library for the Square Connect v2 API
173 lines (148 loc) • 8.45 kB
JavaScript
/**
* Square Connect API
* Client library for accessing the Square Connect APIs
*
* OpenAPI spec version: 2.0
* Contact: developers@squareup.com
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
*
* Swagger Codegen version: 2.3.0-SNAPSHOT
*
*/
var ApiClient = require('../ApiClient');
var CatalogCustomAttributeDefinitionNumberConfig = require('./CatalogCustomAttributeDefinitionNumberConfig');
var CatalogCustomAttributeDefinitionSelectionConfig = require('./CatalogCustomAttributeDefinitionSelectionConfig');
var CatalogCustomAttributeDefinitionStringConfig = require('./CatalogCustomAttributeDefinitionStringConfig');
var SourceApplication = require('./SourceApplication');
/**
* The CatalogCustomAttributeDefinition model module.
* Note: This model is in beta.
* @module model/CatalogCustomAttributeDefinition
*/
/**
* Constructs a new <code>CatalogCustomAttributeDefinition</code>.
* Contains information defining a custom attribute. Custom attributes are intended to store additional information about a catalog object or to associate a catalog object with an entity in another system. Do not use custom attributes to store any sensitive information (personally identifiable information, card details, etc.). [Read more about custom attributes](/catalog-api/add-custom-attributes)
* @alias module:model/CatalogCustomAttributeDefinition
* @class
* @param type {String} The type of this custom attribute. Cannot be modified after creation. Required. See [CatalogCustomAttributeDefinitionType](#type-catalogcustomattributedefinitiontype) for possible values
* @param name {String} The name of this definition for API and seller-facing UI purposes. The name must be unique within the (merchant, application) pair. Required. May not be empty and may not exceed 255 characters. Can be modified after creation.
* @param allowedObjectTypes {Array.<String>} The set of Catalog Object Types that this Custom Attribute may be applied to. Currently, only `ITEM` and `ITEM_VARIATION` are allowed. At least one type must be included. See [CatalogObjectType](#type-catalogobjecttype) for possible values
*/
var exports = function(type, name, allowedObjectTypes) {
var _this = this;
_this['type'] = type;
_this['name'] = name;
_this['allowed_object_types'] = allowedObjectTypes;
};
/**
* Constructs a <code>CatalogCustomAttributeDefinition</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:model/CatalogCustomAttributeDefinition} obj Optional instance to populate.
* @return {module:model/CatalogCustomAttributeDefinition} The populated <code>CatalogCustomAttributeDefinition</code> instance.
*/
exports.constructFromObject = function(data, obj) {
if (data) {
obj = obj || new exports();
if (data.hasOwnProperty('type')) {
obj['type'] = ApiClient.convertToType(data['type'], 'String');
}
if (data.hasOwnProperty('name')) {
obj['name'] = ApiClient.convertToType(data['name'], 'String');
}
if (data.hasOwnProperty('description')) {
obj['description'] = ApiClient.convertToType(data['description'], 'String');
}
if (data.hasOwnProperty('source_application')) {
obj['source_application'] = SourceApplication.constructFromObject(data['source_application']);
}
if (data.hasOwnProperty('allowed_object_types')) {
obj['allowed_object_types'] = ApiClient.convertToType(data['allowed_object_types'], ['String']);
}
if (data.hasOwnProperty('seller_visibility')) {
obj['seller_visibility'] = ApiClient.convertToType(data['seller_visibility'], 'String');
}
if (data.hasOwnProperty('app_visibility')) {
obj['app_visibility'] = ApiClient.convertToType(data['app_visibility'], 'String');
}
if (data.hasOwnProperty('string_config')) {
obj['string_config'] = CatalogCustomAttributeDefinitionStringConfig.constructFromObject(data['string_config']);
}
if (data.hasOwnProperty('number_config')) {
obj['number_config'] = CatalogCustomAttributeDefinitionNumberConfig.constructFromObject(data['number_config']);
}
if (data.hasOwnProperty('selection_config')) {
obj['selection_config'] = CatalogCustomAttributeDefinitionSelectionConfig.constructFromObject(data['selection_config']);
}
if (data.hasOwnProperty('custom_attribute_usage_count')) {
obj['custom_attribute_usage_count'] = ApiClient.convertToType(data['custom_attribute_usage_count'], 'Number');
}
if (data.hasOwnProperty('key')) {
obj['key'] = ApiClient.convertToType(data['key'], 'String');
}
}
return obj;
}
/**
* The type of this custom attribute. Cannot be modified after creation. Required. See [CatalogCustomAttributeDefinitionType](#type-catalogcustomattributedefinitiontype) for possible values
* @member {String} type
*/
exports.prototype['type'] = undefined;
/**
* The name of this definition for API and seller-facing UI purposes. The name must be unique within the (merchant, application) pair. Required. May not be empty and may not exceed 255 characters. Can be modified after creation.
* @member {String} name
*/
exports.prototype['name'] = undefined;
/**
* Seller-oriented description of the meaning of this Custom Attribute, any constraints that the seller should observe, etc. May be displayed as a tooltip in Square UIs.
* @member {String} description
*/
exports.prototype['description'] = undefined;
/**
* __Read only.__ Contains information about the application that created this custom attribute definition.
* @member {module:model/SourceApplication} source_application
*/
exports.prototype['source_application'] = undefined;
/**
* The set of Catalog Object Types that this Custom Attribute may be applied to. Currently, only `ITEM` and `ITEM_VARIATION` are allowed. At least one type must be included. See [CatalogObjectType](#type-catalogobjecttype) for possible values
* @member {Array.<String>} allowed_object_types
*/
exports.prototype['allowed_object_types'] = undefined;
/**
* The visibility of a custom attribute in seller-facing UIs (including Square Point of Sale applications and Square Dashboard). May be modified. See [CatalogCustomAttributeDefinitionSellerVisibility](#type-catalogcustomattributedefinitionsellervisibility) for possible values
* @member {String} seller_visibility
*/
exports.prototype['seller_visibility'] = undefined;
/**
* The visibility of a custom attribute to applications other than the application that created the attribute. See [CatalogCustomAttributeDefinitionAppVisibility](#type-catalogcustomattributedefinitionappvisibility) for possible values
* @member {String} app_visibility
*/
exports.prototype['app_visibility'] = undefined;
/**
* Optionally, populated when `type` = `STRING`, unset otherwise.
* @member {module:model/CatalogCustomAttributeDefinitionStringConfig} string_config
*/
exports.prototype['string_config'] = undefined;
/**
* Optionally, populated when `type` = `NUMBER`, unset otherwise.
* @member {module:model/CatalogCustomAttributeDefinitionNumberConfig} number_config
*/
exports.prototype['number_config'] = undefined;
/**
* Populated when `type` is set to `SELECTION`, unset otherwise.
* @member {module:model/CatalogCustomAttributeDefinitionSelectionConfig} selection_config
*/
exports.prototype['selection_config'] = undefined;
/**
* __Read-only.__ The number of custom attributes that reference this custom attribute definition. Set by the server in response to a ListCatalog request with `include_counts` set to `true`. If the actual count is greater than 100, `custom_attribute_usage_count` will be set to `100`.
* @member {Number} custom_attribute_usage_count
*/
exports.prototype['custom_attribute_usage_count'] = undefined;
/**
* The name of the desired custom attribute key that can be used to access the custom attribute value on catalog objects. Cannot be modified after the custom attribute definition has been created. Must be between 1 and 60 characters, and may only contain the characters `[a-zA-Z0-9_-]`.
* @member {String} key
*/
exports.prototype['key'] = undefined;
module.exports = exports;