Class: Merge::Accounting::RemoteResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/merge_ruby_client/accounting/types/remote_response.rb

Overview

# The RemoteResponse Object

### Description
The `RemoteResponse` object is used to represent information returned from a
third-party endpoint.
### Usage Example
View the `RemoteResponse` returned from your `DataPassthrough`.

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method:, path:, status:, response:, response_headers: OMIT, response_type: OMIT, headers: OMIT, additional_properties: nil) ⇒ Merge::Accounting::RemoteResponse

Parameters:

  • method (String)
  • path (String)
  • status (Integer)
  • response (Object)
  • response_headers (Hash{String => Object}) (defaults to: OMIT)
  • response_type (Merge::Accounting::ResponseTypeEnum) (defaults to: OMIT)
  • headers (Hash{String => Object}) (defaults to: OMIT)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/merge_ruby_client/accounting/types/remote_response.rb', line 47

def initialize(method:, path:, status:, response:, response_headers: OMIT, response_type: OMIT, headers: OMIT,
               additional_properties: nil)
  @method = method
  @path = path
  @status = status
  @response = response
  @response_headers = response_headers if response_headers != OMIT
  @response_type = response_type if response_type != OMIT
  @headers = headers if headers != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "method": method,
    "path": path,
    "status": status,
    "response": response,
    "response_headers": response_headers,
    "response_type": response_type,
    "headers": headers
  }.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



31
32
33
# File 'lib/merge_ruby_client/accounting/types/remote_response.rb', line 31

def additional_properties
  @additional_properties
end

#headersHash{String => Object} (readonly)

Returns:

  • (Hash{String => Object})


29
30
31
# File 'lib/merge_ruby_client/accounting/types/remote_response.rb', line 29

def headers
  @headers
end

#methodString (readonly)

Returns:

  • (String)


17
18
19
# File 'lib/merge_ruby_client/accounting/types/remote_response.rb', line 17

def method
  @method
end

#pathString (readonly)

Returns:

  • (String)


19
20
21
# File 'lib/merge_ruby_client/accounting/types/remote_response.rb', line 19

def path
  @path
end

#responseObject (readonly)

Returns:

  • (Object)


23
24
25
# File 'lib/merge_ruby_client/accounting/types/remote_response.rb', line 23

def response
  @response
end

#response_headersHash{String => Object} (readonly)

Returns:

  • (Hash{String => Object})


25
26
27
# File 'lib/merge_ruby_client/accounting/types/remote_response.rb', line 25

def response_headers
  @response_headers
end

#response_typeMerge::Accounting::ResponseTypeEnum (readonly)



27
28
29
# File 'lib/merge_ruby_client/accounting/types/remote_response.rb', line 27

def response_type
  @response_type
end

#statusInteger (readonly)

Returns:

  • (Integer)


21
22
23
# File 'lib/merge_ruby_client/accounting/types/remote_response.rb', line 21

def status
  @status
end

Class Method Details

.from_json(json_object:) ⇒ Merge::Accounting::RemoteResponse

Deserialize a JSON object to an instance of RemoteResponse

Parameters:

  • json_object (String)

Returns:



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/merge_ruby_client/accounting/types/remote_response.rb', line 74

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"]
  status = parsed_json["status"]
  response = parsed_json["response"]
  response_headers = parsed_json["response_headers"]
  response_type = parsed_json["response_type"]
  headers = parsed_json["headers"]
  new(
    method: method,
    path: path,
    status: status,
    response: response,
    response_headers: response_headers,
    response_type: response_type,
    headers: headers,
    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)


109
110
111
112
113
114
115
116
117
# File 'lib/merge_ruby_client/accounting/types/remote_response.rb', line 109

def self.validate_raw(obj:)
  obj.method.is_a?(String) != 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.status.is_a?(Integer) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
  obj.response.is_a?(Object) != false || raise("Passed value for field obj.response is not the expected type, validation failed.")
  obj.response_headers&.is_a?(Hash) != false || raise("Passed value for field obj.response_headers is not the expected type, validation failed.")
  obj.response_type&.is_a?(Merge::Accounting::ResponseTypeEnum) != false || raise("Passed value for field obj.response_type 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.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of RemoteResponse to a JSON object

Returns:

  • (String)


99
100
101
# File 'lib/merge_ruby_client/accounting/types/remote_response.rb', line 99

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