Class: Vapi::CreateByoPhoneNumberDto

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(credential_id:, fallback_destination: OMIT, number_e_164_check_enabled: OMIT, number: OMIT, name: OMIT, assistant_id: OMIT, squad_id: OMIT, server: OMIT, additional_properties: nil) ⇒ Vapi::CreateByoPhoneNumberDto

Parameters:

  • fallback_destination (Vapi::CreateByoPhoneNumberDtoFallbackDestination) (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.
  • number_e_164_check_enabled (Boolean) (defaults to: OMIT)

    This is the flag to toggle the E164 check for the number field. This is an advanced property which should be used if you know your use case requires it. Use cases:

    • false: To allow non-E164 numbers like +001234567890, 1234, or abc. This is useful for dialing out to non-E164 numbers on your SIP trunks.
    • true (default): To allow only E164 numbers like +14155551234. This is standard for PSTN calls. If false, the number is still required to only contain alphanumeric characters (regex: /^\+?[a-zA-Z0-9]+$/). @default true (E164 check is enabled)
  • number (String) (defaults to: OMIT)

    This is the number of the customer.

  • credential_id (String)

    This is the credential of your own SIP trunk or Carrier (type byo-sip-trunk) which can be used to make calls to this phone number. You can add the SIP trunk or Carrier credential in the Provider Credentials page on the Dashboard to get the credentialId.

  • 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 (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
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/vapi_server_sdk/types/create_byo_phone_number_dto.rb', line 100

def initialize(credential_id:, fallback_destination: OMIT, number_e_164_check_enabled: OMIT, number: OMIT,
               name: OMIT, assistant_id: OMIT, squad_id: OMIT, server: OMIT, additional_properties: nil)
  @fallback_destination = fallback_destination if fallback_destination != OMIT
  @number_e_164_check_enabled = number_e_164_check_enabled if number_e_164_check_enabled != OMIT
  @number = number if number != OMIT
  @credential_id = credential_id
  @name = name if name != OMIT
  @assistant_id = assistant_id if assistant_id != OMIT
  @squad_id = squad_id if squad_id != OMIT
  @server = server if server != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "fallbackDestination": fallback_destination,
    "numberE164CheckEnabled": number_e_164_check_enabled,
    "number": number,
    "credentialId": credential_id,
    "name": name,
    "assistantId": assistant_id,
    "squadId": squad_id,
    "server": server
  }.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



55
56
57
# File 'lib/vapi_server_sdk/types/create_byo_phone_number_dto.rb', line 55

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.



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

def assistant_id
  @assistant_id
end

#credential_idString (readonly)

Returns This is the credential of your own SIP trunk or Carrier (type byo-sip-trunk) which can be used to make calls to this phone number. You can add the SIP trunk or Carrier credential in the Provider Credentials page on the Dashboard to get the credentialId.

Returns:

  • (String)

    This is the credential of your own SIP trunk or Carrier (type byo-sip-trunk) which can be used to make calls to this phone number. You can add the SIP trunk or Carrier credential in the Provider Credentials page on the Dashboard to get the credentialId.



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

def credential_id
  @credential_id
end

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

    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/create_byo_phone_number_dto.rb', line 16

def fallback_destination
  @fallback_destination
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/create_byo_phone_number_dto.rb', line 36

def name
  @name
end

#numberString (readonly)

Returns This is the number of the customer.

Returns:

  • (String)

    This is the number of the customer.



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

def number
  @number
end

#number_e_164_check_enabledBoolean (readonly)

Returns This is the flag to toggle the E164 check for the number field. This is an advanced property which should be used if you know your use case requires it. Use cases:

  • false: To allow non-E164 numbers like +001234567890, 1234, or abc. This is useful for dialing out to non-E164 numbers on your SIP trunks.
  • true (default): To allow only E164 numbers like +14155551234. This is standard for PSTN calls. If false, the number is still required to only contain alphanumeric characters (regex: /^\+?[a-zA-Z0-9]+$/). @default true (E164 check is enabled).

Returns:

  • (Boolean)

    This is the flag to toggle the E164 check for the number field. This is an advanced property which should be used if you know your use case requires it. Use cases:

    • false: To allow non-E164 numbers like +001234567890, 1234, or abc. This is useful for dialing out to non-E164 numbers on your SIP trunks.
    • true (default): To allow only E164 numbers like +14155551234. This is standard for PSTN calls. If false, the number is still required to only contain alphanumeric characters (regex: /^\+?[a-zA-Z0-9]+$/). @default true (E164 check is enabled)


27
28
29
# File 'lib/vapi_server_sdk/types/create_byo_phone_number_dto.rb', line 27

def number_e_164_check_enabled
  @number_e_164_check_enabled
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


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

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



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

def squad_id
  @squad_id
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::CreateByoPhoneNumberDto

Deserialize a JSON object to an instance of CreateByoPhoneNumberDto

Parameters:

  • json_object (String)

Returns:



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

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::CreateByoPhoneNumberDtoFallbackDestination.from_json(json_object: fallback_destination)
  end
  number_e_164_check_enabled = parsed_json["numberE164CheckEnabled"]
  number = parsed_json["number"]
  credential_id = parsed_json["credentialId"]
  name = parsed_json["name"]
  assistant_id = parsed_json["assistantId"]
  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
  new(
    fallback_destination: fallback_destination,
    number_e_164_check_enabled: number_e_164_check_enabled,
    number: number,
    credential_id: credential_id,
    name: name,
    assistant_id: assistant_id,
    squad_id: squad_id,
    server: server,
    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)


176
177
178
179
180
181
182
183
184
185
# File 'lib/vapi_server_sdk/types/create_byo_phone_number_dto.rb', line 176

def self.validate_raw(obj:)
  obj.fallback_destination.nil? || Vapi::CreateByoPhoneNumberDtoFallbackDestination.validate_raw(obj: obj.fallback_destination)
  obj.number_e_164_check_enabled&.is_a?(Boolean) != false || raise("Passed value for field obj.number_e_164_check_enabled 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.credential_id.is_a?(String) != false || raise("Passed value for field obj.credential_id 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.nil? || Vapi::Server.validate_raw(obj: obj.server)
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of CreateByoPhoneNumberDto to a JSON object

Returns:

  • (String)


166
167
168
# File 'lib/vapi_server_sdk/types/create_byo_phone_number_dto.rb', line 166

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