Sha256: ce35595bc5cc2f2c712df7dfcbee9c486d05219934fa306b48482e55afdb8d86

Contents?: true

Size: 757 Bytes

Versions: 11

Compression:

Stored size: 757 Bytes

Contents

# frozen_string_literal: true

module Billomat
  module Actions
    # This class allows to download the invoice as a pdf.
    # The PDF comes in a base64 encoded string in the response body.
    class Pdf
      # @param invoice_id [String] the invoice ID
      # @param opts [Hash] the options for this action
      # @return [Billomat::Actions::Pdf]
      def initialize(invoice_id, opts = {})
        @invoice_id = invoice_id
        @opts = opts
      end

      # Calls the gateway.
      #
      # @return [TrueClass]
      def call
        resp = Billomat::Gateway.new(:get, path).run
        resp['pdf']
      end

      # @return [String] the path for the PDF action
      def path
        "/invoices/#{@invoice_id}/pdf"
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
billomat-1.2.5 lib/billomat/actions/pdf.rb
billomat-1.2.4 lib/billomat/actions/pdf.rb
billomat-1.2.3 lib/billomat/actions/pdf.rb
billomat-1.2.2 lib/billomat/actions/pdf.rb
billomat-1.2.1 lib/billomat/actions/pdf.rb
billomat-1.2.0 lib/billomat/actions/pdf.rb
billomat-1.1.0 lib/billomat/actions/pdf.rb
billomat-1.0.0 lib/billomat/actions/pdf.rb
billomat-0.4.1 lib/billomat/actions/pdf.rb
billomat-0.4.0 lib/billomat/actions/pdf.rb
billomat-0.3.0 lib/billomat/actions/pdf.rb