Class: Merge::Crm::AssociationTypeRequestRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/merge_ruby_client/crm/types/association_type_request_request.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source_object_class:, target_object_classes:, remote_key_name:, display_name: OMIT, cardinality: OMIT, is_required: OMIT, additional_properties: nil) ⇒ Merge::Crm::AssociationTypeRequestRequest

Parameters:



39
40
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_type_request_request.rb', line 39

def initialize(source_object_class:, target_object_classes:, remote_key_name:, display_name: OMIT,
               cardinality: OMIT, is_required: OMIT, additional_properties: nil)
  @source_object_class = source_object_class
  @target_object_classes = target_object_classes
  @remote_key_name = remote_key_name
  @display_name = display_name if display_name != OMIT
  @cardinality = cardinality if cardinality != OMIT
  @is_required = is_required if is_required != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "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
  }.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



24
25
26
# File 'lib/merge_ruby_client/crm/types/association_type_request_request.rb', line 24

def additional_properties
  @additional_properties
end

#cardinalityMerge::Crm::CardinalityEnum (readonly)



20
21
22
# File 'lib/merge_ruby_client/crm/types/association_type_request_request.rb', line 20

def cardinality
  @cardinality
end

#display_nameString (readonly)

Returns:

  • (String)


18
19
20
# File 'lib/merge_ruby_client/crm/types/association_type_request_request.rb', line 18

def display_name
  @display_name
end

#is_requiredBoolean (readonly)

Returns:

  • (Boolean)


22
23
24
# File 'lib/merge_ruby_client/crm/types/association_type_request_request.rb', line 22

def is_required
  @is_required
end

#remote_key_nameString (readonly)

Returns:

  • (String)


16
17
18
# File 'lib/merge_ruby_client/crm/types/association_type_request_request.rb', line 16

def remote_key_name
  @remote_key_name
end

#source_object_classMerge::Crm::ObjectClassDescriptionRequest (readonly)



12
13
14
# File 'lib/merge_ruby_client/crm/types/association_type_request_request.rb', line 12

def source_object_class
  @source_object_class
end

#target_object_classesArray<Merge::Crm::ObjectClassDescriptionRequest> (readonly)



14
15
16
# File 'lib/merge_ruby_client/crm/types/association_type_request_request.rb', line 14

def target_object_classes
  @target_object_classes
end

Class Method Details

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

Deserialize a JSON object to an instance of AssociationTypeRequestRequest

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
86
87
88
89
90
# File 'lib/merge_ruby_client/crm/types/association_type_request_request.rb', line 64

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  if parsed_json["source_object_class"].nil?
    source_object_class = nil
  else
    source_object_class = parsed_json["source_object_class"].to_json
    source_object_class = Merge::Crm::ObjectClassDescriptionRequest.from_json(json_object: source_object_class)
  end
  target_object_classes = parsed_json["target_object_classes"]&.map do |item|
    item = item.to_json
    Merge::Crm::ObjectClassDescriptionRequest.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(
    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

.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)


105
106
107
108
109
110
111
112
# File 'lib/merge_ruby_client/crm/types/association_type_request_request.rb', line 105

def self.validate_raw(obj:)
  Merge::Crm::ObjectClassDescriptionRequest.validate_raw(obj: obj.source_object_class)
  obj.target_object_classes.is_a?(Array) != false || raise("Passed value for field obj.target_object_classes is not the expected type, validation failed.")
  obj.remote_key_name.is_a?(String) != false || raise("Passed value for field obj.remote_key_name is not the expected type, validation failed.")
  obj.display_name&.is_a?(String) != false || raise("Passed value for field obj.display_name is not the expected type, validation failed.")
  obj.cardinality&.is_a?(Merge::Crm::CardinalityEnum) != false || raise("Passed value for field obj.cardinality is not the expected type, validation failed.")
  obj.is_required&.is_a?(Boolean) != false || raise("Passed value for field obj.is_required is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of AssociationTypeRequestRequest to a JSON object

Returns:

  • (String)


95
96
97
# File 'lib/merge_ruby_client/crm/types/association_type_request_request.rb', line 95

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