Class: Weft::Payment

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

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 = {}) ⇒ Payment

Initializes the object

Parameters:

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

    Model attributes in the form of hash



103
104
105
106
107
108
109
110
111
112
113
114
115
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# File 'lib/weft/generated/models/payment.rb', line 103

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `Weft::Payment` 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::Payment`. 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?(:'tx_hash')
    self.tx_hash = attributes[:'tx_hash']
  else
    self.tx_hash = nil
  end

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

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

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

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

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

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

  if attributes.key?(:'resource_url')
    self.resource_url = attributes[:'resource_url']
  end

  if attributes.key?(:'resource_host')
    self.resource_host = attributes[:'resource_host']
  end

  if attributes.key?(:'settlement_latency_ms')
    self.settlement_latency_ms = attributes[:'settlement_latency_ms']
  end

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

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

Instance Attribute Details

#amountObject

Amount in atomic units (1 USDC = 1,000,000)



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

def amount
  @amount
end

#amount_formattedObject

Human-readable amount (e.g. "1.00 USDC")



30
31
32
# File 'lib/weft/generated/models/payment.rb', line 30

def amount_formatted
  @amount_formatted
end

#api_key_nameObject

Returns the value of attribute api_key_name.



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

def api_key_name
  @api_key_name
end

#currencyObject

Returns the value of attribute currency.



32
33
34
# File 'lib/weft/generated/models/payment.rb', line 32

def currency
  @currency
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#networkObject

CAIP-2 chain identifier



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

def network
  @network
end

#payer_addressObject

Returns the value of attribute payer_address.



22
23
24
# File 'lib/weft/generated/models/payment.rb', line 22

def payer_address
  @payer_address
end

#recipient_addressObject

Returns the value of attribute recipient_address.



24
25
26
# File 'lib/weft/generated/models/payment.rb', line 24

def recipient_address
  @recipient_address
end

#resource_hostObject

Returns the value of attribute resource_host.



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

def resource_host
  @resource_host
end

#resource_urlObject

Returns the value of attribute resource_url.



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

def resource_url
  @resource_url
end

#settled_atObject

Returns the value of attribute settled_at.



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

def settled_at
  @settled_at
end

#settlement_latency_msObject

Returns the value of attribute settlement_latency_ms.



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

def settlement_latency_ms
  @settlement_latency_ms
end

#tx_hashObject

Returns the value of attribute tx_hash.



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

def tx_hash
  @tx_hash
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



67
68
69
# File 'lib/weft/generated/models/payment.rb', line 67

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



72
73
74
# File 'lib/weft/generated/models/payment.rb', line 72

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

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



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/weft/generated/models/payment.rb', line 48

def self.attribute_map
  {
    :'id' => :'id',
    :'tx_hash' => :'tx_hash',
    :'payer_address' => :'payer_address',
    :'recipient_address' => :'recipient_address',
    :'amount' => :'amount',
    :'amount_formatted' => :'amount_formatted',
    :'currency' => :'currency',
    :'network' => :'network',
    :'resource_url' => :'resource_url',
    :'resource_host' => :'resource_host',
    :'settlement_latency_ms' => :'settlement_latency_ms',
    :'settled_at' => :'settled_at',
    :'api_key_name' => :'api_key_name'
  }
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



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

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



96
97
98
99
# File 'lib/weft/generated/models/payment.rb', line 96

def self.openapi_nullable
  Set.new([
  ])
end

.openapi_typesObject

Attribute type mapping.



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/weft/generated/models/payment.rb', line 77

def self.openapi_types
  {
    :'id' => :'Integer',
    :'tx_hash' => :'String',
    :'payer_address' => :'String',
    :'recipient_address' => :'String',
    :'amount' => :'Integer',
    :'amount_formatted' => :'String',
    :'currency' => :'String',
    :'network' => :'String',
    :'resource_url' => :'String',
    :'resource_host' => :'String',
    :'settlement_latency_ms' => :'Integer',
    :'settled_at' => :'Time',
    :'api_key_name' => :'String'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



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

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      id == o.id &&
      tx_hash == o.tx_hash &&
      payer_address == o.payer_address &&
      recipient_address == o.recipient_address &&
      amount == o.amount &&
      amount_formatted == o.amount_formatted &&
      currency == o.currency &&
      network == o.network &&
      resource_url == o.resource_url &&
      resource_host == o.resource_host &&
      settlement_latency_ms == o.settlement_latency_ms &&
      settled_at == o.settled_at &&
      api_key_name == o.api_key_name
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


377
378
379
# File 'lib/weft/generated/models/payment.rb', line 377

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



383
384
385
# File 'lib/weft/generated/models/payment.rb', line 383

def hash
  [id, tx_hash, payer_address, recipient_address, amount, amount_formatted, currency, network, resource_url, resource_host, settlement_latency_ms, settled_at, api_key_name].hash
end

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properties with the reasons



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

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 @tx_hash.nil?
    invalid_properties.push('invalid value for "tx_hash", tx_hash cannot be nil.')
  end

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

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

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

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

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

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

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

  if @api_key_name.nil?
    invalid_properties.push('invalid value for "api_key_name", api_key_name 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



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

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



240
241
242
243
244
245
246
247
248
249
250
251
252
253
# File 'lib/weft/generated/models/payment.rb', line 240

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if @id.nil?
  return false if @tx_hash.nil?
  return false if @payer_address.nil?
  return false if @recipient_address.nil?
  return false if @amount.nil?
  return false if @amount_formatted.nil?
  return false if @currency.nil?
  return false if @network.nil?
  return false if @settled_at.nil?
  return false if @api_key_name.nil?
  true
end