Class: Vapi::TwilioPhoneNumber

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, org_id:, created_at:, updated_at:, number:, twilio_account_sid:, fallback_destination: OMIT, hooks: OMIT, sms_enabled: OMIT, status: OMIT, twilio_auth_token: OMIT, twilio_api_key: OMIT, twilio_api_secret: OMIT, name: OMIT, assistant_id: OMIT, workflow_id: OMIT, squad_id: OMIT, server: OMIT, additional_properties: nil) ⇒ Vapi::TwilioPhoneNumber

Parameters:

  • fallback_destination (Vapi::TwilioPhoneNumberFallbackDestination) (defaults to: OMIT)

    This is the fallback destination an inbound call will be transferred to if:

    1. ‘assistantId` is not set

    2. ‘squadId` is not set

    3. and, ‘assistant-request` message to the `serverUrl` fails

    If this is not set and above conditions are met, the inbound call is hung up with an error message.

  • hooks (Array<Vapi::PhoneNumberHookCallRinging>) (defaults to: OMIT)

    This is the hooks that will be used for incoming calls to this phone number.

  • sms_enabled (Boolean) (defaults to: OMIT)

    Controls whether Vapi sets the messaging webhook URL on the Twilio number during import. If set to ‘false`, Vapi will not update the Twilio messaging URL, leaving it as is. If `true` or omitted (default), Vapi will configure both the voice and messaging URLs. @default true

  • id (String)

    This is the unique identifier for the phone number.

  • org_id (String)

    This is the unique identifier for the org that this phone number belongs to.

  • created_at (DateTime)

    This is the ISO 8601 date-time string of when the phone number was created.

  • updated_at (DateTime)

    This is the ISO 8601 date-time string of when the phone number was last updated.

  • status (Vapi::TwilioPhoneNumberStatus) (defaults to: OMIT)

    This is the status of the phone number.

  • twilio_auth_token (String) (defaults to: OMIT)

    This is the Twilio Auth Token for the phone number.

  • twilio_api_key (String) (defaults to: OMIT)

    This is the Twilio API Key for the phone number.

  • twilio_api_secret (String) (defaults to: OMIT)

    This is the Twilio API Secret for the phone number.

  • name (String) (defaults to: OMIT)

    This is the name of the phone number. This is just for your own reference.

  • assistant_id (String) (defaults to: OMIT)

    This is the assistant that will be used for incoming calls to this phone number. If neither ‘assistantId`, `squadId` nor `workflowId` is set, `assistant-request` will be sent to your Server URL. Check `ServerMessage` and `ServerMessageResponse` for the shape of the message and response that is expected.

  • workflow_id (String) (defaults to: OMIT)

    This is the workflow that will be used for incoming calls to this phone number. If neither ‘assistantId`, `squadId`, nor `workflowId` is set, `assistant-request` will be sent to your Server URL. Check `ServerMessage` and `ServerMessageResponse` for the shape of the message and response that is expected.

  • squad_id (String) (defaults to: OMIT)

    This is the squad that will be used for incoming calls to this phone number. If neither ‘assistantId`, `squadId`, nor `workflowId` is set, `assistant-request` will be sent to your Server URL. Check `ServerMessage` and `ServerMessageResponse` for the shape of the message and response that is expected.

  • server (Vapi::Server) (defaults to: OMIT)

    This is where Vapi will send webhooks. You can find all webhooks available along with their shape in ServerMessage schema. The order of precedence is:

    1. assistant.server

    2. phoneNumber.server

    3. org.server

  • number (String)

    These are the digits of the phone number you own on your Twilio.

  • twilio_account_sid (String)

    This is the Twilio Account SID for the phone number.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# File 'lib/vapi_server_sdk/types/twilio_phone_number.rb', line 133

def initialize(id:, org_id:, created_at:, updated_at:, number:, twilio_account_sid:, fallback_destination: OMIT, hooks: OMIT, sms_enabled: OMIT,
               status: OMIT, twilio_auth_token: OMIT, twilio_api_key: OMIT, twilio_api_secret: OMIT, name: OMIT, assistant_id: OMIT, workflow_id: OMIT, squad_id: OMIT, server: OMIT, additional_properties: nil)
  @fallback_destination = fallback_destination if fallback_destination != OMIT
  @hooks = hooks if hooks != OMIT
  @sms_enabled = sms_enabled if sms_enabled != OMIT
  @id = id
  @org_id = org_id
  @created_at = created_at
  @updated_at = updated_at
  @status = status if status != OMIT
  @twilio_auth_token = twilio_auth_token if twilio_auth_token != OMIT
  @twilio_api_key = twilio_api_key if twilio_api_key != OMIT
  @twilio_api_secret = twilio_api_secret if twilio_api_secret != OMIT
  @name = name if name != OMIT
  @assistant_id = assistant_id if assistant_id != OMIT
  @workflow_id = workflow_id if workflow_id != OMIT
  @squad_id = squad_id if squad_id != OMIT
  @server = server if server != OMIT
  @number = number
  @twilio_account_sid = 
  @additional_properties = additional_properties
  @_field_set = {
    "fallbackDestination": fallback_destination,
    "hooks": hooks,
    "smsEnabled": sms_enabled,
    "id": id,
    "orgId": org_id,
    "createdAt": created_at,
    "updatedAt": updated_at,
    "status": status,
    "twilioAuthToken": twilio_auth_token,
    "twilioApiKey": twilio_api_key,
    "twilioApiSecret": twilio_api_secret,
    "name": name,
    "assistantId": assistant_id,
    "workflowId": workflow_id,
    "squadId": squad_id,
    "server": server,
    "number": number,
    "twilioAccountSid": 
  }.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



78
79
80
# File 'lib/vapi_server_sdk/types/twilio_phone_number.rb', line 78

def additional_properties
  @additional_properties
end

#assistant_idString (readonly)

Returns This is the assistant that will be used for incoming calls to this phone number. If neither ‘assistantId`, `squadId` nor `workflowId` is set, `assistant-request` will be sent to your Server URL. Check `ServerMessage` and `ServerMessageResponse` for the shape of the message and response that is expected.

Returns:

  • (String)

    This is the assistant that will be used for incoming calls to this phone number. If neither ‘assistantId`, `squadId` nor `workflowId` is set, `assistant-request` will be sent to your Server URL. Check `ServerMessage` and `ServerMessageResponse` for the shape of the message and response that is expected.



53
54
55
# File 'lib/vapi_server_sdk/types/twilio_phone_number.rb', line 53

def assistant_id
  @assistant_id
end

#created_atDateTime (readonly)

Returns This is the ISO 8601 date-time string of when the phone number was created.

Returns:

  • (DateTime)

    This is the ISO 8601 date-time string of when the phone number was created.



35
36
37
# File 'lib/vapi_server_sdk/types/twilio_phone_number.rb', line 35

def created_at
  @created_at
end

#fallback_destinationVapi::TwilioPhoneNumberFallbackDestination (readonly)

Returns This is the fallback destination an inbound call will be transferred to if:

  1. ‘assistantId` is not set

  2. ‘squadId` is not set

  3. and, ‘assistant-request` message to the `serverUrl` fails

If this is not set and above conditions are met, the inbound call is hung up with an error message.

Returns:

  • (Vapi::TwilioPhoneNumberFallbackDestination)

    This is the fallback destination an inbound call will be transferred to if:

    1. ‘assistantId` is not set

    2. ‘squadId` is not set

    3. and, ‘assistant-request` message to the `serverUrl` fails

    If this is not set and above conditions are met, the inbound call is hung up with an error message.



19
20
21
# File 'lib/vapi_server_sdk/types/twilio_phone_number.rb', line 19

def fallback_destination
  @fallback_destination
end

#hooksArray<Vapi::PhoneNumberHookCallRinging> (readonly)

Returns This is the hooks that will be used for incoming calls to this phone number.

Returns:



21
22
23
# File 'lib/vapi_server_sdk/types/twilio_phone_number.rb', line 21

def hooks
  @hooks
end

#idString (readonly)

Returns This is the unique identifier for the phone number.

Returns:

  • (String)

    This is the unique identifier for the phone number.



31
32
33
# File 'lib/vapi_server_sdk/types/twilio_phone_number.rb', line 31

def id
  @id
end

#nameString (readonly)

Returns This is the name of the phone number. This is just for your own reference.

Returns:

  • (String)

    This is the name of the phone number. This is just for your own reference.



47
48
49
# File 'lib/vapi_server_sdk/types/twilio_phone_number.rb', line 47

def name
  @name
end

#numberString (readonly)

Returns These are the digits of the phone number you own on your Twilio.

Returns:

  • (String)

    These are the digits of the phone number you own on your Twilio.



74
75
76
# File 'lib/vapi_server_sdk/types/twilio_phone_number.rb', line 74

def number
  @number
end

#org_idString (readonly)

Returns This is the unique identifier for the org that this phone number belongs to.

Returns:

  • (String)

    This is the unique identifier for the org that this phone number belongs to.



33
34
35
# File 'lib/vapi_server_sdk/types/twilio_phone_number.rb', line 33

def org_id
  @org_id
end

#serverVapi::Server (readonly)

Returns This is where Vapi will send webhooks. You can find all webhooks available along with their shape in ServerMessage schema. The order of precedence is:

  1. assistant.server

  2. phoneNumber.server

  3. org.server.

Returns:

  • (Vapi::Server)

    This is where Vapi will send webhooks. You can find all webhooks available along with their shape in ServerMessage schema. The order of precedence is:

    1. assistant.server

    2. phoneNumber.server

    3. org.server



72
73
74
# File 'lib/vapi_server_sdk/types/twilio_phone_number.rb', line 72

def server
  @server
end

#sms_enabledBoolean (readonly)

Returns Controls whether Vapi sets the messaging webhook URL on the Twilio number during import. If set to ‘false`, Vapi will not update the Twilio messaging URL, leaving it as is. If `true` or omitted (default), Vapi will configure both the voice and messaging URLs. @default true.

Returns:

  • (Boolean)

    Controls whether Vapi sets the messaging webhook URL on the Twilio number during import. If set to ‘false`, Vapi will not update the Twilio messaging URL, leaving it as is. If `true` or omitted (default), Vapi will configure both the voice and messaging URLs. @default true



29
30
31
# File 'lib/vapi_server_sdk/types/twilio_phone_number.rb', line 29

def sms_enabled
  @sms_enabled
end

#squad_idString (readonly)

Returns This is the squad that will be used for incoming calls to this phone number. If neither ‘assistantId`, `squadId`, nor `workflowId` is set, `assistant-request` will be sent to your Server URL. Check `ServerMessage` and `ServerMessageResponse` for the shape of the message and response that is expected.

Returns:

  • (String)

    This is the squad that will be used for incoming calls to this phone number. If neither ‘assistantId`, `squadId`, nor `workflowId` is set, `assistant-request` will be sent to your Server URL. Check `ServerMessage` and `ServerMessageResponse` for the shape of the message and response that is expected.



65
66
67
# File 'lib/vapi_server_sdk/types/twilio_phone_number.rb', line 65

def squad_id
  @squad_id
end

#statusVapi::TwilioPhoneNumberStatus (readonly)

Returns This is the status of the phone number.

Returns:



39
40
41
# File 'lib/vapi_server_sdk/types/twilio_phone_number.rb', line 39

def status
  @status
end

#twilio_account_sidString (readonly)

Returns This is the Twilio Account SID for the phone number.

Returns:

  • (String)

    This is the Twilio Account SID for the phone number.



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

def 
  @twilio_account_sid
end

#twilio_api_keyString (readonly)

Returns This is the Twilio API Key for the phone number.

Returns:

  • (String)

    This is the Twilio API Key for the phone number.



43
44
45
# File 'lib/vapi_server_sdk/types/twilio_phone_number.rb', line 43

def twilio_api_key
  @twilio_api_key
end

#twilio_api_secretString (readonly)

Returns This is the Twilio API Secret for the phone number.

Returns:

  • (String)

    This is the Twilio API Secret for the phone number.



45
46
47
# File 'lib/vapi_server_sdk/types/twilio_phone_number.rb', line 45

def twilio_api_secret
  @twilio_api_secret
end

#twilio_auth_tokenString (readonly)

Returns This is the Twilio Auth Token for the phone number.

Returns:

  • (String)

    This is the Twilio Auth Token for the phone number.



41
42
43
# File 'lib/vapi_server_sdk/types/twilio_phone_number.rb', line 41

def twilio_auth_token
  @twilio_auth_token
end

#updated_atDateTime (readonly)

Returns This is the ISO 8601 date-time string of when the phone number was last updated.

Returns:

  • (DateTime)

    This is the ISO 8601 date-time string of when the phone number was last updated.



37
38
39
# File 'lib/vapi_server_sdk/types/twilio_phone_number.rb', line 37

def updated_at
  @updated_at
end

#workflow_idString (readonly)

Returns This is the workflow that will be used for incoming calls to this phone number. If neither ‘assistantId`, `squadId`, nor `workflowId` is set, `assistant-request` will be sent to your Server URL. Check `ServerMessage` and `ServerMessageResponse` for the shape of the message and response that is expected.

Returns:

  • (String)

    This is the workflow that will be used for incoming calls to this phone number. If neither ‘assistantId`, `squadId`, nor `workflowId` is set, `assistant-request` will be sent to your Server URL. Check `ServerMessage` and `ServerMessageResponse` for the shape of the message and response that is expected.



59
60
61
# File 'lib/vapi_server_sdk/types/twilio_phone_number.rb', line 59

def workflow_id
  @workflow_id
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::TwilioPhoneNumber

Deserialize a JSON object to an instance of TwilioPhoneNumber

Parameters:

  • json_object (String)

Returns:



182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
# File 'lib/vapi_server_sdk/types/twilio_phone_number.rb', line 182

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  if parsed_json["fallbackDestination"].nil?
    fallback_destination = nil
  else
    fallback_destination = parsed_json["fallbackDestination"].to_json
    fallback_destination = Vapi::TwilioPhoneNumberFallbackDestination.from_json(json_object: fallback_destination)
  end
  hooks = parsed_json["hooks"]&.map do |item|
    item = item.to_json
    Vapi::PhoneNumberHookCallRinging.from_json(json_object: item)
  end
  sms_enabled = parsed_json["smsEnabled"]
  id = parsed_json["id"]
  org_id = parsed_json["orgId"]
  created_at = (DateTime.parse(parsed_json["createdAt"]) unless parsed_json["createdAt"].nil?)
  updated_at = (DateTime.parse(parsed_json["updatedAt"]) unless parsed_json["updatedAt"].nil?)
  status = parsed_json["status"]
  twilio_auth_token = parsed_json["twilioAuthToken"]
  twilio_api_key = parsed_json["twilioApiKey"]
  twilio_api_secret = parsed_json["twilioApiSecret"]
  name = parsed_json["name"]
  assistant_id = parsed_json["assistantId"]
  workflow_id = parsed_json["workflowId"]
  squad_id = parsed_json["squadId"]
  if parsed_json["server"].nil?
    server = nil
  else
    server = parsed_json["server"].to_json
    server = Vapi::Server.from_json(json_object: server)
  end
  number = parsed_json["number"]
   = parsed_json["twilioAccountSid"]
  new(
    fallback_destination: fallback_destination,
    hooks: hooks,
    sms_enabled: sms_enabled,
    id: id,
    org_id: org_id,
    created_at: created_at,
    updated_at: updated_at,
    status: status,
    twilio_auth_token: twilio_auth_token,
    twilio_api_key: twilio_api_key,
    twilio_api_secret: twilio_api_secret,
    name: name,
    assistant_id: assistant_id,
    workflow_id: workflow_id,
    squad_id: squad_id,
    server: server,
    number: number,
    twilio_account_sid: ,
    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)


252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
# File 'lib/vapi_server_sdk/types/twilio_phone_number.rb', line 252

def self.validate_raw(obj:)
  obj.fallback_destination.nil? || Vapi::TwilioPhoneNumberFallbackDestination.validate_raw(obj: obj.fallback_destination)
  obj.hooks&.is_a?(Array) != false || raise("Passed value for field obj.hooks is not the expected type, validation failed.")
  obj.sms_enabled&.is_a?(Boolean) != false || raise("Passed value for field obj.sms_enabled is not the expected type, validation failed.")
  obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
  obj.org_id.is_a?(String) != false || raise("Passed value for field obj.org_id is not the expected type, validation failed.")
  obj.created_at.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.")
  obj.updated_at.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.")
  obj.status&.is_a?(Vapi::TwilioPhoneNumberStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
  obj.twilio_auth_token&.is_a?(String) != false || raise("Passed value for field obj.twilio_auth_token is not the expected type, validation failed.")
  obj.twilio_api_key&.is_a?(String) != false || raise("Passed value for field obj.twilio_api_key is not the expected type, validation failed.")
  obj.twilio_api_secret&.is_a?(String) != false || raise("Passed value for field obj.twilio_api_secret is not the expected type, validation failed.")
  obj.name&.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
  obj.assistant_id&.is_a?(String) != false || raise("Passed value for field obj.assistant_id is not the expected type, validation failed.")
  obj.workflow_id&.is_a?(String) != false || raise("Passed value for field obj.workflow_id is not the expected type, validation failed.")
  obj.squad_id&.is_a?(String) != false || raise("Passed value for field obj.squad_id is not the expected type, validation failed.")
  obj.server.nil? || Vapi::Server.validate_raw(obj: obj.server)
  obj.number.is_a?(String) != false || raise("Passed value for field obj.number is not the expected type, validation failed.")
  obj..is_a?(String) != false || raise("Passed value for field obj.twilio_account_sid is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of TwilioPhoneNumber to a JSON object

Returns:

  • (String)


242
243
244
# File 'lib/vapi_server_sdk/types/twilio_phone_number.rb', line 242

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