Class: Cryptopay::BeneficiaryAddress

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ BeneficiaryAddress

Initializes the object



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

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

Class Method Details

.build_from_hash(data) ⇒ Cryptopay::BeneficiaryAddress

Builds the object from hash



31
32
33
34
# File 'lib/cryptopay/models/beneficiary_address.rb', line 31

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

Instance Method Details

#cityObject

The city of the address.



48
49
50
# File 'lib/cryptopay/models/beneficiary_address.rb', line 48

def city
  @attributes[:city]
end

#countryObject

The 2-letter ISO country code of the address.



43
44
45
# File 'lib/cryptopay/models/beneficiary_address.rb', line 43

def country
  @attributes[:country]
end

#inspectObject



107
108
109
# File 'lib/cryptopay/models/beneficiary_address.rb', line 107

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?



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/cryptopay/models/beneficiary_address.rb', line 69

def invalid_properties
  properties = []

  if !country.nil? && country.to_s.length > 2
    properties.push('invalid value for "country", the character length must be smaller than or equal to 2.')
  end

  if !city.nil? && city.to_s.length > 35
    properties.push('invalid value for "city", the character length must be smaller than or equal to 35.')
  end

  if !line_1.nil? && line_1.to_s.length > 70
    properties.push('invalid value for "line_1", the character length must be smaller than or equal to 70.')
  end

  if !line_2.nil? && line_2.to_s.length > 70
    properties.push('invalid value for "line_2", the character length must be smaller than or equal to 70.')
  end

  if !post_code.nil? && post_code.to_s.length > 16
    properties.push('invalid value for "post_code", the character length must be smaller than or equal to 16.')
  end

  properties
end

#line_1Object

First line of the address.



53
54
55
# File 'lib/cryptopay/models/beneficiary_address.rb', line 53

def line_1
  @attributes[:line_1]
end

#line_2Object

Second line of the address.



58
59
60
# File 'lib/cryptopay/models/beneficiary_address.rb', line 58

def line_2
  @attributes[:line_2]
end

#post_codeObject

Postal code of the address.



63
64
65
# File 'lib/cryptopay/models/beneficiary_address.rb', line 63

def post_code
  @attributes[:post_code]
end

#to_hashHash

Returns the object in the form of hash



103
104
105
# File 'lib/cryptopay/models/beneficiary_address.rb', line 103

def to_hash
  ENCODER.to_hash(@attributes)
end

#valid?Boolean

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



97
98
99
# File 'lib/cryptopay/models/beneficiary_address.rb', line 97

def valid?
  invalid_properties.empty?
end