Class: Vapi::VapiPhoneNumber

Inherits:
Object
  • Object
show all
Defined in:
lib/vapi_server_sdk/types/vapi_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:, fallback_destination: OMIT, hooks: OMIT, status: OMIT, number: OMIT, name: OMIT, assistant_id: OMIT, workflow_id: OMIT, squad_id: OMIT, server: OMIT, number_desired_area_code: OMIT, sip_uri: OMIT, authentication: OMIT, additional_properties: nil) ⇒ Vapi::VapiPhoneNumber

Parameters:

  • fallback_destination (Vapi::VapiPhoneNumberFallbackDestination) (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.

  • 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::VapiPhoneNumberStatus) (defaults to: OMIT)

    This is the status of the phone number.

  • number (String) (defaults to: OMIT)

    These are the digits of the phone number you purchased from Vapi.

  • 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_desired_area_code (String) (defaults to: OMIT)

    This is the area code of the phone number to purchase.

  • sip_uri (String) (defaults to: OMIT)

    This is the SIP URI of the phone number. You can SIP INVITE this. The assistant attached to this number will answer. This is case-insensitive.

  • authentication (Vapi::SipAuthentication) (defaults to: OMIT)

    This enables authentication for incoming SIP INVITE requests to the ‘sipUri`. If not set, any username/password to the 401 challenge of the SIP INVITE will be accepted.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



124
125
126
127
128
129
130
131
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
# File 'lib/vapi_server_sdk/types/vapi_phone_number.rb', line 124

def initialize(id:, org_id:, created_at:, updated_at:, fallback_destination: OMIT, hooks: OMIT, status: OMIT,
               number: OMIT, name: OMIT, assistant_id: OMIT, workflow_id: OMIT, squad_id: OMIT, server: OMIT, number_desired_area_code: OMIT, sip_uri: OMIT, authentication: OMIT, additional_properties: nil)
  @fallback_destination = fallback_destination if fallback_destination != OMIT
  @hooks = hooks if hooks != OMIT
  @id = id
  @org_id = org_id
  @created_at = created_at
  @updated_at = updated_at
  @status = status if status != OMIT
  @number = number if number != 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_desired_area_code = number_desired_area_code if number_desired_area_code != OMIT
  @sip_uri = sip_uri if sip_uri != OMIT
  @authentication = authentication if authentication != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "fallbackDestination": fallback_destination,
    "hooks": hooks,
    "id": id,
    "orgId": org_id,
    "createdAt": created_at,
    "updatedAt": updated_at,
    "status": status,
    "number": number,
    "name": name,
    "assistantId": assistant_id,
    "workflowId": workflow_id,
    "squadId": squad_id,
    "server": server,
    "numberDesiredAreaCode": number_desired_area_code,
    "sipUri": sip_uri,
    "authentication": authentication
  }.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



73
74
75
# File 'lib/vapi_server_sdk/types/vapi_phone_number.rb', line 73

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.



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

def assistant_id
  @assistant_id
end

#authenticationVapi::SipAuthentication (readonly)

Returns This enables authentication for incoming SIP INVITE requests to the ‘sipUri`. If not set, any username/password to the 401 challenge of the SIP INVITE will be accepted.

Returns:

  • (Vapi::SipAuthentication)

    This enables authentication for incoming SIP INVITE requests to the ‘sipUri`. If not set, any username/password to the 401 challenge of the SIP INVITE will be accepted.



71
72
73
# File 'lib/vapi_server_sdk/types/vapi_phone_number.rb', line 71

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



28
29
30
# File 'lib/vapi_server_sdk/types/vapi_phone_number.rb', line 28

def created_at
  @created_at
end

#fallback_destinationVapi::VapiPhoneNumberFallbackDestination (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::VapiPhoneNumberFallbackDestination)

    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.



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

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:



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

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.



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

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.



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

def name
  @name
end

#numberString (readonly)

Returns These are the digits of the phone number you purchased from Vapi.

Returns:

  • (String)

    These are the digits of the phone number you purchased from Vapi.



34
35
36
# File 'lib/vapi_server_sdk/types/vapi_phone_number.rb', line 34

def number
  @number
end

#number_desired_area_codeString (readonly)

Returns This is the area code of the phone number to purchase.

Returns:

  • (String)

    This is the area code of the phone number to purchase.



63
64
65
# File 'lib/vapi_server_sdk/types/vapi_phone_number.rb', line 63

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



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

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



61
62
63
# File 'lib/vapi_server_sdk/types/vapi_phone_number.rb', line 61

def server
  @server
end

#sip_uriString (readonly)

Returns This is the SIP URI of the phone number. You can SIP INVITE this. The assistant attached to this number will answer. This is case-insensitive.

Returns:

  • (String)

    This is the SIP URI of the phone number. You can SIP INVITE this. The assistant attached to this number will answer. This is case-insensitive.



67
68
69
# File 'lib/vapi_server_sdk/types/vapi_phone_number.rb', line 67

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



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

def squad_id
  @squad_id
end

#statusVapi::VapiPhoneNumberStatus (readonly)

Returns This is the status of the phone number.

Returns:



32
33
34
# File 'lib/vapi_server_sdk/types/vapi_phone_number.rb', line 32

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



30
31
32
# File 'lib/vapi_server_sdk/types/vapi_phone_number.rb', line 30

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.



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

def workflow_id
  @workflow_id
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::VapiPhoneNumber

Deserialize a JSON object to an instance of VapiPhoneNumber

Parameters:

  • json_object (String)

Returns:



169
170
171
172
173
174
175
176
177
178
179
180
181
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
# File 'lib/vapi_server_sdk/types/vapi_phone_number.rb', line 169

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::VapiPhoneNumberFallbackDestination.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
  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"]
  number = parsed_json["number"]
  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_desired_area_code = parsed_json["numberDesiredAreaCode"]
  sip_uri = parsed_json["sipUri"]
  if parsed_json["authentication"].nil?
    authentication = nil
  else
    authentication = parsed_json["authentication"].to_json
    authentication = Vapi::SipAuthentication.from_json(json_object: authentication)
  end
  new(
    fallback_destination: fallback_destination,
    hooks: hooks,
    id: id,
    org_id: org_id,
    created_at: created_at,
    updated_at: updated_at,
    status: status,
    number: number,
    name: name,
    assistant_id: assistant_id,
    workflow_id: workflow_id,
    squad_id: squad_id,
    server: server,
    number_desired_area_code: number_desired_area_code,
    sip_uri: sip_uri,
    authentication: authentication,
    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)


240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
# File 'lib/vapi_server_sdk/types/vapi_phone_number.rb', line 240

def self.validate_raw(obj:)
  obj.fallback_destination.nil? || Vapi::VapiPhoneNumberFallbackDestination.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.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::VapiPhoneNumberStatus) != false || raise("Passed value for field obj.status 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.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_desired_area_code&.is_a?(String) != false || raise("Passed value for field obj.number_desired_area_code is not the expected type, validation failed.")
  obj.sip_uri&.is_a?(String) != false || raise("Passed value for field obj.sip_uri is not the expected type, validation failed.")
  obj.authentication.nil? || Vapi::SipAuthentication.validate_raw(obj: obj.authentication)
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of VapiPhoneNumber to a JSON object

Returns:

  • (String)


230
231
232
# File 'lib/vapi_server_sdk/types/vapi_phone_number.rb', line 230

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