Class: SquareConnect::V1Tender
- Inherits:
-
Object
- Object
- SquareConnect::V1Tender
- Defined in:
- lib/square_connect/models/v1_tender.rb
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.
-
#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.
-
#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
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 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 |
# File 'lib/square_connect/models/v1_tender.rb', line 116 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?(:'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 end |
Instance Attribute Details
#card_brand ⇒ Object
The brand of credit card provided.
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.
49 50 51 |
# File 'lib/square_connect/models/v1_tender.rb', line 49 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.
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 |
#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.
52 53 54 |
# File 'lib/square_connect/models/v1_tender.rb', line 52 def refunded_money @refunded_money 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.
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.
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/square_connect/models/v1_tender.rb', line 77 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', :'change_back_money' => :'change_back_money', :'refunded_money' => :'refunded_money' } end |
.swagger_types ⇒ Object
Attribute type mapping.
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/square_connect/models/v1_tender.rb', line 96 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', :'change_back_money' => :'V1Money', :'refunded_money' => :'V1Money' } end |
Instance Method Details
#==(o) ⇒ Object
Checks equality by comparing each attribute.
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
# File 'lib/square_connect/models/v1_tender.rb', line 227 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 && change_back_money == o.change_back_money && refunded_money == o.refunded_money end |
#_deserialize(type, value) ⇒ Object
Deserializes the data based on type
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 |
# File 'lib/square_connect/models/v1_tender.rb', line 281 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
347 348 349 350 351 352 353 354 355 356 357 358 359 |
# File 'lib/square_connect/models/v1_tender.rb', line 347 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
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
# File 'lib/square_connect/models/v1_tender.rb', line 260 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
247 248 249 |
# File 'lib/square_connect/models/v1_tender.rb', line 247 def eql?(o) self == o end |
#hash ⇒ Fixnum
Calculates hash code according to all attributes.
253 254 255 |
# File 'lib/square_connect/models/v1_tender.rb', line 253 def hash [id, type, name, employee_id, receipt_url, card_brand, pan_suffix, entry_method, payment_note, total_money, tendered_money, change_back_money, refunded_money].hash end |
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
178 179 180 181 |
# File 'lib/square_connect/models/v1_tender.rb', line 178 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)
327 328 329 |
# File 'lib/square_connect/models/v1_tender.rb', line 327 def to_body to_hash end |
#to_hash ⇒ Hash
Returns the object in the form of hash
333 334 335 336 337 338 339 340 341 |
# File 'lib/square_connect/models/v1_tender.rb', line 333 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
321 322 323 |
# File 'lib/square_connect/models/v1_tender.rb', line 321 def to_s to_hash.to_s end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
185 186 187 188 189 190 191 192 193 |
# File 'lib/square_connect/models/v1_tender.rb', line 185 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 |