Class: Vapi::Tools::ToolsCreateResponse
- Inherits:
-
Object
- Object
- Vapi::Tools::ToolsCreateResponse
- Defined in:
- lib/vapi_server_sdk/tools/types/tools_create_response.rb
Instance Attribute Summary collapse
- #discriminant ⇒ String readonly
- #member ⇒ Object readonly
Class Method Summary collapse
- .dtmf(member:) ⇒ Vapi::Tools::ToolsCreateResponse
- .end_call(member:) ⇒ Vapi::Tools::ToolsCreateResponse
-
.from_json(json_object:) ⇒ Vapi::Tools::ToolsCreateResponse
Deserialize a JSON object to an instance of ToolsCreateResponse.
- .function(member:) ⇒ Vapi::Tools::ToolsCreateResponse
- .ghl(member:) ⇒ Vapi::Tools::ToolsCreateResponse
- .make(member:) ⇒ Vapi::Tools::ToolsCreateResponse
- .output(member:) ⇒ Vapi::Tools::ToolsCreateResponse
- .transfer_call(member:) ⇒ Vapi::Tools::ToolsCreateResponse
-
.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.
Instance Method Summary collapse
- #initialize(member:, discriminant:) ⇒ Vapi::Tools::ToolsCreateResponse constructor
-
#is_a?(obj) ⇒ Boolean
For Union Types, is_a? functionality is delegated to the wrapped member.
- #kind_of? ⇒ Object
-
#to_json(*_args) ⇒ String
For Union Types, to_json functionality is delegated to the wrapped member.
Constructor Details
#initialize(member:, discriminant:) ⇒ Vapi::Tools::ToolsCreateResponse
26 27 28 29 |
# File 'lib/vapi_server_sdk/tools/types/tools_create_response.rb', line 26 def initialize(member:, discriminant:) @member = member @discriminant = discriminant end |
Instance Attribute Details
#discriminant ⇒ String (readonly)
18 19 20 |
# File 'lib/vapi_server_sdk/tools/types/tools_create_response.rb', line 18 def discriminant @discriminant end |
#member ⇒ Object (readonly)
16 17 18 |
# File 'lib/vapi_server_sdk/tools/types/tools_create_response.rb', line 16 def member @member end |
Class Method Details
.dtmf(member:) ⇒ Vapi::Tools::ToolsCreateResponse
120 121 122 |
# File 'lib/vapi_server_sdk/tools/types/tools_create_response.rb', line 120 def self.dtmf(member:) new(member: member, discriminant: "dtmf") end |
.end_call(member:) ⇒ Vapi::Tools::ToolsCreateResponse
126 127 128 |
# File 'lib/vapi_server_sdk/tools/types/tools_create_response.rb', line 126 def self.end_call(member:) new(member: member, discriminant: "endCall") end |
.from_json(json_object:) ⇒ Vapi::Tools::ToolsCreateResponse
Deserialize a JSON object to an instance of ToolsCreateResponse
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/vapi_server_sdk/tools/types/tools_create_response.rb', line 35 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) member = case struct.type when "dtmf" Vapi::DtmfTool.from_json(json_object: json_object) when "endCall" Vapi::EndCallTool.from_json(json_object: json_object) when "function" Vapi::FunctionTool.from_json(json_object: json_object) when "ghl" Vapi::GhlTool.from_json(json_object: json_object) when "make" Vapi::MakeTool.from_json(json_object: json_object) when "transferCall" Vapi::TransferCallTool.from_json(json_object: json_object) when "output" Vapi::OutputTool.from_json(json_object: json_object) else Vapi::DtmfTool.from_json(json_object: json_object) end new(member: member, discriminant: struct.type) end |
.function(member:) ⇒ Vapi::Tools::ToolsCreateResponse
132 133 134 |
# File 'lib/vapi_server_sdk/tools/types/tools_create_response.rb', line 132 def self.function(member:) new(member: member, discriminant: "function") end |
.ghl(member:) ⇒ Vapi::Tools::ToolsCreateResponse
138 139 140 |
# File 'lib/vapi_server_sdk/tools/types/tools_create_response.rb', line 138 def self.ghl(member:) new(member: member, discriminant: "ghl") end |
.make(member:) ⇒ Vapi::Tools::ToolsCreateResponse
144 145 146 |
# File 'lib/vapi_server_sdk/tools/types/tools_create_response.rb', line 144 def self.make(member:) new(member: member, discriminant: "make") end |
.output(member:) ⇒ Vapi::Tools::ToolsCreateResponse
156 157 158 |
# File 'lib/vapi_server_sdk/tools/types/tools_create_response.rb', line 156 def self.output(member:) new(member: member, discriminant: "output") end |
.transfer_call(member:) ⇒ Vapi::Tools::ToolsCreateResponse
150 151 152 |
# File 'lib/vapi_server_sdk/tools/types/tools_create_response.rb', line 150 def self.transfer_call(member:) new(member: member, discriminant: "transferCall") 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.
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/vapi_server_sdk/tools/types/tools_create_response.rb', line 89 def self.validate_raw(obj:) case obj.type when "dtmf" Vapi::DtmfTool.validate_raw(obj: obj) when "endCall" Vapi::EndCallTool.validate_raw(obj: obj) when "function" Vapi::FunctionTool.validate_raw(obj: obj) when "ghl" Vapi::GhlTool.validate_raw(obj: obj) when "make" Vapi::MakeTool.validate_raw(obj: obj) when "transferCall" Vapi::TransferCallTool.validate_raw(obj: obj) when "output" Vapi::OutputTool.validate_raw(obj: obj) else raise("Passed value matched no type within the union, validation failed.") end end |
Instance Method Details
#is_a?(obj) ⇒ Boolean
For Union Types, is_a? functionality is delegated to the wrapped member.
114 115 116 |
# File 'lib/vapi_server_sdk/tools/types/tools_create_response.rb', line 114 def is_a?(obj) @member.is_a?(obj) end |
#kind_of? ⇒ Object
21 |
# File 'lib/vapi_server_sdk/tools/types/tools_create_response.rb', line 21 alias kind_of? is_a? |
#to_json(*_args) ⇒ String
For Union Types, to_json functionality is delegated to the wrapped member.
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/vapi_server_sdk/tools/types/tools_create_response.rb', line 61 def to_json(*_args) case @discriminant when "dtmf" { **@member.to_json, type: @discriminant }.to_json when "endCall" { **@member.to_json, type: @discriminant }.to_json when "function" { **@member.to_json, type: @discriminant }.to_json when "ghl" { **@member.to_json, type: @discriminant }.to_json when "make" { **@member.to_json, type: @discriminant }.to_json when "transferCall" { **@member.to_json, type: @discriminant }.to_json when "output" { **@member.to_json, type: @discriminant }.to_json else { "type": @discriminant, value: @member }.to_json end @member.to_json end |