Class: Cryptopay::InvoiceTransaction

Inherits:
Object
  • Object
show all
Defined in:
lib/cryptopay/models/invoice_transaction.rb

Overview

Cryptocurrency transaction hash and its risk level details

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ InvoiceTransaction

Initializes the object

Parameters:

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

    Model attributes in the form of hash



33
34
35
# File 'lib/cryptopay/models/invoice_transaction.rb', line 33

def initialize(attributes = {})
  @attributes = ENCODER.sanitize(attributes)
end

Class Method Details

.build_from_hash(data) ⇒ Cryptopay::InvoiceTransaction

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:



26
27
28
29
# File 'lib/cryptopay/models/invoice_transaction.rb', line 26

def self.build_from_hash(data)
  attributes = ENCODER.build_from_hash(data)
  new(attributes)
end

Instance Method Details

#inspectObject



72
73
74
# File 'lib/cryptopay/models/invoice_transaction.rb', line 72

def inspect
  "#<#{self.class}:0x#{object_id.to_s(16)}> JSON: " + JSON.pretty_generate(to_hash)
end

#invalid_propertiesObject

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

Returns:

  • Array for valid properties with the reasons



48
49
50
51
52
53
54
55
56
57
58
# File 'lib/cryptopay/models/invoice_transaction.rb', line 48

def invalid_properties
  properties = []

  properties.push('invalid value for "txid", txid cannot be nil.') if txid.nil?

  risk&.invalid_properties&.each do |prop|
    properties.push("invalid value for \"risk\": #{prop}")
  end

  properties
end

#riskObject



42
43
44
# File 'lib/cryptopay/models/invoice_transaction.rb', line 42

def risk
  @attributes[:risk]
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



68
69
70
# File 'lib/cryptopay/models/invoice_transaction.rb', line 68

def to_hash
  ENCODER.to_hash(@attributes)
end

#txidObject

Transaction hash



38
39
40
# File 'lib/cryptopay/models/invoice_transaction.rb', line 38

def txid
  @attributes[:txid]
end

#valid?Boolean

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

Returns:

  • (Boolean)

    true if the model is valid



62
63
64
# File 'lib/cryptopay/models/invoice_transaction.rb', line 62

def valid?
  invalid_properties.empty?
end