Class: Belvo::Invoice

Inherits:
Resource show all
Defined in:
lib/belvo/resources.rb

Overview

An Invoice is the representation of an electronic invoice, that can be received or sent, by a business or an individual and has been uploaded to the fiscal institution website

Instance Attribute Summary

Attributes inherited from Resource

#endpoint

Instance Method Summary collapse

Methods inherited from Resource

#clean, #delete, #detail, #list, #resume

Constructor Details

#initialize(session) ⇒ Invoice

Returns a new instance of Invoice.



284
285
286
287
# File 'lib/belvo/resources.rb', line 284

def initialize(session)
  super(session)
  @endpoint = 'invoices/'
end

Instance Method Details

#retrieve(link:, date_from:, date_to:, type:, options: nil) ⇒ Hash

Returns created invoices details.

Parameters:

  • link (String)

    Link UUID

  • date_from (String)

    Date string (YYYY-MM-DD)

  • date_to (String)

    Date string (YYYY-MM-DD)

  • options (InvoiceOptions) (defaults to: nil)

    Configurable properties

Returns:

  • (Hash)

    created invoices details

Raises:



295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
# File 'lib/belvo/resources.rb', line 295

def retrieve(link:, date_from:, date_to:, type:, options: nil)
  options = InvoiceOptions.from(options)
  body = {
    link: link,
    date_from: date_from,
    date_to: date_to,
    type: type,
    token: options.token,
    encryption_key: options.encryption_key,
    save_data: options.save_data || true,
    attach_xml: options.attach_xml
  }.merge(options)
  body = clean body: body
  @session.post(@endpoint, body)
end