Class: Merge::Crm::RemoteField
- Inherits:
-
Object
- Object
- Merge::Crm::RemoteField
- Defined in:
- lib/merge_ruby_client/crm/types/remote_field.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
- #remote_field_class ⇒ Merge::Crm::RemoteFieldRemoteFieldClass readonly
- #value ⇒ Object readonly
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Merge::Crm::RemoteField
Deserialize a JSON object to an instance of RemoteField.
-
.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(remote_field_class:, value: OMIT, additional_properties: nil) ⇒ Merge::Crm::RemoteField constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of RemoteField to a JSON object.
Constructor Details
#initialize(remote_field_class:, value: OMIT, additional_properties: nil) ⇒ Merge::Crm::RemoteField
26 27 28 29 30 31 32 33 |
# File 'lib/merge_ruby_client/crm/types/remote_field.rb', line 26 def initialize(remote_field_class:, value: OMIT, additional_properties: nil) @remote_field_class = remote_field_class @value = value if value != OMIT @additional_properties = additional_properties @_field_set = { "remote_field_class": remote_field_class, "value": value }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
15 16 17 |
# File 'lib/merge_ruby_client/crm/types/remote_field.rb', line 15 def additional_properties @additional_properties end |
#remote_field_class ⇒ Merge::Crm::RemoteFieldRemoteFieldClass (readonly)
11 12 13 |
# File 'lib/merge_ruby_client/crm/types/remote_field.rb', line 11 def remote_field_class @remote_field_class end |
#value ⇒ Object (readonly)
13 14 15 |
# File 'lib/merge_ruby_client/crm/types/remote_field.rb', line 13 def value @value end |
Class Method Details
.from_json(json_object:) ⇒ Merge::Crm::RemoteField
Deserialize a JSON object to an instance of RemoteField
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/merge_ruby_client/crm/types/remote_field.rb', line 39 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) if parsed_json["remote_field_class"].nil? remote_field_class = nil else remote_field_class = parsed_json["remote_field_class"].to_json remote_field_class = Merge::Crm::RemoteFieldRemoteFieldClass.from_json(json_object: remote_field_class) end value = parsed_json["value"] new( remote_field_class: remote_field_class, value: value, 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.
69 70 71 72 |
# File 'lib/merge_ruby_client/crm/types/remote_field.rb', line 69 def self.validate_raw(obj:) Merge::Crm::RemoteFieldRemoteFieldClass.validate_raw(obj: obj.remote_field_class) obj.value&.is_a?(Object) != false || raise("Passed value for field obj.value is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of RemoteField to a JSON object
59 60 61 |
# File 'lib/merge_ruby_client/crm/types/remote_field.rb', line 59 def to_json(*_args) @_field_set&.to_json end |