Class: Merge::Hris::DataPassthroughRequest

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

Overview

# The DataPassthrough Object

### Description
The `DataPassthrough` object is used to send information to an
otherwise-unsupported third-party endpoint.
### Usage Example
Create a `DataPassthrough` to get team hierarchies from your Rippling
integration.

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method:, path:, base_url_override: OMIT, data: OMIT, multipart_form_data: OMIT, headers: OMIT, request_format: OMIT, normalize_response: OMIT, additional_properties: nil) ⇒ Merge::Hris::DataPassthroughRequest

Parameters:

  • method (Merge::Hris::MethodEnum)
  • path (String)

    The path of the request in the third party’s platform.

  • base_url_override (String) (defaults to: OMIT)

    An optional override of the third party’s base url for the request.

  • data (String) (defaults to: OMIT)

    The data with the request. You must include a ‘request_format` parameter matching the data’s format

  • multipart_form_data (Array<Merge::Hris::MultipartFormFieldRequest>) (defaults to: OMIT)

    Pass an array of ‘MultipartFormField` objects in here instead of using the `data` param if `request_format` is set to `MULTIPART`.

  • headers (Hash{String => Object}) (defaults to: OMIT)

    The headers to use for the request (Merge will handle the account’s authorization headers). ‘Content-Type` header is required for passthrough. Choose content type corresponding to expected format of receiving server.

  • request_format (Merge::Hris::RequestFormatEnum) (defaults to: OMIT)
  • normalize_response (Boolean) (defaults to: OMIT)

    Optional. If true, the response will always be an object of the form ‘T, “value”: …` where `T` will be one of `string, boolean, number, null, array, object`.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/merge_ruby_client/hris/types/data_passthrough_request.rb', line 65

def initialize(method:, path:, base_url_override: OMIT, data: OMIT, multipart_form_data: OMIT, headers: OMIT,
               request_format: OMIT, normalize_response: OMIT, additional_properties: nil)
  @method = method
  @path = path
  @base_url_override = base_url_override if base_url_override != OMIT
  @data = data if data != OMIT
  @multipart_form_data = multipart_form_data if multipart_form_data != OMIT
  @headers = headers if headers != OMIT
  @request_format = request_format if request_format != OMIT
  @normalize_response = normalize_response if normalize_response != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "method": method,
    "path": path,
    "base_url_override": base_url_override,
    "data": data,
    "multipart_form_data": multipart_form_data,
    "headers": headers,
    "request_format": request_format,
    "normalize_response": normalize_response
  }.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



42
43
44
# File 'lib/merge_ruby_client/hris/types/data_passthrough_request.rb', line 42

def additional_properties
  @additional_properties
end

#base_url_overrideString (readonly)

Returns An optional override of the third party’s base url for the request.

Returns:

  • (String)

    An optional override of the third party’s base url for the request.



24
25
26
# File 'lib/merge_ruby_client/hris/types/data_passthrough_request.rb', line 24

def base_url_override
  @base_url_override
end

#dataString (readonly)

Returns The data with the request. You must include a ‘request_format` parameter matching the data’s format.

Returns:

  • (String)

    The data with the request. You must include a ‘request_format` parameter matching the data’s format



27
28
29
# File 'lib/merge_ruby_client/hris/types/data_passthrough_request.rb', line 27

def data
  @data
end

#headersHash{String => Object} (readonly)

Returns The headers to use for the request (Merge will handle the account’s authorization headers). ‘Content-Type` header is required for passthrough. Choose content type corresponding to expected format of receiving server.

Returns:

  • (Hash{String => Object})

    The headers to use for the request (Merge will handle the account’s authorization headers). ‘Content-Type` header is required for passthrough. Choose content type corresponding to expected format of receiving server.



34
35
36
# File 'lib/merge_ruby_client/hris/types/data_passthrough_request.rb', line 34

def headers
  @headers
end

#methodMerge::Hris::MethodEnum (readonly)



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

def method
  @method
end

#multipart_form_dataArray<Merge::Hris::MultipartFormFieldRequest> (readonly)

Returns Pass an array of ‘MultipartFormField` objects in here instead of using the `data` param if `request_format` is set to `MULTIPART`.

Returns:



30
31
32
# File 'lib/merge_ruby_client/hris/types/data_passthrough_request.rb', line 30

def multipart_form_data
  @multipart_form_data
end

#normalize_responseBoolean (readonly)

Returns Optional. If true, the response will always be an object of the form ‘T, “value”: …` where `T` will be one of `string, boolean, number, null, array, object`.

Returns:

  • (Boolean)

    Optional. If true, the response will always be an object of the form ‘T, “value”: …` where `T` will be one of `string, boolean, number, null, array, object`.



40
41
42
# File 'lib/merge_ruby_client/hris/types/data_passthrough_request.rb', line 40

def normalize_response
  @normalize_response
end

#pathString (readonly)

Returns The path of the request in the third party’s platform.

Returns:

  • (String)

    The path of the request in the third party’s platform.



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

def path
  @path
end

#request_formatMerge::Hris::RequestFormatEnum (readonly)



36
37
38
# File 'lib/merge_ruby_client/hris/types/data_passthrough_request.rb', line 36

def request_format
  @request_format
end

Class Method Details

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

Deserialize a JSON object to an instance of DataPassthroughRequest

Parameters:

  • json_object (String)

Returns:



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
# File 'lib/merge_ruby_client/hris/types/data_passthrough_request.rb', line 94

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  method = parsed_json["method"]
  path = parsed_json["path"]
  base_url_override = parsed_json["base_url_override"]
  data = parsed_json["data"]
  multipart_form_data = parsed_json["multipart_form_data"]&.map do |item|
    item = item.to_json
    Merge::Hris::MultipartFormFieldRequest.from_json(json_object: item)
  end
  headers = parsed_json["headers"]
  request_format = parsed_json["request_format"]
  normalize_response = parsed_json["normalize_response"]
  new(
    method: method,
    path: path,
    base_url_override: base_url_override,
    data: data,
    multipart_form_data: multipart_form_data,
    headers: headers,
    request_format: request_format,
    normalize_response: normalize_response,
    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)


134
135
136
137
138
139
140
141
142
143
# File 'lib/merge_ruby_client/hris/types/data_passthrough_request.rb', line 134

def self.validate_raw(obj:)
  obj.method.is_a?(Merge::Hris::MethodEnum) != false || raise("Passed value for field obj.method is not the expected type, validation failed.")
  obj.path.is_a?(String) != false || raise("Passed value for field obj.path is not the expected type, validation failed.")
  obj.base_url_override&.is_a?(String) != false || raise("Passed value for field obj.base_url_override is not the expected type, validation failed.")
  obj.data&.is_a?(String) != false || raise("Passed value for field obj.data is not the expected type, validation failed.")
  obj.multipart_form_data&.is_a?(Array) != false || raise("Passed value for field obj.multipart_form_data is not the expected type, validation failed.")
  obj.headers&.is_a?(Hash) != false || raise("Passed value for field obj.headers is not the expected type, validation failed.")
  obj.request_format&.is_a?(Merge::Hris::RequestFormatEnum) != false || raise("Passed value for field obj.request_format is not the expected type, validation failed.")
  obj.normalize_response&.is_a?(Boolean) != false || raise("Passed value for field obj.normalize_response is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of DataPassthroughRequest to a JSON object

Returns:

  • (String)


124
125
126
# File 'lib/merge_ruby_client/hris/types/data_passthrough_request.rb', line 124

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