diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index 529223f2..88af8ccb 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -9,6 +9,7 @@ docs/AdditionalDenialReason.md docs/Address.md docs/AnswerCallback.md docs/AsyncLookupRequest.md +docs/AttestationLevelEnum.md docs/BlockedWebhook.md docs/BridgeCompleteCallback.md docs/BridgeTargetCompleteCallback.md @@ -241,6 +242,7 @@ lib/bandwidth-sdk/models/additional_denial_reason.rb lib/bandwidth-sdk/models/address.rb lib/bandwidth-sdk/models/answer_callback.rb lib/bandwidth-sdk/models/async_lookup_request.rb +lib/bandwidth-sdk/models/attestation_level_enum.rb lib/bandwidth-sdk/models/blocked_webhook.rb lib/bandwidth-sdk/models/bridge_complete_callback.rb lib/bandwidth-sdk/models/bridge_target_complete_callback.rb diff --git a/README.md b/README.md index 7c9b430e..a3ee4489 100644 --- a/README.md +++ b/README.md @@ -175,6 +175,7 @@ Class | Method | HTTP request | Description - [Bandwidth::Address](docs/Address.md) - [Bandwidth::AnswerCallback](docs/AnswerCallback.md) - [Bandwidth::AsyncLookupRequest](docs/AsyncLookupRequest.md) + - [Bandwidth::AttestationLevelEnum](docs/AttestationLevelEnum.md) - [Bandwidth::BlockedWebhook](docs/BlockedWebhook.md) - [Bandwidth::BridgeCompleteCallback](docs/BridgeCompleteCallback.md) - [Bandwidth::BridgeTargetCompleteCallback](docs/BridgeTargetCompleteCallback.md) diff --git a/bandwidth.yml b/bandwidth.yml index bffc6469..b88af843 100644 --- a/bandwidth.yml +++ b/bandwidth.yml @@ -3241,6 +3241,16 @@ components: - direction - to - from + attestationLevelEnum: + type: string + enum: + - A + - B + - C + description: >- + The STIR/SHAKEN attestation level Bandwidth signs the call with: `A` + (full), `B` (partial), or `C` (gateway). + example: B callbackMethodEnum: type: string nullable: true @@ -3419,6 +3429,52 @@ components: entire value cannot exceed 350 characters, including parameters and separators. + requestedAttestationLevel: + nullable: true + allOf: + - $ref: '#/components/schemas/attestationLevelEnum' + description: >- + The STIR/SHAKEN attestation level (`A`, `B`, or `C`) you request + Bandwidth sign this call with. + + Applies to outbound calls to US destinations only, and only to + accounts that use the + + Hosted + Signing Service; it is ignored + + for all other accounts. If omitted, the attestation policy + configured on your account is used. + + + Cannot be combined with `identity`. A request that includes both is + rejected with a `400`, as is + + any value other than `A`, `B`, or `C`. + identity: + nullable: true + type: string + minLength: 1 + maxLength: 2000 + pattern: ^ *[A-Za-z0-9\-_.+/=;:<>"][A-Za-z0-9\-_.+/=;:<>" ]*$ + description: >- + A complete SIP `Identity` header value that you signed yourself. It + must be a valid STIR/SHAKEN + + PASSporT and may not exceed 2000 characters. Bandwidth sends it + unmodified on the outbound call and + + does not sign the call. Bandwidth checks only the format and size of + the value, not the signature. + + Applies to outbound calls to US destinations only. + + + Cannot be combined with `requestedAttestationLevel`. A request that + includes both, or a value that is too long + + or not in the expected format, is rejected with a `400`. + example: eyJhbGciOiJFUzI1NiIsInBwdCI6InNoYWtlbiIsInR5cCI6InBhc3Nwb3J0IiwieDV1IjoiaHR0cHM6Ly9jZXJ0LmV4YW1wbGUvY2VydC5wZW0ifQ.eyJhdHRlc3QiOiJBIiwiZGVzdCI6eyJ0biI6WyIxOTE5NTU1MTIzNCJdfSwiaWF0IjoxNzAwMDAwMDAwLCJvcmlnIjp7InRuIjoiMTU1NTU1NTEyMTIifSwib3JpZ2lkIjoiMTIzNCJ9.c2lnbmF0dXJl;info=;alg=ES256;ppt="shaken" applicationId: type: string description: The id of the application associated with the `from` number. @@ -3688,6 +3744,20 @@ components: type: integer example: 5 description: The priority of this call over other calls from your account. + requestedAttestationLevel: + nullable: true + allOf: + - $ref: '#/components/schemas/attestationLevelEnum' + description: >- + The `requestedAttestationLevel` provided in the Create Call request, + if any. This is the level you requested, + + which can differ from the level the call is ultimately signed with. + identity: + nullable: true + type: string + description: The `identity` value provided in the Create Call request, if any. + example: eyJhbGciOiJFUzI1NiIsInBwdCI6InNoYWtlbiIsInR5cCI6InBhc3Nwb3J0IiwieDV1IjoiaHR0cHM6Ly9jZXJ0LmV4YW1wbGUvY2VydC5wZW0ifQ.eyJhdHRlc3QiOiJBIiwiZGVzdCI6eyJ0biI6WyIxOTE5NTU1MTIzNCJdfSwiaWF0IjoxNzAwMDAwMDAwLCJvcmlnIjp7InRuIjoiMTU1NTU1NTEyMTIifSwib3JpZ2lkIjoiMTIzNCJ9.c2lnbmF0dXJl;info=;alg=ES256;ppt="shaken" callState: type: object properties: diff --git a/docs/AttestationLevelEnum.md b/docs/AttestationLevelEnum.md new file mode 100644 index 00000000..d75a4948 --- /dev/null +++ b/docs/AttestationLevelEnum.md @@ -0,0 +1,15 @@ +# Bandwidth::AttestationLevelEnum + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::AttestationLevelEnum.new() +``` + diff --git a/docs/CreateCall.md b/docs/CreateCall.md index 29020367..28b12fb9 100644 --- a/docs/CreateCall.md +++ b/docs/CreateCall.md @@ -9,6 +9,8 @@ | **privacy** | **Boolean** | Hide the calling number. The `displayName` field can be used to customize the displayed name. | [optional] | | **display_name** | **String** | The caller display name to use when the call is created. May not exceed 256 characters nor contain control characters such as new lines. If `privacy` is true, only the following values are valid: `Restricted`, `Anonymous`, `Private`, or `Unavailable`. | [optional] | | **uui** | **String** | A comma-separated list of 'User-To-User' headers to be sent in the INVITE when calling a SIP URI. Each value must end with an 'encoding' parameter as described in <a href='https://tools.ietf.org/html/rfc7433'>RFC 7433</a>. Only 'jwt', 'base64' and 'hex' encodings are allowed. The entire value cannot exceed 350 characters, including parameters and separators. | [optional] | +| **requested_attestation_level** | [**AttestationLevelEnum**](AttestationLevelEnum.md) | The STIR/SHAKEN attestation level (`A`, `B`, or `C`) you request Bandwidth sign this call with. Applies to outbound calls to US destinations only, and only to accounts that use the <a href='/docs/voice/stir-shaken/hosted-signing-service'>Hosted Signing Service</a>; it is ignored for all other accounts. If omitted, the attestation policy configured on your account is used. Cannot be combined with `identity`. A request that includes both is rejected with a `400`, as is any value other than `A`, `B`, or `C`. | [optional] | +| **identity** | **String** | A complete SIP `Identity` header value that you signed yourself. It must be a valid STIR/SHAKEN PASSporT and may not exceed 2000 characters. Bandwidth sends it unmodified on the outbound call and does not sign the call. Bandwidth checks only the format and size of the value, not the signature. Applies to outbound calls to US destinations only. Cannot be combined with `requestedAttestationLevel`. A request that includes both, or a value that is too long or not in the expected format, is rejected with a `400`. | [optional] | | **application_id** | **String** | The id of the application associated with the `from` number. | | | **answer_url** | **String** | The full URL to send the <a href='/docs/voice/webhooks/answer'>Answer</a> event to when the called party answers. This endpoint should return the first <a href='/docs/voice/bxml'>BXML document</a> to be executed in the call. Must use `https` if specifying `username` and `password`. | | | **answer_method** | [**CallbackMethodEnum**](CallbackMethodEnum.md) | | [optional][default to 'POST'] | @@ -37,6 +39,8 @@ instance = Bandwidth::CreateCall.new( privacy: false, display_name: John Doe, uui: eyJhbGciOiJIUzI1NiJ9.WyJoaSJd.-znkjYyCkgz4djmHUPSXl9YrJ6Nix_XvmlwKGFh5ERM;encoding=jwt,aGVsbG8gd29ybGQ;encoding=base64, + requested_attestation_level: null, + identity: eyJhbGciOiJFUzI1NiIsInBwdCI6InNoYWtlbiIsInR5cCI6InBhc3Nwb3J0IiwieDV1IjoiaHR0cHM6Ly9jZXJ0LmV4YW1wbGUvY2VydC5wZW0ifQ.eyJhdHRlc3QiOiJBIiwiZGVzdCI6eyJ0biI6WyIxOTE5NTU1MTIzNCJdfSwiaWF0IjoxNzAwMDAwMDAwLCJvcmlnIjp7InRuIjoiMTU1NTU1NTEyMTIifSwib3JpZ2lkIjoiMTIzNCJ9.c2lnbmF0dXJl;info=<https://cert.example/cert.pem>;alg=ES256;ppt="shaken", application_id: 1234-qwer-5679-tyui, answer_url: https://www.myCallbackServer.example/webhooks/answer, answer_method: null, diff --git a/docs/CreateCallResponse.md b/docs/CreateCallResponse.md index e6412103..0da3afe4 100644 --- a/docs/CreateCallResponse.md +++ b/docs/CreateCallResponse.md @@ -25,6 +25,8 @@ | **fallback_username** | **String** | Basic auth username. | [optional] | | **fallback_password** | **String** | Basic auth password. | [optional] | | **priority** | **Integer** | The priority of this call over other calls from your account. | [optional] | +| **requested_attestation_level** | [**AttestationLevelEnum**](AttestationLevelEnum.md) | The `requestedAttestationLevel` provided in the Create Call request, if any. This is the level you requested, which can differ from the level the call is ultimately signed with. | [optional] | +| **identity** | **String** | The `identity` value provided in the Create Call request, if any. | [optional] | ## Example @@ -52,7 +54,9 @@ instance = Bandwidth::CreateCallResponse.new( password: mySecretPassword1!, fallback_username: mySecretUsername, fallback_password: mySecretPassword1!, - priority: 5 + priority: 5, + requested_attestation_level: null, + identity: eyJhbGciOiJFUzI1NiIsInBwdCI6InNoYWtlbiIsInR5cCI6InBhc3Nwb3J0IiwieDV1IjoiaHR0cHM6Ly9jZXJ0LmV4YW1wbGUvY2VydC5wZW0ifQ.eyJhdHRlc3QiOiJBIiwiZGVzdCI6eyJ0biI6WyIxOTE5NTU1MTIzNCJdfSwiaWF0IjoxNzAwMDAwMDAwLCJvcmlnIjp7InRuIjoiMTU1NTU1NTEyMTIifSwib3JpZ2lkIjoiMTIzNCJ9.c2lnbmF0dXJl;info=<https://cert.example/cert.pem>;alg=ES256;ppt="shaken" ) ``` diff --git a/docs/LookupResult.md b/docs/LookupResult.md index 1ada17a5..a0c2aef2 100644 --- a/docs/LookupResult.md +++ b/docs/LookupResult.md @@ -32,8 +32,8 @@ instance = Bandwidth::LookupResult.new( deactivation_date: 2025-06-20 18:35, deactivation_event: null, latest_message_delivery_status: null, - initial_message_delivery_status_date: Thu Jun 19 20:00:00 EDT 2025, - latest_message_delivery_status_date: Fri Jun 20 20:00:00 EDT 2025, + initial_message_delivery_status_date: Fri Jun 20 00:00:00 UTC 2025, + latest_message_delivery_status_date: Sat Jun 21 00:00:00 UTC 2025, rcs_enabled: true ) ``` diff --git a/lib/bandwidth-sdk.rb b/lib/bandwidth-sdk.rb index 83f1d94e..7ab2c50c 100644 --- a/lib/bandwidth-sdk.rb +++ b/lib/bandwidth-sdk.rb @@ -23,6 +23,7 @@ require 'bandwidth-sdk/models/address' require 'bandwidth-sdk/models/answer_callback' require 'bandwidth-sdk/models/async_lookup_request' +require 'bandwidth-sdk/models/attestation_level_enum' require 'bandwidth-sdk/models/blocked_webhook' require 'bandwidth-sdk/models/bridge_complete_callback' require 'bandwidth-sdk/models/bridge_target_complete_callback' diff --git a/lib/bandwidth-sdk/models/attestation_level_enum.rb b/lib/bandwidth-sdk/models/attestation_level_enum.rb new file mode 100644 index 00000000..43650553 --- /dev/null +++ b/lib/bandwidth-sdk/models/attestation_level_enum.rb @@ -0,0 +1,41 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +Generator version: 7.24.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class AttestationLevelEnum + A = 'A'.freeze + B = 'B'.freeze + C = 'C'.freeze + + def self.all_vars + @all_vars ||= [A, B, C].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if AttestationLevelEnum.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #AttestationLevelEnum" + end + end +end diff --git a/lib/bandwidth-sdk/models/create_call.rb b/lib/bandwidth-sdk/models/create_call.rb index 0454ec4b..53cbfae1 100644 --- a/lib/bandwidth-sdk/models/create_call.rb +++ b/lib/bandwidth-sdk/models/create_call.rb @@ -30,6 +30,12 @@ class CreateCall < ApiModelBase # A comma-separated list of 'User-To-User' headers to be sent in the INVITE when calling a SIP URI. Each value must end with an 'encoding' parameter as described in RFC 7433. Only 'jwt', 'base64' and 'hex' encodings are allowed. The entire value cannot exceed 350 characters, including parameters and separators. attr_accessor :uui + # The STIR/SHAKEN attestation level (`A`, `B`, or `C`) you request Bandwidth sign this call with. Applies to outbound calls to US destinations only, and only to accounts that use the Hosted Signing Service; it is ignored for all other accounts. If omitted, the attestation policy configured on your account is used. Cannot be combined with `identity`. A request that includes both is rejected with a `400`, as is any value other than `A`, `B`, or `C`. + attr_accessor :requested_attestation_level + + # A complete SIP `Identity` header value that you signed yourself. It must be a valid STIR/SHAKEN PASSporT and may not exceed 2000 characters. Bandwidth sends it unmodified on the outbound call and does not sign the call. Bandwidth checks only the format and size of the value, not the signature. Applies to outbound calls to US destinations only. Cannot be combined with `requestedAttestationLevel`. A request that includes both, or a value that is too long or not in the expected format, is rejected with a `400`. + attr_accessor :identity + # The id of the application associated with the `from` number. attr_accessor :application_id @@ -104,6 +110,8 @@ def self.attribute_map :'privacy' => :'privacy', :'display_name' => :'displayName', :'uui' => :'uui', + :'requested_attestation_level' => :'requestedAttestationLevel', + :'identity' => :'identity', :'application_id' => :'applicationId', :'answer_url' => :'answerUrl', :'answer_method' => :'answerMethod', @@ -141,6 +149,8 @@ def self.openapi_types :'privacy' => :'Boolean', :'display_name' => :'String', :'uui' => :'String', + :'requested_attestation_level' => :'AttestationLevelEnum', + :'identity' => :'String', :'application_id' => :'String', :'answer_url' => :'String', :'answer_method' => :'CallbackMethodEnum', @@ -166,6 +176,8 @@ def self.openapi_nullable :'privacy', :'display_name', :'uui', + :'requested_attestation_level', + :'identity', :'answer_method', :'username', :'password', @@ -222,6 +234,14 @@ def initialize(attributes = {}) self.uui = attributes[:'uui'] end + if attributes.key?(:'requested_attestation_level') + self.requested_attestation_level = attributes[:'requested_attestation_level'] + end + + if attributes.key?(:'identity') + self.identity = attributes[:'identity'] + end + if attributes.key?(:'application_id') self.application_id = attributes[:'application_id'] else @@ -320,6 +340,19 @@ def list_invalid_properties invalid_properties.push('invalid value for "display_name", the character length must be smaller than or equal to 256.') end + if !@identity.nil? && @identity.to_s.length > 2000 + invalid_properties.push('invalid value for "identity", the character length must be smaller than or equal to 2000.') + end + + if !@identity.nil? && @identity.to_s.length < 1 + invalid_properties.push('invalid value for "identity", the character length must be greater than or equal to 1.') + end + + pattern = Regexp.new(/^ *[A-Za-z0-9\-_.+\/=;:<>"][A-Za-z0-9\-_.+\/=;:<>" ]*$/) + if !@identity.nil? && @identity !~ pattern + invalid_properties.push("invalid value for \"identity\", must conform to the pattern #{pattern}.") + end + if @application_id.nil? invalid_properties.push('invalid value for "application_id", application_id cannot be nil.') end @@ -394,6 +427,9 @@ def valid? return false if @to.nil? return false if @from.nil? return false if !@display_name.nil? && @display_name.to_s.length > 256 + return false if !@identity.nil? && @identity.to_s.length > 2000 + return false if !@identity.nil? && @identity.to_s.length < 1 + return false if !@identity.nil? && @identity !~ Regexp.new(/^ *[A-Za-z0-9\-_.+\/=;:<>"][A-Za-z0-9\-_.+\/=;:<>" ]*$/) return false if @application_id.nil? return false if @answer_url.nil? return false if @answer_url.to_s.length > 2048 @@ -443,6 +479,25 @@ def display_name=(display_name) @display_name = display_name end + # Custom attribute writer method with validation + # @param [Object] identity Value to be assigned + def identity=(identity) + if !identity.nil? && identity.to_s.length > 2000 + fail ArgumentError, 'invalid value for "identity", the character length must be smaller than or equal to 2000.' + end + + if !identity.nil? && identity.to_s.length < 1 + fail ArgumentError, 'invalid value for "identity", the character length must be greater than or equal to 1.' + end + + pattern = Regexp.new(/^ *[A-Za-z0-9\-_.+\/=;:<>"][A-Za-z0-9\-_.+\/=;:<>" ]*$/) + if !identity.nil? && identity !~ pattern + fail ArgumentError, "invalid value for \"identity\", must conform to the pattern #{pattern}." + end + + @identity = identity + end + # Custom attribute writer method with validation # @param [Object] application_id Value to be assigned def application_id=(application_id) @@ -589,6 +644,8 @@ def ==(o) privacy == o.privacy && display_name == o.display_name && uui == o.uui && + requested_attestation_level == o.requested_attestation_level && + identity == o.identity && application_id == o.application_id && answer_url == o.answer_url && answer_method == o.answer_method && @@ -616,7 +673,7 @@ def eql?(o) # Calculates hash code according to all attributes. # @return [Integer] Hash code def hash - [to, from, privacy, display_name, uui, application_id, answer_url, answer_method, username, password, answer_fallback_url, answer_fallback_method, fallback_username, fallback_password, disconnect_url, disconnect_method, call_timeout, callback_timeout, machine_detection, priority, tag].hash + [to, from, privacy, display_name, uui, requested_attestation_level, identity, application_id, answer_url, answer_method, username, password, answer_fallback_url, answer_fallback_method, fallback_username, fallback_password, disconnect_url, disconnect_method, call_timeout, callback_timeout, machine_detection, priority, tag].hash end # Builds the object from hash diff --git a/lib/bandwidth-sdk/models/create_call_response.rb b/lib/bandwidth-sdk/models/create_call_response.rb index 590eb55f..569c33d3 100644 --- a/lib/bandwidth-sdk/models/create_call_response.rb +++ b/lib/bandwidth-sdk/models/create_call_response.rb @@ -75,6 +75,12 @@ class CreateCallResponse < ApiModelBase # The priority of this call over other calls from your account. attr_accessor :priority + # The `requestedAttestationLevel` provided in the Create Call request, if any. This is the level you requested, which can differ from the level the call is ultimately signed with. + attr_accessor :requested_attestation_level + + # The `identity` value provided in the Create Call request, if any. + attr_accessor :identity + class EnumAttributeValidator attr_reader :datatype attr_reader :allowable_values @@ -120,7 +126,9 @@ def self.attribute_map :'password' => :'password', :'fallback_username' => :'fallbackUsername', :'fallback_password' => :'fallbackPassword', - :'priority' => :'priority' + :'priority' => :'priority', + :'requested_attestation_level' => :'requestedAttestationLevel', + :'identity' => :'identity' } end @@ -157,7 +165,9 @@ def self.openapi_types :'password' => :'String', :'fallback_username' => :'String', :'fallback_password' => :'String', - :'priority' => :'Integer' + :'priority' => :'Integer', + :'requested_attestation_level' => :'AttestationLevelEnum', + :'identity' => :'String' } end @@ -175,7 +185,9 @@ def self.openapi_nullable :'password', :'fallback_username', :'fallback_password', - :'priority' + :'priority', + :'requested_attestation_level', + :'identity' ]) end @@ -298,6 +310,14 @@ def initialize(attributes = {}) if attributes.key?(:'priority') self.priority = attributes[:'priority'] end + + if attributes.key?(:'requested_attestation_level') + self.requested_attestation_level = attributes[:'requested_attestation_level'] + end + + if attributes.key?(:'identity') + self.identity = attributes[:'identity'] + end end # Show invalid properties with the reasons. Usually used together with valid? @@ -505,7 +525,9 @@ def ==(o) password == o.password && fallback_username == o.fallback_username && fallback_password == o.fallback_password && - priority == o.priority + priority == o.priority && + requested_attestation_level == o.requested_attestation_level && + identity == o.identity end # @see the `==` method @@ -517,7 +539,7 @@ def eql?(o) # Calculates hash code according to all attributes. # @return [Integer] Hash code def hash - [application_id, account_id, call_id, to, from, enqueued_time, call_url, call_timeout, callback_timeout, tag, answer_method, answer_url, answer_fallback_method, answer_fallback_url, disconnect_method, disconnect_url, username, password, fallback_username, fallback_password, priority].hash + [application_id, account_id, call_id, to, from, enqueued_time, call_url, call_timeout, callback_timeout, tag, answer_method, answer_url, answer_fallback_method, answer_fallback_url, disconnect_method, disconnect_url, username, password, fallback_username, fallback_password, priority, requested_attestation_level, identity].hash end # Builds the object from hash diff --git a/spec/unit/api/calls_api_spec.rb b/spec/unit/api/calls_api_spec.rb index ec9063a6..8f6acead 100644 --- a/spec/unit/api/calls_api_spec.rb +++ b/spec/unit/api/calls_api_spec.rb @@ -60,6 +60,8 @@ machine_detection: amd_config, priority: 5, tag: 'tag_example', + requested_attestation_level: Bandwidth::AttestationLevelEnum::B, + identity: 'eyJhbGciOiJFUzI1NiJ9.eyJhdHRlc3QiOiJBIn0.c2ln;info=;alg=ES256;ppt="shaken"', ) data, status_code = @calls_api_instance.create_call_with_http_info(BW_ACCOUNT_ID, call_body) diff --git a/spec/unit/models/attestation_level_enum_spec.rb b/spec/unit/models/attestation_level_enum_spec.rb new file mode 100644 index 00000000..a9977dec --- /dev/null +++ b/spec/unit/models/attestation_level_enum_spec.rb @@ -0,0 +1,40 @@ +# Unit tests for Bandwidth::AttestationLevelEnum +describe Bandwidth::AttestationLevelEnum do + describe 'constants' do + it 'defines A' do + expect(Bandwidth::AttestationLevelEnum::A).to eq('A') + end + + it 'defines B' do + expect(Bandwidth::AttestationLevelEnum::B).to eq('B') + end + + it 'defines C' do + expect(Bandwidth::AttestationLevelEnum::C).to eq('C') + end + end + + describe '.all_vars' do + it 'returns every valid enum value' do + expect(Bandwidth::AttestationLevelEnum.all_vars).to eq([ + 'A', + 'B', + 'C' + ]) + end + end + + describe '.build_from_hash' do + it 'returns the value when it matches a valid enum value' do + expect(Bandwidth::AttestationLevelEnum.build_from_hash('A')).to eq('A') + expect(Bandwidth::AttestationLevelEnum.build_from_hash('B')).to eq('B') + expect(Bandwidth::AttestationLevelEnum.build_from_hash('C')).to eq('C') + end + + it 'raises an error for an invalid enum value' do + expect { + Bandwidth::AttestationLevelEnum.build_from_hash('invalid') + }.to raise_error(RuntimeError) + end + end +end diff --git a/spec/unit/models/create_call_response_spec.rb b/spec/unit/models/create_call_response_spec.rb index c9b02efe..796ab565 100644 --- a/spec/unit/models/create_call_response_spec.rb +++ b/spec/unit/models/create_call_response_spec.rb @@ -30,7 +30,9 @@ password: 'pass', fallback_username: 'fallback_user', fallback_password: 'fallback_pass', - priority: 5 + priority: 5, + requested_attestation_level: Bandwidth::AttestationLevelEnum::B, + identity: 'eyJhbGciOiJFUzI1NiJ9.eyJhdHRlc3QiOiJBIn0.c2ln;info=;alg=ES256;ppt="shaken"' }) } describe '#initialize' do @@ -67,7 +69,9 @@ :'password', :'fallback_username', :'fallback_password', - :'priority' + :'priority', + :'requested_attestation_level', + :'identity' ])) end end @@ -95,7 +99,9 @@ password: 'pass', fallbackUsername: 'fallback_user', fallbackPassword: 'fallback_pass', - priority: 5 + priority: 5, + requestedAttestationLevel: 'B', + identity: 'eyJhbGciOiJFUzI1NiJ9.eyJhdHRlc3QiOiJBIn0.c2ln;info=;alg=ES256;ppt="shaken"' }) expect(create_call_response_from_hash).to be_instance_of(Bandwidth::CreateCallResponse) expect(create_call_response_from_hash.application_id).to eq('04e88489-df02-4e34-a0ee-27a91849555f') @@ -119,12 +125,14 @@ expect(create_call_response_from_hash.fallback_username).to eq('fallback_user') expect(create_call_response_from_hash.fallback_password).to eq('fallback_pass') expect(create_call_response_from_hash.priority).to eq(5) + expect(create_call_response_from_hash.requested_attestation_level).to eq(Bandwidth::AttestationLevelEnum::B) + expect(create_call_response_from_hash.identity).to eq('eyJhbGciOiJFUzI1NiJ9.eyJhdHRlc3QiOiJBIn0.c2ln;info=;alg=ES256;ppt="shaken"') end end describe '#to_s' do it 'returns a string representation of the object' do - expect(create_call_response_values.to_s).to eq({ :applicationId => '04e88489-df02-4e34-a0ee-27a91849555f', :accountId => '9900000', :callId => 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85', :to => '+19195551234', :from => '+19195554321', :enqueuedTime => '2022-06-16T13:15:07.160Z', :callUrl => 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-1', :callTimeout => 30.0, :callbackTimeout => 15.0, :tag => 'custom tag', :answerMethod => 'POST', :answerUrl => 'https://example.com/answer', :answerFallbackMethod => 'POST', :answerFallbackUrl => 'https://example.com/answer-fallback', :disconnectMethod => 'POST', :disconnectUrl => 'https://example.com/disconnect', :username => 'user', :password => 'pass', :fallbackUsername => 'fallback_user', :fallbackPassword => 'fallback_pass', :priority => 5 }.to_s) + expect(create_call_response_values.to_s).to eq({ :applicationId => '04e88489-df02-4e34-a0ee-27a91849555f', :accountId => '9900000', :callId => 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85', :to => '+19195551234', :from => '+19195554321', :enqueuedTime => '2022-06-16T13:15:07.160Z', :callUrl => 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-1', :callTimeout => 30.0, :callbackTimeout => 15.0, :tag => 'custom tag', :answerMethod => 'POST', :answerUrl => 'https://example.com/answer', :answerFallbackMethod => 'POST', :answerFallbackUrl => 'https://example.com/answer-fallback', :disconnectMethod => 'POST', :disconnectUrl => 'https://example.com/disconnect', :username => 'user', :password => 'pass', :fallbackUsername => 'fallback_user', :fallbackPassword => 'fallback_pass', :priority => 5, :requestedAttestationLevel => 'B', :identity => 'eyJhbGciOiJFUzI1NiJ9.eyJhdHRlc3QiOiJBIn0.c2ln;info=;alg=ES256;ppt="shaken"' }.to_s) end end @@ -167,7 +175,9 @@ password: 'pass', fallbackUsername: 'fallback_user', fallbackPassword: 'fallback_pass', - priority: 5 + priority: 5, + requestedAttestationLevel: Bandwidth::AttestationLevelEnum::B, + identity: 'eyJhbGciOiJFUzI1NiJ9.eyJhdHRlc3QiOiJBIn0.c2ln;info=;alg=ES256;ppt="shaken"' }) end end diff --git a/spec/unit/models/create_call_spec.rb b/spec/unit/models/create_call_spec.rb index 2c562186..bee855ae 100644 --- a/spec/unit/models/create_call_spec.rb +++ b/spec/unit/models/create_call_spec.rb @@ -12,6 +12,8 @@ privacy: false, display_name: 'Caller Name', uui: 'eyJ0eXAiOiJKV1Q;encoding=jwt', + requested_attestation_level: Bandwidth::AttestationLevelEnum::B, + identity: 'eyJhbGciOiJFUzI1NiJ9.eyJhdHRlc3QiOiJBIn0.c2ln;info=;alg=ES256;ppt="shaken"', application_id: '04e88489-df02-4e34-a0ee-27a91849555f', answer_url: 'https://example.com/answer', answer_method: Bandwidth::CallbackMethodEnum::POST, @@ -56,6 +58,8 @@ :'privacy', :'display_name', :'uui', + :'requested_attestation_level', + :'identity', :'answer_method', :'username', :'password', @@ -81,6 +85,8 @@ privacy: false, displayName: 'Caller Name', uui: 'eyJ0eXAiOiJKV1Q;encoding=jwt', + requestedAttestationLevel: 'B', + identity: 'eyJhbGciOiJFUzI1NiJ9.eyJhdHRlc3QiOiJBIn0.c2ln;info=;alg=ES256;ppt="shaken"', applicationId: '04e88489-df02-4e34-a0ee-27a91849555f', answerUrl: 'https://example.com/answer', answerMethod: 'POST', @@ -103,6 +109,8 @@ expect(create_call_from_hash.privacy).to eq(false) expect(create_call_from_hash.display_name).to eq('Caller Name') expect(create_call_from_hash.uui).to eq('eyJ0eXAiOiJKV1Q;encoding=jwt') + expect(create_call_from_hash.requested_attestation_level).to eq(Bandwidth::AttestationLevelEnum::B) + expect(create_call_from_hash.identity).to eq('eyJhbGciOiJFUzI1NiJ9.eyJhdHRlc3QiOiJBIn0.c2ln;info=;alg=ES256;ppt="shaken"') expect(create_call_from_hash.application_id).to eq('04e88489-df02-4e34-a0ee-27a91849555f') expect(create_call_from_hash.answer_url).to eq('https://example.com/answer') expect(create_call_from_hash.answer_method).to eq(Bandwidth::CallbackMethodEnum::POST) @@ -123,7 +131,7 @@ describe '#to_s' do it 'returns a string representation of the object' do - expect(create_call_values.to_s).to eq({ :to => '+19195551234', :from => '+19195554321', :privacy => false, :displayName => 'Caller Name', :uui => 'eyJ0eXAiOiJKV1Q;encoding=jwt', :applicationId => '04e88489-df02-4e34-a0ee-27a91849555f', :answerUrl => 'https://example.com/answer', :answerMethod => 'POST', :username => 'user', :password => 'pass', :answerFallbackUrl => 'https://example.com/answer-fallback', :answerFallbackMethod => 'POST', :fallbackUsername => 'fallback_user', :fallbackPassword => 'fallback_pass', :disconnectUrl => 'https://example.com/disconnect', :disconnectMethod => 'POST', :callTimeout => 30, :callbackTimeout => 15, :machineDetection => {}, :priority => 5, :tag => 'custom tag' }.to_s) + expect(create_call_values.to_s).to eq({ :to => '+19195551234', :from => '+19195554321', :privacy => false, :displayName => 'Caller Name', :uui => 'eyJ0eXAiOiJKV1Q;encoding=jwt', :requestedAttestationLevel => 'B', :identity => 'eyJhbGciOiJFUzI1NiJ9.eyJhdHRlc3QiOiJBIn0.c2ln;info=;alg=ES256;ppt="shaken"', :applicationId => '04e88489-df02-4e34-a0ee-27a91849555f', :answerUrl => 'https://example.com/answer', :answerMethod => 'POST', :username => 'user', :password => 'pass', :answerFallbackUrl => 'https://example.com/answer-fallback', :answerFallbackMethod => 'POST', :fallbackUsername => 'fallback_user', :fallbackPassword => 'fallback_pass', :disconnectUrl => 'https://example.com/disconnect', :disconnectMethod => 'POST', :callTimeout => 30, :callbackTimeout => 15, :machineDetection => {}, :priority => 5, :tag => 'custom tag' }.to_s) end end @@ -148,6 +156,8 @@ privacy: false, displayName: 'Caller Name', uui: 'eyJ0eXAiOiJKV1Q;encoding=jwt', + requestedAttestationLevel: Bandwidth::AttestationLevelEnum::B, + identity: 'eyJhbGciOiJFUzI1NiJ9.eyJhdHRlc3QiOiJBIn0.c2ln;info=;alg=ES256;ppt="shaken"', applicationId: '04e88489-df02-4e34-a0ee-27a91849555f', answerUrl: 'https://example.com/answer', answerMethod: Bandwidth::CallbackMethodEnum::POST, @@ -187,6 +197,20 @@ }.to raise_error(ArgumentError, 'invalid value for "display_name", the character length must be smaller than or equal to 256.') end + it '#identity=' do + expect { + Bandwidth::CreateCall.new({ to: 'a', from: 'a', application_id: 'a', answer_url: 'a', identity: 'a' * 2001 }) + }.to raise_error(ArgumentError, 'invalid value for "identity", the character length must be smaller than or equal to 2000.') + + expect { + Bandwidth::CreateCall.new({ to: 'a', from: 'a', application_id: 'a', answer_url: 'a', identity: '' }) + }.to raise_error(ArgumentError, 'invalid value for "identity", the character length must be greater than or equal to 1.') + + expect { + Bandwidth::CreateCall.new({ to: 'a', from: 'a', application_id: 'a', answer_url: 'a', identity: 'invalid!' }) + }.to raise_error(ArgumentError, /invalid value for "identity", must conform to the pattern/) + end + it '#application_id=' do expect { Bandwidth::CreateCall.new({ to: 'a', from: 'a', application_id: nil, answer_url: 'a' })