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

#as_json, #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



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

def self.base_path
  '/invoices'
end

.resource_nameString

Returns the resource’s name.

Returns:

  • (String)

    the resource’s name



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

def self.resource_name
  'invoice'
end

Instance Method Details

#cancel!Object

Cancels the invoice by calling the Cancel action.



23
24
25
# File 'lib/billomat/models/invoice.rb', line 23

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

#complete!Object

Completes the invoice by calling the Complete action.



18
19
20
# File 'lib/billomat/models/invoice.rb', line 18

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



30
31
32
33
34
# File 'lib/billomat/models/invoice.rb', line 30

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.



37
38
39
# File 'lib/billomat/models/invoice.rb', line 37

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