square-connect
Version:
JavaScript client library for the Square Connect v2 API
188 lines (159 loc) • 6.28 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 AdditionalRecipient = require('./AdditionalRecipient');
var Money = require('./Money');
var TenderCardDetails = require('./TenderCardDetails');
var TenderCashDetails = require('./TenderCashDetails');
/**
* The Tender model module.
* @module model/Tender
*/
/**
* Constructs a new <code>Tender</code>.
* Represents a tender (i.e., a method of payment) used in a Square transaction.
* @alias module:model/Tender
* @class
* @param type {String} The type of tender, such as `CARD` or `CASH`. See [TenderType](#type-tendertype) for possible values
*/
var exports = function(type) {
var _this = this;
_this['type'] = type;
};
/**
* Constructs a <code>Tender</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/Tender} obj Optional instance to populate.
* @return {module:model/Tender} The populated <code>Tender</code> instance.
*/
exports.constructFromObject = function(data, obj) {
if (data) {
obj = obj || new exports();
if (data.hasOwnProperty('id')) {
obj['id'] = ApiClient.convertToType(data['id'], 'String');
}
if (data.hasOwnProperty('location_id')) {
obj['location_id'] = ApiClient.convertToType(data['location_id'], 'String');
}
if (data.hasOwnProperty('transaction_id')) {
obj['transaction_id'] = ApiClient.convertToType(data['transaction_id'], 'String');
}
if (data.hasOwnProperty('created_at')) {
obj['created_at'] = ApiClient.convertToType(data['created_at'], 'String');
}
if (data.hasOwnProperty('note')) {
obj['note'] = ApiClient.convertToType(data['note'], 'String');
}
if (data.hasOwnProperty('amount_money')) {
obj['amount_money'] = Money.constructFromObject(data['amount_money']);
}
if (data.hasOwnProperty('tip_money')) {
obj['tip_money'] = Money.constructFromObject(data['tip_money']);
}
if (data.hasOwnProperty('processing_fee_money')) {
obj['processing_fee_money'] = Money.constructFromObject(data['processing_fee_money']);
}
if (data.hasOwnProperty('customer_id')) {
obj['customer_id'] = ApiClient.convertToType(data['customer_id'], 'String');
}
if (data.hasOwnProperty('type')) {
obj['type'] = ApiClient.convertToType(data['type'], 'String');
}
if (data.hasOwnProperty('card_details')) {
obj['card_details'] = TenderCardDetails.constructFromObject(data['card_details']);
}
if (data.hasOwnProperty('cash_details')) {
obj['cash_details'] = TenderCashDetails.constructFromObject(data['cash_details']);
}
if (data.hasOwnProperty('additional_recipients')) {
obj['additional_recipients'] = ApiClient.convertToType(data['additional_recipients'], [AdditionalRecipient]);
}
if (data.hasOwnProperty('payment_id')) {
obj['payment_id'] = ApiClient.convertToType(data['payment_id'], 'String');
}
}
return obj;
}
/**
* The tender's unique ID.
* @member {String} id
*/
exports.prototype['id'] = undefined;
/**
* The ID of the transaction's associated location.
* @member {String} location_id
*/
exports.prototype['location_id'] = undefined;
/**
* The ID of the tender's associated transaction.
* @member {String} transaction_id
*/
exports.prototype['transaction_id'] = undefined;
/**
* The timestamp for when the tender was created, in RFC 3339 format.
* @member {String} created_at
*/
exports.prototype['created_at'] = undefined;
/**
* An optional note associated with the tender at the time of payment.
* @member {String} note
*/
exports.prototype['note'] = undefined;
/**
* The total amount of the tender, including `tip_money`. If the tender has a `payment_id`, the `total_money` of the corresponding `Payment` will be equal to the `amount_money` of the tender.
* @member {module:model/Money} amount_money
*/
exports.prototype['amount_money'] = undefined;
/**
* The tip's amount of the tender.
* @member {module:model/Money} tip_money
*/
exports.prototype['tip_money'] = undefined;
/**
* The amount of any Square processing fees applied to the tender. This field is not immediately populated when a new transaction is created. It is usually available after about ten seconds.
* @member {module:model/Money} processing_fee_money
*/
exports.prototype['processing_fee_money'] = undefined;
/**
* If the tender is associated with a customer or represents a customer's card on file, this is the ID of the associated customer.
* @member {String} customer_id
*/
exports.prototype['customer_id'] = undefined;
/**
* The type of tender, such as `CARD` or `CASH`. See [TenderType](#type-tendertype) for possible values
* @member {String} type
*/
exports.prototype['type'] = undefined;
/**
* The details of the card tender. This value is present only if the value of `type` is `CARD`.
* @member {module:model/TenderCardDetails} card_details
*/
exports.prototype['card_details'] = undefined;
/**
* The details of the cash tender. This value is present only if the value of `type` is `CASH`.
* @member {module:model/TenderCashDetails} cash_details
*/
exports.prototype['cash_details'] = undefined;
/**
* Additional recipients (other than the merchant) receiving a portion of this tender. For example, fees assessed on the purchase by a third party integration.
* @member {Array.<module:model/AdditionalRecipient>} additional_recipients
*/
exports.prototype['additional_recipients'] = undefined;
/**
* The ID of the `Payment` that corresponds to this tender. This value is only present for payments created with the v2 Payments API.
* @member {String} payment_id
*/
exports.prototype['payment_id'] = undefined;
module.exports = exports;