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.



336
337
338
339
# File 'lib/belvo/resources.rb', line 336

def initialize(session)
  super(session)
  @endpoint = 'api/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:



347
348
349
350
351
352
353
354
355
356
357
358
359
360
# File 'lib/belvo/resources.rb', line 347

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,
    save_data: options.save_data || true,
    attach_xml: options.attach_xml
  }.merge(options)
  body = clean body: body
  @session.post(@endpoint, body)
end