Class: Vapi::Blocks::UpdateBlockDtoTool

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

Overview

This is the tool that the block will call. To use an existing tool, use

`toolId`.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(member:, discriminant:) ⇒ Vapi::Blocks::UpdateBlockDtoTool

Parameters:

  • member (Object)
  • discriminant (String)


28
29
30
31
# File 'lib/vapi_server_sdk/blocks/types/update_block_dto_tool.rb', line 28

def initialize(member:, discriminant:)
  @member = member
  @discriminant = discriminant
end

Instance Attribute Details

#discriminantString (readonly)

Returns:

  • (String)


20
21
22
# File 'lib/vapi_server_sdk/blocks/types/update_block_dto_tool.rb', line 20

def discriminant
  @discriminant
end

#memberObject (readonly)

Returns:

  • (Object)


18
19
20
# File 'lib/vapi_server_sdk/blocks/types/update_block_dto_tool.rb', line 18

def member
  @member
end

Class Method Details

.dtmf(member:) ⇒ Vapi::Blocks::UpdateBlockDtoTool



122
123
124
# File 'lib/vapi_server_sdk/blocks/types/update_block_dto_tool.rb', line 122

def self.dtmf(member:)
  new(member: member, discriminant: "dtmf")
end

.end_call(member:) ⇒ Vapi::Blocks::UpdateBlockDtoTool



128
129
130
# File 'lib/vapi_server_sdk/blocks/types/update_block_dto_tool.rb', line 128

def self.end_call(member:)
  new(member: member, discriminant: "endCall")
end

.from_json(json_object:) ⇒ Vapi::Blocks::UpdateBlockDtoTool

Deserialize a JSON object to an instance of UpdateBlockDtoTool

Parameters:

  • json_object (String)

Returns:



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/vapi_server_sdk/blocks/types/update_block_dto_tool.rb', line 37

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  member = case struct.type
           when "dtmf"
             Vapi::CreateDtmfToolDto.from_json(json_object: json_object)
           when "endCall"
             Vapi::CreateEndCallToolDto.from_json(json_object: json_object)
           when "voicemail"
             Vapi::CreateVoicemailToolDto.from_json(json_object: json_object)
           when "function"
             Vapi::CreateFunctionToolDto.from_json(json_object: json_object)
           when "ghl"
             Vapi::CreateGhlToolDto.from_json(json_object: json_object)
           when "make"
             Vapi::CreateMakeToolDto.from_json(json_object: json_object)
           when "transferCall"
             Vapi::CreateTransferCallToolDto.from_json(json_object: json_object)
           else
             Vapi::CreateDtmfToolDto.from_json(json_object: json_object)
           end
  new(member: member, discriminant: struct.type)
end

.function(member:) ⇒ Vapi::Blocks::UpdateBlockDtoTool



140
141
142
# File 'lib/vapi_server_sdk/blocks/types/update_block_dto_tool.rb', line 140

def self.function(member:)
  new(member: member, discriminant: "function")
end

.ghl(member:) ⇒ Vapi::Blocks::UpdateBlockDtoTool



146
147
148
# File 'lib/vapi_server_sdk/blocks/types/update_block_dto_tool.rb', line 146

def self.ghl(member:)
  new(member: member, discriminant: "ghl")
end

.make(member:) ⇒ Vapi::Blocks::UpdateBlockDtoTool



152
153
154
# File 'lib/vapi_server_sdk/blocks/types/update_block_dto_tool.rb', line 152

def self.make(member:)
  new(member: member, discriminant: "make")
end

.transfer_call(member:) ⇒ Vapi::Blocks::UpdateBlockDtoTool



158
159
160
# File 'lib/vapi_server_sdk/blocks/types/update_block_dto_tool.rb', line 158

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.

Parameters:

  • obj (Object)

Returns:

  • (Void)


91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/vapi_server_sdk/blocks/types/update_block_dto_tool.rb', line 91

def self.validate_raw(obj:)
  case obj.type
  when "dtmf"
    Vapi::CreateDtmfToolDto.validate_raw(obj: obj)
  when "endCall"
    Vapi::CreateEndCallToolDto.validate_raw(obj: obj)
  when "voicemail"
    Vapi::CreateVoicemailToolDto.validate_raw(obj: obj)
  when "function"
    Vapi::CreateFunctionToolDto.validate_raw(obj: obj)
  when "ghl"
    Vapi::CreateGhlToolDto.validate_raw(obj: obj)
  when "make"
    Vapi::CreateMakeToolDto.validate_raw(obj: obj)
  when "transferCall"
    Vapi::CreateTransferCallToolDto.validate_raw(obj: obj)
  else
    raise("Passed value matched no type within the union, validation failed.")
  end
end

.voicemail(member:) ⇒ Vapi::Blocks::UpdateBlockDtoTool



134
135
136
# File 'lib/vapi_server_sdk/blocks/types/update_block_dto_tool.rb', line 134

def self.voicemail(member:)
  new(member: member, discriminant: "voicemail")
end

Instance Method Details

#is_a?(obj) ⇒ Boolean

For Union Types, is_a? functionality is delegated to the wrapped member.

Parameters:

  • obj (Object)

Returns:

  • (Boolean)


116
117
118
# File 'lib/vapi_server_sdk/blocks/types/update_block_dto_tool.rb', line 116

def is_a?(obj)
  @member.is_a?(obj)
end

#kind_of?Object



23
# File 'lib/vapi_server_sdk/blocks/types/update_block_dto_tool.rb', line 23

alias kind_of? is_a?

#to_json(*_args) ⇒ String

For Union Types, to_json functionality is delegated to the wrapped member.

Returns:

  • (String)


63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/vapi_server_sdk/blocks/types/update_block_dto_tool.rb', line 63

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 "voicemail"
    { **@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
  else
    { "type": @discriminant, value: @member }.to_json
  end
  @member.to_json
end