Class: Verifalia::Credits::Balance

Inherits:
Object
  • Object
show all
Defined in:
lib/verifalia/credits/balance.rb

Overview

The credits balance for the Verifalia account.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(credit_packs, free_credits, free_credits_reset_in) ⇒ Balance

Returns a new instance of Balance.



45
46
47
48
49
# File 'lib/verifalia/credits/balance.rb', line 45

def initialize(credit_packs, free_credits, free_credits_reset_in)
  @credit_packs = credit_packs
  @free_credits = free_credits
  @free_credits_reset_in = free_credits_reset_in
end

Instance Attribute Details

#credit_packsObject (readonly)

The number of credit packs (that is, non-expiring credits) available for the account.



37
38
39
# File 'lib/verifalia/credits/balance.rb', line 37

def credit_packs
  @credit_packs
end

#free_creditsObject (readonly)

The number of free daily credits of the account, where available.



40
41
42
# File 'lib/verifalia/credits/balance.rb', line 40

def free_credits
  @free_credits
end

#free_credits_reset_inObject (readonly)

A string representing the amount of time before the daily credits expire, where available, expressed in the form hh:mm:ss.



43
44
45
# File 'lib/verifalia/credits/balance.rb', line 43

def free_credits_reset_in
  @free_credits_reset_in
end

Class Method Details

.from_json(data) ⇒ Object

Parse a Balance from a JSON string.



52
53
54
55
56
# File 'lib/verifalia/credits/balance.rb', line 52

def self.from_json(data)
  Balance.new data['creditPacks'],
              data['freeCredits'],
              data['freeCreditsResetIn']
end