Class: CandidApiClient::Financials::Types::AllocationCreate
- Inherits:
-
Object
- Object
- CandidApiClient::Financials::Types::AllocationCreate
- 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
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
- #amount_cents ⇒ Integer readonly
- #target ⇒ CandidApiClient::Financials::Types::AllocationTargetCreate readonly
Class Method Summary collapse
-
.from_json(json_object:) ⇒ CandidApiClient::Financials::Types::AllocationCreate
Deserialize a JSON object to an instance of AllocationCreate.
-
.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.
Instance Method Summary collapse
- #initialize(amount_cents:, target:, additional_properties: nil) ⇒ CandidApiClient::Financials::Types::AllocationCreate constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of AllocationCreate to a JSON object.
Constructor Details
#initialize(amount_cents:, target:, additional_properties: nil) ⇒ CandidApiClient::Financials::Types::AllocationCreate
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_properties ⇒ OpenStruct (readonly)
Returns 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_cents ⇒ Integer (readonly)
15 16 17 |
# File 'lib/candidhealth/financials/types/allocation_create.rb', line 15 def amount_cents @amount_cents end |
#target ⇒ CandidApiClient::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
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.
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
61 62 63 |
# File 'lib/candidhealth/financials/types/allocation_create.rb', line 61 def to_json(*_args) @_field_set&.to_json end |