Class: CandidApiClient::InsurancePayments::V1::Types::InsurancePayment

Inherits:
Object
  • Object
show all
Defined in:
lib/candidhealth/insurance_payments/v_1/types/insurance_payment.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(insurance_payment_id:, payer:, amount_cents:, allocations:, payment_timestamp: OMIT, payment_note: OMIT, additional_properties: nil) ⇒ CandidApiClient::InsurancePayments::V1::Types::InsurancePayment

Parameters:



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/candidhealth/insurance_payments/v_1/types/insurance_payment.rb', line 42

def initialize(insurance_payment_id:, payer:, amount_cents:, allocations:, payment_timestamp: OMIT,
               payment_note: OMIT, additional_properties: nil)
  @insurance_payment_id = insurance_payment_id
  @payer = payer
  @amount_cents = amount_cents
  @payment_timestamp = payment_timestamp if payment_timestamp != OMIT
  @payment_note = payment_note if payment_note != OMIT
  @allocations = allocations
  @additional_properties = additional_properties
  @_field_set = {
    "insurance_payment_id": insurance_payment_id,
    "payer": payer,
    "amount_cents": amount_cents,
    "payment_timestamp": payment_timestamp,
    "payment_note": payment_note,
    "allocations": allocations
  }.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



27
28
29
# File 'lib/candidhealth/insurance_payments/v_1/types/insurance_payment.rb', line 27

def additional_properties
  @additional_properties
end

#allocationsArray<CandidApiClient::Financials::Types::Allocation> (readonly)



25
26
27
# File 'lib/candidhealth/insurance_payments/v_1/types/insurance_payment.rb', line 25

def allocations
  @allocations
end

#amount_centsInteger (readonly)

Returns:

  • (Integer)


19
20
21
# File 'lib/candidhealth/insurance_payments/v_1/types/insurance_payment.rb', line 19

def amount_cents
  @amount_cents
end

#insurance_payment_idString (readonly)

Returns:

  • (String)


15
16
17
# File 'lib/candidhealth/insurance_payments/v_1/types/insurance_payment.rb', line 15

def insurance_payment_id
  @insurance_payment_id
end

#payerCandidApiClient::Payers::V3::Types::Payer (readonly)



17
18
19
# File 'lib/candidhealth/insurance_payments/v_1/types/insurance_payment.rb', line 17

def payer
  @payer
end

#payment_noteString (readonly)

Returns:

  • (String)


23
24
25
# File 'lib/candidhealth/insurance_payments/v_1/types/insurance_payment.rb', line 23

def payment_note
  @payment_note
end

#payment_timestampDateTime (readonly)

Returns:

  • (DateTime)


21
22
23
# File 'lib/candidhealth/insurance_payments/v_1/types/insurance_payment.rb', line 21

def payment_timestamp
  @payment_timestamp
end

Class Method Details

.from_json(json_object:) ⇒ CandidApiClient::InsurancePayments::V1::Types::InsurancePayment

Deserialize a JSON object to an instance of InsurancePayment

Parameters:

  • json_object (String)

Returns:



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
95
# File 'lib/candidhealth/insurance_payments/v_1/types/insurance_payment.rb', line 67

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  insurance_payment_id = struct["insurance_payment_id"]
  if parsed_json["payer"].nil?
    payer = nil
  else
    payer = parsed_json["payer"].to_json
    payer = CandidApiClient::Payers::V3::Types::Payer.from_json(json_object: payer)
  end
  amount_cents = struct["amount_cents"]
  payment_timestamp = unless parsed_json["payment_timestamp"].nil?
                        DateTime.parse(parsed_json["payment_timestamp"])
                      end
  payment_note = struct["payment_note"]
  allocations = parsed_json["allocations"]&.map do |item|
    item = item.to_json
    CandidApiClient::Financials::Types::Allocation.from_json(json_object: item)
  end
  new(
    insurance_payment_id: insurance_payment_id,
    payer: payer,
    amount_cents: amount_cents,
    payment_timestamp: payment_timestamp,
    payment_note: payment_note,
    allocations: allocations,
    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)


110
111
112
113
114
115
116
117
# File 'lib/candidhealth/insurance_payments/v_1/types/insurance_payment.rb', line 110

def self.validate_raw(obj:)
  obj.insurance_payment_id.is_a?(String) != false || raise("Passed value for field obj.insurance_payment_id is not the expected type, validation failed.")
  CandidApiClient::Payers::V3::Types::Payer.validate_raw(obj: obj.payer)
  obj.amount_cents.is_a?(Integer) != false || raise("Passed value for field obj.amount_cents is not the expected type, validation failed.")
  obj.payment_timestamp&.is_a?(DateTime) != false || raise("Passed value for field obj.payment_timestamp is not the expected type, validation failed.")
  obj.payment_note&.is_a?(String) != false || raise("Passed value for field obj.payment_note is not the expected type, validation failed.")
  obj.allocations.is_a?(Array) != false || raise("Passed value for field obj.allocations is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of InsurancePayment to a JSON object

Returns:

  • (String)


100
101
102
# File 'lib/candidhealth/insurance_payments/v_1/types/insurance_payment.rb', line 100

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