Sha256: 42370e02d9b2532350ffe36f41a3dc64b5f4eaa6f6aaf3e301597bc24231119d

Contents?: true

Size: 1.03 KB

Versions: 11

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

module Billomat
  module Models
    # Representation of the invoice resource
    class Invoice < Base
      # @return [String] the resource's base path
      def self.base_path
        '/invoices'
      end

      # @return [String] the resource's name
      def self.resource_name
        'invoice'
      end

      # Completes the invoice by calling the Complete action.
      def complete!
        Billomat::Actions::Complete.new(id).call
      end

      # Cancels the invoice by calling the Cancel action.
      def cancel!
        Billomat::Actions::Cancel.new(id).call
      end

      # Sends the invoice as an email to the given recipient.
      #
      # @param [String] recipient The email address of the recipient
      def send_email(recipient)
        email_params = { recipients: { to: recipient } }

        Billomat::Actions::Email.new(id, email_params).call
      end

      # Allows to download the invoice as an PDF.
      def to_pdf
        Billomat::Actions::Pdf.new(id).call
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

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