Class: Verifalia::Credits::Client

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

Overview

Manages credit packs, daily free credits and usage consumption for the Verifalia account.

Instance Method Summary collapse

Constructor Details

#initialize(rest_client) ⇒ Client

Returns a new instance of Client.



38
39
40
# File 'lib/verifalia/credits/client.rb', line 38

def initialize(rest_client)
  @rest_client = rest_client
end

Instance Method Details

#get_balanceVerifalia::Credits::Balance

Returns the current credits balance for the Verifalia account.

Returns:



44
45
46
47
48
49
50
51
# File 'lib/verifalia/credits/client.rb', line 44

def get_balance
  response = @rest_client.invoke 'get',
                                 'credits/balance'

  return Balance.from_json(JSON.parse(response.body)) if response.status == 200

  raise "Unexpected HTTP response: #{response.status} #{response.body}"
end