Class: SquareConnect::V1Order

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

Overview

V1Order

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ V1Order

Initializes the object

Parameters:

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

    Model attributes in the form of hash



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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
# File 'lib/square_connect/models/v1_order.rb', line 155

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?(:'errors')
    if (value = attributes[:'errors']).is_a?(Array)
      self.errors = value
    end
  end

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  if attributes.has_key?(:'order_history')
    if (value = attributes[:'order_history']).is_a?(Array)
      self.order_history = value
    end
  end

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

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

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

end

Instance Attribute Details

#btc_price_satoshiObject

For Bitcoin transactions, the price of the buyer’s order in satoshi (100 million satoshi equals 1 BTC).



88
89
90
# File 'lib/square_connect/models/v1_order.rb', line 88

def btc_price_satoshi
  @btc_price_satoshi
end

#btc_receive_addressObject

For Bitcoin transactions, the address that the buyer sent Bitcoin to.



85
86
87
# File 'lib/square_connect/models/v1_order.rb', line 85

def btc_receive_address
  @btc_receive_address
end

#buyer_emailObject

The email address of the order’s buyer.



22
23
24
# File 'lib/square_connect/models/v1_order.rb', line 22

def buyer_email
  @buyer_email
end

#buyer_noteObject

A note provided by the buyer when the order was created, if any.



64
65
66
# File 'lib/square_connect/models/v1_order.rb', line 64

def buyer_note
  @buyer_note
end

#canceled_noteObject

A note provided by the merchant when the order’s state was set to CANCELED, if any.



73
74
75
# File 'lib/square_connect/models/v1_order.rb', line 73

def canceled_note
  @canceled_note
end

#completed_noteObject

A note provided by the merchant when the order’s state was set to COMPLETED, if any



67
68
69
# File 'lib/square_connect/models/v1_order.rb', line 67

def completed_note
  @completed_note
end

#created_atObject

The time when the order was created, in ISO 8601 format.



52
53
54
# File 'lib/square_connect/models/v1_order.rb', line 52

def created_at
  @created_at
end

#errorsObject

Any errors that occurred during the request.



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

def errors
  @errors
end

#expires_atObject

The time when the order expires if no action is taken, in ISO 8601 format.



58
59
60
# File 'lib/square_connect/models/v1_order.rb', line 58

def expires_at
  @expires_at
end

#idObject

The order’s unique identifier.



19
20
21
# File 'lib/square_connect/models/v1_order.rb', line 19

def id
  @id
end

#order_historyObject

The history of actions associated with the order.



79
80
81
# File 'lib/square_connect/models/v1_order.rb', line 79

def order_history
  @order_history
end

#payment_idObject

The unique identifier of the payment associated with the order.



61
62
63
# File 'lib/square_connect/models/v1_order.rb', line 61

def payment_id
  @payment_id
end

#promo_codeObject

The promo code provided by the buyer, if any.



82
83
84
# File 'lib/square_connect/models/v1_order.rb', line 82

def promo_code
  @promo_code
end

#recipient_nameObject

The name of the order’s buyer.



25
26
27
# File 'lib/square_connect/models/v1_order.rb', line 25

def recipient_name
  @recipient_name
end

#recipient_phone_numberObject

The phone number to use for the order’s delivery.



28
29
30
# File 'lib/square_connect/models/v1_order.rb', line 28

def recipient_phone_number
  @recipient_phone_number
end

#refunded_noteObject

A note provided by the merchant when the order’s state was set to REFUNDED, if any.



70
71
72
# File 'lib/square_connect/models/v1_order.rb', line 70

def refunded_note
  @refunded_note
end

#shipping_addressObject

The address to ship the order to.



34
35
36
# File 'lib/square_connect/models/v1_order.rb', line 34

def shipping_address
  @shipping_address
end

#stateObject

Whether the tax is an ADDITIVE tax or an INCLUSIVE tax. See [V1OrderState](#type-v1orderstate) for possible values



31
32
33
# File 'lib/square_connect/models/v1_order.rb', line 31

def state
  @state
end

#subtotal_moneyObject

The amount of all items purchased in the order, before taxes and shipping.



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

def subtotal_money
  @subtotal_money
end

#tenderObject

The tender used to pay for the order.



76
77
78
# File 'lib/square_connect/models/v1_order.rb', line 76

def tender
  @tender
end

#total_discount_moneyObject

The total of all discounts applied to the order.



49
50
51
# File 'lib/square_connect/models/v1_order.rb', line 49

def total_discount_money
  @total_discount_money
end

#total_price_moneyObject

The total cost of the order.



46
47
48
# File 'lib/square_connect/models/v1_order.rb', line 46

def total_price_money
  @total_price_money
end

#total_shipping_moneyObject

The shipping cost for the order.



40
41
42
# File 'lib/square_connect/models/v1_order.rb', line 40

def total_shipping_money
  @total_shipping_money
end

#total_tax_moneyObject

The total of all taxes applied to the order.



43
44
45
# File 'lib/square_connect/models/v1_order.rb', line 43

def total_tax_money
  @total_tax_money
end

#updated_atObject

The time when the order was last modified, in ISO 8601 format.



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

def updated_at
  @updated_at
end

Class Method Details

.attribute_mapObject

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



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/square_connect/models/v1_order.rb', line 92

def self.attribute_map
  {
    :'errors' => :'errors',
    :'id' => :'id',
    :'buyer_email' => :'buyer_email',
    :'recipient_name' => :'recipient_name',
    :'recipient_phone_number' => :'recipient_phone_number',
    :'state' => :'state',
    :'shipping_address' => :'shipping_address',
    :'subtotal_money' => :'subtotal_money',
    :'total_shipping_money' => :'total_shipping_money',
    :'total_tax_money' => :'total_tax_money',
    :'total_price_money' => :'total_price_money',
    :'total_discount_money' => :'total_discount_money',
    :'created_at' => :'created_at',
    :'updated_at' => :'updated_at',
    :'expires_at' => :'expires_at',
    :'payment_id' => :'payment_id',
    :'buyer_note' => :'buyer_note',
    :'completed_note' => :'completed_note',
    :'refunded_note' => :'refunded_note',
    :'canceled_note' => :'canceled_note',
    :'tender' => :'tender',
    :'order_history' => :'order_history',
    :'promo_code' => :'promo_code',
    :'btc_receive_address' => :'btc_receive_address',
    :'btc_price_satoshi' => :'btc_price_satoshi'
  }
end

.swagger_typesObject

Attribute type mapping.



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
# File 'lib/square_connect/models/v1_order.rb', line 123

def self.swagger_types
  {
    :'errors' => :'Array<Error>',
    :'id' => :'String',
    :'buyer_email' => :'String',
    :'recipient_name' => :'String',
    :'recipient_phone_number' => :'String',
    :'state' => :'String',
    :'shipping_address' => :'Address',
    :'subtotal_money' => :'V1Money',
    :'total_shipping_money' => :'V1Money',
    :'total_tax_money' => :'V1Money',
    :'total_price_money' => :'V1Money',
    :'total_discount_money' => :'V1Money',
    :'created_at' => :'String',
    :'updated_at' => :'String',
    :'expires_at' => :'String',
    :'payment_id' => :'String',
    :'buyer_note' => :'String',
    :'completed_note' => :'String',
    :'refunded_note' => :'String',
    :'canceled_note' => :'String',
    :'tender' => :'V1Tender',
    :'order_history' => :'Array<V1OrderHistoryEntry>',
    :'promo_code' => :'String',
    :'btc_receive_address' => :'String',
    :'btc_price_satoshi' => :'Float'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



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
# File 'lib/square_connect/models/v1_order.rb', line 282

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      errors == o.errors &&
      id == o.id &&
      buyer_email == o.buyer_email &&
      recipient_name == o.recipient_name &&
      recipient_phone_number == o.recipient_phone_number &&
      state == o.state &&
      shipping_address == o.shipping_address &&
      subtotal_money == o.subtotal_money &&
      total_shipping_money == o.total_shipping_money &&
      total_tax_money == o.total_tax_money &&
      total_price_money == o.total_price_money &&
      total_discount_money == o.total_discount_money &&
      created_at == o.created_at &&
      updated_at == o.updated_at &&
      expires_at == o.expires_at &&
      payment_id == o.payment_id &&
      buyer_note == o.buyer_note &&
      completed_note == o.completed_note &&
      refunded_note == o.refunded_note &&
      canceled_note == o.canceled_note &&
      tender == o.tender &&
      order_history == o.order_history &&
      promo_code == o.promo_code &&
      btc_receive_address == o.btc_receive_address &&
      btc_price_satoshi == o.btc_price_satoshi
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



348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
# File 'lib/square_connect/models/v1_order.rb', line 348

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



414
415
416
417
418
419
420
421
422
423
424
425
426
# File 'lib/square_connect/models/v1_order.rb', line 414

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



327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
# File 'lib/square_connect/models/v1_order.rb', line 327

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


314
315
316
# File 'lib/square_connect/models/v1_order.rb', line 314

def eql?(o)
  self == o
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



320
321
322
# File 'lib/square_connect/models/v1_order.rb', line 320

def hash
  [errors, id, buyer_email, recipient_name, recipient_phone_number, state, shipping_address, subtotal_money, total_shipping_money, total_tax_money, total_price_money, total_discount_money, created_at, updated_at, expires_at, payment_id, buyer_note, completed_note, refunded_note, canceled_note, tender, order_history, promo_code, btc_receive_address, btc_price_satoshi].hash
end

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properies with the reasons



269
270
271
272
# File 'lib/square_connect/models/v1_order.rb', line 269

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



394
395
396
# File 'lib/square_connect/models/v1_order.rb', line 394

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



400
401
402
403
404
405
406
407
408
# File 'lib/square_connect/models/v1_order.rb', line 400

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



388
389
390
# File 'lib/square_connect/models/v1_order.rb', line 388

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



276
277
278
# File 'lib/square_connect/models/v1_order.rb', line 276

def valid?
  return true
end