Class: Dolibarr::Api::Invoices::Payments

Inherits:
Object
  • Object
show all
Defined in:
lib/dolibarr-api/api/invoices/payments.rb

Instance Method Summary collapse

Constructor Details

#initialize(connection) ⇒ Payments

Returns a new instance of Payments.



5
6
7
# File 'lib/dolibarr-api/api/invoices/payments.rb', line 5

def initialize(connection)
  @connection = connection
end

Instance Method Details

#create(id:, invoices_add_payment_model:) ⇒ Object

Raises:

  • (ArgumentError)


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

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

  @connection.call(
    :POST,
    '/invoices/{id}/payments'
      .gsub('{id}', ERB::Util.url_encode(id.to_s)),
    type: nil,
    auth: ['api_key'],
    body: invoices_add_payment_model
  )
end

#list(id:) ⇒ Object

Raises:

  • (ArgumentError)


23
24
25
26
27
28
29
30
31
32
33
# File 'lib/dolibarr-api/api/invoices/payments.rb', line 23

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

  @connection.call(
    :GET,
    '/invoices/{id}/payments'
      .gsub('{id}', ERB::Util.url_encode(id.to_s)),
    type: nil,
    auth: ['api_key']
  )
end

#update(id:, invoices_update_payment_model: nil) ⇒ Object

Raises:

  • (ArgumentError)


35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/dolibarr-api/api/invoices/payments.rb', line 35

def update(id:, invoices_update_payment_model: nil)
  raise ArgumentError, 'id is required' if id.nil?

  @connection.call(
    :PUT,
    '/invoices/payments/{id}'
      .gsub('{id}', ERB::Util.url_encode(id.to_s)),
    type: nil,
    auth: ['api_key'],
    body: invoices_update_payment_model
  )
end