From 3961094787d4fb15a3f94c0cb42ec0ffa3daee8b Mon Sep 17 00:00:00 2001 From: atelegu Date: Fri, 19 Jun 2026 13:05:57 +0530 Subject: [PATCH 01/10] VAPI-3162-REFER --- .openapi-generator/FILES | 2 + bandwidth.yml | 63 ++++ lib/bandwidth-sdk.rb | 2 + .../models/refer_call_status_enum.rb | 37 ++ .../models/refer_complete_callback.rb | 331 ++++++++++++++++++ .../models/refer_call_status_enum_spec.rb | 34 ++ .../models/refer_complete_callback_spec.rb | 201 +++++++++++ 7 files changed, 670 insertions(+) create mode 100644 lib/bandwidth-sdk/models/refer_call_status_enum.rb create mode 100644 lib/bandwidth-sdk/models/refer_complete_callback.rb create mode 100644 spec/unit/models/refer_call_status_enum_spec.rb create mode 100644 spec/unit/models/refer_complete_callback_spec.rb diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index 425d0417..29d91be4 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -388,6 +388,8 @@ lib/bandwidth-sdk/models/recording_transcription_metadata.rb lib/bandwidth-sdk/models/recording_transcriptions.rb lib/bandwidth-sdk/models/redirect_callback.rb lib/bandwidth-sdk/models/redirect_method_enum.rb +lib/bandwidth-sdk/models/refer_call_status_enum.rb +lib/bandwidth-sdk/models/refer_complete_callback.rb lib/bandwidth-sdk/models/sip_connection_metadata.rb lib/bandwidth-sdk/models/sip_credentials.rb lib/bandwidth-sdk/models/sms_message_content.rb diff --git a/bandwidth.yml b/bandwidth.yml index 5e2bc9b3..aef6826a 100644 --- a/bandwidth.yml +++ b/bandwidth.yml @@ -3209,6 +3209,13 @@ components: Setting the conference state to `completed` ends the conference and ejects all members. example: completed + referCallStatusEnum: + type: string + enum: + - success + - failure + description: The status of the SIP REFER request. + example: success machineDetectionModeEnum: type: string default: async @@ -5047,6 +5054,62 @@ components: $ref: '#/components/schemas/transferCallerId' transferTo: $ref: '#/components/schemas/transferTo' + referCompleteCallback: + type: object + description: >- + This event is sent to the referCompleteUrl of the verb when the + SIP REFER request has been resolved — either the remote endpoint has + accepted and redirected the call (success) or the REFER was rejected or + timed out (failure). On success the original call is terminated. + properties: + eventType: + $ref: '#/components/schemas/eventType' + eventTime: + $ref: '#/components/schemas/eventTime' + accountId: + $ref: '#/components/schemas/accountId' + applicationId: + $ref: '#/components/schemas/applicationId1' + from: + $ref: '#/components/schemas/from' + to: + $ref: '#/components/schemas/to' + direction: + $ref: '#/components/schemas/callDirectionEnum' + callId: + $ref: '#/components/schemas/callId' + callUrl: + $ref: '#/components/schemas/callUrl' + enqueuedTime: + $ref: '#/components/schemas/enqueuedTime' + startTime: + $ref: '#/components/schemas/startTime' + answerTime: + $ref: '#/components/schemas/answerTime' + tag: + $ref: '#/components/schemas/tag1' + referTo: + type: string + description: The SIP URI that the call was referred to. + example: sip:alice@atlanta.example.com + referCallStatus: + $ref: '#/components/schemas/referCallStatusEnum' + referSipResponseCode: + type: integer + description: >- + The SIP response code received in response to the REFER request. + Present when the status of the REFER is known (e.g. 202 Accepted or + 405 Method Not Allowed). Absent when the REFER was not attempted. + example: 202 + nullable: true + notifySipResponseCode: + type: integer + description: >- + The SIP response code received in a NOTIFY from the remote endpoint + after it attempted to reach the transfer target. Present only if a + NOTIFY was received before the 30-second timeout. + example: 200 + nullable: true transcriptionAvailableCallback: type: object description: >- diff --git a/lib/bandwidth-sdk.rb b/lib/bandwidth-sdk.rb index a15c309c..9c324eb9 100644 --- a/lib/bandwidth-sdk.rb +++ b/lib/bandwidth-sdk.rb @@ -174,6 +174,8 @@ require 'bandwidth-sdk/models/recording_transcriptions' require 'bandwidth-sdk/models/redirect_callback' require 'bandwidth-sdk/models/redirect_method_enum' +require 'bandwidth-sdk/models/refer_call_status_enum' +require 'bandwidth-sdk/models/refer_complete_callback' require 'bandwidth-sdk/models/sip_connection_metadata' require 'bandwidth-sdk/models/sip_credentials' require 'bandwidth-sdk/models/sms_message_content' diff --git a/lib/bandwidth-sdk/models/refer_call_status_enum.rb b/lib/bandwidth-sdk/models/refer_call_status_enum.rb new file mode 100644 index 00000000..3eea58b4 --- /dev/null +++ b/lib/bandwidth-sdk/models/refer_call_status_enum.rb @@ -0,0 +1,37 @@ +=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.17.0 +=end + +require 'date' +require 'time' + +module Bandwidth + class ReferCallStatusEnum + SUCCESS = "success".freeze + FAILURE = "failure".freeze + + def self.all_vars + @all_vars ||= [SUCCESS, FAILURE].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 ReferCallStatusEnum.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #ReferCallStatusEnum" + end + end +end \ No newline at end of file diff --git a/lib/bandwidth-sdk/models/refer_complete_callback.rb b/lib/bandwidth-sdk/models/refer_complete_callback.rb new file mode 100644 index 00000000..7edb8d66 --- /dev/null +++ b/lib/bandwidth-sdk/models/refer_complete_callback.rb @@ -0,0 +1,331 @@ +=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.17.0 +=end + +require 'date' +require 'time' + +module Bandwidth + # This event is sent to the referCompleteUrl of the verb when the SIP REFER request has been resolved — either the remote endpoint has accepted and redirected the call (success) or the REFER was rejected or timed out (failure). On success the original call is terminated. + class ReferCompleteCallback < ApiModelBase + # The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect. + attr_accessor :event_type + + # The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution. + attr_accessor :event_time + + # The user account associated with the call. + attr_accessor :account_id + + # The id of the application associated with the call. + attr_accessor :application_id + + # The provided identifier of the caller. Must be a phone number in E.164 format (e.g. +15555555555). + attr_accessor :from + + # The phone number that received the call, in E.164 format (e.g. +15555555555). + attr_accessor :to + + attr_accessor :direction + + # The call id associated with the event. + attr_accessor :call_id + + # The URL of the call associated with the event. + attr_accessor :call_url + + # (optional) If call queueing is enabled and this is an outbound call, time the call was queued, in ISO 8601 format. + attr_accessor :enqueued_time + + # Time the call was started, in ISO 8601 format. + attr_accessor :start_time + + # Time the call was answered, in ISO 8601 format. + attr_accessor :answer_time + + # (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present. + attr_accessor :tag + + # The SIP URI that the call was referred to. + attr_accessor :refer_to + + attr_accessor :refer_call_status + + # The SIP response code received in response to the REFER request. Present when the status of the REFER is known (e.g. 202 Accepted or 405 Method Not Allowed). Absent when the REFER was not attempted. + attr_accessor :refer_sip_response_code + + # The SIP response code received in a NOTIFY from the remote endpoint after it attempted to reach the transfer target. Present only if a NOTIFY was received before the 30-second timeout. + attr_accessor :notify_sip_response_code + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'event_type' => :'eventType', + :'event_time' => :'eventTime', + :'account_id' => :'accountId', + :'application_id' => :'applicationId', + :'from' => :'from', + :'to' => :'to', + :'direction' => :'direction', + :'call_id' => :'callId', + :'call_url' => :'callUrl', + :'enqueued_time' => :'enqueuedTime', + :'start_time' => :'startTime', + :'answer_time' => :'answerTime', + :'tag' => :'tag', + :'refer_to' => :'referTo', + :'refer_call_status' => :'referCallStatus', + :'refer_sip_response_code' => :'referSipResponseCode', + :'notify_sip_response_code' => :'notifySipResponseCode' + } + end + + # Returns attribute mapping this model knows about + def self.acceptable_attribute_map + attribute_map + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + acceptable_attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'event_type' => :'String', + :'event_time' => :'Time', + :'account_id' => :'String', + :'application_id' => :'String', + :'from' => :'String', + :'to' => :'String', + :'direction' => :'CallDirectionEnum', + :'call_id' => :'String', + :'call_url' => :'String', + :'enqueued_time' => :'Time', + :'start_time' => :'Time', + :'answer_time' => :'Time', + :'tag' => :'String', + :'refer_to' => :'String', + :'refer_call_status' => :'ReferCallStatusEnum', + :'refer_sip_response_code' => :'Integer', + :'notify_sip_response_code' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'enqueued_time', + :'answer_time', + :'tag', + :'refer_sip_response_code', + :'notify_sip_response_code' + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Bandwidth::ReferCompleteCallback` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + acceptable_attribute_map = self.class.acceptable_attribute_map + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!acceptable_attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::ReferCompleteCallback`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'event_type') + self.event_type = attributes[:'event_type'] + end + + if attributes.key?(:'event_time') + self.event_time = attributes[:'event_time'] + end + + if attributes.key?(:'account_id') + self.account_id = attributes[:'account_id'] + end + + if attributes.key?(:'application_id') + self.application_id = attributes[:'application_id'] + end + + if attributes.key?(:'from') + self.from = attributes[:'from'] + end + + if attributes.key?(:'to') + self.to = attributes[:'to'] + end + + if attributes.key?(:'direction') + self.direction = attributes[:'direction'] + end + + if attributes.key?(:'call_id') + self.call_id = attributes[:'call_id'] + end + + if attributes.key?(:'call_url') + self.call_url = attributes[:'call_url'] + end + + if attributes.key?(:'enqueued_time') + self.enqueued_time = attributes[:'enqueued_time'] + end + + if attributes.key?(:'start_time') + self.start_time = attributes[:'start_time'] + end + + if attributes.key?(:'answer_time') + self.answer_time = attributes[:'answer_time'] + end + + if attributes.key?(:'tag') + self.tag = attributes[:'tag'] + end + + if attributes.key?(:'refer_to') + self.refer_to = attributes[:'refer_to'] + end + + if attributes.key?(:'refer_call_status') + self.refer_call_status = attributes[:'refer_call_status'] + end + + if attributes.key?(:'refer_sip_response_code') + self.refer_sip_response_code = attributes[:'refer_sip_response_code'] + end + + if attributes.key?(:'notify_sip_response_code') + self.notify_sip_response_code = attributes[:'notify_sip_response_code'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + event_type == o.event_type && + event_time == o.event_time && + account_id == o.account_id && + application_id == o.application_id && + from == o.from && + to == o.to && + direction == o.direction && + call_id == o.call_id && + call_url == o.call_url && + enqueued_time == o.enqueued_time && + start_time == o.start_time && + answer_time == o.answer_time && + tag == o.tag && + refer_to == o.refer_to && + refer_call_status == o.refer_call_status && + refer_sip_response_code == o.refer_sip_response_code && + notify_sip_response_code == o.notify_sip_response_code + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [event_type, event_time, account_id, application_id, from, to, direction, call_id, call_url, enqueued_time, start_time, answer_time, tag, refer_to, refer_call_status, refer_sip_response_code, notify_sip_response_code].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + end + +end \ No newline at end of file diff --git a/spec/unit/models/refer_call_status_enum_spec.rb b/spec/unit/models/refer_call_status_enum_spec.rb new file mode 100644 index 00000000..5e032de0 --- /dev/null +++ b/spec/unit/models/refer_call_status_enum_spec.rb @@ -0,0 +1,34 @@ +# Unit tests for Bandwidth::ReferCallStatusEnum +describe Bandwidth::ReferCallStatusEnum do + describe 'constants' do + it 'defines SUCCESS' do + expect(Bandwidth::ReferCallStatusEnum::SUCCESS).to eq('success') + end + + it 'defines FAILURE' do + expect(Bandwidth::ReferCallStatusEnum::FAILURE).to eq('failure') + end + end + + describe '.all_vars' do + it 'returns every valid enum value' do + expect(Bandwidth::ReferCallStatusEnum.all_vars).to eq([ + 'success', + 'failure' + ]) + end + end + + describe '.build_from_hash' do + it 'returns the value when it matches a valid enum value' do + expect(Bandwidth::ReferCallStatusEnum.build_from_hash('success')).to eq('success') + expect(Bandwidth::ReferCallStatusEnum.build_from_hash('failure')).to eq('failure') + end + + it 'raises an error for an invalid enum value' do + expect { + Bandwidth::ReferCallStatusEnum.build_from_hash('invalid') + }.to raise_error(RuntimeError) + end + end +end \ No newline at end of file diff --git a/spec/unit/models/refer_complete_callback_spec.rb b/spec/unit/models/refer_complete_callback_spec.rb new file mode 100644 index 00000000..f5e38481 --- /dev/null +++ b/spec/unit/models/refer_complete_callback_spec.rb @@ -0,0 +1,201 @@ +Original file line number Diff line number Diff line change +# Unit tests for Bandwidth::ReferCompleteCallback +describe Bandwidth::ReferCompleteCallback do + let(:refer_complete_callback_default) { Bandwidth::ReferCompleteCallback.new } + let(:refer_complete_callback_success) { Bandwidth::ReferCompleteCallback.new({ + event_type: 'referComplete', + event_time: '2022-06-16T13:15:07.160Z', + account_id: '9900000', + application_id: '04e88489-df02-4e34-a0ee-27a91849555f', + from: '+19195554321', + to: '+19195551234', + direction: Bandwidth::CallDirectionEnum::INBOUND, + call_id: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85', + call_url: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85', + start_time: '2022-06-16T13:15:07.160Z', + answer_time: '2022-06-16T13:15:18.126Z', + tag: 'custom tag', + refer_to: 'sip:alice@atlanta.example.com', + refer_call_status: Bandwidth::ReferCallStatusEnum::SUCCESS + }) } + let(:refer_complete_callback_failure) { Bandwidth::ReferCompleteCallback.new({ + event_type: 'referComplete', + event_time: '2022-06-16T13:15:07.160Z', + account_id: '9900000', + application_id: '04e88489-df02-4e34-a0ee-27a91849555f', + from: '+19195554321', + to: '+19195551234', + direction: Bandwidth::CallDirectionEnum::INBOUND, + call_id: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85', + call_url: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85', + start_time: '2022-06-16T13:15:07.160Z', + answer_time: '2022-06-16T13:15:18.126Z', + tag: 'custom tag', + refer_to: 'sip:alice@atlanta.example.com', + refer_call_status: Bandwidth::ReferCallStatusEnum::FAILURE, + refer_sip_response_code: 405 + }) } + + describe '#initialize' do + it 'causes an ArgumentError by passing an Array to the initialize method' do + expect { + Bandwidth::ReferCompleteCallback.new([]) + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do + expect { + Bandwidth::ReferCompleteCallback.new({ invalid: true }) + }.to raise_error(ArgumentError) + end + end + + describe '#acceptable_attributes' do + it 'expects acceptable JSON attributes to be those in the attribute map' do + expect(Bandwidth::ReferCompleteCallback.acceptable_attributes).to eq(Bandwidth::ReferCompleteCallback.attribute_map.values) + end + end + + describe '#openapi_nullable' do + it 'expects nullable attributes to be the set of nullable fields' do + expect(Bandwidth::ReferCompleteCallback.openapi_nullable).to eq(Set.new([ + :'enqueued_time', + :'answer_time', + :'tag', + :'refer_sip_response_code', + :'notify_sip_response_code' + ])) + end + end + + describe '#build_from_hash' do + it 'validates instance of ReferCompleteCallback created by the build_from_hash method (success)' do + callback = Bandwidth::ReferCompleteCallback.build_from_hash({ + eventType: 'referComplete', + eventTime: '2022-06-16T13:15:07.160Z', + accountId: '9900000', + applicationId: '04e88489-df02-4e34-a0ee-27a91849555f', + from: '+19195554321', + to: '+19195551234', + direction: Bandwidth::CallDirectionEnum::INBOUND, + callId: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85', + callUrl: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85', + startTime: '2022-06-16T13:15:07.160Z', + answerTime: '2022-06-16T13:15:18.126Z', + tag: 'custom tag', + referTo: 'sip:alice@atlanta.example.com', + referCallStatus: 'success', + referSipResponseCode: nil, + notifySipResponseCode: nil + }) + expect(callback).to be_instance_of(Bandwidth::ReferCompleteCallback) + expect(callback.event_type).to eq('referComplete') + expect(callback.account_id).to eq('9900000') + expect(callback.refer_to).to eq('sip:alice@atlanta.example.com') + expect(callback.refer_call_status).to eq(Bandwidth::ReferCallStatusEnum::SUCCESS) + expect(callback.refer_sip_response_code).to be_nil + expect(callback.notify_sip_response_code).to be_nil + end + + it 'validates instance of ReferCompleteCallback for a rejected REFER (referSipResponseCode=405)' do + callback = Bandwidth::ReferCompleteCallback.build_from_hash({ + eventType: 'referComplete', + eventTime: '2022-06-16T13:15:07.160Z', + accountId: '9900000', + applicationId: '04e88489-df02-4e34-a0ee-27a91849555f', + from: '+19195554321', + to: '+19195551234', + direction: 'inbound', + callId: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85', + callUrl: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85', + startTime: '2022-06-16T13:15:07.160Z', + answerTime: '2022-06-16T13:15:18.126Z', + referTo: 'sip:alice@atlanta.example.com', + referCallStatus: 'failure', + referSipResponseCode: 405 + }) + expect(callback).to be_instance_of(Bandwidth::ReferCompleteCallback) + expect(callback.refer_call_status).to eq(Bandwidth::ReferCallStatusEnum::FAILURE) + expect(callback.refer_sip_response_code).to eq(405) + expect(callback.notify_sip_response_code).to be_nil + end + + it 'validates instance of ReferCompleteCallback for an unreachable destination (notifySipResponseCode present)' do + callback = Bandwidth::ReferCompleteCallback.build_from_hash({ + eventType: 'referComplete', + eventTime: '2022-06-16T13:15:07.160Z', + accountId: '9900000', + applicationId: '04e88489-df02-4e34-a0ee-27a91849555f', + from: '+19195554321', + to: '+19195551234', + direction: 'inbound', + callId: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85', + callUrl: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85', + startTime: '2022-06-16T13:15:07.160Z', + answerTime: '2022-06-16T13:15:18.126Z', + referTo: 'sip:alice@atlanta.example.com', + referCallStatus: 'failure', + referSipResponseCode: 202, + notifySipResponseCode: 503 + }) + expect(callback).to be_instance_of(Bandwidth::ReferCompleteCallback) + expect(callback.refer_call_status).to eq(Bandwidth::ReferCallStatusEnum::FAILURE) + expect(callback.refer_sip_response_code).to eq(202) + expect(callback.notify_sip_response_code).to eq(503) + end + end + + describe '#to_s' do + it 'returns a string representation of the object' do + expect(refer_complete_callback_success.to_s).to eq('{:eventType=>"referComplete", :eventTime=>"2022-06-16T13:15:07.160Z", :accountId=>"9900000", :applicationId=>"04e88489-df02-4e34-a0ee-27a91849555f", :from=>"+19195554321", :to=>"+19195551234", :direction=>"inbound", :callId=>"c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", :callUrl=>"https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", :startTime=>"2022-06-16T13:15:07.160Z", :answerTime=>"2022-06-16T13:15:18.126Z", :tag=>"custom tag", :referTo=>"sip:alice@atlanta.example.com", :referCallStatus=>"success"}') + end + end + + describe '#eq? #==' do + it 'returns true/false when comparing objects' do + expect(refer_complete_callback_default.eql?(Bandwidth::ReferCompleteCallback.new)).to be true + expect(refer_complete_callback_default.eql?(refer_complete_callback_success)).to be false + end + end + + describe '#to_body #to_hash' do + it 'returns a hash representation of the success callback' do + expect(refer_complete_callback_success.to_body).to eq({ + eventType: 'referComplete', + eventTime: '2022-06-16T13:15:07.160Z', + accountId: '9900000', + applicationId: '04e88489-df02-4e34-a0ee-27a91849555f', + from: '+19195554321', + to: '+19195551234', + direction: Bandwidth::CallDirectionEnum::INBOUND, + callId: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85', + callUrl: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85', + startTime: '2022-06-16T13:15:07.160Z', + answerTime: '2022-06-16T13:15:18.126Z', + tag: 'custom tag', + referTo: 'sip:alice@atlanta.example.com', + referCallStatus: Bandwidth::ReferCallStatusEnum::SUCCESS + }) + end + + it 'returns a hash representation of the failure callback with referSipResponseCode' do + expect(refer_complete_callback_failure.to_body).to eq({ + eventType: 'referComplete', + eventTime: '2022-06-16T13:15:07.160Z', + accountId: '9900000', + applicationId: '04e88489-df02-4e34-a0ee-27a91849555f', + from: '+19195554321', + to: '+19195551234', + direction: Bandwidth::CallDirectionEnum::INBOUND, + callId: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85', + callUrl: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85', + startTime: '2022-06-16T13:15:07.160Z', + answerTime: '2022-06-16T13:15:18.126Z', + tag: 'custom tag', + referTo: 'sip:alice@atlanta.example.com', + referCallStatus: Bandwidth::ReferCallStatusEnum::FAILURE, + referSipResponseCode: 405 + }) + end + end +end \ No newline at end of file From 63d9927d09814944fa6a5c368181cd5409f41b40 Mon Sep 17 00:00:00 2001 From: atelegu Date: Fri, 19 Jun 2026 14:10:36 +0530 Subject: [PATCH 02/10] VAPI-3162-REFER --- spec/unit/models/refer_complete_callback_spec.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/spec/unit/models/refer_complete_callback_spec.rb b/spec/unit/models/refer_complete_callback_spec.rb index f5e38481..8ee0dd7e 100644 --- a/spec/unit/models/refer_complete_callback_spec.rb +++ b/spec/unit/models/refer_complete_callback_spec.rb @@ -1,4 +1,3 @@ -Original file line number Diff line number Diff line change # Unit tests for Bandwidth::ReferCompleteCallback describe Bandwidth::ReferCompleteCallback do let(:refer_complete_callback_default) { Bandwidth::ReferCompleteCallback.new } From 06f9afb6a50cb2c6b9da264c0f289674b3040c9e Mon Sep 17 00:00:00 2001 From: atelegu Date: Fri, 19 Jun 2026 17:23:18 +0530 Subject: [PATCH 03/10] VAPI-3162-REFER --- .openapi-generator/FILES | 6 ++ bandwidth.yml | 35 +++++++ lib/bandwidth-sdk.rb | 3 + lib/bandwidth-sdk/models/refer.rb | 91 +++++++++++++++++++ .../models/refer_complete_method_enum.rb | 22 +++++ lib/bandwidth-sdk/models/sip_uri.rb | 62 +++++++++++++ .../models/refer_complete_method_enum_spec.rb | 19 ++++ spec/unit/models/refer_spec.rb | 49 ++++++++++ spec/unit/models/sip_uri_spec.rb | 15 +++ 9 files changed, 302 insertions(+) create mode 100644 lib/bandwidth-sdk/models/refer.rb create mode 100644 lib/bandwidth-sdk/models/refer_complete_method_enum.rb create mode 100644 lib/bandwidth-sdk/models/sip_uri.rb create mode 100644 spec/unit/models/refer_complete_method_enum_spec.rb create mode 100644 spec/unit/models/refer_spec.rb create mode 100644 spec/unit/models/sip_uri_spec.rb diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index 29d91be4..208a707a 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -388,10 +388,13 @@ lib/bandwidth-sdk/models/recording_transcription_metadata.rb lib/bandwidth-sdk/models/recording_transcriptions.rb lib/bandwidth-sdk/models/redirect_callback.rb lib/bandwidth-sdk/models/redirect_method_enum.rb +lib/bandwidth-sdk/models/refer.rb lib/bandwidth-sdk/models/refer_call_status_enum.rb lib/bandwidth-sdk/models/refer_complete_callback.rb +lib/bandwidth-sdk/models/refer_complete_method_enum.rb lib/bandwidth-sdk/models/sip_connection_metadata.rb lib/bandwidth-sdk/models/sip_credentials.rb +lib/bandwidth-sdk/models/sip_uri.rb lib/bandwidth-sdk/models/sms_message_content.rb lib/bandwidth-sdk/models/standalone_card_orientation_enum.rb lib/bandwidth-sdk/models/status_callback.rb @@ -433,3 +436,6 @@ lib/bandwidth-sdk/models/webhook_subscription_request_schema.rb lib/bandwidth-sdk/models/webhook_subscription_type_enum.rb lib/bandwidth-sdk/models/webhook_subscriptions_list_body.rb lib/bandwidth-sdk/version.rb +spec/unit/models/refer_complete_method_enum_spec.rb +spec/unit/models/refer_spec.rb +spec/unit/models/sip_uri_spec.rb diff --git a/bandwidth.yml b/bandwidth.yml index aef6826a..7d397b7c 100644 --- a/bandwidth.yml +++ b/bandwidth.yml @@ -3216,6 +3216,14 @@ components: - failure description: The status of the SIP REFER request. example: success + referCompleteMethodEnum: + type: string + description: HTTP method used for referCompleteUrl callback. + default: POST + enum: + - GET + - POST + example: POST machineDetectionModeEnum: type: string default: async @@ -5054,6 +5062,33 @@ components: $ref: '#/components/schemas/transferCallerId' transferTo: $ref: '#/components/schemas/transferTo' + sipUri: + type: object + description: SIP URI destination for Refer-To header. + properties: + sipUri: + type: string + description: SIP URI destination (e.g. sip:alice@atlanta.example.com). + example: sip:alice@atlanta.example.com + required: + - sipUri + refer: + type: object + description: Send a SIP REFER for an inbound SIP URI call. + properties: + referCompleteUrl: + type: string + description: Optional callback URL for referComplete event. Relative URL allowed. + referCompleteMethod: + $ref: '#/components/schemas/referCompleteMethodEnum' + tag: + type: string + description: Optional tag echoed in future callbacks. Max length 256. + maxLength: 256 + sipUri: + $ref: '#/components/schemas/sipUri' + required: + - sipUri referCompleteCallback: type: object description: >- diff --git a/lib/bandwidth-sdk.rb b/lib/bandwidth-sdk.rb index 9c324eb9..a6b8d74e 100644 --- a/lib/bandwidth-sdk.rb +++ b/lib/bandwidth-sdk.rb @@ -174,10 +174,13 @@ require 'bandwidth-sdk/models/recording_transcriptions' require 'bandwidth-sdk/models/redirect_callback' require 'bandwidth-sdk/models/redirect_method_enum' +require 'bandwidth-sdk/models/refer' require 'bandwidth-sdk/models/refer_call_status_enum' require 'bandwidth-sdk/models/refer_complete_callback' +require 'bandwidth-sdk/models/refer_complete_method_enum' require 'bandwidth-sdk/models/sip_connection_metadata' require 'bandwidth-sdk/models/sip_credentials' +require 'bandwidth-sdk/models/sip_uri' require 'bandwidth-sdk/models/sms_message_content' require 'bandwidth-sdk/models/standalone_card_orientation_enum' require 'bandwidth-sdk/models/status_callback' diff --git a/lib/bandwidth-sdk/models/refer.rb b/lib/bandwidth-sdk/models/refer.rb new file mode 100644 index 00000000..0db96a4a --- /dev/null +++ b/lib/bandwidth-sdk/models/refer.rb @@ -0,0 +1,91 @@ +require 'date' +require 'time' + +module Bandwidth + class Refer < ApiModelBase + attr_accessor :refer_complete_url + attr_accessor :refer_complete_method + attr_accessor :tag + attr_accessor :sip_uri + + def self.attribute_map + { + :'refer_complete_url' => :'referCompleteUrl', + :'refer_complete_method' => :'referCompleteMethod', + :'tag' => :'tag', + :'sip_uri' => :'sipUri' + } + end + + def self.acceptable_attribute_map + attribute_map + end + + def self.acceptable_attributes + acceptable_attribute_map.values + end + + def self.openapi_types + { + :'refer_complete_url' => :'String', + :'refer_complete_method' => :'ReferCompleteMethodEnum', + :'tag' => :'String', + :'sip_uri' => :'SipUri' + } + end + + def self.openapi_nullable + Set.new([:'refer_complete_url', :'refer_complete_method', :'tag']) + end + + def initialize(attributes = {}) + raise ArgumentError, "attributes must be a Hash" unless attributes.is_a?(Hash) + + acceptable_attribute_map = self.class.acceptable_attribute_map + attributes = attributes.each_with_object({}) do |(k, v), h| + raise ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::Refer`." unless acceptable_attribute_map.key?(k.to_sym) + h[k.to_sym] = v + end + + self.refer_complete_url = attributes[:'refer_complete_url'] if attributes.key?(:'refer_complete_url') + self.refer_complete_method = attributes[:'refer_complete_method'] if attributes.key?(:'refer_complete_method') + self.tag = attributes[:'tag'] if attributes.key?(:'tag') + self.sip_uri = attributes[:'sip_uri'] if attributes.key?(:'sip_uri') + + # required nested destination + raise ArgumentError, "`sip_uri` is required for Bandwidth::Refer" if self.sip_uri.nil? + # optional validation + if !self.refer_complete_method.nil? + ReferCompleteMethodEnum.build_from_hash(self.refer_complete_method) + end + if !self.tag.nil? && self.tag.length > 256 + raise ArgumentError, "`tag` max length is 256" + end + end + + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && !attributes[attribute_map[key]].nil? + transformed_hash[key.to_s] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next unless is_nullable && instance_variable_defined?(:"@#{attr}") + end + hash[param] = _to_hash(value) + end + hash + end + end +end \ No newline at end of file diff --git a/lib/bandwidth-sdk/models/refer_complete_method_enum.rb b/lib/bandwidth-sdk/models/refer_complete_method_enum.rb new file mode 100644 index 00000000..b3e5bd32 --- /dev/null +++ b/lib/bandwidth-sdk/models/refer_complete_method_enum.rb @@ -0,0 +1,22 @@ +require 'date' +require 'time' + +module Bandwidth + class ReferCompleteMethodEnum + GET = "GET".freeze + POST = "POST".freeze + + def self.all_vars + @all_vars ||= [GET, POST].freeze + end + + def self.build_from_hash(value) + new.build_from_hash(value) + end + + def build_from_hash(value) + return value if ReferCompleteMethodEnum.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #ReferCompleteMethodEnum" + end + end +end \ No newline at end of file diff --git a/lib/bandwidth-sdk/models/sip_uri.rb b/lib/bandwidth-sdk/models/sip_uri.rb new file mode 100644 index 00000000..7576d151 --- /dev/null +++ b/lib/bandwidth-sdk/models/sip_uri.rb @@ -0,0 +1,62 @@ +require 'date' +require 'time' + +module Bandwidth + class SipUri < ApiModelBase + # SIP URI destination (e.g. sip:alice@atlanta.example.com) + attr_accessor :sip_uri + + def self.attribute_map + { :'sip_uri' => :'sipUri' } + end + + def self.acceptable_attribute_map + attribute_map + end + + def self.acceptable_attributes + acceptable_attribute_map.values + end + + def self.openapi_types + { :'sip_uri' => :'String' } + end + + def self.openapi_nullable + Set.new([]) + end + + def initialize(attributes = {}) + raise ArgumentError, "attributes must be a Hash" unless attributes.is_a?(Hash) + + acceptable_attribute_map = self.class.acceptable_attribute_map + attributes = attributes.each_with_object({}) do |(k, v), h| + raise ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::SipUri`." unless acceptable_attribute_map.key?(k.to_sym) + h[k.to_sym] = v + end + + self.sip_uri = attributes[:'sip_uri'] if attributes.key?(:'sip_uri') + end + + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + next if attributes[attribute_map[key]].nil? + transformed_hash[key.to_s] = _deserialize(type, attributes[attribute_map[key]]) + end + new(transformed_hash) + end + + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = send(attr) + next if value.nil? + hash[param] = _to_hash(value) + end + hash + end + end +end \ No newline at end of file diff --git a/spec/unit/models/refer_complete_method_enum_spec.rb b/spec/unit/models/refer_complete_method_enum_spec.rb new file mode 100644 index 00000000..de14efeb --- /dev/null +++ b/spec/unit/models/refer_complete_method_enum_spec.rb @@ -0,0 +1,19 @@ +describe Bandwidth::ReferCompleteMethodEnum do + it 'defines GET and POST' do + expect(Bandwidth::ReferCompleteMethodEnum::GET).to eq('GET') + expect(Bandwidth::ReferCompleteMethodEnum::POST).to eq('POST') + end + + it 'returns all vars' do + expect(Bandwidth::ReferCompleteMethodEnum.all_vars).to eq(['GET', 'POST']) + end + + it 'builds from valid hash values' do + expect(Bandwidth::ReferCompleteMethodEnum.build_from_hash('GET')).to eq('GET') + expect(Bandwidth::ReferCompleteMethodEnum.build_from_hash('POST')).to eq('POST') + end + + it 'raises for invalid values' do + expect { Bandwidth::ReferCompleteMethodEnum.build_from_hash('PUT') }.to raise_error(RuntimeError) + end +end \ No newline at end of file diff --git a/spec/unit/models/refer_spec.rb b/spec/unit/models/refer_spec.rb new file mode 100644 index 00000000..f1ea0f01 --- /dev/null +++ b/spec/unit/models/refer_spec.rb @@ -0,0 +1,49 @@ +describe Bandwidth::Refer do + let(:sip_uri) { Bandwidth::SipUri.new(sip_uri: 'sip:alice@atlanta.example.com') } + + it 'initializes and serializes with valid attributes' do + model = Bandwidth::Refer.new( + refer_complete_url: 'https://example.com/referComplete', + refer_complete_method: Bandwidth::ReferCompleteMethodEnum::POST, + tag: 'custom-tag', + sip_uri: sip_uri + ) + + expect(model.to_hash).to eq({ + referCompleteUrl: 'https://example.com/referComplete', + referCompleteMethod: 'POST', + tag: 'custom-tag', + sipUri: { sipUri: 'sip:alice@atlanta.example.com' } + }) + end + + it 'requires sip_uri' do + expect { + Bandwidth::Refer.new(refer_complete_method: 'POST') + }.to raise_error(ArgumentError) + end + + it 'rejects invalid method enum' do + expect { + Bandwidth::Refer.new(sip_uri: sip_uri, refer_complete_method: 'PUT') + }.to raise_error(RuntimeError) + end + + it 'rejects invalid attributes' do + expect { + Bandwidth::Refer.new(sip_uri: sip_uri, invalid: true) + }.to raise_error(ArgumentError) + end + + it 'builds from hash' do + model = Bandwidth::Refer.build_from_hash({ + referCompleteUrl: 'https://example.com/referComplete', + referCompleteMethod: 'GET', + tag: 'x', + sipUri: { sipUri: 'sip:alice@atlanta.example.com' } + }) + + expect(model.refer_complete_method).to eq('GET') + expect(model.sip_uri.sip_uri).to eq('sip:alice@atlanta.example.com') + end +end \ No newline at end of file diff --git a/spec/unit/models/sip_uri_spec.rb b/spec/unit/models/sip_uri_spec.rb new file mode 100644 index 00000000..b1bd9f2b --- /dev/null +++ b/spec/unit/models/sip_uri_spec.rb @@ -0,0 +1,15 @@ +describe Bandwidth::SipUri do + it 'initializes with valid value' do + model = Bandwidth::SipUri.new(sip_uri: 'sip:alice@atlanta.example.com') + expect(model.sip_uri).to eq('sip:alice@atlanta.example.com') + end + + it 'raises on invalid attribute' do + expect { Bandwidth::SipUri.new(invalid: true) }.to raise_error(ArgumentError) + end + + it 'builds from hash and serializes' do + model = Bandwidth::SipUri.build_from_hash({ sipUri: 'sip:alice@atlanta.example.com' }) + expect(model.to_hash).to eq({ sipUri: 'sip:alice@atlanta.example.com' }) + end +end \ No newline at end of file From 75fc16f449473d52642b2f663809ba14f6f17e07 Mon Sep 17 00:00:00 2001 From: atelegu Date: Fri, 19 Jun 2026 17:37:58 +0530 Subject: [PATCH 04/10] VAPI-3162-REFER --- lib/bandwidth-sdk/models/refer.rb | 10 ++++++++++ lib/bandwidth-sdk/models/refer_complete_callback.rb | 2 +- lib/bandwidth-sdk/models/refer_complete_method_enum.rb | 10 ++++++++++ lib/bandwidth-sdk/models/sip_uri.rb | 10 ++++++++++ 4 files changed, 31 insertions(+), 1 deletion(-) diff --git a/lib/bandwidth-sdk/models/refer.rb b/lib/bandwidth-sdk/models/refer.rb index 0db96a4a..9fd16710 100644 --- a/lib/bandwidth-sdk/models/refer.rb +++ b/lib/bandwidth-sdk/models/refer.rb @@ -1,7 +1,17 @@ +=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.17.0 +=end + require 'date' require 'time' module Bandwidth + #BXML verb model. Sends a SIP REFER for an inbound SIP URI call class Refer < ApiModelBase attr_accessor :refer_complete_url attr_accessor :refer_complete_method diff --git a/lib/bandwidth-sdk/models/refer_complete_callback.rb b/lib/bandwidth-sdk/models/refer_complete_callback.rb index 7edb8d66..50833e10 100644 --- a/lib/bandwidth-sdk/models/refer_complete_callback.rb +++ b/lib/bandwidth-sdk/models/refer_complete_callback.rb @@ -13,7 +13,7 @@ module Bandwidth # This event is sent to the referCompleteUrl of the verb when the SIP REFER request has been resolved — either the remote endpoint has accepted and redirected the call (success) or the REFER was rejected or timed out (failure). On success the original call is terminated. class ReferCompleteCallback < ApiModelBase - # The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect. + # The event type for this webhook. For this callback, the value is `referComplete`. attr_accessor :event_type # The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution. diff --git a/lib/bandwidth-sdk/models/refer_complete_method_enum.rb b/lib/bandwidth-sdk/models/refer_complete_method_enum.rb index b3e5bd32..77ee209f 100644 --- a/lib/bandwidth-sdk/models/refer_complete_method_enum.rb +++ b/lib/bandwidth-sdk/models/refer_complete_method_enum.rb @@ -1,7 +1,17 @@ +=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.17.0 +=end + require 'date' require 'time' module Bandwidth + # HTTP method enum for referCompleteUrl callback requests. class ReferCompleteMethodEnum GET = "GET".freeze POST = "POST".freeze diff --git a/lib/bandwidth-sdk/models/sip_uri.rb b/lib/bandwidth-sdk/models/sip_uri.rb index 7576d151..f513a9cf 100644 --- a/lib/bandwidth-sdk/models/sip_uri.rb +++ b/lib/bandwidth-sdk/models/sip_uri.rb @@ -1,7 +1,17 @@ +=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.17.0 +=end + require 'date' require 'time' module Bandwidth + # Nested SIP URI destination model used by . class SipUri < ApiModelBase # SIP URI destination (e.g. sip:alice@atlanta.example.com) attr_accessor :sip_uri From 51c8b79da52fee534836cb8d208b6f8ded1db371 Mon Sep 17 00:00:00 2001 From: atelegu Date: Fri, 19 Jun 2026 19:46:47 +0530 Subject: [PATCH 05/10] VAPI-3162-REFER --- .openapi-generator/FILES | 4 +++- bandwidth.yml | 6 ----- lib/bandwidth-sdk/models/bxml/verbs/refer.rb | 20 ++++++++++++++++ .../models/refer_complete_callback.rb | 23 +------------------ .../models/refer_complete_callback_spec.rb | 11 +-------- 5 files changed, 25 insertions(+), 39 deletions(-) create mode 100644 lib/bandwidth-sdk/models/bxml/verbs/refer.rb diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index 208a707a..cfa2e14e 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -436,6 +436,8 @@ lib/bandwidth-sdk/models/webhook_subscription_request_schema.rb lib/bandwidth-sdk/models/webhook_subscription_type_enum.rb lib/bandwidth-sdk/models/webhook_subscriptions_list_body.rb lib/bandwidth-sdk/version.rb +spec/unit/models/refer_call_status_enum_spec.rb +spec/unit/models/refer_complete_callback_spec.rb spec/unit/models/refer_complete_method_enum_spec.rb spec/unit/models/refer_spec.rb -spec/unit/models/sip_uri_spec.rb +spec/unit/models/sip_uri_spec.rb \ No newline at end of file diff --git a/bandwidth.yml b/bandwidth.yml index 7d397b7c..a6ca622b 100644 --- a/bandwidth.yml +++ b/bandwidth.yml @@ -5115,18 +5115,12 @@ components: $ref: '#/components/schemas/callId' callUrl: $ref: '#/components/schemas/callUrl' - enqueuedTime: - $ref: '#/components/schemas/enqueuedTime' startTime: $ref: '#/components/schemas/startTime' answerTime: $ref: '#/components/schemas/answerTime' tag: $ref: '#/components/schemas/tag1' - referTo: - type: string - description: The SIP URI that the call was referred to. - example: sip:alice@atlanta.example.com referCallStatus: $ref: '#/components/schemas/referCallStatusEnum' referSipResponseCode: diff --git a/lib/bandwidth-sdk/models/bxml/verbs/refer.rb b/lib/bandwidth-sdk/models/bxml/verbs/refer.rb new file mode 100644 index 00000000..bf716b48 --- /dev/null +++ b/lib/bandwidth-sdk/models/bxml/verbs/refer.rb @@ -0,0 +1,20 @@ +module Bandwidth + module Bxml + class Refer < Bandwidth::Bxml::NestableVerb + def initialize(sip_uri, attributes = {}) + super('Refer', nil, [sip_uri], attributes) + @attribute_map = { + refer_complete_url: 'referCompleteUrl', + refer_complete_method: 'referCompleteMethod', + refer_complete_fallback_url: 'referCompleteFallbackUrl', + refer_complete_fallback_method: 'referCompleteFallbackMethod', + username: 'username', + password: 'password', + fallback_username: 'fallbackUsername', + fallback_password: 'fallbackPassword', + tag: 'tag' + } + end + end + end +end \ No newline at end of file diff --git a/lib/bandwidth-sdk/models/refer_complete_callback.rb b/lib/bandwidth-sdk/models/refer_complete_callback.rb index 50833e10..fda3658a 100644 --- a/lib/bandwidth-sdk/models/refer_complete_callback.rb +++ b/lib/bandwidth-sdk/models/refer_complete_callback.rb @@ -39,9 +39,6 @@ class ReferCompleteCallback < ApiModelBase # The URL of the call associated with the event. attr_accessor :call_url - # (optional) If call queueing is enabled and this is an outbound call, time the call was queued, in ISO 8601 format. - attr_accessor :enqueued_time - # Time the call was started, in ISO 8601 format. attr_accessor :start_time @@ -51,9 +48,6 @@ class ReferCompleteCallback < ApiModelBase # (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present. attr_accessor :tag - # The SIP URI that the call was referred to. - attr_accessor :refer_to - attr_accessor :refer_call_status # The SIP response code received in response to the REFER request. Present when the status of the REFER is known (e.g. 202 Accepted or 405 Method Not Allowed). Absent when the REFER was not attempted. @@ -96,11 +90,9 @@ def self.attribute_map :'direction' => :'direction', :'call_id' => :'callId', :'call_url' => :'callUrl', - :'enqueued_time' => :'enqueuedTime', :'start_time' => :'startTime', :'answer_time' => :'answerTime', :'tag' => :'tag', - :'refer_to' => :'referTo', :'refer_call_status' => :'referCallStatus', :'refer_sip_response_code' => :'referSipResponseCode', :'notify_sip_response_code' => :'notifySipResponseCode' @@ -129,11 +121,9 @@ def self.openapi_types :'direction' => :'CallDirectionEnum', :'call_id' => :'String', :'call_url' => :'String', - :'enqueued_time' => :'Time', :'start_time' => :'Time', :'answer_time' => :'Time', :'tag' => :'String', - :'refer_to' => :'String', :'refer_call_status' => :'ReferCallStatusEnum', :'refer_sip_response_code' => :'Integer', :'notify_sip_response_code' => :'Integer' @@ -143,7 +133,6 @@ def self.openapi_types # List of attributes with nullable: true def self.openapi_nullable Set.new([ - :'enqueued_time', :'answer_time', :'tag', :'refer_sip_response_code', @@ -203,10 +192,6 @@ def initialize(attributes = {}) self.call_url = attributes[:'call_url'] end - if attributes.key?(:'enqueued_time') - self.enqueued_time = attributes[:'enqueued_time'] - end - if attributes.key?(:'start_time') self.start_time = attributes[:'start_time'] end @@ -219,10 +204,6 @@ def initialize(attributes = {}) self.tag = attributes[:'tag'] end - if attributes.key?(:'refer_to') - self.refer_to = attributes[:'refer_to'] - end - if attributes.key?(:'refer_call_status') self.refer_call_status = attributes[:'refer_call_status'] end @@ -265,11 +246,9 @@ def ==(o) direction == o.direction && call_id == o.call_id && call_url == o.call_url && - enqueued_time == o.enqueued_time && start_time == o.start_time && answer_time == o.answer_time && tag == o.tag && - refer_to == o.refer_to && refer_call_status == o.refer_call_status && refer_sip_response_code == o.refer_sip_response_code && notify_sip_response_code == o.notify_sip_response_code @@ -284,7 +263,7 @@ def eql?(o) # Calculates hash code according to all attributes. # @return [Integer] Hash code def hash - [event_type, event_time, account_id, application_id, from, to, direction, call_id, call_url, enqueued_time, start_time, answer_time, tag, refer_to, refer_call_status, refer_sip_response_code, notify_sip_response_code].hash + [event_type, event_time, account_id, application_id, from, to, direction, call_id, call_url, start_time, answer_time, tag, refer_call_status, refer_sip_response_code, notify_sip_response_code].hash end # Builds the object from hash diff --git a/spec/unit/models/refer_complete_callback_spec.rb b/spec/unit/models/refer_complete_callback_spec.rb index 8ee0dd7e..81a8e361 100644 --- a/spec/unit/models/refer_complete_callback_spec.rb +++ b/spec/unit/models/refer_complete_callback_spec.rb @@ -14,7 +14,6 @@ start_time: '2022-06-16T13:15:07.160Z', answer_time: '2022-06-16T13:15:18.126Z', tag: 'custom tag', - refer_to: 'sip:alice@atlanta.example.com', refer_call_status: Bandwidth::ReferCallStatusEnum::SUCCESS }) } let(:refer_complete_callback_failure) { Bandwidth::ReferCompleteCallback.new({ @@ -30,7 +29,6 @@ start_time: '2022-06-16T13:15:07.160Z', answer_time: '2022-06-16T13:15:18.126Z', tag: 'custom tag', - refer_to: 'sip:alice@atlanta.example.com', refer_call_status: Bandwidth::ReferCallStatusEnum::FAILURE, refer_sip_response_code: 405 }) } @@ -58,7 +56,6 @@ describe '#openapi_nullable' do it 'expects nullable attributes to be the set of nullable fields' do expect(Bandwidth::ReferCompleteCallback.openapi_nullable).to eq(Set.new([ - :'enqueued_time', :'answer_time', :'tag', :'refer_sip_response_code', @@ -82,7 +79,6 @@ startTime: '2022-06-16T13:15:07.160Z', answerTime: '2022-06-16T13:15:18.126Z', tag: 'custom tag', - referTo: 'sip:alice@atlanta.example.com', referCallStatus: 'success', referSipResponseCode: nil, notifySipResponseCode: nil @@ -90,7 +86,6 @@ expect(callback).to be_instance_of(Bandwidth::ReferCompleteCallback) expect(callback.event_type).to eq('referComplete') expect(callback.account_id).to eq('9900000') - expect(callback.refer_to).to eq('sip:alice@atlanta.example.com') expect(callback.refer_call_status).to eq(Bandwidth::ReferCallStatusEnum::SUCCESS) expect(callback.refer_sip_response_code).to be_nil expect(callback.notify_sip_response_code).to be_nil @@ -109,7 +104,6 @@ callUrl: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85', startTime: '2022-06-16T13:15:07.160Z', answerTime: '2022-06-16T13:15:18.126Z', - referTo: 'sip:alice@atlanta.example.com', referCallStatus: 'failure', referSipResponseCode: 405 }) @@ -132,7 +126,6 @@ callUrl: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85', startTime: '2022-06-16T13:15:07.160Z', answerTime: '2022-06-16T13:15:18.126Z', - referTo: 'sip:alice@atlanta.example.com', referCallStatus: 'failure', referSipResponseCode: 202, notifySipResponseCode: 503 @@ -146,7 +139,7 @@ describe '#to_s' do it 'returns a string representation of the object' do - expect(refer_complete_callback_success.to_s).to eq('{:eventType=>"referComplete", :eventTime=>"2022-06-16T13:15:07.160Z", :accountId=>"9900000", :applicationId=>"04e88489-df02-4e34-a0ee-27a91849555f", :from=>"+19195554321", :to=>"+19195551234", :direction=>"inbound", :callId=>"c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", :callUrl=>"https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", :startTime=>"2022-06-16T13:15:07.160Z", :answerTime=>"2022-06-16T13:15:18.126Z", :tag=>"custom tag", :referTo=>"sip:alice@atlanta.example.com", :referCallStatus=>"success"}') + expect(refer_complete_callback_success.to_s).to eq('{:eventType=>"referComplete", :eventTime=>"2022-06-16T13:15:07.160Z", :accountId=>"9900000", :applicationId=>"04e88489-df02-4e34-a0ee-27a91849555f", :from=>"+19195554321", :to=>"+19195551234", :direction=>"inbound", :callId=>"c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", :callUrl=>"https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", :startTime=>"2022-06-16T13:15:07.160Z", :answerTime=>"2022-06-16T13:15:18.126Z", :tag=>"custom tag", :referCallStatus=>"success"}') end end @@ -172,7 +165,6 @@ startTime: '2022-06-16T13:15:07.160Z', answerTime: '2022-06-16T13:15:18.126Z', tag: 'custom tag', - referTo: 'sip:alice@atlanta.example.com', referCallStatus: Bandwidth::ReferCallStatusEnum::SUCCESS }) end @@ -191,7 +183,6 @@ startTime: '2022-06-16T13:15:07.160Z', answerTime: '2022-06-16T13:15:18.126Z', tag: 'custom tag', - referTo: 'sip:alice@atlanta.example.com', referCallStatus: Bandwidth::ReferCallStatusEnum::FAILURE, referSipResponseCode: 405 }) From 9d297002cde3890271993d867cc95cebe5256359 Mon Sep 17 00:00:00 2001 From: atelegu Date: Sat, 20 Jun 2026 11:55:17 +0530 Subject: [PATCH 06/10] VAPI-3162-REFER --- lib/bandwidth-sdk/models/sip_uri.rb | 8 ++++---- spec/unit/models/refer_spec.rb | 8 ++++---- spec/unit/models/sip_uri_spec.rb | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/bandwidth-sdk/models/sip_uri.rb b/lib/bandwidth-sdk/models/sip_uri.rb index f513a9cf..8a8bd392 100644 --- a/lib/bandwidth-sdk/models/sip_uri.rb +++ b/lib/bandwidth-sdk/models/sip_uri.rb @@ -14,10 +14,10 @@ module Bandwidth # Nested SIP URI destination model used by . class SipUri < ApiModelBase # SIP URI destination (e.g. sip:alice@atlanta.example.com) - attr_accessor :sip_uri + attr_accessor :uri def self.attribute_map - { :'sip_uri' => :'sipUri' } + { :'uri' => :'uri' } end def self.acceptable_attribute_map @@ -29,7 +29,7 @@ def self.acceptable_attributes end def self.openapi_types - { :'sip_uri' => :'String' } + { :'uri' => :'String' } end def self.openapi_nullable @@ -45,7 +45,7 @@ def initialize(attributes = {}) h[k.to_sym] = v end - self.sip_uri = attributes[:'sip_uri'] if attributes.key?(:'sip_uri') + self.uri = attributes[:'uri'] if attributes.key?(:'uri') end def self.build_from_hash(attributes) diff --git a/spec/unit/models/refer_spec.rb b/spec/unit/models/refer_spec.rb index f1ea0f01..91e56819 100644 --- a/spec/unit/models/refer_spec.rb +++ b/spec/unit/models/refer_spec.rb @@ -1,5 +1,5 @@ describe Bandwidth::Refer do - let(:sip_uri) { Bandwidth::SipUri.new(sip_uri: 'sip:alice@atlanta.example.com') } + let(:sip_uri) { Bandwidth::SipUri.new(uri: 'sip:alice@atlanta.example.com') } it 'initializes and serializes with valid attributes' do model = Bandwidth::Refer.new( @@ -13,7 +13,7 @@ referCompleteUrl: 'https://example.com/referComplete', referCompleteMethod: 'POST', tag: 'custom-tag', - sipUri: { sipUri: 'sip:alice@atlanta.example.com' } + sipUri: { uri: 'sip:alice@atlanta.example.com' } }) end @@ -40,10 +40,10 @@ referCompleteUrl: 'https://example.com/referComplete', referCompleteMethod: 'GET', tag: 'x', - sipUri: { sipUri: 'sip:alice@atlanta.example.com' } + sipUri: { uri: 'sip:alice@atlanta.example.com' } }) expect(model.refer_complete_method).to eq('GET') - expect(model.sip_uri.sip_uri).to eq('sip:alice@atlanta.example.com') + expect(model.sip_uri.uri).to eq('sip:alice@atlanta.example.com') end end \ No newline at end of file diff --git a/spec/unit/models/sip_uri_spec.rb b/spec/unit/models/sip_uri_spec.rb index b1bd9f2b..c29d6453 100644 --- a/spec/unit/models/sip_uri_spec.rb +++ b/spec/unit/models/sip_uri_spec.rb @@ -1,7 +1,7 @@ describe Bandwidth::SipUri do it 'initializes with valid value' do - model = Bandwidth::SipUri.new(sip_uri: 'sip:alice@atlanta.example.com') - expect(model.sip_uri).to eq('sip:alice@atlanta.example.com') + model = Bandwidth::SipUri.new(uri: 'sip:alice@atlanta.example.com') + expect(model.uri).to eq('sip:alice@atlanta.example.com') end it 'raises on invalid attribute' do @@ -9,7 +9,7 @@ end it 'builds from hash and serializes' do - model = Bandwidth::SipUri.build_from_hash({ sipUri: 'sip:alice@atlanta.example.com' }) - expect(model.to_hash).to eq({ sipUri: 'sip:alice@atlanta.example.com' }) + model = Bandwidth::SipUri.build_from_hash({ uri: 'sip:alice@atlanta.example.com' }) + expect(model.to_hash).to eq({ uri: 'sip:alice@atlanta.example.com' }) end end \ No newline at end of file From b54f869231ccdcf36eca9e06e373614602fce2ca Mon Sep 17 00:00:00 2001 From: atelegu Date: Sat, 20 Jun 2026 12:02:43 +0530 Subject: [PATCH 07/10] VAPI-3162-REFER --- lib/bandwidth-sdk.rb | 1 + lib/bandwidth-sdk/models/bxml/verbs/refer.rb | 6 ------ 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/bandwidth-sdk.rb b/lib/bandwidth-sdk.rb index a6b8d74e..6380a047 100644 --- a/lib/bandwidth-sdk.rb +++ b/lib/bandwidth-sdk.rb @@ -240,6 +240,7 @@ require 'bandwidth-sdk/models/bxml/verbs/play_audio' require 'bandwidth-sdk/models/bxml/verbs/record' require 'bandwidth-sdk/models/bxml/verbs/redirect' +require 'bandwidth-sdk/models/bxml/verbs/refer' require 'bandwidth-sdk/models/bxml/verbs/resume_recording' require 'bandwidth-sdk/models/bxml/verbs/ring' require 'bandwidth-sdk/models/bxml/verbs/send_dtmf' diff --git a/lib/bandwidth-sdk/models/bxml/verbs/refer.rb b/lib/bandwidth-sdk/models/bxml/verbs/refer.rb index bf716b48..776b0652 100644 --- a/lib/bandwidth-sdk/models/bxml/verbs/refer.rb +++ b/lib/bandwidth-sdk/models/bxml/verbs/refer.rb @@ -6,12 +6,6 @@ module Bandwidth @attribute_map = { refer_complete_url: 'referCompleteUrl', refer_complete_method: 'referCompleteMethod', - refer_complete_fallback_url: 'referCompleteFallbackUrl', - refer_complete_fallback_method: 'referCompleteFallbackMethod', - username: 'username', - password: 'password', - fallback_username: 'fallbackUsername', - fallback_password: 'fallbackPassword', tag: 'tag' } end From 539a192ce3abfb7be24d05967c9cbd491751e511 Mon Sep 17 00:00:00 2001 From: atelegu Date: Sat, 20 Jun 2026 12:06:39 +0530 Subject: [PATCH 08/10] VAPI-3162-REFER --- .../models/refer_complete_callback_spec.rb | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/spec/unit/models/refer_complete_callback_spec.rb b/spec/unit/models/refer_complete_callback_spec.rb index 81a8e361..a6e2fb93 100644 --- a/spec/unit/models/refer_complete_callback_spec.rb +++ b/spec/unit/models/refer_complete_callback_spec.rb @@ -187,5 +187,27 @@ referSipResponseCode: 405 }) end + + it 'handles NOTIFY timeout (202 accepted, no NOTIFY received)' do + callback = Bandwidth::ReferCompleteCallback.build_from_hash({ + eventType: 'referComplete', + eventTime: '2022-06-16T13:15:07.160Z', + accountId: '9900000', + applicationId: '04e88489-df02-4e34-a0ee-27a91849555f', + from: '+19195554321', + to: '+19195551234', + direction: 'inbound', + callId: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85', + callUrl: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85', + startTime: '2022-06-16T13:15:07.160Z', + answerTime: '2022-06-16T13:15:18.126Z', + referCallStatus: 'failure', + referSipResponseCode: 202 + }) + + expect(callback.refer_call_status).to eq(Bandwidth::ReferCallStatusEnum::FAILURE) + expect(callback.refer_sip_response_code).to eq(202) + expect(callback.notify_sip_response_code).to be_nil + end end end \ No newline at end of file From d33a62a30ca127d0f2a562e5f0223dc93c7095ad Mon Sep 17 00:00:00 2001 From: atelegu Date: Sat, 20 Jun 2026 12:07:42 +0530 Subject: [PATCH 09/10] VAPI-3162-REFER --- spec/unit/models/refer_spec.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/spec/unit/models/refer_spec.rb b/spec/unit/models/refer_spec.rb index 91e56819..ccd0015d 100644 --- a/spec/unit/models/refer_spec.rb +++ b/spec/unit/models/refer_spec.rb @@ -35,6 +35,12 @@ }.to raise_error(ArgumentError) end + it 'rejects a tag exceeding 256 characters' do + expect { + Bandwidth::Refer.new(sip_uri: sip_uri, tag: 'x' * 257) + }.to raise_error(ArgumentError) + end + it 'builds from hash' do model = Bandwidth::Refer.build_from_hash({ referCompleteUrl: 'https://example.com/referComplete', From c367380d7f3606a3bc2d9c0850adaee506ba9c69 Mon Sep 17 00:00:00 2001 From: atelegu Date: Sat, 20 Jun 2026 12:20:11 +0530 Subject: [PATCH 10/10] VAPI-3162-REFER --- lib/bandwidth-sdk/models/bxml/verbs/{refer.rb => refer.rb} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename lib/bandwidth-sdk/models/bxml/verbs/{refer.rb => refer.rb} (100%) diff --git a/lib/bandwidth-sdk/models/bxml/verbs/refer.rb b/lib/bandwidth-sdk/models/bxml/verbs/refer.rb similarity index 100% rename from lib/bandwidth-sdk/models/bxml/verbs/refer.rb rename to lib/bandwidth-sdk/models/bxml/verbs/refer.rb