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:, twilio_auth_token:, fallback_destination: OMIT, name: OMIT, assistant_id: OMIT, squad_id: OMIT, server_url: OMIT, server_url_secret: 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.

  • 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.

  • 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` nor `squadId` 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` nor `squadId` 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_url (String) (defaults to: OMIT)

    This is the server URL where messages will be sent for calls on this number. This includes the ‘assistant-request` message. You can see the shape of the messages sent in `ServerMessage`. This overrides the `org.serverUrl`. Order of precedence: tool.server.url > assistant.serverUrl > phoneNumber.serverUrl > org.serverUrl.

  • server_url_secret (String) (defaults to: OMIT)

    This is the secret Vapi will send with every message to your server. It’s sent as a header called x-vapi-secret. Same precedence logic as serverUrl.

  • 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.

  • twilio_auth_token (String)

    This is the Twilio Auth Token for the phone number.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/vapi_server_sdk/types/twilio_phone_number.rb', line 93

def initialize(id:, org_id:, created_at:, updated_at:, number:, twilio_account_sid:, twilio_auth_token:, fallback_destination: OMIT, name: OMIT, assistant_id: OMIT,
               squad_id: OMIT, server_url: OMIT, server_url_secret: OMIT, additional_properties: nil)
  @fallback_destination = fallback_destination if fallback_destination != OMIT
  @id = id
  @org_id = org_id
  @created_at = created_at
  @updated_at = updated_at
  @name = name if name != OMIT
  @assistant_id = assistant_id if assistant_id != OMIT
  @squad_id = squad_id if squad_id != OMIT
  @server_url = server_url if server_url != OMIT
  @server_url_secret = server_url_secret if server_url_secret != OMIT
  @number = number
  @twilio_account_sid = 
  @twilio_auth_token = twilio_auth_token
  @additional_properties = additional_properties
  @_field_set = {
    "fallbackDestination": fallback_destination,
    "id": id,
    "orgId": org_id,
    "createdAt": created_at,
    "updatedAt": updated_at,
    "name": name,
    "assistantId": assistant_id,
    "squadId": squad_id,
    "serverUrl": server_url,
    "serverUrlSecret": server_url_secret,
    "number": number,
    "twilioAccountSid": ,
    "twilioAuthToken": twilio_auth_token
  }.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



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

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` nor `squadId` 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` nor `squadId` 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.



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

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.



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

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.



16
17
18
# File 'lib/vapi_server_sdk/types/twilio_phone_number.rb', line 16

def fallback_destination
  @fallback_destination
end

#idString (readonly)

Returns This is the unique identifier for the phone number.

Returns:

  • (String)

    This is the unique identifier for the phone number.



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

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.



26
27
28
# File 'lib/vapi_server_sdk/types/twilio_phone_number.rb', line 26

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.



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

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.



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

def org_id
  @org_id
end

#server_urlString (readonly)

Returns This is the server URL where messages will be sent for calls on this number. This includes the ‘assistant-request` message. You can see the shape of the messages sent in `ServerMessage`. This overrides the `org.serverUrl`. Order of precedence: tool.server.url > assistant.serverUrl > phoneNumber.serverUrl > org.serverUrl.

Returns:

  • (String)

    This is the server URL where messages will be sent for calls on this number. This includes the ‘assistant-request` message. You can see the shape of the messages sent in `ServerMessage`. This overrides the `org.serverUrl`. Order of precedence: tool.server.url > assistant.serverUrl > phoneNumber.serverUrl > org.serverUrl.



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

def server_url
  @server_url
end

#server_url_secretString (readonly)

Returns This is the secret Vapi will send with every message to your server. It’s sent as a header called x-vapi-secret. Same precedence logic as serverUrl.

Returns:

  • (String)

    This is the secret Vapi will send with every message to your server. It’s sent as a header called x-vapi-secret. Same precedence logic as serverUrl.



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

def server_url_secret
  @server_url_secret
end

#squad_idString (readonly)

Returns This is the squad that will be used for incoming calls to this phone number. If neither ‘assistantId` nor `squadId` 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` nor `squadId` 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.



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

def squad_id
  @squad_id
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.



50
51
52
# File 'lib/vapi_server_sdk/types/twilio_phone_number.rb', line 50

def 
  @twilio_account_sid
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.



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

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.



24
25
26
# File 'lib/vapi_server_sdk/types/twilio_phone_number.rb', line 24

def updated_at
  @updated_at
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::TwilioPhoneNumber

Deserialize a JSON object to an instance of TwilioPhoneNumber

Parameters:

  • json_object (String)

Returns:



132
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
# File 'lib/vapi_server_sdk/types/twilio_phone_number.rb', line 132

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
  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?)
  name = parsed_json["name"]
  assistant_id = parsed_json["assistantId"]
  squad_id = parsed_json["squadId"]
  server_url = parsed_json["serverUrl"]
  server_url_secret = parsed_json["serverUrlSecret"]
  number = parsed_json["number"]
   = parsed_json["twilioAccountSid"]
  twilio_auth_token = parsed_json["twilioAuthToken"]
  new(
    fallback_destination: fallback_destination,
    id: id,
    org_id: org_id,
    created_at: created_at,
    updated_at: updated_at,
    name: name,
    assistant_id: assistant_id,
    squad_id: squad_id,
    server_url: server_url,
    server_url_secret: server_url_secret,
    number: number,
    twilio_account_sid: ,
    twilio_auth_token: twilio_auth_token,
    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)


184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# File 'lib/vapi_server_sdk/types/twilio_phone_number.rb', line 184

def self.validate_raw(obj:)
  obj.fallback_destination.nil? || Vapi::TwilioPhoneNumberFallbackDestination.validate_raw(obj: obj.fallback_destination)
  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.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.squad_id&.is_a?(String) != false || raise("Passed value for field obj.squad_id is not the expected type, validation failed.")
  obj.server_url&.is_a?(String) != false || raise("Passed value for field obj.server_url is not the expected type, validation failed.")
  obj.server_url_secret&.is_a?(String) != false || raise("Passed value for field obj.server_url_secret is not the expected type, validation failed.")
  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.")
  obj.twilio_auth_token.is_a?(String) != false || raise("Passed value for field obj.twilio_auth_token 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)


174
175
176
# File 'lib/vapi_server_sdk/types/twilio_phone_number.rb', line 174

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