class Charging::ServiceAccount
Represents a Charging
service account.
Constants
- ATTRIBUTES
Attributes
application_token[R]
Responds the current application token
last_response[R]
Responds the last http response from the API.
Public Class Methods
current()
click to toggle source
# File lib/charging/service_account.rb, line 16 def self.current @current ||= find_by_token(Charging.configuration.application_token) end
find_by_token(token)
click to toggle source
Finds a service account by it's access token. Returns the service account instance with all fields set if successful. If something went wrong, it raises Charging::Http::LastResponseError
.
API documentation: charging.financeconnect.com.br/static/docs/accounts_and_domains.html#get-account-entry-point
# File lib/charging/service_account.rb, line 33 def self.find_by_token(token) response = Http.get('/account/', token) raise Http::LastResponseError.new(response) if response.code != 200 self.load_service_account_for response, token rescue ::RestClient::Exception => exception raise Http::LastResponseError.new(exception.response) end
Private Class Methods
load_service_account_for(response, token)
click to toggle source
# File lib/charging/service_account.rb, line 45 def self.load_service_account_for(response, token) data = MultiJson.decode(response.body) self.new(data, response, token) end