Class: Nfe::ServiceInvoice

Inherits:
Data
  • Object
show all
Defined in:
lib/nfe/resources/dto/service_invoice.rb,
sig/nfe/resources/dto/service_invoice.rbs

Overview

Immutable value object for a service invoice (NFS-e) as returned by the NFE.io api.nfe.io/v1 service-invoice API.

The nf-servico-v1.yaml OpenAPI spec defines NO component schemas (the shape is derived from the operations), so this DTO is hand-written — mirror of the fields the Node/PHP SDKs read. ServiceInvoice.from_api maps the API camelCase keys onto snake_case members, drops unknown keys, and is nil-tolerant (+from_api(nil)+ returns nil).

flow_status drives the polling lifecycle; pass it to FlowStatus.terminal? to decide when the document is settled.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeServiceInvoice

Returns a new instance of ServiceInvoice.

Parameters:

  • id: (String, nil)
  • flow_status: (String, nil)
  • flow_message: (String, nil)
  • status: (Object)
  • environment: (Object)
  • rps_number: (Object)
  • rps_serial_number: (Object)
  • number: (Object)
  • check_code: (String, nil)
  • issued_on: (String, nil)
  • cancelled_on: (String, nil)
  • amount_net: (Object)
  • services_amount: (Object)
  • borrower: (Object)
  • city_service_code: (Object)
  • federal_service_code: (Object)
  • description: (String, nil)
  • pdf: (Object)
  • xml: (Object)
  • created_on: (String, nil)
  • modified_on: (String, nil)


28
# File 'sig/nfe/resources/dto/service_invoice.rbs', line 28

def initialize: (id: String?, flow_status: String?, flow_message: String?, status: untyped, environment: untyped, rps_number: untyped, rps_serial_number: untyped, number: untyped, check_code: String?, issued_on: String?, cancelled_on: String?, amount_net: untyped, services_amount: untyped, borrower: untyped, city_service_code: untyped, federal_service_code: untyped, description: String?, pdf: untyped, xml: untyped, created_on: String?, modified_on: String?) -> void

Instance Attribute Details

#amount_netObject (readonly)

Returns the value of attribute amount_net.

Returns:

  • (Object)


14
15
16
# File 'sig/nfe/resources/dto/service_invoice.rbs', line 14

def amount_net
  @amount_net
end

#borrowerObject (readonly)

Returns the value of attribute borrower.

Returns:

  • (Object)


16
17
18
# File 'sig/nfe/resources/dto/service_invoice.rbs', line 16

def borrower
  @borrower
end

#cancelled_onString? (readonly)

Returns the value of attribute cancelled_on.

Returns:

  • (String, nil)


13
14
15
# File 'sig/nfe/resources/dto/service_invoice.rbs', line 13

def cancelled_on
  @cancelled_on
end

#check_codeString? (readonly)

Returns the value of attribute check_code.

Returns:

  • (String, nil)


11
12
13
# File 'sig/nfe/resources/dto/service_invoice.rbs', line 11

def check_code
  @check_code
end

#city_service_codeObject (readonly)

Returns the value of attribute city_service_code.

Returns:

  • (Object)


17
18
19
# File 'sig/nfe/resources/dto/service_invoice.rbs', line 17

def city_service_code
  @city_service_code
end

#created_onString? (readonly)

Returns the value of attribute created_on.

Returns:

  • (String, nil)


22
23
24
# File 'sig/nfe/resources/dto/service_invoice.rbs', line 22

def created_on
  @created_on
end

#descriptionString? (readonly)

Returns the value of attribute description.

Returns:

  • (String, nil)


19
20
21
# File 'sig/nfe/resources/dto/service_invoice.rbs', line 19

def description
  @description
end

#environmentObject (readonly)

Returns the value of attribute environment.

Returns:

  • (Object)


7
8
9
# File 'sig/nfe/resources/dto/service_invoice.rbs', line 7

def environment
  @environment
end

#federal_service_codeObject (readonly)

Returns the value of attribute federal_service_code.

Returns:

  • (Object)


18
19
20
# File 'sig/nfe/resources/dto/service_invoice.rbs', line 18

def federal_service_code
  @federal_service_code
end

#flow_messageString? (readonly)

Returns the value of attribute flow_message.

Returns:

  • (String, nil)


5
6
7
# File 'sig/nfe/resources/dto/service_invoice.rbs', line 5

def flow_message
  @flow_message
end

#flow_statusString? (readonly)

Returns the value of attribute flow_status.

Returns:

  • (String, nil)


4
5
6
# File 'sig/nfe/resources/dto/service_invoice.rbs', line 4

def flow_status
  @flow_status
end

#idString? (readonly)

Returns the value of attribute id.

Returns:

  • (String, nil)


3
4
5
# File 'sig/nfe/resources/dto/service_invoice.rbs', line 3

def id
  @id
end

#issued_onString? (readonly)

Returns the value of attribute issued_on.

Returns:

  • (String, nil)


12
13
14
# File 'sig/nfe/resources/dto/service_invoice.rbs', line 12

def issued_on
  @issued_on
end

#modified_onString? (readonly)

Returns the value of attribute modified_on.

Returns:

  • (String, nil)


23
24
25
# File 'sig/nfe/resources/dto/service_invoice.rbs', line 23

def modified_on
  @modified_on
end

#numberObject (readonly)

Returns the value of attribute number.

Returns:

  • (Object)


10
11
12
# File 'sig/nfe/resources/dto/service_invoice.rbs', line 10

def number
  @number
end

#pdfObject (readonly)

Returns the value of attribute pdf.

Returns:

  • (Object)


20
21
22
# File 'sig/nfe/resources/dto/service_invoice.rbs', line 20

def pdf
  @pdf
end

#rps_numberObject (readonly)

Returns the value of attribute rps_number.

Returns:

  • (Object)


8
9
10
# File 'sig/nfe/resources/dto/service_invoice.rbs', line 8

def rps_number
  @rps_number
end

#rps_serial_numberObject (readonly)

Returns the value of attribute rps_serial_number.

Returns:

  • (Object)


9
10
11
# File 'sig/nfe/resources/dto/service_invoice.rbs', line 9

def rps_serial_number
  @rps_serial_number
end

#services_amountObject (readonly)

Returns the value of attribute services_amount.

Returns:

  • (Object)


15
16
17
# File 'sig/nfe/resources/dto/service_invoice.rbs', line 15

def services_amount
  @services_amount
end

#statusObject (readonly)

Returns the value of attribute status.

Returns:

  • (Object)


6
7
8
# File 'sig/nfe/resources/dto/service_invoice.rbs', line 6

def status
  @status
end

#xmlObject (readonly)

Returns the value of attribute xml.

Returns:

  • (Object)


21
22
23
# File 'sig/nfe/resources/dto/service_invoice.rbs', line 21

def xml
  @xml
end

Class Method Details

.from_api(payload) ⇒ Nfe::ServiceInvoice?

Build a Nfe::ServiceInvoice from an API payload.

Parameters:

  • payload (Hash, nil)

    the response object.

Returns:



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/nfe/resources/dto/service_invoice.rb', line 42

def self.from_api(payload)
  return nil if payload.nil?

  new(
    id: payload["id"],
    flow_status: payload["flowStatus"],
    flow_message: payload["flowMessage"],
    status: payload["status"],
    environment: payload["environment"],
    rps_number: payload["rpsNumber"],
    rps_serial_number: payload["rpsSerialNumber"],
    number: payload["number"],
    check_code: payload["checkCode"],
    issued_on: payload["issuedOn"],
    cancelled_on: payload["cancelledOn"],
    amount_net: payload["amountNet"],
    services_amount: payload["servicesAmount"],
    borrower: payload["borrower"],
    city_service_code: payload["cityServiceCode"],
    federal_service_code: payload["federalServiceCode"],
    description: payload["description"],
    pdf: payload["pdf"],
    xml: payload["xml"],
    created_on: payload["createdOn"],
    modified_on: payload["modifiedOn"]
  )
end

.newinstance

Parameters:

  • id: (String, nil)
  • flow_status: (String, nil)
  • flow_message: (String, nil)
  • status: (Object)
  • environment: (Object)
  • rps_number: (Object)
  • rps_serial_number: (Object)
  • number: (Object)
  • check_code: (String, nil)
  • issued_on: (String, nil)
  • cancelled_on: (String, nil)
  • amount_net: (Object)
  • services_amount: (Object)
  • borrower: (Object)
  • city_service_code: (Object)
  • federal_service_code: (Object)
  • description: (String, nil)
  • pdf: (Object)
  • xml: (Object)
  • created_on: (String, nil)
  • modified_on: (String, nil)

Returns:

  • (instance)


27
# File 'sig/nfe/resources/dto/service_invoice.rbs', line 27

def self.new: (id: String?, flow_status: String?, flow_message: String?, status: untyped, environment: untyped, rps_number: untyped, rps_serial_number: untyped, number: untyped, check_code: String?, issued_on: String?, cancelled_on: String?, amount_net: untyped, services_amount: untyped, borrower: untyped, city_service_code: untyped, federal_service_code: untyped, description: String?, pdf: untyped, xml: untyped, created_on: String?, modified_on: String?) -> instance