Class: Vapi::ResponseErrorEvent

Inherits:
Object
  • Object
show all
Defined in:
lib/vapi_server_sdk/types/response_error_event.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, code:, message:, sequence_number:, param: OMIT, additional_properties: nil) ⇒ Vapi::ResponseErrorEvent

Parameters:

  • type (String)

    Event type

  • code (String)

    Error code

  • message (String)

    Error message

  • param (String) (defaults to: OMIT)

    Parameter that caused the error

  • sequence_number (Float)

    Sequence number of the event

  • 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/vapi_server_sdk/types/response_error_event.rb', line 33

def initialize(type:, code:, message:, sequence_number:, param: OMIT, additional_properties: nil)
  @type = type
  @code = code
  @message = message
  @param = param if param != OMIT
  @sequence_number = sequence_number
  @additional_properties = additional_properties
  @_field_set = {
    "type": type,
    "code": code,
    "message": message,
    "param": param,
    "sequence_number": sequence_number
  }.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/vapi_server_sdk/types/response_error_event.rb', line 19

def additional_properties
  @additional_properties
end

#codeString (readonly)

Returns Error code.

Returns:

  • (String)

    Error code



11
12
13
# File 'lib/vapi_server_sdk/types/response_error_event.rb', line 11

def code
  @code
end

#messageString (readonly)

Returns Error message.

Returns:

  • (String)

    Error message



13
14
15
# File 'lib/vapi_server_sdk/types/response_error_event.rb', line 13

def message
  @message
end

#paramString (readonly)

Returns Parameter that caused the error.

Returns:

  • (String)

    Parameter that caused the error



15
16
17
# File 'lib/vapi_server_sdk/types/response_error_event.rb', line 15

def param
  @param
end

#sequence_numberFloat (readonly)

Returns Sequence number of the event.

Returns:

  • (Float)

    Sequence number of the event



17
18
19
# File 'lib/vapi_server_sdk/types/response_error_event.rb', line 17

def sequence_number
  @sequence_number
end

#typeString (readonly)

Returns Event type.

Returns:

  • (String)

    Event type



9
10
11
# File 'lib/vapi_server_sdk/types/response_error_event.rb', line 9

def type
  @type
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::ResponseErrorEvent

Deserialize a JSON object to an instance of ResponseErrorEvent

Parameters:

  • json_object (String)

Returns:



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

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  type = parsed_json["type"]
  code = parsed_json["code"]
  message = parsed_json["message"]
  param = parsed_json["param"]
  sequence_number = parsed_json["sequence_number"]
  new(
    type: type,
    code: code,
    message: message,
    param: param,
    sequence_number: sequence_number,
    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/vapi_server_sdk/types/response_error_event.rb', line 86

def self.validate_raw(obj:)
  obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.")
  obj.code.is_a?(String) != false || raise("Passed value for field obj.code 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.")
  obj.param&.is_a?(String) != false || raise("Passed value for field obj.param is not the expected type, validation failed.")
  obj.sequence_number.is_a?(Float) != false || raise("Passed value for field obj.sequence_number is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of ResponseErrorEvent to a JSON object

Returns:

  • (String)


76
77
78
# File 'lib/vapi_server_sdk/types/response_error_event.rb', line 76

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