Class: SquareConnect::V1Tender
- Inherits:
-
Object
- Object
- SquareConnect::V1Tender
- Defined in:
- lib/square_connect/models/v1_tender.rb
Overview
A tender represents a discrete monetary exchange. Square represents this exchange as a money object with a specific currency and amount, where the amount is given in the smallest denomination of the given currency. Square POS can accept more than one form of tender for a single payment (such as by splitting a bill between a credit card and a gift card). The ‘tender` field of the Payment object lists all forms of tender used for the payment. Split tender payments behave slightly differently from single tender payments: The receipt_url for a split tender corresponds only to the first tender listed in the tender field. To get the receipt URLs for the remaining tenders, use the receipt_url fields of the corresponding Tender objects. *A note on gift cards**: when a customer purchases a Square gift card from a merchant, the merchant receives the full amount of the gift card in the associated payment. When that gift card is used as a tender, the balance of the gift card is reduced and the merchant receives no funds. A `Tender` object with a type of `SQUARE_GIFT_CARD` indicates a gift card was used for some or all of the associated payment.
Defined Under Namespace
Classes: EnumAttributeValidator
Instance Attribute Summary collapse
-
#card_brand ⇒ Object
The brand of credit card provided.
-
#change_back_money ⇒ Object
The amount of total_money returned to the buyer as change.
-
#employee_id ⇒ Object
The ID of the employee that processed the tender.
-
#entry_method ⇒ Object
The tender’s unique ID.
-
#id ⇒ Object
The tender’s unique ID.
-
#is_exchange ⇒ Object
Indicates whether or not the tender is associated with an exchange.
-
#name ⇒ Object
A human-readable description of the tender.
-
#pan_suffix ⇒ Object
The last four digits of the provided credit card’s account number.
-
#payment_note ⇒ Object
Notes entered by the merchant about the tender at the time of payment, if any.
-
#receipt_url ⇒ Object
The URL of the receipt for the tender.
-
#refunded_money ⇒ Object
The total of all refunds applied to this tender.
-
#settled_at ⇒ Object
The time when the tender was settled, in ISO 8601 format.
-
#tendered_at ⇒ Object
The time when the tender was created, in ISO 8601 format.
-
#tendered_money ⇒ Object
The amount of total_money applied to the payment.
-
#total_money ⇒ Object
The total amount of money provided in this form of tender.
-
#type ⇒ Object
The type of tender.
Class Method Summary collapse
-
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
-
.swagger_types ⇒ Object
Attribute type mapping.
Instance Method Summary collapse
-
#==(o) ⇒ Object
Checks equality by comparing each attribute.
-
#_deserialize(type, value) ⇒ Object
Deserializes the data based on type.
-
#_to_hash(value) ⇒ Hash
Outputs non-array value in the form of hash For object, use to_hash.
-
#build_from_hash(attributes) ⇒ Object
Builds the object from hash.
- #eql?(o) ⇒ Boolean
-
#hash ⇒ Fixnum
Calculates hash code according to all attributes.
-
#initialize(attributes = {}) ⇒ V1Tender
constructor
Initializes the object.
-
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons.
-
#to_body ⇒ Hash
to_body is an alias to to_hash (backward compatibility).
-
#to_hash ⇒ Hash
Returns the object in the form of hash.
-
#to_s ⇒ String
Returns the string representation of the object.
-
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid.
Constructor Details
#initialize(attributes = {}) ⇒ V1Tender
Initializes the object
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
# File 'lib/square_connect/models/v1_tender.rb', line 131 def initialize(attributes = {}) return unless attributes.is_a?(Hash) # convert string to symbol for hash key attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} if attributes.has_key?(:'id') self.id = attributes[:'id'] end if attributes.has_key?(:'type') self.type = attributes[:'type'] end if attributes.has_key?(:'name') self.name = attributes[:'name'] end if attributes.has_key?(:'employee_id') self.employee_id = attributes[:'employee_id'] end if attributes.has_key?(:'receipt_url') self.receipt_url = attributes[:'receipt_url'] end if attributes.has_key?(:'card_brand') self.card_brand = attributes[:'card_brand'] end if attributes.has_key?(:'pan_suffix') self.pan_suffix = attributes[:'pan_suffix'] end if attributes.has_key?(:'entry_method') self.entry_method = attributes[:'entry_method'] end if attributes.has_key?(:'payment_note') self.payment_note = attributes[:'payment_note'] end if attributes.has_key?(:'total_money') self.total_money = attributes[:'total_money'] end if attributes.has_key?(:'tendered_money') self.tendered_money = attributes[:'tendered_money'] end if attributes.has_key?(:'tendered_at') self.tendered_at = attributes[:'tendered_at'] end if attributes.has_key?(:'settled_at') self.settled_at = attributes[:'settled_at'] end if attributes.has_key?(:'change_back_money') self.change_back_money = attributes[:'change_back_money'] end if attributes.has_key?(:'refunded_money') self.refunded_money = attributes[:'refunded_money'] end if attributes.has_key?(:'is_exchange') self.is_exchange = attributes[:'is_exchange'] end end |
Instance Attribute Details
#card_brand ⇒ Object
The brand of credit card provided. See [V1TenderCardBrand](#type-v1tendercardbrand) for possible values
31 32 33 |
# File 'lib/square_connect/models/v1_tender.rb', line 31 def card_brand @card_brand end |
#change_back_money ⇒ Object
The amount of total_money returned to the buyer as change.
55 56 57 |
# File 'lib/square_connect/models/v1_tender.rb', line 55 def change_back_money @change_back_money end |
#employee_id ⇒ Object
The ID of the employee that processed the tender.
25 26 27 |
# File 'lib/square_connect/models/v1_tender.rb', line 25 def employee_id @employee_id end |
#entry_method ⇒ Object
The tender’s unique ID. See [V1TenderEntryMethod](#type-v1tenderentrymethod) for possible values
37 38 39 |
# File 'lib/square_connect/models/v1_tender.rb', line 37 def entry_method @entry_method end |
#id ⇒ Object
The tender’s unique ID.
16 17 18 |
# File 'lib/square_connect/models/v1_tender.rb', line 16 def id @id end |
#is_exchange ⇒ Object
Indicates whether or not the tender is associated with an exchange. If is_exchange is true, the tender represents the value of goods returned in an exchange not the actual money paid. The exchange value reduces the tender amounts needed to pay for items purchased in the exchange.
61 62 63 |
# File 'lib/square_connect/models/v1_tender.rb', line 61 def is_exchange @is_exchange end |
#name ⇒ Object
A human-readable description of the tender.
22 23 24 |
# File 'lib/square_connect/models/v1_tender.rb', line 22 def name @name end |
#pan_suffix ⇒ Object
The last four digits of the provided credit card’s account number.
34 35 36 |
# File 'lib/square_connect/models/v1_tender.rb', line 34 def pan_suffix @pan_suffix end |
#payment_note ⇒ Object
Notes entered by the merchant about the tender at the time of payment, if any. Typically only present for tender with the type: OTHER.
40 41 42 |
# File 'lib/square_connect/models/v1_tender.rb', line 40 def payment_note @payment_note end |
#receipt_url ⇒ Object
The URL of the receipt for the tender.
28 29 30 |
# File 'lib/square_connect/models/v1_tender.rb', line 28 def receipt_url @receipt_url end |
#refunded_money ⇒ Object
The total of all refunds applied to this tender. This amount is always negative or zero.
58 59 60 |
# File 'lib/square_connect/models/v1_tender.rb', line 58 def refunded_money @refunded_money end |
#settled_at ⇒ Object
The time when the tender was settled, in ISO 8601 format.
52 53 54 |
# File 'lib/square_connect/models/v1_tender.rb', line 52 def settled_at @settled_at end |
#tendered_at ⇒ Object
The time when the tender was created, in ISO 8601 format.
49 50 51 |
# File 'lib/square_connect/models/v1_tender.rb', line 49 def tendered_at @tendered_at end |
#tendered_money ⇒ Object
The amount of total_money applied to the payment.
46 47 48 |
# File 'lib/square_connect/models/v1_tender.rb', line 46 def tendered_money @tendered_money end |
#total_money ⇒ Object
The total amount of money provided in this form of tender.
43 44 45 |
# File 'lib/square_connect/models/v1_tender.rb', line 43 def total_money @total_money end |
#type ⇒ Object
The type of tender. See [V1TenderType](#type-v1tendertype) for possible values
19 20 21 |
# File 'lib/square_connect/models/v1_tender.rb', line 19 def type @type end |
Class Method Details
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/square_connect/models/v1_tender.rb', line 86 def self.attribute_map { :'id' => :'id', :'type' => :'type', :'name' => :'name', :'employee_id' => :'employee_id', :'receipt_url' => :'receipt_url', :'card_brand' => :'card_brand', :'pan_suffix' => :'pan_suffix', :'entry_method' => :'entry_method', :'payment_note' => :'payment_note', :'total_money' => :'total_money', :'tendered_money' => :'tendered_money', :'tendered_at' => :'tendered_at', :'settled_at' => :'settled_at', :'change_back_money' => :'change_back_money', :'refunded_money' => :'refunded_money', :'is_exchange' => :'is_exchange' } end |
.swagger_types ⇒ Object
Attribute type mapping.
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/square_connect/models/v1_tender.rb', line 108 def self.swagger_types { :'id' => :'String', :'type' => :'String', :'name' => :'String', :'employee_id' => :'String', :'receipt_url' => :'String', :'card_brand' => :'String', :'pan_suffix' => :'String', :'entry_method' => :'String', :'payment_note' => :'String', :'total_money' => :'V1Money', :'tendered_money' => :'V1Money', :'tendered_at' => :'String', :'settled_at' => :'String', :'change_back_money' => :'V1Money', :'refunded_money' => :'V1Money', :'is_exchange' => :'BOOLEAN' } end |
Instance Method Details
#==(o) ⇒ Object
Checks equality by comparing each attribute.
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 |
# File 'lib/square_connect/models/v1_tender.rb', line 254 def ==(o) return true if self.equal?(o) self.class == o.class && id == o.id && type == o.type && name == o.name && employee_id == o.employee_id && receipt_url == o.receipt_url && card_brand == o.card_brand && pan_suffix == o.pan_suffix && entry_method == o.entry_method && payment_note == o.payment_note && total_money == o.total_money && tendered_money == o.tendered_money && tendered_at == o.tendered_at && settled_at == o.settled_at && change_back_money == o.change_back_money && refunded_money == o.refunded_money && is_exchange == o.is_exchange end |
#_deserialize(type, value) ⇒ Object
Deserializes the data based on type
311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 |
# File 'lib/square_connect/models/v1_tender.rb', line 311 def _deserialize(type, value) case type.to_sym when :DateTime DateTime.parse(value) when :Date Date.parse(value) when :String value.to_s when :Integer value.to_i when :Float value.to_f when :BOOLEAN if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false end when :Object # generic object (usually a Hash), return directly value when /\AArray<(?<inner_type>.+)>\z/ inner_type = Regexp.last_match[:inner_type] value.map { |v| _deserialize(inner_type, v) } when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/ k_type = Regexp.last_match[:k_type] v_type = Regexp.last_match[:v_type] {}.tap do |hash| value.each do |k, v| hash[_deserialize(k_type, k)] = _deserialize(v_type, v) end end else # model temp_model = SquareConnect.const_get(type).new temp_model.build_from_hash(value) end end |
#_to_hash(value) ⇒ Hash
Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value
377 378 379 380 381 382 383 384 385 386 387 388 389 |
# File 'lib/square_connect/models/v1_tender.rb', line 377 def _to_hash(value) if value.is_a?(Array) value.compact.map{ |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash value.to_hash else value end end |
#build_from_hash(attributes) ⇒ Object
Builds the object from hash
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 |
# File 'lib/square_connect/models/v1_tender.rb', line 290 def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.swagger_types.each_pair do |key, type| if type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) end # or else data not found in attributes(hash), not an issue as the data can be optional end self end |
#eql?(o) ⇒ Boolean
277 278 279 |
# File 'lib/square_connect/models/v1_tender.rb', line 277 def eql?(o) self == o end |
#hash ⇒ Fixnum
Calculates hash code according to all attributes.
283 284 285 |
# File 'lib/square_connect/models/v1_tender.rb', line 283 def hash [id, type, name, employee_id, receipt_url, card_brand, pan_suffix, entry_method, payment_note, total_money, tendered_money, tendered_at, settled_at, change_back_money, refunded_money, is_exchange].hash end |
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
205 206 207 208 |
# File 'lib/square_connect/models/v1_tender.rb', line 205 def list_invalid_properties invalid_properties = Array.new return invalid_properties end |
#to_body ⇒ Hash
to_body is an alias to to_hash (backward compatibility)
357 358 359 |
# File 'lib/square_connect/models/v1_tender.rb', line 357 def to_body to_hash end |
#to_hash ⇒ Hash
Returns the object in the form of hash
363 364 365 366 367 368 369 370 371 |
# File 'lib/square_connect/models/v1_tender.rb', line 363 def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) next if value.nil? hash[param] = _to_hash(value) end hash end |
#to_s ⇒ String
Returns the string representation of the object
351 352 353 |
# File 'lib/square_connect/models/v1_tender.rb', line 351 def to_s to_hash.to_s end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
212 213 214 215 216 217 218 219 220 |
# File 'lib/square_connect/models/v1_tender.rb', line 212 def valid? type_validator = EnumAttributeValidator.new('String', ["CREDIT_CARD", "CASH", "THIRD_PARTY_CARD", "NO_SALE", "SQUARE_WALLET", "SQUARE_GIFT_CARD", "UNKNOWN", "OTHER"]) return false unless type_validator.valid?(@type) card_brand_validator = EnumAttributeValidator.new('String', ["OTHER_BRAND", "VISA", "MASTER_CARD", "AMERICAN_EXPRESS", "DISCOVER", "DISCOVER_DINERS", "JCB", "CHINA_UNIONPAY", "SQUARE_GIFT_CARD"]) return false unless card_brand_validator.valid?(@card_brand) entry_method_validator = EnumAttributeValidator.new('String', ["MANUAL", "SCANNED", "SQUARE_CASH", "SQUARE_WALLET", "SWIPED", "WEB_FORM", "OTHER"]) return false unless entry_method_validator.valid?(@entry_method) return true end |