class Moip2::AccountsApi
Attributes
client[R]
Public Class Methods
new(client)
click to toggle source
# File lib/moip2/accounts_api.rb, line 5 def initialize(client) @client = client end
Public Instance Methods
base_path()
click to toggle source
# File lib/moip2/accounts_api.rb, line 9 def base_path "/v2/accounts" end
create(account)
click to toggle source
# File lib/moip2/accounts_api.rb, line 13 def create(account) Resource::Account.new client, client.post(base_path, account) end
exists?(data)
click to toggle source
# File lib/moip2/accounts_api.rb, line 17 def exists?(data) raise "Use: {email: 'dev@moip.com'} 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)
click to toggle source
# File lib/moip2/accounts_api.rb, line 25 def show(id) Resource::Account.new client, client.get("#{base_path}/#{id}") end
Private Instance Methods
has_attribute_to_search(data)
click to toggle source
# File lib/moip2/accounts_api.rb, line 31 def has_attribute_to_search(data) data.key?(:tax_document) || data.key?(:email) end
to_search(data)
click to toggle source
# File lib/moip2/accounts_api.rb, line 35 def to_search(data) data.key?(:tax_document) ? "tax_document=#{data[:tax_document]}" : "email=#{data[:email]}" end