Class: CandidApiClient::Financials::Types::Allocation
- Inherits:
-
Object
- Object
- CandidApiClient::Financials::Types::Allocation
- Defined in:
- lib/candidhealth/financials/types/allocation.rb
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::AllocationTarget readonly
Class Method Summary collapse
-
.from_json(json_object:) ⇒ CandidApiClient::Financials::Types::Allocation
Deserialize a JSON object to an instance of Allocation.
-
.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::Allocation constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of Allocation to a JSON object.
Constructor Details
#initialize(amount_cents:, target:, additional_properties: nil) ⇒ CandidApiClient::Financials::Types::Allocation
27 28 29 30 31 32 |
# File 'lib/candidhealth/financials/types/allocation.rb', line 27 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.
16 17 18 |
# File 'lib/candidhealth/financials/types/allocation.rb', line 16 def additional_properties @additional_properties end |
#amount_cents ⇒ Integer (readonly)
12 13 14 |
# File 'lib/candidhealth/financials/types/allocation.rb', line 12 def amount_cents @amount_cents end |
#target ⇒ CandidApiClient::Financials::Types::AllocationTarget (readonly)
14 15 16 |
# File 'lib/candidhealth/financials/types/allocation.rb', line 14 def target @target end |
Class Method Details
.from_json(json_object:) ⇒ CandidApiClient::Financials::Types::Allocation
Deserialize a JSON object to an instance of Allocation
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/candidhealth/financials/types/allocation.rb', line 38 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::AllocationTarget.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.
68 69 70 71 |
# File 'lib/candidhealth/financials/types/allocation.rb', line 68 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::AllocationTarget.validate_raw(obj: obj.target) end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of Allocation to a JSON object
58 59 60 |
# File 'lib/candidhealth/financials/types/allocation.rb', line 58 def to_json(*_args) @_field_set&.to_json end |