Class: Cryptopay::Beneficiary
- Inherits:
-
Object
- Object
- Cryptopay::Beneficiary
- Defined in:
- lib/cryptopay/models/beneficiary.rb
Overview
Beneficiary information.
Class Method Summary collapse
-
.build_from_hash(data) ⇒ Cryptopay::Beneficiary
Builds the object from hash.
Instance Method Summary collapse
- #address ⇒ Object
-
#initialize(attributes = {}) ⇒ Beneficiary
constructor
Initializes the object.
- #inspect ⇒ Object
-
#invalid_properties ⇒ Object
Show invalid properties with the reasons.
-
#name ⇒ Object
The registered name of the company for a ‘legal_person` or the full name for a `natural_person`.
-
#to_hash ⇒ Hash
Returns the object in the form of hash.
- #type ⇒ Object
-
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid.
Constructor Details
#initialize(attributes = {}) ⇒ Beneficiary
Initializes the object
35 36 37 |
# File 'lib/cryptopay/models/beneficiary.rb', line 35 def initialize(attributes = {}) @attributes = ENCODER.sanitize(attributes) end |
Class Method Details
.build_from_hash(data) ⇒ Cryptopay::Beneficiary
Builds the object from hash
28 29 30 31 |
# File 'lib/cryptopay/models/beneficiary.rb', line 28 def self.build_from_hash(data) attributes = ENCODER.build_from_hash(data) new(attributes) end |
Instance Method Details
#address ⇒ Object
48 49 50 |
# File 'lib/cryptopay/models/beneficiary.rb', line 48 def address @attributes[:address] end |
#inspect ⇒ Object
88 89 90 |
# File 'lib/cryptopay/models/beneficiary.rb', line 88 def inspect "#<#{self.class}:0x#{object_id.to_s(16)}> JSON: " + JSON.pretty_generate(to_hash) end |
#invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/cryptopay/models/beneficiary.rb', line 54 def invalid_properties properties = [] properties.push('invalid value for "type", type cannot be nil.') if type.nil? if !type.nil? && !%w[natural_person legal_person].include?(type) properties.push('invalid value for type, must be one of "natural_person", "legal_person"') end properties.push('invalid value for "name", name cannot be nil.') if name.nil? if name.to_s.length > 100 properties.push('invalid value for "name", the character length must be smaller than or equal to 100.') end address&.invalid_properties&.each do |prop| properties.push("invalid value for \"address\": #{prop}") end properties end |
#name ⇒ Object
The registered name of the company for a ‘legal_person` or the full name for a `natural_person`. Note that only following symbols will be stored, regardless of the input value: letters of any language, digits `0-9`, symbols `&` `!` `,` `.` `-` and single spaces. Symbols `\`, `/`, newlines and tabs will be replaced with spaces. Everything else will be removed, including double spaces and spaces in the end.
44 45 46 |
# File 'lib/cryptopay/models/beneficiary.rb', line 44 def name @attributes[:name] end |
#to_hash ⇒ Hash
Returns the object in the form of hash
84 85 86 |
# File 'lib/cryptopay/models/beneficiary.rb', line 84 def to_hash ENCODER.to_hash(@attributes) end |
#type ⇒ Object
39 40 41 |
# File 'lib/cryptopay/models/beneficiary.rb', line 39 def type @attributes[:type] end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
78 79 80 |
# File 'lib/cryptopay/models/beneficiary.rb', line 78 def valid? invalid_properties.empty? end |