class Contaazul::Client
Public Class Methods
new(options = {})
click to toggle source
# File lib/contaazul/client.rb, line 9 def initialize(options = {}) options = Contaazul.options.merge(options) Configuration::VALID_OPTIONS_KEYS.each do |key| send("#{key}=", options[key]) end Contaazul.company_token = options[:company_token] if options[:company_token] end
Public Instance Methods
client(id, options={})
click to toggle source
Get a single client
@param id [String] ID of client to fetch @return [Hash::Mash] Client
information
# File lib/contaazul/client.rb, line 45 def client(id, options={}) record = Contaazul.get("pub/contact/customer/#{id}") record end
clients()
click to toggle source
Get all clients
@return [Array(Hash)] Clients information
# File lib/contaazul/client.rb, line 36 def clients records = Contaazul.get("pub/contact/customer") records end
create_client(options={})
click to toggle source
Create a client
@param options [Hash] client information. @option options [String] :description @return [Hashie::Mash] Newly created client info
# File lib/contaazul/client.rb, line 55 def create_client(options={}) record = Contaazul.post("pub/contact/customer", options) record end
create_link()
click to toggle source
# File lib/contaazul/client.rb, line 27 def create_link response = Contaazul.get("pub/oauth/requestkey/#{self.external_token}") "https://app.contaazul.com.br/authorization/request/#{response}?redirectTo=#{self.return_url}" end
delete_client(id, options={})
click to toggle source
Delete a client
@param id [String] Client
ID @return [Boolean] Indicating success of deletion
# File lib/contaazul/client.rb, line 76 def delete_client(id, options={}) record = Contaazul.delete("pub/contact/customer/#{id}") record end
edit_client(id, options={})
click to toggle source
Edit a client
@param id [String] Client
ID @param options [Hash] Client
information. @option options [String] :description @return
[Hashie::Mash] Newly updated client info
# File lib/contaazul/client.rb, line 67 def edit_client(id, options={}) record = Contaazul.patch("pub/contact/customer/#{id}", options) record end
to_s()
click to toggle source
Calls superclass method
# File lib/contaazul/client.rb, line 22 def to_s return create_link unless false #authenticated? super end