Class: Sendly::CreditTransaction
- Inherits:
-
Object
- Object
- Sendly::CreditTransaction
- Defined in:
- lib/sendly/types.rb
Overview
Represents a credit transaction
Constant Summary collapse
- TYPES =
Transaction type constants
%w[purchase usage refund adjustment bonus].freeze
Instance Attribute Summary collapse
-
#amount ⇒ Object
readonly
Returns the value of attribute amount.
-
#balance_after ⇒ Object
readonly
Returns the value of attribute balance_after.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#message_id ⇒ Object
readonly
Returns the value of attribute message_id.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #credit? ⇒ Boolean
- #debit? ⇒ Boolean
-
#initialize(data) ⇒ CreditTransaction
constructor
A new instance of CreditTransaction.
Constructor Details
#initialize(data) ⇒ CreditTransaction
Returns a new instance of CreditTransaction.
436 437 438 439 440 441 442 443 444 |
# File 'lib/sendly/types.rb', line 436 def initialize(data) @id = data["id"] @type = data["type"] @amount = data["amount"] || 0 @balance_after = data["balance_after"] || data["balanceAfter"] || 0 @description = data["description"] @message_id = data["message_id"] || data["messageId"] @created_at = parse_time(data["created_at"] || data["createdAt"]) end |
Instance Attribute Details
#amount ⇒ Object (readonly)
Returns the value of attribute amount.
431 432 433 |
# File 'lib/sendly/types.rb', line 431 def amount @amount end |
#balance_after ⇒ Object (readonly)
Returns the value of attribute balance_after.
431 432 433 |
# File 'lib/sendly/types.rb', line 431 def balance_after @balance_after end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
431 432 433 |
# File 'lib/sendly/types.rb', line 431 def created_at @created_at end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
431 432 433 |
# File 'lib/sendly/types.rb', line 431 def description @description end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
431 432 433 |
# File 'lib/sendly/types.rb', line 431 def id @id end |
#message_id ⇒ Object (readonly)
Returns the value of attribute message_id.
431 432 433 |
# File 'lib/sendly/types.rb', line 431 def @message_id end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
431 432 433 |
# File 'lib/sendly/types.rb', line 431 def type @type end |
Instance Method Details
#credit? ⇒ Boolean
446 447 448 |
# File 'lib/sendly/types.rb', line 446 def credit? amount > 0 end |
#debit? ⇒ Boolean
450 451 452 |
# File 'lib/sendly/types.rb', line 450 def debit? amount < 0 end |