Method: Merge::Crm::AssociationType.from_json

Defined in:
lib/merge_ruby_client/crm/types/association_type.rb

.from_json(json_object:) ⇒ Merge::Crm::AssociationType

Deserialize a JSON object to an instance of AssociationType

Parameters:

  • json_object (String)

Returns:



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/merge_ruby_client/crm/types/association_type.rb', line 92

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  id = parsed_json["id"]
  remote_id = parsed_json["remote_id"]
  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_class = parsed_json["source_object_class"]
  target_object_classes = parsed_json["target_object_classes"]&.map do |item|
    item = item.to_json
    Merge::Crm::AssociationSubType.from_json(json_object: item)
  end
  remote_key_name = parsed_json["remote_key_name"]
  display_name = parsed_json["display_name"]
  cardinality = parsed_json["cardinality"]
  is_required = parsed_json["is_required"]
  new(
    id: id,
    remote_id: remote_id,
    created_at: created_at,
    modified_at: modified_at,
    source_object_class: source_object_class,
    target_object_classes: target_object_classes,
    remote_key_name: remote_key_name,
    display_name: display_name,
    cardinality: cardinality,
    is_required: is_required,
    additional_properties: struct
  )
end