Class: Merge::Crm::Association
- Inherits:
-
Object
- Object
- Merge::Crm::Association
- Defined in:
- lib/merge_ruby_client/crm/types/association.rb
Overview
# The Association Object
### Description
The `Association` record refers to an instance of an Association Type.
### Usage Example
TODO
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#association_type ⇒ Merge::Crm::AssociationAssociationType
readonly
The association type the association belongs to.
-
#created_at ⇒ DateTime
readonly
The datetime that this object was created by Merge.
-
#modified_at ⇒ DateTime
readonly
The datetime that this object was modified by Merge.
- #source_object ⇒ String readonly
- #target_object ⇒ String readonly
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Merge::Crm::Association
Deserialize a JSON object to an instance of Association.
-
.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(created_at: OMIT, modified_at: OMIT, source_object: OMIT, target_object: OMIT, association_type: OMIT, additional_properties: nil) ⇒ Merge::Crm::Association constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of Association to a JSON object.
Constructor Details
#initialize(created_at: OMIT, modified_at: OMIT, source_object: OMIT, target_object: OMIT, association_type: OMIT, additional_properties: nil) ⇒ Merge::Crm::Association
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/merge_ruby_client/crm/types/association.rb', line 41 def initialize(created_at: OMIT, modified_at: OMIT, source_object: OMIT, target_object: OMIT, association_type: OMIT, additional_properties: nil) @created_at = created_at if created_at != OMIT @modified_at = modified_at if modified_at != OMIT @source_object = source_object if source_object != OMIT @target_object = target_object if target_object != OMIT @association_type = association_type if association_type != OMIT @additional_properties = additional_properties @_field_set = { "created_at": created_at, "modified_at": modified_at, "source_object": source_object, "target_object": target_object, "association_type": association_type }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
27 28 29 |
# File 'lib/merge_ruby_client/crm/types/association.rb', line 27 def additional_properties @additional_properties end |
#association_type ⇒ Merge::Crm::AssociationAssociationType (readonly)
Returns The association type the association belongs to.
25 26 27 |
# File 'lib/merge_ruby_client/crm/types/association.rb', line 25 def association_type @association_type end |
#created_at ⇒ DateTime (readonly)
Returns The datetime that this object was created by Merge.
17 18 19 |
# File 'lib/merge_ruby_client/crm/types/association.rb', line 17 def created_at @created_at end |
#modified_at ⇒ DateTime (readonly)
Returns The datetime that this object was modified by Merge.
19 20 21 |
# File 'lib/merge_ruby_client/crm/types/association.rb', line 19 def modified_at @modified_at end |
#source_object ⇒ String (readonly)
21 22 23 |
# File 'lib/merge_ruby_client/crm/types/association.rb', line 21 def source_object @source_object end |
#target_object ⇒ String (readonly)
23 24 25 |
# File 'lib/merge_ruby_client/crm/types/association.rb', line 23 def target_object @target_object end |
Class Method Details
.from_json(json_object:) ⇒ Merge::Crm::Association
Deserialize a JSON object to an instance of Association
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/merge_ruby_client/crm/types/association.rb', line 64 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) created_at = (DateTime.parse(parsed_json["created_at"]) unless parsed_json["created_at"].nil?) modified_at = (DateTime.parse(parsed_json["modified_at"]) unless parsed_json["modified_at"].nil?) source_object = parsed_json["source_object"] target_object = parsed_json["target_object"] if parsed_json["association_type"].nil? association_type = nil else association_type = parsed_json["association_type"].to_json association_type = Merge::Crm::AssociationAssociationType.from_json(json_object: association_type) end new( created_at: created_at, modified_at: modified_at, source_object: source_object, target_object: target_object, association_type: association_type, 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.
100 101 102 103 104 105 106 |
# File 'lib/merge_ruby_client/crm/types/association.rb', line 100 def self.validate_raw(obj:) obj.created_at&.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") obj.modified_at&.is_a?(DateTime) != false || raise("Passed value for field obj.modified_at is not the expected type, validation failed.") obj.source_object&.is_a?(String) != false || raise("Passed value for field obj.source_object is not the expected type, validation failed.") obj.target_object&.is_a?(String) != false || raise("Passed value for field obj.target_object is not the expected type, validation failed.") obj.association_type.nil? || Merge::Crm::AssociationAssociationType.validate_raw(obj: obj.association_type) end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of Association to a JSON object
90 91 92 |
# File 'lib/merge_ruby_client/crm/types/association.rb', line 90 def to_json(*_args) @_field_set&.to_json end |