Class: Smartbill::Sdk::Services::InvoicesService

Inherits:
BaseService
  • Object
show all
Defined in:
lib/smartbill/sdk/services/invoices_service.rb

Overview

/invoice endpoints.

Instance Method Summary collapse

Methods inherited from BaseService

#initialize

Constructor Details

This class inherits a constructor from Smartbill::Sdk::Services::BaseService

Instance Method Details

#cancel(cif, series_name, number) ⇒ Object



32
33
34
# File 'lib/smartbill/sdk/services/invoices_service.rb', line 32

def cancel(cif, series_name, number)
  cancel_restore("cancel", cif, series_name, number)
end

#create(invoice) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/smartbill/sdk/services/invoices_service.rb', line 8

def create(invoice)
  validate(invoice, Contracts::InvoiceContract)
  parse(execute(build_request(
                  method: "POST", base_url: @client.base_url, path: "invoice",
                  json_body: dump(invoice), auth_header: @client.auth_header
                )), Models::InvoiceCreateResponse)
end

#delete(cif, series_name, number) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/smartbill/sdk/services/invoices_service.rb', line 16

def delete(cif, series_name, number)
  parse(execute(build_request(
                  method: "DELETE", base_url: @client.base_url, path: "invoice",
                  params: { "cif" => cif, "seriesName" => series_name, "number" => number },
                  auth_header: @client.auth_header
                )), Models::BaseResponse)
end

#payment_status(cif, series_name, number) ⇒ Object



40
41
42
43
44
45
46
# File 'lib/smartbill/sdk/services/invoices_service.rb', line 40

def payment_status(cif, series_name, number)
  parse(execute(build_request(
                  method: "GET", base_url: @client.base_url, path: "invoice/paymentstatus",
                  params: { "cif" => cif, "seriesName" => series_name, "number" => number },
                  auth_header: @client.auth_header
                )), Models::PaymentStatusResponse)
end

#pdf(cif, series_name, number) ⇒ Object

Returns the raw PDF body as a binary String.



49
50
51
52
53
54
55
# File 'lib/smartbill/sdk/services/invoices_service.rb', line 49

def pdf(cif, series_name, number)
  execute(build_request(
            method: "GET", base_url: @client.base_url, path: "invoice/pdf",
            params: { "cif" => cif, "seriesName" => series_name, "number" => number },
            accept: "application/octet-stream", auth_header: @client.auth_header
          ), binary: true)
end

#restore(cif, series_name, number) ⇒ Object



36
37
38
# File 'lib/smartbill/sdk/services/invoices_service.rb', line 36

def restore(cif, series_name, number)
  cancel_restore("restore", cif, series_name, number)
end

#reverse(storno) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/smartbill/sdk/services/invoices_service.rb', line 24

def reverse(storno)
  validate(storno, Contracts::StornoContract)
  parse(execute(build_request(
                  method: "POST", base_url: @client.base_url, path: "invoice/reverse",
                  json_body: dump(storno), auth_header: @client.auth_header
                )), Models::StornoResponse)
end