Class: Merge::Hris::ModelOperation

Inherits:
Object
  • Object
show all
Defined in:
lib/merge_ruby_client/hris/types/model_operation.rb

Overview

# The ModelOperation Object

### Description
The `ModelOperation` object is used to represent the operations that are
currently supported for a given model.
### Usage Example
View what operations are supported for the `Candidate` endpoint.

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model_name:, available_operations:, required_post_parameters:, supported_fields:, additional_properties: nil) ⇒ Merge::Hris::ModelOperation

Parameters:

  • model_name (String)
  • available_operations (Array<String>)
  • required_post_parameters (Array<String>)
  • supported_fields (Array<String>)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/merge_ruby_client/hris/types/model_operation.rb', line 37

def initialize(model_name:, available_operations:, required_post_parameters:, supported_fields:,
               additional_properties: nil)
  @model_name = model_name
  @available_operations = available_operations
  @required_post_parameters = required_post_parameters
  @supported_fields = supported_fields
  @additional_properties = additional_properties
  @_field_set = {
    "model_name": model_name,
    "available_operations": available_operations,
    "required_post_parameters": required_post_parameters,
    "supported_fields": supported_fields
  }
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/hris/types/model_operation.rb', line 24

def additional_properties
  @additional_properties
end

#available_operationsArray<String> (readonly)

Returns:

  • (Array<String>)


18
19
20
# File 'lib/merge_ruby_client/hris/types/model_operation.rb', line 18

def available_operations
  @available_operations
end

#model_nameString (readonly)

Returns:

  • (String)


16
17
18
# File 'lib/merge_ruby_client/hris/types/model_operation.rb', line 16

def model_name
  @model_name
end

#required_post_parametersArray<String> (readonly)

Returns:

  • (Array<String>)


20
21
22
# File 'lib/merge_ruby_client/hris/types/model_operation.rb', line 20

def required_post_parameters
  @required_post_parameters
end

#supported_fieldsArray<String> (readonly)

Returns:

  • (Array<String>)


22
23
24
# File 'lib/merge_ruby_client/hris/types/model_operation.rb', line 22

def supported_fields
  @supported_fields
end

Class Method Details

.from_json(json_object:) ⇒ Merge::Hris::ModelOperation

Deserialize a JSON object to an instance of ModelOperation

Parameters:

  • json_object (String)

Returns:



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/merge_ruby_client/hris/types/model_operation.rb', line 56

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  model_name = parsed_json["model_name"]
  available_operations = parsed_json["available_operations"]
  required_post_parameters = parsed_json["required_post_parameters"]
  supported_fields = parsed_json["supported_fields"]
  new(
    model_name: model_name,
    available_operations: available_operations,
    required_post_parameters: required_post_parameters,
    supported_fields: supported_fields,
    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)


85
86
87
88
89
90
# File 'lib/merge_ruby_client/hris/types/model_operation.rb', line 85

def self.validate_raw(obj:)
  obj.model_name.is_a?(String) != false || raise("Passed value for field obj.model_name is not the expected type, validation failed.")
  obj.available_operations.is_a?(Array) != false || raise("Passed value for field obj.available_operations is not the expected type, validation failed.")
  obj.required_post_parameters.is_a?(Array) != false || raise("Passed value for field obj.required_post_parameters is not the expected type, validation failed.")
  obj.supported_fields.is_a?(Array) != false || raise("Passed value for field obj.supported_fields is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of ModelOperation to a JSON object

Returns:

  • (String)


75
76
77
# File 'lib/merge_ruby_client/hris/types/model_operation.rb', line 75

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