Class: Merge::Crm::RemoteFieldClass

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id: OMIT, display_name: OMIT, remote_key_name: OMIT, description: OMIT, is_custom: OMIT, is_required: OMIT, field_type: OMIT, field_format: OMIT, field_choices: OMIT, item_schema: OMIT, additional_properties: nil) ⇒ Merge::Crm::RemoteFieldClass

Parameters:

  • id (String) (defaults to: OMIT)
  • display_name (String) (defaults to: OMIT)
  • remote_key_name (String) (defaults to: OMIT)
  • description (String) (defaults to: OMIT)
  • is_custom (Boolean) (defaults to: OMIT)
  • is_required (Boolean) (defaults to: OMIT)
  • field_type (Merge::Crm::FieldTypeEnum) (defaults to: OMIT)
  • field_format (Merge::Crm::FieldFormatEnum) (defaults to: OMIT)
  • field_choices (Array<Merge::Crm::RemoteFieldClassFieldChoicesItem>) (defaults to: OMIT)
  • item_schema (Merge::Crm::ItemSchema) (defaults to: OMIT)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/merge_ruby_client/crm/types/remote_field_class.rb', line 53

def initialize(id: OMIT, display_name: OMIT, remote_key_name: OMIT, description: OMIT, is_custom: OMIT,
               is_required: OMIT, field_type: OMIT, field_format: OMIT, field_choices: OMIT, item_schema: OMIT, additional_properties: nil)
  @id = id if id != OMIT
  @display_name = display_name if display_name != OMIT
  @remote_key_name = remote_key_name if remote_key_name != OMIT
  @description = description if description != OMIT
  @is_custom = is_custom if is_custom != OMIT
  @is_required = is_required if is_required != OMIT
  @field_type = field_type if field_type != OMIT
  @field_format = field_format if field_format != OMIT
  @field_choices = field_choices if field_choices != OMIT
  @item_schema = item_schema if item_schema != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "id": id,
    "display_name": display_name,
    "remote_key_name": remote_key_name,
    "description": description,
    "is_custom": is_custom,
    "is_required": is_required,
    "field_type": field_type,
    "field_format": field_format,
    "field_choices": field_choices,
    "item_schema": item_schema
  }.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



34
35
36
# File 'lib/merge_ruby_client/crm/types/remote_field_class.rb', line 34

def additional_properties
  @additional_properties
end

#descriptionString (readonly)

Returns:

  • (String)


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

def description
  @description
end

#display_nameString (readonly)

Returns:

  • (String)


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

def display_name
  @display_name
end

#field_choicesArray<Merge::Crm::RemoteFieldClassFieldChoicesItem> (readonly)



30
31
32
# File 'lib/merge_ruby_client/crm/types/remote_field_class.rb', line 30

def field_choices
  @field_choices
end

#field_formatMerge::Crm::FieldFormatEnum (readonly)



28
29
30
# File 'lib/merge_ruby_client/crm/types/remote_field_class.rb', line 28

def field_format
  @field_format
end

#field_typeMerge::Crm::FieldTypeEnum (readonly)



26
27
28
# File 'lib/merge_ruby_client/crm/types/remote_field_class.rb', line 26

def field_type
  @field_type
end

#idString (readonly)

Returns:

  • (String)


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

def id
  @id
end

#is_customBoolean (readonly)

Returns:

  • (Boolean)


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

def is_custom
  @is_custom
end

#is_requiredBoolean (readonly)

Returns:

  • (Boolean)


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

def is_required
  @is_required
end

#item_schemaMerge::Crm::ItemSchema (readonly)



32
33
34
# File 'lib/merge_ruby_client/crm/types/remote_field_class.rb', line 32

def item_schema
  @item_schema
end

#remote_key_nameString (readonly)

Returns:

  • (String)


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

def remote_key_name
  @remote_key_name
end

Class Method Details

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

Deserialize a JSON object to an instance of RemoteFieldClass

Parameters:

  • json_object (String)

Returns:



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

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  id = parsed_json["id"]
  display_name = parsed_json["display_name"]
  remote_key_name = parsed_json["remote_key_name"]
  description = parsed_json["description"]
  is_custom = parsed_json["is_custom"]
  is_required = parsed_json["is_required"]
  field_type = parsed_json["field_type"]
  field_format = parsed_json["field_format"]
  field_choices = parsed_json["field_choices"]&.map do |item|
    item = item.to_json
    Merge::Crm::RemoteFieldClassFieldChoicesItem.from_json(json_object: item)
  end
  if parsed_json["item_schema"].nil?
    item_schema = nil
  else
    item_schema = parsed_json["item_schema"].to_json
    item_schema = Merge::Crm::ItemSchema.from_json(json_object: item_schema)
  end
  new(
    id: id,
    display_name: display_name,
    remote_key_name: remote_key_name,
    description: description,
    is_custom: is_custom,
    is_required: is_required,
    field_type: field_type,
    field_format: field_format,
    field_choices: field_choices,
    item_schema: item_schema,
    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)


135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/merge_ruby_client/crm/types/remote_field_class.rb', line 135

def self.validate_raw(obj:)
  obj.id&.is_a?(String) != false || raise("Passed value for field obj.id 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.remote_key_name&.is_a?(String) != false || raise("Passed value for field obj.remote_key_name is not the expected type, validation failed.")
  obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
  obj.is_custom&.is_a?(Boolean) != false || raise("Passed value for field obj.is_custom 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.")
  obj.field_type&.is_a?(Merge::Crm::FieldTypeEnum) != false || raise("Passed value for field obj.field_type is not the expected type, validation failed.")
  obj.field_format&.is_a?(Merge::Crm::FieldFormatEnum) != false || raise("Passed value for field obj.field_format is not the expected type, validation failed.")
  obj.field_choices&.is_a?(Array) != false || raise("Passed value for field obj.field_choices is not the expected type, validation failed.")
  obj.item_schema.nil? || Merge::Crm::ItemSchema.validate_raw(obj: obj.item_schema)
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of RemoteFieldClass to a JSON object

Returns:

  • (String)


125
126
127
# File 'lib/merge_ruby_client/crm/types/remote_field_class.rb', line 125

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