Class: Cryptopay::Customer
- Inherits:
-
Object
- Object
- Cryptopay::Customer
- Defined in:
- lib/cryptopay/models/customer.rb
Class Method Summary collapse
-
.build_from_hash(data) ⇒ Cryptopay::Customer
Builds the object from hash.
Instance Method Summary collapse
-
#addresses ⇒ Object
The list of refund addresses where Cryptopay will refund High-Risk transactions to.
-
#currency ⇒ Object
The customer’s currency in your system.
-
#id ⇒ Object
The customer’s reference ID in your system.
-
#initialize(attributes = {}) ⇒ Customer
constructor
Initializes the object.
- #inspect ⇒ Object
-
#invalid_properties ⇒ Object
Show invalid properties with the reasons.
-
#to_hash ⇒ Hash
Returns the object in the form of hash.
-
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid.
Constructor Details
#initialize(attributes = {}) ⇒ Customer
Initializes the object
34 35 36 |
# File 'lib/cryptopay/models/customer.rb', line 34 def initialize(attributes = {}) @attributes = ENCODER.sanitize(attributes) end |
Class Method Details
.build_from_hash(data) ⇒ Cryptopay::Customer
Builds the object from hash
27 28 29 30 |
# File 'lib/cryptopay/models/customer.rb', line 27 def self.build_from_hash(data) attributes = ENCODER.build_from_hash(data) new(attributes) end |
Instance Method Details
#addresses ⇒ Object
The list of refund addresses where Cryptopay will refund High-Risk transactions to
49 50 51 |
# File 'lib/cryptopay/models/customer.rb', line 49 def addresses @attributes[:addresses] end |
#currency ⇒ Object
The customer’s currency in your system
44 45 46 |
# File 'lib/cryptopay/models/customer.rb', line 44 def currency @attributes[:currency] end |
#id ⇒ Object
The customer’s reference ID in your system
39 40 41 |
# File 'lib/cryptopay/models/customer.rb', line 39 def id @attributes[:id] end |
#inspect ⇒ Object
85 86 87 |
# File 'lib/cryptopay/models/customer.rb', line 85 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?
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/cryptopay/models/customer.rb', line 55 def invalid_properties properties = [] properties.push('invalid value for "id", id cannot be nil.') if id.nil? properties.push('invalid value for "currency", currency cannot be nil.') if currency.nil? properties.push('invalid value for "addresses", addresses cannot be nil.') if addresses.nil? addresses&.each_with_index do |item, index| item.invalid_properties.each do |prop| properties.push("invalid value for \"addresses.#{index}\": #{prop}") end end properties end |
#to_hash ⇒ Hash
Returns the object in the form of hash
81 82 83 |
# File 'lib/cryptopay/models/customer.rb', line 81 def to_hash ENCODER.to_hash(@attributes) end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
75 76 77 |
# File 'lib/cryptopay/models/customer.rb', line 75 def valid? invalid_properties.empty? end |