Class: Dolibarr::Api::Thirdparties::Representative

Inherits:
Object
  • Object
show all
Defined in:
lib/dolibarr-api/api/thirdparties/representative.rb

Instance Method Summary collapse

Constructor Details

#initialize(connection) ⇒ Representative

Returns a new instance of Representative.



5
6
7
# File 'lib/dolibarr-api/api/thirdparties/representative.rb', line 5

def initialize(connection)
  @connection = connection
end

Instance Method Details

#create(id:, representative_id:) ⇒ Object

Raises:

  • (ArgumentError)


9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/dolibarr-api/api/thirdparties/representative.rb', line 9

def create(id:, representative_id:)
  raise ArgumentError, 'id is required' if id.nil?
  raise ArgumentError, 'representative_id is required' if representative_id.nil?

  @connection.call(
    :POST,
    '/thirdparties/{id}/representative/{representative_id}'
      .gsub('{id}', ERB::Util.url_encode(id.to_s))
      .gsub('{representative_id}', ERB::Util.url_encode(representative_id.to_s)),
    type: nil,
    auth: ['api_key']
  )
end

#delete(id:, representative_id:) ⇒ Object

Raises:

  • (ArgumentError)


23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/dolibarr-api/api/thirdparties/representative.rb', line 23

def delete(id:, representative_id:)
  raise ArgumentError, 'id is required' if id.nil?
  raise ArgumentError, 'representative_id is required' if representative_id.nil?

  @connection.call(
    :DELETE,
    '/thirdparties/{id}/representative/{representative_id}'
      .gsub('{id}', ERB::Util.url_encode(id.to_s))
      .gsub('{representative_id}', ERB::Util.url_encode(representative_id.to_s)),
    type: nil,
    auth: ['api_key']
  )
end