Class: Cryptopay::Account
- Inherits:
-
Object
- Object
- Cryptopay::Account
- Defined in:
- lib/cryptopay/models/account.rb
Class Method Summary collapse
-
.build_from_hash(data) ⇒ Cryptopay::Account
Builds the object from hash.
Instance Method Summary collapse
-
#balance ⇒ Object
Account balance.
-
#currency ⇒ Object
Account currency.
-
#id ⇒ Object
Account ID.
-
#initialize(attributes = {}) ⇒ Account
constructor
Initializes the object.
- #inspect ⇒ Object
-
#invalid_properties ⇒ Object
Show invalid properties with the reasons.
-
#project_id ⇒ Object
Project ID which the account belongs to.
-
#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 = {}) ⇒ Account
Initializes the object
36 37 38 |
# File 'lib/cryptopay/models/account.rb', line 36 def initialize(attributes = {}) @attributes = ENCODER.sanitize(attributes) end |
Class Method Details
.build_from_hash(data) ⇒ Cryptopay::Account
Builds the object from hash
29 30 31 32 |
# File 'lib/cryptopay/models/account.rb', line 29 def self.build_from_hash(data) attributes = ENCODER.build_from_hash(data) new(attributes) end |
Instance Method Details
#balance ⇒ Object
Account balance
51 52 53 |
# File 'lib/cryptopay/models/account.rb', line 51 def balance @attributes[:balance] end |
#currency ⇒ Object
Account currency
46 47 48 |
# File 'lib/cryptopay/models/account.rb', line 46 def currency @attributes[:currency] end |
#id ⇒ Object
Account ID
41 42 43 |
# File 'lib/cryptopay/models/account.rb', line 41 def id @attributes[:id] end |
#inspect ⇒ Object
88 89 90 |
# File 'lib/cryptopay/models/account.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?
62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/cryptopay/models/account.rb', line 62 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 "balance", balance cannot be nil.') if balance.nil? properties.push('invalid value for "project_id", project_id cannot be nil.') if project_id.nil? properties end |
#project_id ⇒ Object
Project ID which the account belongs to
56 57 58 |
# File 'lib/cryptopay/models/account.rb', line 56 def project_id @attributes[:project_id] end |
#to_hash ⇒ Hash
Returns the object in the form of hash
84 85 86 |
# File 'lib/cryptopay/models/account.rb', line 84 def to_hash ENCODER.to_hash(@attributes) end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
78 79 80 |
# File 'lib/cryptopay/models/account.rb', line 78 def valid? invalid_properties.empty? end |