Class: Billomat::Actions::Complete

Inherits:
Object
  • Object
show all
Defined in:
lib/billomat/actions/complete.rb

Overview

Completes an invoice by calling the /complete path on a resource

Instance Method Summary collapse

Constructor Details

#initialize(invoice_id, opts = {}) ⇒ Billomat::Actions::Complete

Returns a Complete object

Examples:

Billomat::Actions::Complete('12345', { template_id: '10231' })

Parameters:

  • invoice_id (String)

    The ID of the invoice

  • opts (Hash) (defaults to: {})

    The options for this request



17
18
19
20
# File 'lib/billomat/actions/complete.rb', line 17

def initialize(invoice_id, opts = {})
  @invoice_id = invoice_id
  @opts = opts
end

Instance Method Details

#callTrueClass

Calls the gateway

Returns:

  • (TrueClass)


26
27
28
29
30
# File 'lib/billomat/actions/complete.rb', line 26

def call
  Billomat::Gateway.new(:put, path, wrapped_data).run

  true
end

#pathString

Returns The complete path with the invoice_id.

Returns:

  • (String)

    The complete path with the invoice_id



41
42
43
# File 'lib/billomat/actions/complete.rb', line 41

def path
  "/invoices/#{@invoice_id}/complete"
end

#wrapped_dataHash

The given options have to be wrapped

Returns:

  • (Hash)

    The payload for the complete request



36
37
38
# File 'lib/billomat/actions/complete.rb', line 36

def wrapped_data
  { complete: @opts }
end