Class: Cryptopay::CustomerAddress

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ CustomerAddress

Initializes the object

Parameters:

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

    Model attributes in the form of hash



34
35
36
# File 'lib/cryptopay/models/customer_address.rb', line 34

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

Class Method Details

.build_from_hash(data) ⇒ Cryptopay::CustomerAddress

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:



27
28
29
30
# File 'lib/cryptopay/models/customer_address.rb', line 27

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

Instance Method Details

#addressObject

Cryptocurrency address



39
40
41
# File 'lib/cryptopay/models/customer_address.rb', line 39

def address
  @attributes[:address]
end

#currencyObject

Cryptocurrency name



44
45
46
# File 'lib/cryptopay/models/customer_address.rb', line 44

def currency
  @attributes[:currency]
end

#inspectObject



79
80
81
# File 'lib/cryptopay/models/customer_address.rb', line 79

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



55
56
57
58
59
60
61
62
63
64
65
# File 'lib/cryptopay/models/customer_address.rb', line 55

def invalid_properties
  properties = []

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

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

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

  properties
end

#networkObject

Cryptocurrency network



49
50
51
# File 'lib/cryptopay/models/customer_address.rb', line 49

def network
  @attributes[:network]
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



75
76
77
# File 'lib/cryptopay/models/customer_address.rb', line 75

def to_hash
  ENCODER.to_hash(@attributes)
end

#valid?Boolean

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

Returns:

  • (Boolean)

    true if the model is valid



69
70
71
# File 'lib/cryptopay/models/customer_address.rb', line 69

def valid?
  invalid_properties.empty?
end