Class: Pinnacle::BadRequestErrorBodyError

Inherits:
Object
  • Object
show all
Defined in:
lib/rcs/types/bad_request_error_body_error.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code: OMIT, expected: OMIT, received: OMIT, path: OMIT, message: OMIT, additional_properties: nil) ⇒ Pinnacle::BadRequestErrorBodyError

Parameters:

  • code (String) (defaults to: OMIT)
  • expected (String) (defaults to: OMIT)
  • received (String) (defaults to: OMIT)
  • path (Array<String>) (defaults to: OMIT)
  • message (String) (defaults to: OMIT)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/rcs/types/bad_request_error_body_error.rb', line 33

def initialize(code: OMIT, expected: OMIT, received: OMIT, path: OMIT, message: OMIT, additional_properties: nil)
  @code = code if code != OMIT
  @expected = expected if expected != OMIT
  @received = received if received != OMIT
  @path = path if path != OMIT
  @message = message if message != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "code": code,
    "expected": expected,
    "received": received,
    "path": path,
    "message": message
  }.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



19
20
21
# File 'lib/rcs/types/bad_request_error_body_error.rb', line 19

def additional_properties
  @additional_properties
end

#codeString (readonly)

Returns:

  • (String)


9
10
11
# File 'lib/rcs/types/bad_request_error_body_error.rb', line 9

def code
  @code
end

#expectedString (readonly)

Returns:

  • (String)


11
12
13
# File 'lib/rcs/types/bad_request_error_body_error.rb', line 11

def expected
  @expected
end

#messageString (readonly)

Returns:

  • (String)


17
18
19
# File 'lib/rcs/types/bad_request_error_body_error.rb', line 17

def message
  @message
end

#pathArray<String> (readonly)

Returns:

  • (Array<String>)


15
16
17
# File 'lib/rcs/types/bad_request_error_body_error.rb', line 15

def path
  @path
end

#receivedString (readonly)

Returns:

  • (String)


13
14
15
# File 'lib/rcs/types/bad_request_error_body_error.rb', line 13

def received
  @received
end

Class Method Details

.from_json(json_object:) ⇒ Pinnacle::BadRequestErrorBodyError

Deserialize a JSON object to an instance of BadRequestErrorBodyError

Parameters:

  • json_object (String)

Returns:



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/rcs/types/bad_request_error_body_error.rb', line 55

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  code = parsed_json["code"]
  expected = parsed_json["expected"]
  received = parsed_json["received"]
  path = parsed_json["path"]
  message = parsed_json["message"]
  new(
    code: code,
    expected: expected,
    received: received,
    path: path,
    message: message,
    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)


86
87
88
89
90
91
92
# File 'lib/rcs/types/bad_request_error_body_error.rb', line 86

def self.validate_raw(obj:)
  obj.code&.is_a?(String) != false || raise("Passed value for field obj.code is not the expected type, validation failed.")
  obj.expected&.is_a?(String) != false || raise("Passed value for field obj.expected is not the expected type, validation failed.")
  obj.received&.is_a?(String) != false || raise("Passed value for field obj.received is not the expected type, validation failed.")
  obj.path&.is_a?(Array) != false || raise("Passed value for field obj.path is not the expected type, validation failed.")
  obj.message&.is_a?(String) != false || raise("Passed value for field obj.message is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of BadRequestErrorBodyError to a JSON object

Returns:

  • (String)


76
77
78
# File 'lib/rcs/types/bad_request_error_body_error.rb', line 76

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