Class: Weft::Purchase

Inherits:
ApiModelBase show all
Defined in:
lib/weft/generated/models/purchase.rb

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApiModelBase

_deserialize, #_to_hash, #to_body, #to_s

Constructor Details

#initialize(attributes = {}) ⇒ Purchase

Initializes the object

Parameters:

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

    Model attributes in the form of hash



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
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
# File 'lib/weft/generated/models/purchase.rb', line 135

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `Weft::Purchase` initialize method"
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  acceptable_attribute_map = self.class.acceptable_attribute_map
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!acceptable_attribute_map.key?(k.to_sym))
      fail ArgumentError, "`#{k}` is not a valid attribute in `Weft::Purchase`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
    end
    h[k.to_sym] = v
  }

  if attributes.key?(:'id')
    self.id = attributes[:'id']
  else
    self.id = nil
  end

  if attributes.key?(:'status')
    self.status = attributes[:'status']
  else
    self.status = nil
  end

  if attributes.key?(:'amount_usd')
    self.amount_usd = attributes[:'amount_usd']
  else
    self.amount_usd = nil
  end

  if attributes.key?(:'recipient_address')
    self.recipient_address = attributes[:'recipient_address']
  else
    self.recipient_address = nil
  end

  if attributes.key?(:'network')
    self.network = attributes[:'network']
  else
    self.network = nil
  end

  if attributes.key?(:'protocol')
    self.protocol = attributes[:'protocol']
  else
    self.protocol = nil
  end

  if attributes.key?(:'context')
    self.context = attributes[:'context']
  else
    self.context = nil
  end

  if attributes.key?(:'tx_hash')
    self.tx_hash = attributes[:'tx_hash']
  else
    self.tx_hash = nil
  end

  if attributes.key?(:'reject_reason')
    self.reject_reason = attributes[:'reject_reason']
  else
    self.reject_reason = nil
  end

  if attributes.key?(:'failure_reason')
    self.failure_reason = attributes[:'failure_reason']
  else
    self.failure_reason = nil
  end

  if attributes.key?(:'idempotency_key')
    self.idempotency_key = attributes[:'idempotency_key']
  else
    self.idempotency_key = nil
  end

  if attributes.key?(:'signed_at')
    self.signed_at = attributes[:'signed_at']
  else
    self.signed_at = nil
  end

  if attributes.key?(:'settled_at')
    self.settled_at = attributes[:'settled_at']
  else
    self.settled_at = nil
  end

  if attributes.key?(:'artifact')
    self.artifact = attributes[:'artifact']
  else
    self.artifact = nil
  end
end

Instance Attribute Details

#amount_usdObject

Exact decimal USD amount with up to six fractional digits.



23
24
25
# File 'lib/weft/generated/models/purchase.rb', line 23

def amount_usd
  @amount_usd
end

#artifactObject

Returns the value of attribute artifact.



45
46
47
# File 'lib/weft/generated/models/purchase.rb', line 45

def artifact
  @artifact
end

#contextObject

Returns the value of attribute context.



31
32
33
# File 'lib/weft/generated/models/purchase.rb', line 31

def context
  @context
end

#failure_reasonObject

Returns the value of attribute failure_reason.



37
38
39
# File 'lib/weft/generated/models/purchase.rb', line 37

def failure_reason
  @failure_reason
end

#idObject

Returns the value of attribute id.



18
19
20
# File 'lib/weft/generated/models/purchase.rb', line 18

def id
  @id
end

#idempotency_keyObject

Returns the value of attribute idempotency_key.



39
40
41
# File 'lib/weft/generated/models/purchase.rb', line 39

def idempotency_key
  @idempotency_key
end

#networkObject

Returns the value of attribute network.



27
28
29
# File 'lib/weft/generated/models/purchase.rb', line 27

def network
  @network
end

#protocolObject

Returns the value of attribute protocol.



29
30
31
# File 'lib/weft/generated/models/purchase.rb', line 29

def protocol
  @protocol
end

#recipient_addressObject

Returns the value of attribute recipient_address.



25
26
27
# File 'lib/weft/generated/models/purchase.rb', line 25

def recipient_address
  @recipient_address
end

#reject_reasonObject

Returns the value of attribute reject_reason.



35
36
37
# File 'lib/weft/generated/models/purchase.rb', line 35

def reject_reason
  @reject_reason
end

#settled_atObject

Returns the value of attribute settled_at.



43
44
45
# File 'lib/weft/generated/models/purchase.rb', line 43

def settled_at
  @settled_at
end

#signed_atObject

Returns the value of attribute signed_at.



41
42
43
# File 'lib/weft/generated/models/purchase.rb', line 41

def signed_at
  @signed_at
end

#statusObject

Returns the value of attribute status.



20
21
22
# File 'lib/weft/generated/models/purchase.rb', line 20

def status
  @status
end

#tx_hashObject

Returns the value of attribute tx_hash.



33
34
35
# File 'lib/weft/generated/models/purchase.rb', line 33

def tx_hash
  @tx_hash
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



90
91
92
# File 'lib/weft/generated/models/purchase.rb', line 90

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



95
96
97
# File 'lib/weft/generated/models/purchase.rb', line 95

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

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



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/weft/generated/models/purchase.rb', line 70

def self.attribute_map
  {
    :'id' => :'id',
    :'status' => :'status',
    :'amount_usd' => :'amount_usd',
    :'recipient_address' => :'recipient_address',
    :'network' => :'network',
    :'protocol' => :'protocol',
    :'context' => :'context',
    :'tx_hash' => :'tx_hash',
    :'reject_reason' => :'reject_reason',
    :'failure_reason' => :'failure_reason',
    :'idempotency_key' => :'idempotency_key',
    :'signed_at' => :'signed_at',
    :'settled_at' => :'settled_at',
    :'artifact' => :'artifact'
  }
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



389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
# File 'lib/weft/generated/models/purchase.rb', line 389

def self.build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  attributes = attributes.transform_keys(&:to_sym)
  transformed_hash = {}
  openapi_types.each_pair do |key, type|
    if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = nil
    elsif type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the attribute
      # is documented as an array but the input is not
      if attributes[attribute_map[key]].is_a?(Array)
        transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
      end
    elsif !attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
    end
  end
  new(transformed_hash)
end

.openapi_nullableObject

List of attributes with nullable: true



120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/weft/generated/models/purchase.rb', line 120

def self.openapi_nullable
  Set.new([
    :'protocol',
    :'context',
    :'tx_hash',
    :'reject_reason',
    :'failure_reason',
    :'idempotency_key',
    :'settled_at',
    :'artifact'
  ])
end

.openapi_typesObject

Attribute type mapping.



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

def self.openapi_types
  {
    :'id' => :'Integer',
    :'status' => :'String',
    :'amount_usd' => :'String',
    :'recipient_address' => :'String',
    :'network' => :'String',
    :'protocol' => :'String',
    :'context' => :'String',
    :'tx_hash' => :'String',
    :'reject_reason' => :'String',
    :'failure_reason' => :'String',
    :'idempotency_key' => :'String',
    :'signed_at' => :'Time',
    :'settled_at' => :'Time',
    :'artifact' => :'PurchaseArtifact'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
# File 'lib/weft/generated/models/purchase.rb', line 355

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      id == o.id &&
      status == o.status &&
      amount_usd == o.amount_usd &&
      recipient_address == o.recipient_address &&
      network == o.network &&
      protocol == o.protocol &&
      context == o.context &&
      tx_hash == o.tx_hash &&
      reject_reason == o.reject_reason &&
      failure_reason == o.failure_reason &&
      idempotency_key == o.idempotency_key &&
      signed_at == o.signed_at &&
      settled_at == o.settled_at &&
      artifact == o.artifact
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


376
377
378
# File 'lib/weft/generated/models/purchase.rb', line 376

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



382
383
384
# File 'lib/weft/generated/models/purchase.rb', line 382

def hash
  [id, status, amount_usd, recipient_address, network, protocol, context, tx_hash, reject_reason, failure_reason, idempotency_key, signed_at, settled_at, artifact].hash
end

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properties with the reasons



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
# File 'lib/weft/generated/models/purchase.rb', line 236

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  if @id.nil?
    invalid_properties.push('invalid value for "id", id cannot be nil.')
  end

  if @status.nil?
    invalid_properties.push('invalid value for "status", status cannot be nil.')
  end

  if @amount_usd.nil?
    invalid_properties.push('invalid value for "amount_usd", amount_usd cannot be nil.')
  end

  if @recipient_address.nil?
    invalid_properties.push('invalid value for "recipient_address", recipient_address cannot be nil.')
  end

  if @network.nil?
    invalid_properties.push('invalid value for "network", network cannot be nil.')
  end

  if @signed_at.nil?
    invalid_properties.push('invalid value for "signed_at", signed_at cannot be nil.')
  end

  invalid_properties
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



411
412
413
414
415
416
417
418
419
420
421
422
423
# File 'lib/weft/generated/models/purchase.rb', line 411

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    if value.nil?
      is_nullable = self.class.openapi_nullable.include?(attr)
      next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
    end

    hash[param] = _to_hash(value)
  end
  hash
end

#valid?Boolean

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

Returns:

  • (Boolean)

    true if the model is valid



268
269
270
271
272
273
274
275
276
277
278
279
280
281
# File 'lib/weft/generated/models/purchase.rb', line 268

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if @id.nil?
  return false if @status.nil?
  status_validator = EnumAttributeValidator.new('String', ["signed", "settled", "locked", "rejected", "declined", "expired", "reverted"])
  return false unless status_validator.valid?(@status)
  return false if @amount_usd.nil?
  return false if @recipient_address.nil?
  return false if @network.nil?
  protocol_validator = EnumAttributeValidator.new('String', ["mpp", "x402"])
  return false unless protocol_validator.valid?(@protocol)
  return false if @signed_at.nil?
  true
end