Class: SquareConnect::V1Tender

Inherits:
Object
  • Object
show all
Defined in:
lib/square_connect/models/v1_tender.rb

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ V1Tender

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



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
175
176
177
178
179
180
181
182
183
# File 'lib/square_connect/models/v1_tender.rb', line 121

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

  if attributes.has_key?(:'is_exchange')
    self.is_exchange = attributes[:'is_exchange']
  end

end

Instance Attribute Details

#card_brandObject

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_moneyObject

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_idObject

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_methodObject

The tender’s unique ID.



37
38
39
# File 'lib/square_connect/models/v1_tender.rb', line 37

def entry_method
  @entry_method
end

#idObject

The tender’s unique ID.



16
17
18
# File 'lib/square_connect/models/v1_tender.rb', line 16

def id
  @id
end

#is_exchangeObject

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.



55
56
57
# File 'lib/square_connect/models/v1_tender.rb', line 55

def is_exchange
  @is_exchange
end

#nameObject

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_suffixObject

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_noteObject

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_urlObject

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_moneyObject

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_moneyObject

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_moneyObject

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

#typeObject

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_mapObject

Attribute mapping from ruby-style variable name to JSON key.



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/square_connect/models/v1_tender.rb', line 80

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',
    :'is_exchange' => :'is_exchange'
  }
end

.swagger_typesObject

Attribute type mapping.



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/square_connect/models/v1_tender.rb', line 100

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',
    :'is_exchange' => :'BOOLEAN'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
# File 'lib/square_connect/models/v1_tender.rb', line 236

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 &&
      is_exchange == o.is_exchange
end

#_deserialize(type, value) ⇒ Object

Deserializes the data based on type

Parameters:

  • string

    type Data type

  • string

    value Value to be deserialized

Returns:

  • (Object)

    Deserialized data



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
318
319
320
321
322
323
324
325
326
327
# File 'lib/square_connect/models/v1_tender.rb', line 291

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

Parameters:

  • value (Object)

    Any valid value

Returns:

  • (Hash)

    Returns the value in the form of hash



357
358
359
360
361
362
363
364
365
366
367
368
369
# File 'lib/square_connect/models/v1_tender.rb', line 357

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

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
# File 'lib/square_connect/models/v1_tender.rb', line 270

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

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


257
258
259
# File 'lib/square_connect/models/v1_tender.rb', line 257

def eql?(o)
  self == o
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



263
264
265
# File 'lib/square_connect/models/v1_tender.rb', line 263

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, is_exchange].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properies with the reasons



187
188
189
190
# File 'lib/square_connect/models/v1_tender.rb', line 187

def list_invalid_properties
  invalid_properties = Array.new
  return invalid_properties
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)

Returns:

  • (Hash)

    Returns the object in the form of hash



337
338
339
# File 'lib/square_connect/models/v1_tender.rb', line 337

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



343
344
345
346
347
348
349
350
351
# File 'lib/square_connect/models/v1_tender.rb', line 343

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_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



331
332
333
# File 'lib/square_connect/models/v1_tender.rb', line 331

def to_s
  to_hash.to_s
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



194
195
196
197
198
199
200
201
202
# File 'lib/square_connect/models/v1_tender.rb', line 194

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