Class: Vpsa::Api::ThirdParties

Inherits:
Client
  • Object
show all
Defined in:
lib/vpsa/api/third_parties.rb

Instance Attribute Summary

Attributes inherited from Client

#access_token

Instance Method Summary collapse

Methods inherited from Client

#category_levels, #client_classes, #companies, #credit_limits, #default_entries, #entities, #initialize, #installments, #orders, #payment_conditions, #product_categories, #products, #provisions, #receipts, #sales_history, #sellers, #third_parties, #user_data

Methods included from ClassMethods

#require_all

Constructor Details

This class inherits a constructor from Vpsa::Client

Instance Method Details

#block_credit_limit(id, justification) ⇒ Object



44
45
46
# File 'lib/vpsa/api/third_parties.rb', line 44

def block_credit_limit(id, justification)
  return parse_response(self.class.put("/#{id}/limites_credito/bloquear", :body => build_body({"motivo" => justification}),  :headers => header))
end

#create(data) ⇒ Object Also known as: new

Raises:

  • (ArgumentError)


21
22
23
24
25
# File 'lib/vpsa/api/third_parties.rb', line 21

def create(data)
  return parse_response(self.class.post("/", :body => build_body(data), :headers => header)) if data.is_a?(Hash)
  return parse_response(self.class.post("/", :body => build_body(data.as_parameter), :headers => header)) if data.is_a?(Vpsa::Entity::Administrative::ThirdParty)
  raise ArgumentError
end

#credit_limit_information(id) ⇒ Object



34
35
36
# File 'lib/vpsa/api/third_parties.rb', line 34

def credit_limit_information(id)
  return parse_response(self.class.get("/#{id}/limites_credito", :body => build_body,  :headers => header))
end

#find(id) ⇒ Object



17
18
19
# File 'lib/vpsa/api/third_parties.rb', line 17

def find(id)
  return parse_response(self.class.get("/#{id}", :body => build_body,  :headers => header))
end

#list(searcher = nil) ⇒ Object

Raises:

  • (ArgumentError)


10
11
12
13
14
15
# File 'lib/vpsa/api/third_parties.rb', line 10

def list(searcher = nil)
  raise ArgumentError unless searcher.nil? || searcher.is_a?(Vpsa::Searcher::Administrative::ThirdPartySearcher)
  
  return parse_response(self.class.get("/", :body => build_body(searcher.as_parameter),  :headers => header)) if searcher
  return parse_response(self.class.get("/", :body => build_body,  :headers => header)) unless searcher
end

#unlock_credit_limit(id, justification) ⇒ Object



48
49
50
# File 'lib/vpsa/api/third_parties.rb', line 48

def unlock_credit_limit(id, justification)
  return parse_response(self.class.put("/#{id}/limites_credito/desbloquear", :body => build_body({"motivo" => justification}),  :headers => header))
end

#update(id, data) ⇒ Object

Raises:

  • (ArgumentError)


28
29
30
31
32
# File 'lib/vpsa/api/third_parties.rb', line 28

def update(id, data)
  return parse_response(self.class.put("/#{id}", :body => build_body(data), :headers => header)) if data.is_a?(Hash)
  return parse_response(self.class.put("/#{id}", :body => build_body(data.as_parameter), :headers => header)) if data.is_a?(Vpsa::Entity::Administrative::ThirdParty)
  raise ArgumentError
end

#update_credit_limit(id, data) ⇒ Object

Raises:

  • (ArgumentError)


38
39
40
41
42
# File 'lib/vpsa/api/third_parties.rb', line 38

def update_credit_limit(id, data)
  return parse_response(self.class.put("/#{id}/limites_credito/#{id}", :body => build_body(data), :headers => header)) if data.is_a?(Hash)
  return parse_response(self.class.put("/#{id}/limites_credito/#{id}", :body => build_body(data.as_parameter), :headers => header)) if data.is_a?(Vpsa::Entity::Commercial::CreditLimit)
  raise ArgumentError
end