Class: Billomat::Actions::Pdf

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

Overview

This class allows to download the invoice as a pdf. The PDF comes in a base64 encoded string in the response body.

Instance Method Summary collapse

Constructor Details

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

Parameters:

  • invoice_id (String)

    the invoice ID

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

    the options for this action



11
12
13
14
# File 'lib/billomat/actions/pdf.rb', line 11

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

Instance Method Details

#callTrueClass

Calls the gateway.

Returns:

  • (TrueClass)


19
20
21
22
# File 'lib/billomat/actions/pdf.rb', line 19

def call
  resp = Billomat::Gateway.new(:get, path).run
  resp['pdf']
end

#pathString

Returns the path for the PDF action.

Returns:

  • (String)

    the path for the PDF action



25
26
27
# File 'lib/billomat/actions/pdf.rb', line 25

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