Class: Bvr::Credit
- Inherits:
-
Struct
- Object
- Struct
- Bvr::Credit
- Defined in:
- lib/bvr/credit.rb
Constant Summary collapse
- API_COMMANDS =
{ add: 'settransaction' }
Instance Attribute Summary collapse
-
#customer ⇒ Object
Returns the value of attribute customer.
-
#raw_balance ⇒ Object
Returns the value of attribute raw_balance.
-
#raw_specific_balance ⇒ Object
Returns the value of attribute raw_specific_balance.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#customer ⇒ Object
Returns the value of attribute customer
2 3 4 |
# File 'lib/bvr/credit.rb', line 2 def customer @customer end |
#raw_balance ⇒ Object
Returns the value of attribute raw_balance
2 3 4 |
# File 'lib/bvr/credit.rb', line 2 def raw_balance @raw_balance end |
#raw_specific_balance ⇒ Object
Returns the value of attribute raw_specific_balance
2 3 4 |
# File 'lib/bvr/credit.rb', line 2 def raw_specific_balance @raw_specific_balance end |
Class Method Details
.add(id, amount) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/bvr/credit.rb', line 7 def self.add(id, amount) params = { command: API_COMMANDS[:add], customer: id, amount: amount } Bvr.connection.get(params) end |
Instance Method Details
#add(amount) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/bvr/credit.rb', line 17 def add(amount) response = Bvr::Credit.add(self.customer.id, amount) return false unless response['Result'] == 'Success' add_amount(amount) && true end |
#balance ⇒ Object
25 26 27 |
# File 'lib/bvr/credit.rb', line 25 def balance @_balance ||= Float(self.raw_balance) end |
#rm(amount) ⇒ Object
29 30 31 |
# File 'lib/bvr/credit.rb', line 29 def rm(amount) self.add(-1 * amount) end |
#specific_balance ⇒ Object
33 34 35 |
# File 'lib/bvr/credit.rb', line 33 def specific_balance @_specific_balance ||= Float(self.raw_specific_balance) end |