Class: ProcessOut::Balance
- Inherits:
-
Object
- Object
- ProcessOut::Balance
- Defined in:
- lib/processout/balance.rb
Instance Attribute Summary collapse
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#currency ⇒ Object
Returns the value of attribute currency.
-
#expiry ⇒ Object
Returns the value of attribute expiry.
Instance Method Summary collapse
-
#fill_with_data(data) ⇒ Object
- Fills the object with data coming from the API Params:
data
-
Hash
of data coming from the API.
- Fills the object with data coming from the API Params:
-
#initialize(client, data = {}) ⇒ Balance
constructor
- Initializes the Balance object Params:
client
ProcessOut
client instancedata
-
data that can be used to fill the object.
- Initializes the Balance object Params:
-
#new(data = {}) ⇒ Object
Create a new Balance using the current client.
-
#prefill(data) ⇒ Object
- Prefills the object with the data passed as parameters Params:
data
-
Hash
of data.
- Prefills the object with the data passed as parameters Params:
-
#to_json(options) ⇒ Object
Overrides the JSON marshaller to only send the fields we want.
Constructor Details
#initialize(client, data = {}) ⇒ Balance
Initializes the Balance object Params:
client
-
ProcessOut
client instance data
-
data that can be used to fill the object
33 34 35 36 37 38 39 40 |
# File 'lib/processout/balance.rb', line 33 def initialize(client, data = {}) @client = client self.amount = data.fetch(:amount, nil) self.currency = data.fetch(:currency, nil) self.expiry = data.fetch(:expiry, nil) end |
Instance Attribute Details
#amount ⇒ Object
Returns the value of attribute amount.
11 12 13 |
# File 'lib/processout/balance.rb', line 11 def amount @amount end |
#currency ⇒ Object
Returns the value of attribute currency.
12 13 14 |
# File 'lib/processout/balance.rb', line 12 def currency @currency end |
#expiry ⇒ Object
Returns the value of attribute expiry.
13 14 15 |
# File 'lib/processout/balance.rb', line 13 def expiry @expiry end |
Instance Method Details
#fill_with_data(data) ⇒ Object
Fills the object with data coming from the API Params:
data
-
Hash
of data coming from the API
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/processout/balance.rb', line 59 def fill_with_data(data) if data.nil? return self end if data.include? "amount" self.amount = data["amount"] end if data.include? "currency" self.currency = data["currency"] end if data.include? "expiry" self.expiry = data["expiry"] end self end |
#new(data = {}) ⇒ Object
Create a new Balance using the current client
43 44 45 |
# File 'lib/processout/balance.rb', line 43 def new(data = {}) Balance.new(@client, data) end |
#prefill(data) ⇒ Object
Prefills the object with the data passed as parameters Params:
data
-
Hash
of data
79 80 81 82 83 84 85 86 87 88 |
# File 'lib/processout/balance.rb', line 79 def prefill(data) if data.nil? return self end self.amount = data.fetch(:amount, self.amount) self.currency = data.fetch(:currency, self.currency) self.expiry = data.fetch(:expiry, self.expiry) self end |
#to_json(options) ⇒ Object
Overrides the JSON marshaller to only send the fields we want
48 49 50 51 52 53 54 |
# File 'lib/processout/balance.rb', line 48 def to_json() { "amount": self.amount, "currency": self.currency, "expiry": self.expiry, }.to_json end |