Class: Mudbase::WalletTransaction

Inherits:
ApiModelBase show all
Defined in:
lib/mudbase/models/wallet_transaction.rb

Overview

Wallet transaction record (txHash, address, chain, from, to, amount, status, confirmations, etc.).

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

Initializes the object

Parameters:

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

    Model attributes in the form of hash



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
# File 'lib/mudbase/models/wallet_transaction.rb', line 160

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Instance Attribute Details

#_idObject

Returns the value of attribute _id.



19
20
21
# File 'lib/mudbase/models/wallet_transaction.rb', line 19

def _id
  @_id
end

#addressObject

Returns the value of attribute address.



25
26
27
# File 'lib/mudbase/models/wallet_transaction.rb', line 25

def address
  @address
end

#amountObject

Transaction amount (string to handle large numbers)



38
39
40
# File 'lib/mudbase/models/wallet_transaction.rb', line 38

def amount
  @amount
end

#block_hashObject

Returns the value of attribute block_hash.



52
53
54
# File 'lib/mudbase/models/wallet_transaction.rb', line 52

def block_hash
  @block_hash
end

#block_numberObject

Returns the value of attribute block_number.



50
51
52
# File 'lib/mudbase/models/wallet_transaction.rb', line 50

def block_number
  @block_number
end

#chainObject

Returns the value of attribute chain.



27
28
29
# File 'lib/mudbase/models/wallet_transaction.rb', line 27

def chain
  @chain
end

#confirmationsObject

Returns the value of attribute confirmations.



48
49
50
# File 'lib/mudbase/models/wallet_transaction.rb', line 48

def confirmations
  @confirmations
end

#created_atObject

Returns the value of attribute created_at.



59
60
61
# File 'lib/mudbase/models/wallet_transaction.rb', line 59

def created_at
  @created_at
end

#currencyObject

Returns the value of attribute currency.



40
41
42
# File 'lib/mudbase/models/wallet_transaction.rb', line 40

def currency
  @currency
end

#fromObject

Returns the value of attribute from.



29
30
31
# File 'lib/mudbase/models/wallet_transaction.rb', line 29

def from
  @from
end

#from_addressObject

Returns the value of attribute from_address.



33
34
35
# File 'lib/mudbase/models/wallet_transaction.rb', line 33

def from_address
  @from_address
end

#main_tx_confirmed_atObject

Returns the value of attribute main_tx_confirmed_at.



57
58
59
# File 'lib/mudbase/models/wallet_transaction.rb', line 57

def main_tx_confirmed_at
  @main_tx_confirmed_at
end

#main_tx_hashObject

Returns the value of attribute main_tx_hash.



23
24
25
# File 'lib/mudbase/models/wallet_transaction.rb', line 23

def main_tx_hash
  @main_tx_hash
end

#main_tx_statusObject

Returns the value of attribute main_tx_status.



46
47
48
# File 'lib/mudbase/models/wallet_transaction.rb', line 46

def main_tx_status
  @main_tx_status
end

#network_feeObject

Network fee (string to handle large numbers)



55
56
57
# File 'lib/mudbase/models/wallet_transaction.rb', line 55

def network_fee
  @network_fee
end

#statusObject

Returns the value of attribute status.



44
45
46
# File 'lib/mudbase/models/wallet_transaction.rb', line 44

def status
  @status
end

#toObject

Returns the value of attribute to.



31
32
33
# File 'lib/mudbase/models/wallet_transaction.rb', line 31

def to
  @to
end

#to_addressObject

Returns the value of attribute to_address.



35
36
37
# File 'lib/mudbase/models/wallet_transaction.rb', line 35

def to_address
  @to_address
end

#tx_hashObject

Returns the value of attribute tx_hash.



21
22
23
# File 'lib/mudbase/models/wallet_transaction.rb', line 21

def tx_hash
  @tx_hash
end

#typeObject

Returns the value of attribute type.



42
43
44
# File 'lib/mudbase/models/wallet_transaction.rb', line 42

def type
  @type
end

#updated_atObject

Returns the value of attribute updated_at.



61
62
63
# File 'lib/mudbase/models/wallet_transaction.rb', line 61

def updated_at
  @updated_at
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



113
114
115
# File 'lib/mudbase/models/wallet_transaction.rb', line 113

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



118
119
120
# File 'lib/mudbase/models/wallet_transaction.rb', line 118

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

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



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/mudbase/models/wallet_transaction.rb', line 86

def self.attribute_map
  {
    :'_id' => :'_id',
    :'tx_hash' => :'txHash',
    :'main_tx_hash' => :'mainTxHash',
    :'address' => :'address',
    :'chain' => :'chain',
    :'from' => :'from',
    :'to' => :'to',
    :'from_address' => :'fromAddress',
    :'to_address' => :'toAddress',
    :'amount' => :'amount',
    :'currency' => :'currency',
    :'type' => :'type',
    :'status' => :'status',
    :'main_tx_status' => :'mainTxStatus',
    :'confirmations' => :'confirmations',
    :'block_number' => :'blockNumber',
    :'block_hash' => :'blockHash',
    :'network_fee' => :'networkFee',
    :'main_tx_confirmed_at' => :'mainTxConfirmedAt',
    :'created_at' => :'createdAt',
    :'updated_at' => :'updatedAt'
  }
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



341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
# File 'lib/mudbase/models/wallet_transaction.rb', line 341

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



150
151
152
153
154
155
156
# File 'lib/mudbase/models/wallet_transaction.rb', line 150

def self.openapi_nullable
  Set.new([
    :'block_number',
    :'block_hash',
    :'main_tx_confirmed_at',
  ])
end

.openapi_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
# File 'lib/mudbase/models/wallet_transaction.rb', line 123

def self.openapi_types
  {
    :'_id' => :'String',
    :'tx_hash' => :'String',
    :'main_tx_hash' => :'String',
    :'address' => :'String',
    :'chain' => :'String',
    :'from' => :'String',
    :'to' => :'String',
    :'from_address' => :'String',
    :'to_address' => :'String',
    :'amount' => :'String',
    :'currency' => :'String',
    :'type' => :'String',
    :'status' => :'String',
    :'main_tx_status' => :'String',
    :'confirmations' => :'Integer',
    :'block_number' => :'Integer',
    :'block_hash' => :'String',
    :'network_fee' => :'String',
    :'main_tx_confirmed_at' => :'Time',
    :'created_at' => :'Time',
    :'updated_at' => :'Time'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



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
# File 'lib/mudbase/models/wallet_transaction.rb', line 300

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      _id == o._id &&
      tx_hash == o.tx_hash &&
      main_tx_hash == o.main_tx_hash &&
      address == o.address &&
      chain == o.chain &&
      from == o.from &&
      to == o.to &&
      from_address == o.from_address &&
      to_address == o.to_address &&
      amount == o.amount &&
      currency == o.currency &&
      type == o.type &&
      status == o.status &&
      main_tx_status == o.main_tx_status &&
      confirmations == o.confirmations &&
      block_number == o.block_number &&
      block_hash == o.block_hash &&
      network_fee == o.network_fee &&
      main_tx_confirmed_at == o.main_tx_confirmed_at &&
      created_at == o.created_at &&
      updated_at == o.updated_at
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


328
329
330
# File 'lib/mudbase/models/wallet_transaction.rb', line 328

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



334
335
336
# File 'lib/mudbase/models/wallet_transaction.rb', line 334

def hash
  [_id, tx_hash, main_tx_hash, address, chain, from, to, from_address, to_address, amount, currency, type, status, main_tx_status, confirmations, block_number, block_hash, network_fee, main_tx_confirmed_at, created_at, updated_at].hash
end

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properties with the reasons



261
262
263
264
265
# File 'lib/mudbase/models/wallet_transaction.rb', line 261

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  invalid_properties
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



363
364
365
366
367
368
369
370
371
372
373
374
375
# File 'lib/mudbase/models/wallet_transaction.rb', line 363

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



269
270
271
272
273
274
275
276
# File 'lib/mudbase/models/wallet_transaction.rb', line 269

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  status_validator = EnumAttributeValidator.new('String', ["pending", "completed", "failed"])
  return false unless status_validator.valid?(@status)
  main_tx_status_validator = EnumAttributeValidator.new('String', ["pending", "confirmed", "failed"])
  return false unless main_tx_status_validator.valid?(@main_tx_status)
  true
end