Class: ERPC::AccountClient
- Inherits:
-
Object
- Object
- ERPC::AccountClient
- Defined in:
- lib/erpc_sdk/rest.rb
Instance Method Summary collapse
- #get_token_balance ⇒ Object
-
#initialize(transport) ⇒ AccountClient
constructor
A new instance of AccountClient.
Constructor Details
#initialize(transport) ⇒ AccountClient
Returns a new instance of AccountClient.
41 42 43 |
# File 'lib/erpc_sdk/rest.rb', line 41 def initialize(transport) @transport = transport end |
Instance Method Details
#get_token_balance ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/erpc_sdk/rest.rb', line 45 def get_token_balance data = Validation.mapping(@transport.get("/v3/erpc/token-balance")) unless %w[business developer free pro].include?(data["plan"]) raise InvalidResponseError, "ERPC returned an invalid token balance" end Validation.number(data["max_tokens"], integer: true) Validation.number(data["remaining_tokens"], integer: true) Validation.string(data["next_refill_at"]) unless data["next_refill_at"].nil? data rescue InvalidResponseError raise InvalidResponseError, "ERPC returned an invalid token balance" end |