Class: Merge::Crm::RemoteFieldRequest

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(remote_field_class:, value: OMIT, additional_properties: nil) ⇒ Merge::Crm::RemoteFieldRequest

Parameters:



26
27
28
29
30
31
32
33
# File 'lib/merge_ruby_client/crm/types/remote_field_request.rb', line 26

def initialize(remote_field_class:, value: OMIT, additional_properties: nil)
  @remote_field_class = remote_field_class
  @value = value if value != OMIT
  @additional_properties = additional_properties
  @_field_set = { "remote_field_class": remote_field_class, "value": value }.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



15
16
17
# File 'lib/merge_ruby_client/crm/types/remote_field_request.rb', line 15

def additional_properties
  @additional_properties
end

#remote_field_classMerge::Crm::RemoteFieldRequestRemoteFieldClass (readonly)



11
12
13
# File 'lib/merge_ruby_client/crm/types/remote_field_request.rb', line 11

def remote_field_class
  @remote_field_class
end

#valueObject (readonly)

Returns:

  • (Object)


13
14
15
# File 'lib/merge_ruby_client/crm/types/remote_field_request.rb', line 13

def value
  @value
end

Class Method Details

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

Deserialize a JSON object to an instance of RemoteFieldRequest

Parameters:

  • json_object (String)

Returns:



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/merge_ruby_client/crm/types/remote_field_request.rb', line 39

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  if parsed_json["remote_field_class"].nil?
    remote_field_class = nil
  else
    remote_field_class = parsed_json["remote_field_class"].to_json
    remote_field_class = Merge::Crm::RemoteFieldRequestRemoteFieldClass.from_json(json_object: remote_field_class)
  end
  value = parsed_json["value"]
  new(
    remote_field_class: remote_field_class,
    value: value,
    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)


69
70
71
72
# File 'lib/merge_ruby_client/crm/types/remote_field_request.rb', line 69

def self.validate_raw(obj:)
  Merge::Crm::RemoteFieldRequestRemoteFieldClass.validate_raw(obj: obj.remote_field_class)
  obj.value&.is_a?(Object) != false || raise("Passed value for field obj.value is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of RemoteFieldRequest to a JSON object

Returns:

  • (String)


59
60
61
# File 'lib/merge_ruby_client/crm/types/remote_field_request.rb', line 59

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