Class: Merge::Crm::Association

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(created_at: OMIT, modified_at: OMIT, source_object: OMIT, target_object: OMIT, association_type: OMIT, additional_properties: nil) ⇒ Merge::Crm::Association

Parameters:

  • created_at (DateTime) (defaults to: OMIT)

    The datetime that this object was created by Merge.

  • modified_at (DateTime) (defaults to: OMIT)

    The datetime that this object was modified by Merge.

  • source_object (String) (defaults to: OMIT)
  • target_object (String) (defaults to: OMIT)
  • association_type (Merge::Crm::AssociationAssociationType) (defaults to: OMIT)

    The association type the association belongs to.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    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_typeMerge::Crm::AssociationAssociationType (readonly)

Returns The association type the association belongs to.

Returns:



25
26
27
# File 'lib/merge_ruby_client/crm/types/association.rb', line 25

def association_type
  @association_type
end

#created_atDateTime (readonly)

Returns The datetime that this object was created by Merge.

Returns:

  • (DateTime)

    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_atDateTime (readonly)

Returns The datetime that this object was modified by Merge.

Returns:

  • (DateTime)

    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_objectString (readonly)

Returns:

  • (String)


21
22
23
# File 'lib/merge_ruby_client/crm/types/association.rb', line 21

def source_object
  @source_object
end

#target_objectString (readonly)

Returns:

  • (String)


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

Parameters:

  • json_object (String)

Returns:



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.

Parameters:

  • obj (Object)

Returns:

  • (Void)


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

Returns:

  • (String)


90
91
92
# File 'lib/merge_ruby_client/crm/types/association.rb', line 90

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