Class: CandidApiClient::Financials::Types::AllocationCreate

Inherits:
Object
  • Object
show all
Defined in:
lib/candidhealth/financials/types/allocation_create.rb

Overview

Allocations are portions of payments that are applied to specific resources,

known as targets. Each allocation has
and amount, defined in cents, and a target.

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(amount_cents:, target:, additional_properties: nil) ⇒ CandidApiClient::Financials::Types::AllocationCreate

Parameters:



30
31
32
33
34
35
# File 'lib/candidhealth/financials/types/allocation_create.rb', line 30

def initialize(amount_cents:, target:, additional_properties: nil)
  @amount_cents = amount_cents
  @target = target
  @additional_properties = additional_properties
  @_field_set = { "amount_cents": amount_cents, "target": target }
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



19
20
21
# File 'lib/candidhealth/financials/types/allocation_create.rb', line 19

def additional_properties
  @additional_properties
end

#amount_centsInteger (readonly)

Returns:

  • (Integer)


15
16
17
# File 'lib/candidhealth/financials/types/allocation_create.rb', line 15

def amount_cents
  @amount_cents
end

#targetCandidApiClient::Financials::Types::AllocationTargetCreate (readonly)



17
18
19
# File 'lib/candidhealth/financials/types/allocation_create.rb', line 17

def target
  @target
end

Class Method Details

.from_json(json_object:) ⇒ CandidApiClient::Financials::Types::AllocationCreate

Deserialize a JSON object to an instance of AllocationCreate

Parameters:

  • json_object (String)

Returns:



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/candidhealth/financials/types/allocation_create.rb', line 41

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"]
  if parsed_json["target"].nil?
    target = nil
  else
    target = parsed_json["target"].to_json
    target = CandidApiClient::Financials::Types::AllocationTargetCreate.from_json(json_object: target)
  end
  new(
    amount_cents: amount_cents,
    target: target,
    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)


71
72
73
74
# File 'lib/candidhealth/financials/types/allocation_create.rb', line 71

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.")
  CandidApiClient::Financials::Types::AllocationTargetCreate.validate_raw(obj: obj.target)
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of AllocationCreate to a JSON object

Returns:

  • (String)


61
62
63
# File 'lib/candidhealth/financials/types/allocation_create.rb', line 61

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