Class: Smartbill::Sdk::Services::EstimatesService

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

Overview

/estimate 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



24
25
26
# File 'lib/smartbill/sdk/services/estimates_service.rb', line 24

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

#create(estimate) ⇒ Object



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

def create(estimate)
  validate(estimate, Contracts::EstimateContract)
  parse(execute(build_request(
                  method: "POST", base_url: @client.base_url, path: "estimate",
                  json_body: dump(estimate), 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/estimates_service.rb', line 16

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

#invoices_status(cif, series_name, number) ⇒ Object



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

def invoices_status(cif, series_name, number)
  parse(execute(build_request(
                  method: "GET", base_url: @client.base_url, path: "estimate/invoices",
                  params: { "cif" => cif, "seriesName" => series_name, "number" => number },
                  auth_header: @client.auth_header
                )), Models::ProformaInvoicesResponse)
end

#pdf(cif, series_name, number) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/smartbill/sdk/services/estimates_service.rb', line 32

def pdf(cif, series_name, number)
  execute(build_request(
            method: "GET", base_url: @client.base_url, path: "estimate/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



28
29
30
# File 'lib/smartbill/sdk/services/estimates_service.rb', line 28

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