Class: Moip2::AccountsApi
- Inherits:
-
Object
- Object
- Moip2::AccountsApi
- Defined in:
- lib/moip2/accounts_api.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
- #base_path ⇒ Object
- #create(account) ⇒ Object
- #exists?(data) ⇒ Boolean
-
#initialize(client) ⇒ AccountsApi
constructor
A new instance of AccountsApi.
- #show(id) ⇒ Object
Constructor Details
#initialize(client) ⇒ AccountsApi
Returns a new instance of AccountsApi.
5 6 7 |
# File 'lib/moip2/accounts_api.rb', line 5 def initialize(client) @client = client end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
3 4 5 |
# File 'lib/moip2/accounts_api.rb', line 3 def client @client end |
Instance Method Details
#base_path ⇒ Object
9 10 11 |
# File 'lib/moip2/accounts_api.rb', line 9 def base_path "/v2/accounts" end |
#create(account) ⇒ Object
13 14 15 |
# File 'lib/moip2/accounts_api.rb', line 13 def create(account) Resource::Account.new client, client.post(base_path, account) end |
#exists?(data) ⇒ Boolean
17 18 19 20 21 22 23 |
# File 'lib/moip2/accounts_api.rb', line 17 def exists?(data) raise "Use: {email: '[email protected]'} or {tax_document: '999.999.999-99'}" unless has_attribute_to_search(data) response = client.get("#{base_path}/exists?#{to_search(data)}") response.success? end |
#show(id) ⇒ Object
25 26 27 |
# File 'lib/moip2/accounts_api.rb', line 25 def show(id) Resource::Account.new client, client.get("#{base_path}/#{id}") end |