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



15
16
17
18
# File 'lib/billomat/actions/complete.rb', line 15

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

Instance Method Details

#callTrueClass

Calls the gateway.

Returns:

  • (TrueClass)


23
24
25
26
27
# File 'lib/billomat/actions/complete.rb', line 23

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



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

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

#wrapped_dataHash

The given options have to be wrapped.

Returns:

  • (Hash)

    the payload for the complete request



32
33
34
# File 'lib/billomat/actions/complete.rb', line 32

def wrapped_data
  { complete: @opts }
end