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
93 94 95 |
# File 'lib/cryptopay/models/beneficiary.rb', line 93 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 75 76 77 78 79 |
# 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 pattern = Regexp.new(/^[a-zA-Z0-9\s-]+$/) properties.push("invalid value for \"name\", must conform to the pattern #{pattern}.") if name !~ pattern properties.push('invalid value for "address", address cannot be nil.') if address.nil? 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`.
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
89 90 91 |
# File 'lib/cryptopay/models/beneficiary.rb', line 89 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
83 84 85 |
# File 'lib/cryptopay/models/beneficiary.rb', line 83 def valid? invalid_properties.empty? end |