Class: Billomat::Models::Invoice

Inherits:
Base
  • Object
show all
Defined in:
lib/billomat/models/invoice.rb

Overview

Representation of the invoice resource

Instance Attribute Summary

Attributes inherited from Base

#data

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#create, #delete, find, #id, #initialize, #method_missing, #respond_to_missing?, #save, #update, where, #wrapped_data

Constructor Details

This class inherits a constructor from Billomat::Models::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Billomat::Models::Base

Class Method Details

.base_pathString

Returns The resource’s base path.

Returns:

  • (String)

    The resource’s base path



9
10
11
# File 'lib/billomat/models/invoice.rb', line 9

def self.base_path
  '/invoices'
end

.resource_nameString

Returns The resource’s name.

Returns:

  • (String)

    The resource’s name



14
15
16
# File 'lib/billomat/models/invoice.rb', line 14

def self.resource_name
  'invoice'
end

Instance Method Details

#cancel!Object

Cancels the invoice by calling the Cancel action



26
27
28
# File 'lib/billomat/models/invoice.rb', line 26

def cancel!
  Billomat::Actions::Cancel.new(id).call
end

#complete!Object

Completes the invoice by calling the Complete action



20
21
22
# File 'lib/billomat/models/invoice.rb', line 20

def complete!
  Billomat::Actions::Complete.new(id).call
end

#send_email(recipient) ⇒ Object

Sends the invoice as an email to the given recipient

Parameters:

  • recipient (String)

    The email address of the recipient



34
35
36
37
38
# File 'lib/billomat/models/invoice.rb', line 34

def send_email(recipient)
  email_params = { recipients: { to: recipient } }

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

#to_pdfObject

Allows to download the invoice as an PDF



42
43
44
# File 'lib/billomat/models/invoice.rb', line 42

def to_pdf
  Billomat::Actions::Pdf.new(id).call
end