Class: Vapi::ByoPhoneNumber
- Inherits:
-
Object
- Object
- Vapi::ByoPhoneNumber
- Defined in:
- lib/vapi_server_sdk/types/byo_phone_number.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#assistant_id ⇒ String
readonly
This is the assistant that will be used for incoming calls to this phone number.
-
#created_at ⇒ DateTime
readonly
This is the ISO 8601 date-time string of when the phone number was created.
-
#credential_id ⇒ String
readonly
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. -
#fallback_destination ⇒ Vapi::ByoPhoneNumberFallbackDestination
readonly
This is the fallback destination an inbound call will be transferred to if: 1.
-
#id ⇒ String
readonly
This is the unique identifier for the phone number.
-
#name ⇒ String
readonly
This is the name of the phone number.
-
#number ⇒ String
readonly
This is the number of the customer.
-
#number_e_164_check_enabled ⇒ Boolean
readonly
This is the flag to toggle the E164 check for the
numberfield. -
#org_id ⇒ String
readonly
This is the unique identifier for the org that this phone number belongs to.
-
#server ⇒ Vapi::Server
readonly
This is where Vapi will send webhooks.
-
#squad_id ⇒ String
readonly
This is the squad that will be used for incoming calls to this phone number.
-
#updated_at ⇒ DateTime
readonly
This is the ISO 8601 date-time string of when the phone number was last updated.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Vapi::ByoPhoneNumber
Deserialize a JSON object to an instance of ByoPhoneNumber.
-
.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.
Instance Method Summary collapse
- #initialize(id:, org_id:, created_at:, updated_at:, credential_id:, fallback_destination: OMIT, number_e_164_check_enabled: OMIT, name: OMIT, assistant_id: OMIT, squad_id: OMIT, server: OMIT, number: OMIT, additional_properties: nil) ⇒ Vapi::ByoPhoneNumber constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of ByoPhoneNumber to a JSON object.
Constructor Details
#initialize(id:, org_id:, created_at:, updated_at:, credential_id:, fallback_destination: OMIT, number_e_164_check_enabled: OMIT, name: OMIT, assistant_id: OMIT, squad_id: OMIT, server: OMIT, number: OMIT, additional_properties: nil) ⇒ Vapi::ByoPhoneNumber
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/vapi_server_sdk/types/byo_phone_number.rb', line 113 def initialize(id:, org_id:, created_at:, updated_at:, credential_id:, fallback_destination: OMIT, number_e_164_check_enabled: OMIT, name: OMIT, assistant_id: OMIT, squad_id: OMIT, server: OMIT, number: 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 @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 = server if server != OMIT @number = number if number != OMIT @credential_id = credential_id @additional_properties = additional_properties @_field_set = { "fallbackDestination": fallback_destination, "numberE164CheckEnabled": number_e_164_check_enabled, "id": id, "orgId": org_id, "createdAt": created_at, "updatedAt": updated_at, "name": name, "assistantId": assistant_id, "squadId": squad_id, "server": server, "number": number, "credentialId": credential_id }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
64 65 66 |
# File 'lib/vapi_server_sdk/types/byo_phone_number.rb', line 64 def additional_properties @additional_properties end |
#assistant_id ⇒ String (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.
43 44 45 |
# File 'lib/vapi_server_sdk/types/byo_phone_number.rb', line 43 def assistant_id @assistant_id end |
#created_at ⇒ DateTime (readonly)
Returns This is the ISO 8601 date-time string of when the phone number was created.
34 35 36 |
# File 'lib/vapi_server_sdk/types/byo_phone_number.rb', line 34 def created_at @created_at end |
#credential_id ⇒ String (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.
62 63 64 |
# File 'lib/vapi_server_sdk/types/byo_phone_number.rb', line 62 def credential_id @credential_id end |
#fallback_destination ⇒ Vapi::ByoPhoneNumberFallbackDestination (readonly)
Returns This is the fallback destination an inbound call will be transferred to if:
assistantIdis not setsquadIdis not set- and,
assistant-requestmessage to theserverUrlfails If this is not set and above conditions are met, the inbound call is hung up with an error message.
17 18 19 |
# File 'lib/vapi_server_sdk/types/byo_phone_number.rb', line 17 def fallback_destination @fallback_destination end |
#id ⇒ String (readonly)
Returns This is the unique identifier for the phone number.
30 31 32 |
# File 'lib/vapi_server_sdk/types/byo_phone_number.rb', line 30 def id @id end |
#name ⇒ String (readonly)
Returns This is the name of the phone number. This is just for your own reference.
38 39 40 |
# File 'lib/vapi_server_sdk/types/byo_phone_number.rb', line 38 def name @name end |
#number ⇒ String (readonly)
Returns This is the number of the customer.
57 58 59 |
# File 'lib/vapi_server_sdk/types/byo_phone_number.rb', line 57 def number @number end |
#number_e_164_check_enabled ⇒ Boolean (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, orabc. 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. Iffalse, thenumberis still required to only contain alphanumeric characters (regex:/^\+?[a-zA-Z0-9]+$/). @default true (E164 check is enabled).
28 29 30 |
# File 'lib/vapi_server_sdk/types/byo_phone_number.rb', line 28 def number_e_164_check_enabled @number_e_164_check_enabled end |
#org_id ⇒ String (readonly)
Returns This is the unique identifier for the org that this phone number belongs to.
32 33 34 |
# File 'lib/vapi_server_sdk/types/byo_phone_number.rb', line 32 def org_id @org_id end |
#server ⇒ Vapi::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:
- assistant.server
- phoneNumber.server
- org.server.
55 56 57 |
# File 'lib/vapi_server_sdk/types/byo_phone_number.rb', line 55 def server @server end |
#squad_id ⇒ String (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.
48 49 50 |
# File 'lib/vapi_server_sdk/types/byo_phone_number.rb', line 48 def squad_id @squad_id end |
#updated_at ⇒ DateTime (readonly)
Returns This is the ISO 8601 date-time string of when the phone number was last updated.
36 37 38 |
# File 'lib/vapi_server_sdk/types/byo_phone_number.rb', line 36 def updated_at @updated_at end |
Class Method Details
.from_json(json_object:) ⇒ Vapi::ByoPhoneNumber
Deserialize a JSON object to an instance of ByoPhoneNumber
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 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/vapi_server_sdk/types/byo_phone_number.rb', line 150 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::ByoPhoneNumberFallbackDestination.from_json(json_object: fallback_destination) end number_e_164_check_enabled = parsed_json["numberE164CheckEnabled"] 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"] 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"] credential_id = parsed_json["credentialId"] new( fallback_destination: fallback_destination, number_e_164_check_enabled: number_e_164_check_enabled, 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: server, number: number, credential_id: credential_id, 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.
205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
# File 'lib/vapi_server_sdk/types/byo_phone_number.rb', line 205 def self.validate_raw(obj:) obj.fallback_destination.nil? || Vapi::ByoPhoneNumberFallbackDestination.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.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.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.credential_id.is_a?(String) != false || raise("Passed value for field obj.credential_id is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of ByoPhoneNumber to a JSON object
195 196 197 |
# File 'lib/vapi_server_sdk/types/byo_phone_number.rb', line 195 def to_json(*_args) @_field_set&.to_json end |