Class: CandidApiClient::Invoices::V2::Types::Invoice

Inherits:
Object
  • Object
show all
Defined in:
lib/candidhealth/invoices/v_2/types/invoice.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(amount_cents:, created_at:, updated_at:, organization_id:, invoice_destination_metadata:, patient_external_id:, due_date:, status:, items:, note: OMIT, url: OMIT, customer_invoice_url: OMIT, additional_properties: nil) ⇒ CandidApiClient::Invoices::V2::Types::Invoice

Parameters:

  • amount_cents (Integer)

    Total monetary amount (in cents) of all Invoice Items

  • created_at (DateTime)
  • updated_at (DateTime)
  • organization_id (String)
  • invoice_destination_metadata (CandidApiClient::Invoices::V2::Types::InvoiceDestinationMetadata)

    Contains all relevant information from the third-party service this invoice was created in

  • patient_external_id (String)
  • note (String) (defaults to: OMIT)
  • due_date (Date)
  • status (CandidApiClient::Invoices::V2::Types::InvoiceStatus)
  • url (String) (defaults to: OMIT)

    Link to the admin view of the invoice in the third-party service

  • customer_invoice_url (String) (defaults to: OMIT)

    Link to the patient view of the invoice in the third-party service

  • items (CandidApiClient::Invoices::V2::Types::InvoiceItemInfo)

    The InvoiceItem rollup which contains all claim and service line invoice items

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/candidhealth/invoices/v_2/types/invoice.rb', line 63

def initialize(amount_cents:, created_at:, updated_at:, organization_id:, invoice_destination_metadata:,
               patient_external_id:, due_date:, status:, items:, note: OMIT, url: OMIT, customer_invoice_url: OMIT, additional_properties: nil)
  @amount_cents = amount_cents
  @created_at = created_at
  @updated_at = updated_at
  @organization_id = organization_id
  @invoice_destination_metadata = 
  @patient_external_id = patient_external_id
  @note = note if note != OMIT
  @due_date = due_date
  @status = status
  @url = url if url != OMIT
  @customer_invoice_url = customer_invoice_url if customer_invoice_url != OMIT
  @items = items
  @additional_properties = additional_properties
  @_field_set = {
    "amount_cents": amount_cents,
    "created_at": created_at,
    "updated_at": updated_at,
    "organization_id": organization_id,
    "invoice_destination_metadata": ,
    "patient_external_id": patient_external_id,
    "note": note,
    "due_date": due_date,
    "status": status,
    "url": url,
    "customer_invoice_url": customer_invoice_url,
    "items": items
  }.reject do |_k, v|
    v == OMIT
  end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



41
42
43
# File 'lib/candidhealth/invoices/v_2/types/invoice.rb', line 41

def additional_properties
  @additional_properties
end

#amount_centsInteger (readonly)

Returns Total monetary amount (in cents) of all Invoice Items.

Returns:

  • (Integer)

    Total monetary amount (in cents) of all Invoice Items



16
17
18
# File 'lib/candidhealth/invoices/v_2/types/invoice.rb', line 16

def amount_cents
  @amount_cents
end

#created_atDateTime (readonly)

Returns:

  • (DateTime)


18
19
20
# File 'lib/candidhealth/invoices/v_2/types/invoice.rb', line 18

def created_at
  @created_at
end

#customer_invoice_urlString (readonly)

Returns Link to the patient view of the invoice in the third-party service.

Returns:

  • (String)

    Link to the patient view of the invoice in the third-party service



37
38
39
# File 'lib/candidhealth/invoices/v_2/types/invoice.rb', line 37

def customer_invoice_url
  @customer_invoice_url
end

#due_dateDate (readonly)

Returns:

  • (Date)


31
32
33
# File 'lib/candidhealth/invoices/v_2/types/invoice.rb', line 31

def due_date
  @due_date
end

#invoice_destination_metadataCandidApiClient::Invoices::V2::Types::InvoiceDestinationMetadata (readonly)

Returns Contains all relevant information from the third-party service this invoice was created in.

Returns:



25
26
27
# File 'lib/candidhealth/invoices/v_2/types/invoice.rb', line 25

def 
  @invoice_destination_metadata
end

#itemsCandidApiClient::Invoices::V2::Types::InvoiceItemInfo (readonly)

Returns The InvoiceItem rollup which contains all claim and service line invoice items.

Returns:



39
40
41
# File 'lib/candidhealth/invoices/v_2/types/invoice.rb', line 39

def items
  @items
end

#noteString (readonly)

Returns:

  • (String)


29
30
31
# File 'lib/candidhealth/invoices/v_2/types/invoice.rb', line 29

def note
  @note
end

#organization_idString (readonly)

Returns:

  • (String)


22
23
24
# File 'lib/candidhealth/invoices/v_2/types/invoice.rb', line 22

def organization_id
  @organization_id
end

#patient_external_idString (readonly)

Returns:

  • (String)


27
28
29
# File 'lib/candidhealth/invoices/v_2/types/invoice.rb', line 27

def patient_external_id
  @patient_external_id
end

#statusCandidApiClient::Invoices::V2::Types::InvoiceStatus (readonly)



33
34
35
# File 'lib/candidhealth/invoices/v_2/types/invoice.rb', line 33

def status
  @status
end

#updated_atDateTime (readonly)

Returns:

  • (DateTime)


20
21
22
# File 'lib/candidhealth/invoices/v_2/types/invoice.rb', line 20

def updated_at
  @updated_at
end

#urlString (readonly)

Returns Link to the admin view of the invoice in the third-party service.

Returns:

  • (String)

    Link to the admin view of the invoice in the third-party service



35
36
37
# File 'lib/candidhealth/invoices/v_2/types/invoice.rb', line 35

def url
  @url
end

Class Method Details

.from_json(json_object:) ⇒ CandidApiClient::Invoices::V2::Types::Invoice

Deserialize a JSON object to an instance of Invoice

Parameters:

  • json_object (String)

Returns:



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/candidhealth/invoices/v_2/types/invoice.rb', line 100

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  amount_cents = struct["amount_cents"]
  created_at = (DateTime.parse(parsed_json["created_at"]) unless parsed_json["created_at"].nil?)
  updated_at = (DateTime.parse(parsed_json["updated_at"]) unless parsed_json["updated_at"].nil?)
  organization_id = struct["organization_id"]
  if parsed_json["invoice_destination_metadata"].nil?
     = nil
  else
     = parsed_json["invoice_destination_metadata"].to_json
     = CandidApiClient::Invoices::V2::Types::InvoiceDestinationMetadata.from_json(json_object: )
  end
  patient_external_id = struct["patient_external_id"]
  note = struct["note"]
  due_date = (Date.parse(parsed_json["due_date"]) unless parsed_json["due_date"].nil?)
  status = struct["status"]
  url = struct["url"]
  customer_invoice_url = struct["customer_invoice_url"]
  if parsed_json["items"].nil?
    items = nil
  else
    items = parsed_json["items"].to_json
    items = CandidApiClient::Invoices::V2::Types::InvoiceItemInfo.from_json(json_object: items)
  end
  new(
    amount_cents: amount_cents,
    created_at: created_at,
    updated_at: updated_at,
    organization_id: organization_id,
    invoice_destination_metadata: ,
    patient_external_id: patient_external_id,
    note: note,
    due_date: due_date,
    status: status,
    url: url,
    customer_invoice_url: customer_invoice_url,
    items: items,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Leveraged for Union-type generation, validate_raw attempts to parse the given

hash and check each fields type against the current object's property
definitions.

Parameters:

  • obj (Object)

Returns:

  • (Void)


155
156
157
158
159
160
161
162
163
164
165
166
167
168
# File 'lib/candidhealth/invoices/v_2/types/invoice.rb', line 155

def self.validate_raw(obj:)
  obj.amount_cents.is_a?(Integer) != false || raise("Passed value for field obj.amount_cents is not the expected type, validation failed.")
  obj.created_at.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.")
  obj.updated_at.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.")
  obj.organization_id.is_a?(String) != false || raise("Passed value for field obj.organization_id is not the expected type, validation failed.")
  CandidApiClient::Invoices::V2::Types::InvoiceDestinationMetadata.validate_raw(obj: obj.)
  obj.patient_external_id.is_a?(String) != false || raise("Passed value for field obj.patient_external_id is not the expected type, validation failed.")
  obj.note&.is_a?(String) != false || raise("Passed value for field obj.note is not the expected type, validation failed.")
  obj.due_date.is_a?(Date) != false || raise("Passed value for field obj.due_date is not the expected type, validation failed.")
  obj.status.is_a?(CandidApiClient::Invoices::V2::Types::InvoiceStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
  obj.url&.is_a?(String) != false || raise("Passed value for field obj.url is not the expected type, validation failed.")
  obj.customer_invoice_url&.is_a?(String) != false || raise("Passed value for field obj.customer_invoice_url is not the expected type, validation failed.")
  CandidApiClient::Invoices::V2::Types::InvoiceItemInfo.validate_raw(obj: obj.items)
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of Invoice to a JSON object

Returns:

  • (String)


145
146
147
# File 'lib/candidhealth/invoices/v_2/types/invoice.rb', line 145

def to_json(*_args)
  @_field_set&.to_json
end