square-connect
Version:
JavaScript client library for the Square Connect v2 API
226 lines (193 loc) • 10.3 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 Money = require('./Money');
var OrderLineItemAppliedDiscount = require('./OrderLineItemAppliedDiscount');
var OrderLineItemAppliedTax = require('./OrderLineItemAppliedTax');
var OrderLineItemModifier = require('./OrderLineItemModifier');
var OrderLineItemPricingBlocklists = require('./OrderLineItemPricingBlocklists');
var OrderQuantityUnit = require('./OrderQuantityUnit');
/**
* The OrderLineItem model module.
* @module model/OrderLineItem
*/
/**
* Constructs a new <code>OrderLineItem</code>.
* Represents a line item in an order. Each line item describes a different product to purchase, with its own quantity and price details.
* @alias module:model/OrderLineItem
* @class
* @param quantity {String} The quantity purchased, formatted as a decimal number. For example: `\"3\"`. Line items with a quantity of `\"0\"` will be automatically removed upon paying for or otherwise completing the order. Line items with a `quantity_unit` can have non-integer quantities. For example: `\"1.70000\"`.
*/
var exports = function(quantity) {
var _this = this;
_this['quantity'] = quantity;
};
/**
* Constructs a <code>OrderLineItem</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/OrderLineItem} obj Optional instance to populate.
* @return {module:model/OrderLineItem} The populated <code>OrderLineItem</code> instance.
*/
exports.constructFromObject = function(data, obj) {
if (data) {
obj = obj || new exports();
if (data.hasOwnProperty('uid')) {
obj['uid'] = ApiClient.convertToType(data['uid'], 'String');
}
if (data.hasOwnProperty('name')) {
obj['name'] = ApiClient.convertToType(data['name'], 'String');
}
if (data.hasOwnProperty('quantity')) {
obj['quantity'] = ApiClient.convertToType(data['quantity'], 'String');
}
if (data.hasOwnProperty('quantity_unit')) {
obj['quantity_unit'] = OrderQuantityUnit.constructFromObject(data['quantity_unit']);
}
if (data.hasOwnProperty('note')) {
obj['note'] = ApiClient.convertToType(data['note'], 'String');
}
if (data.hasOwnProperty('catalog_object_id')) {
obj['catalog_object_id'] = ApiClient.convertToType(data['catalog_object_id'], 'String');
}
if (data.hasOwnProperty('variation_name')) {
obj['variation_name'] = ApiClient.convertToType(data['variation_name'], 'String');
}
if (data.hasOwnProperty('metadata')) {
obj['metadata'] = ApiClient.convertToType(data['metadata'], {'String': 'String'});
}
if (data.hasOwnProperty('modifiers')) {
obj['modifiers'] = ApiClient.convertToType(data['modifiers'], [OrderLineItemModifier]);
}
if (data.hasOwnProperty('applied_taxes')) {
obj['applied_taxes'] = ApiClient.convertToType(data['applied_taxes'], [OrderLineItemAppliedTax]);
}
if (data.hasOwnProperty('applied_discounts')) {
obj['applied_discounts'] = ApiClient.convertToType(data['applied_discounts'], [OrderLineItemAppliedDiscount]);
}
if (data.hasOwnProperty('base_price_money')) {
obj['base_price_money'] = Money.constructFromObject(data['base_price_money']);
}
if (data.hasOwnProperty('variation_total_price_money')) {
obj['variation_total_price_money'] = Money.constructFromObject(data['variation_total_price_money']);
}
if (data.hasOwnProperty('gross_sales_money')) {
obj['gross_sales_money'] = Money.constructFromObject(data['gross_sales_money']);
}
if (data.hasOwnProperty('total_tax_money')) {
obj['total_tax_money'] = Money.constructFromObject(data['total_tax_money']);
}
if (data.hasOwnProperty('total_discount_money')) {
obj['total_discount_money'] = Money.constructFromObject(data['total_discount_money']);
}
if (data.hasOwnProperty('total_money')) {
obj['total_money'] = Money.constructFromObject(data['total_money']);
}
if (data.hasOwnProperty('pricing_blocklists')) {
obj['pricing_blocklists'] = OrderLineItemPricingBlocklists.constructFromObject(data['pricing_blocklists']);
}
}
return obj;
}
/**
* Unique ID that identifies the line item only within this order.
* @member {String} uid
*/
exports.prototype['uid'] = undefined;
/**
* The name of the line item.
* @member {String} name
*/
exports.prototype['name'] = undefined;
/**
* The quantity purchased, formatted as a decimal number. For example: `\"3\"`. Line items with a quantity of `\"0\"` will be automatically removed upon paying for or otherwise completing the order. Line items with a `quantity_unit` can have non-integer quantities. For example: `\"1.70000\"`.
* @member {String} quantity
*/
exports.prototype['quantity'] = undefined;
/**
* The unit and precision that this line item's quantity is measured in.
* @member {module:model/OrderQuantityUnit} quantity_unit
*/
exports.prototype['quantity_unit'] = undefined;
/**
* The note of the line item.
* @member {String} note
*/
exports.prototype['note'] = undefined;
/**
* The `CatalogItemVariation` id applied to this line item.
* @member {String} catalog_object_id
*/
exports.prototype['catalog_object_id'] = undefined;
/**
* The name of the variation applied to this line item.
* @member {String} variation_name
*/
exports.prototype['variation_name'] = undefined;
/**
* Application-defined data attached to this line item. Metadata fields are intended to store descriptive references or associations with an entity in another system or store brief information about the object. Square does not process this field; it only stores and returns it in relevant API calls. Do not use metadata to store any sensitive information (personally identifiable information, card details, etc.). Keys written by applications must be 60 characters or less and must be in the character set `[a-zA-Z0-9_-]`. Entries may also include metadata generated by Square. These keys are prefixed with a namespace, separated from the key with a ':' character. Values have a max length of 255 characters. An application may have up to 10 entries per metadata field. Entries written by applications are private and can only be read or modified by the same application. See [Metadata](https://developer.squareup.com/docs/build-basics/metadata) for more information.
* @member {Object.<String, String>} metadata
*/
exports.prototype['metadata'] = undefined;
/**
* The `CatalogModifier`s applied to this line item.
* @member {Array.<module:model/OrderLineItemModifier>} modifiers
*/
exports.prototype['modifiers'] = undefined;
/**
* The list of references to taxes applied to this line item. Each `OrderLineItemAppliedTax` has a `tax_uid` that references the `uid` of a top-level `OrderLineItemTax` applied to the line item. On reads, the amount applied is populated. An `OrderLineItemAppliedTax` will be automatically created on every line item for all `ORDER` scoped taxes added to the order. `OrderLineItemAppliedTax` records for `LINE_ITEM` scoped taxes must be added in requests for the tax to apply to any line items. To change the amount of a tax, modify the referenced top-level tax.
* @member {Array.<module:model/OrderLineItemAppliedTax>} applied_taxes
*/
exports.prototype['applied_taxes'] = undefined;
/**
* The list of references to discounts applied to this line item. Each `OrderLineItemAppliedDiscount` has a `discount_uid` that references the `uid` of a top-level `OrderLineItemDiscounts` applied to the line item. On reads, the amount applied is populated. An `OrderLineItemAppliedDiscount` will be automatically created on every line item for all `ORDER` scoped discounts that are added to the order. `OrderLineItemAppliedDiscount` records for `LINE_ITEM` scoped discounts must be added in requests for the discount to apply to any line items. To change the amount of a discount, modify the referenced top-level discount.
* @member {Array.<module:model/OrderLineItemAppliedDiscount>} applied_discounts
*/
exports.prototype['applied_discounts'] = undefined;
/**
* The base price for a single unit of the line item.
* @member {module:model/Money} base_price_money
*/
exports.prototype['base_price_money'] = undefined;
/**
* The total price of all item variations sold in this line item. Calculated as `base_price_money` multiplied by `quantity`. Does not include modifiers.
* @member {module:model/Money} variation_total_price_money
*/
exports.prototype['variation_total_price_money'] = undefined;
/**
* The amount of money made in gross sales for this line item. Calculated as the sum of the variation's total price and each modifier's total price.
* @member {module:model/Money} gross_sales_money
*/
exports.prototype['gross_sales_money'] = undefined;
/**
* The total tax amount of money to collect for the line item.
* @member {module:model/Money} total_tax_money
*/
exports.prototype['total_tax_money'] = undefined;
/**
* The total discount amount of money to collect for the line item.
* @member {module:model/Money} total_discount_money
*/
exports.prototype['total_discount_money'] = undefined;
/**
* The total amount of money to collect for this line item.
* @member {module:model/Money} total_money
*/
exports.prototype['total_money'] = undefined;
/**
* Describes pricing adjustments that are blocked from manual and automatic application to a line item. For more information, see [Apply Taxes and Discounts](https://developer.squareup.com/docs/docs/orders-api/apply-taxes-and-discounts).
* @member {module:model/OrderLineItemPricingBlocklists} pricing_blocklists
*/
exports.prototype['pricing_blocklists'] = undefined;
module.exports = exports;