Class: Varejonline::API::ThirdParties

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

Instance Attribute Summary

Attributes inherited from Client

#access_token

Instance Method Summary collapse

Methods inherited from Client

#card_negotiations, #category_levels, #client_classes, #companies, #credit_limits, #default_entries, #entities, #initialize, #installments, #orders, #payables, #payment_conditions, #payments, #product_categories, #products, #provisions, #receivables, #sales_history, #sellers, #third_parties, #user_data

Methods included from ClassMethods

#require_all

Constructor Details

This class inherits a constructor from Varejonline::Client

Instance Method Details

#block_credit_limit(id, justification) ⇒ Object



47
48
49
# File 'lib/varejonline/api/third_parties.rb', line 47

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
26
# File 'lib/varejonline/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?(Varejonline::Entity::Administrative::ThirdParty)

  raise ArgumentError
end

#credit_limit_information(id) ⇒ Object



36
37
38
# File 'lib/varejonline/api/third_parties.rb', line 36

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/varejonline/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/varejonline/api/third_parties.rb', line 10

def list(searcher = nil)
  raise ArgumentError unless searcher.nil? || searcher.is_a?(Varejonline::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



51
52
53
# File 'lib/varejonline/api/third_parties.rb', line 51

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)


29
30
31
32
33
34
# File 'lib/varejonline/api/third_parties.rb', line 29

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?(Varejonline::Entity::Administrative::ThirdParty)

  raise ArgumentError
end

#update_credit_limit(id, data) ⇒ Object

Raises:

  • (ArgumentError)


40
41
42
43
44
45
# File 'lib/varejonline/api/third_parties.rb', line 40

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?(Varejonline::Entity::Commercial::CreditLimit)

  raise ArgumentError
end