Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ docs/RecordingTranscriptions.md
docs/RecordingsApi.md
docs/RedirectCallback.md
docs/RedirectMethodEnum.md
docs/ReferCompleteCallback.md
docs/SipConnectionMetadata.md
docs/SipCredentials.md
docs/SmsMessageContent.md
Expand Down Expand Up @@ -403,6 +404,7 @@ src/Bandwidth.Standard/Model/RecordingTranscriptionMetadata.cs
src/Bandwidth.Standard/Model/RecordingTranscriptions.cs
src/Bandwidth.Standard/Model/RedirectCallback.cs
src/Bandwidth.Standard/Model/RedirectMethodEnum.cs
src/Bandwidth.Standard/Model/ReferCompleteCallback.cs
src/Bandwidth.Standard/Model/SipConnectionMetadata.cs
src/Bandwidth.Standard/Model/SipCredentials.cs
src/Bandwidth.Standard/Model/SmsMessageContent.cs
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,6 @@ namespace Example
}
}
}
```

<a id="documentation-for-api-endpoints"></a>
## Documentation for API Endpoints

Expand Down Expand Up @@ -330,6 +328,7 @@ Class | Method | HTTP request | Description
- [Model.RecordingTranscriptions](docs/RecordingTranscriptions.md)
- [Model.RedirectCallback](docs/RedirectCallback.md)
- [Model.RedirectMethodEnum](docs/RedirectMethodEnum.md)
- [Model.ReferCompleteCallback](docs/ReferCompleteCallback.md)
- [Model.SipConnectionMetadata](docs/SipConnectionMetadata.md)
- [Model.SipCredentials](docs/SipCredentials.md)
- [Model.SmsMessageContent](docs/SmsMessageContent.md)
Expand Down
92 changes: 92 additions & 0 deletions api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13407,6 +13407,98 @@ components:
example: "+15555555555"
type: string
type: object
referCompleteCallback:
description: "The Refer Complete event is fired when the <Refer> verb finishes\
\ executing. This is sent to the referCompleteUrl specified on the <Refer>\
\ verb, and the BXML returned in it is executed on the call."
properties:
eventType:
description: "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."
example: bridgeComplete
type: string
eventTime:
description: "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."
example: 2022-06-17T22:19:40.375Z
format: date-time
type: string
accountId:
description: The user account associated with the call.
example: "9900000"
type: string
applicationId:
description: The id of the application associated with the call.
example: 04e88489-df02-4e34-a0ee-27a91849555f
type: string
from:
description: The provided identifier of the caller. Must be a phone number
in E.164 format (e.g. +15555555555).
example: "+15555555555"
type: string
to:
description: "The phone number that received the call, in E.164 format (e.g.\
\ +15555555555)."
example: "+15555555555"
type: string
direction:
$ref: '#/components/schemas/callDirectionEnum'
callId:
description: The call id associated with the event.
example: c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85
type: string
callUrl:
description: The URL of the call associated with the event.
example: https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85
format: uri
type: string
enqueuedTime:
description: "(optional) If call queueing is enabled and this is an outbound\
\ call, time the call was queued, in ISO 8601 format."
example: 2022-06-17T22:20:00Z
format: date-time
nullable: true
type: string
startTime:
description: "Time the call was started, in ISO 8601 format."
example: 2022-06-17T22:19:40.375Z
format: date-time
type: string
answerTime:
description: "Time the call was answered, in ISO 8601 format."
example: 2022-06-17T22:20:00Z
format: date-time
nullable: true
type: string
tag:
description: "(optional) The tag specified on call creation. If no tag was\
\ specified or it was previously cleared, this field will not be present."
example: exampleTag
nullable: true
type: string
referCallStatus:
description: "The outcome of the REFER operation. Either \"success\" or\
\ \"failure\"."
example: success
type: string
referSipResponseCode:
description: "The SIP response code returned for the REFER request itself\
\ (e.g. 202, 405, 603)."
example: 202
nullable: true
type: integer
notifySipResponseCode:
description: "The final SIP response code reported via NOTIFY. Present only\
\ when the caller's endpoint sent a final NOTIFY."
example: 200
nullable: true
type: integer
type: object
transcriptionAvailableCallback:
description: The Transcription Available event is sent when the recording transcription
is available to be downloaded.
Expand Down
57 changes: 57 additions & 0 deletions bandwidth.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5047,6 +5047,45 @@ components:
$ref: '#/components/schemas/transferCallerId'
transferTo:
$ref: '#/components/schemas/transferTo'
referCompleteCallback:
type: object
description: >-
The Refer Complete event is fired when the <Refer> verb finishes
executing. This is sent to the referCompleteUrl specified on the
<Refer> verb, and the BXML returned in it is executed on the call.
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'
referCallStatus:
$ref: '#/components/schemas/referCallStatus'
referSipResponseCode:
$ref: '#/components/schemas/referSipResponseCode'
notifySipResponseCode:
$ref: '#/components/schemas/notifySipResponseCode'
transcriptionAvailableCallback:
type: object
description: >-
Expand Down Expand Up @@ -5392,6 +5431,24 @@ components:
or it was previously cleared, this field will not be present.
example: exampleTag
nullable: true
referCallStatus:
type: string
description: The outcome of the REFER operation. Either "success" or "failure".
example: success
referSipResponseCode:
type: integer
description: >-
The SIP response code returned for the REFER request itself (e.g. 202,
405, 603).
example: 202
nullable: true
notifySipResponseCode:
type: integer
description: >-
The final SIP response code reported via NOTIFY. Present only when the
caller's endpoint sent a final NOTIFY.
example: 200
nullable: true
cause:
type: string
description: >-
Expand Down
40 changes: 40 additions & 0 deletions docs/Refer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Bandwidth.Standard.Model.Bxml.Verbs.Refer

The `<Refer>` verb is used to hand off a call to a SIP endpoint via a SIP REFER. The call is transferred to the specified SIP URI, and an optional callback is sent when the transfer completes.

For more details, see the [Bandwidth BXML Refer documentation](https://dev.bandwidth.com/docs/voice/bxml/refer.html).

## Properties

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**ReferCompleteUrl** | **string** | URL to receive the `referComplete` callback when the REFER is finished. | [optional]
**ReferCompleteMethod** | **string** | HTTP method to use for the `referComplete` callback. Must be `GET` or `POST`. | [optional] [default to `POST`]
**Tag** | **string** | Optional custom string to include in callbacks. Max 256 characters. | [optional]
**SipUriElement** | [**Refer.SipUri**](#sipuri-nested-class) | The SIP URI destination for the REFER. Must start with `sip:`. |

## SipUri Nested Class

The `<SipUri>` element specifies the destination SIP URI for the REFER.

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**Uri** | **string** | The SIP URI to refer the call to. Must start with `sip:`. |

## Methods

Name | Description
------------ | -------------
`WithSipUri(string sipUri)` | Sets the SIP URI destination from a string. Returns the `Refer` instance for chaining.
`WithSipUri(SipUri sipUri)` | Sets the SIP URI destination from a `SipUri` object. Returns the `Refer` instance for chaining.
`WithReferCompleteUrl(string referCompleteUrl)` | Sets the `referCompleteUrl` attribute. Returns the `Refer` instance for chaining.
`WithReferCompleteMethod(string referCompleteMethod)` | Sets the `referCompleteMethod` attribute (`GET` or `POST`). Returns the `Refer` instance for chaining.
`WithTag(string tag)` | Sets the `tag` attribute. Returns the `Refer` instance for chaining.

## Validation

- `SipUri.Uri` must start with `sip:` (case-insensitive). An `ArgumentException` is thrown if the value does not match.
- `ReferCompleteMethod` must be either `GET` or `POST`. An `ArgumentException` is thrown for any other value.

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

26 changes: 26 additions & 0 deletions docs/ReferCompleteCallback.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Bandwidth.Standard.Model.ReferCompleteCallback
The Refer Complete event is fired when the <Refer> verb finishes executing. This is sent to the referCompleteUrl specified on the <Refer> verb, and the BXML returned in it is executed on the call.

## Properties

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**EventType** | **string** | 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. | [optional]
**EventTime** | **DateTime** | 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. | [optional]
**AccountId** | **string** | The user account associated with the call. | [optional]
**ApplicationId** | **string** | The id of the application associated with the call. | [optional]
**From** | **string** | The provided identifier of the caller. Must be a phone number in E.164 format (e.g. +15555555555). | [optional]
**To** | **string** | The phone number that received the call, in E.164 format (e.g. +15555555555). | [optional]
**Direction** | **CallDirectionEnum** | | [optional]
**CallId** | **string** | The call id associated with the event. | [optional]
**CallUrl** | **string** | The URL of the call associated with the event. | [optional]
**EnqueuedTime** | **DateTime?** | (optional) If call queueing is enabled and this is an outbound call, time the call was queued, in ISO 8601 format. | [optional]
**StartTime** | **DateTime** | Time the call was started, in ISO 8601 format. | [optional]
**AnswerTime** | **DateTime?** | Time the call was answered, in ISO 8601 format. | [optional]
**Tag** | **string** | (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present. | [optional]
**ReferCallStatus** | **string** | The outcome of the REFER operation. Either &quot;success&quot; or &quot;failure&quot;. | [optional]
**ReferSipResponseCode** | **int?** | The SIP response code returned for the REFER request itself (e.g. 202, 405, 603). | [optional]
**NotifySipResponseCode** | **int?** | The final SIP response code reported via NOTIFY. Present only when the caller&#39;s endpoint sent a final NOTIFY. | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

96 changes: 96 additions & 0 deletions src/Bandwidth.Standard.Test/Unit/Model/Bxml/TestRefer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
using System;
using System.IO;
using System.Xml.Serialization;
using Bandwidth.Standard.Model.Bxml;
using Bandwidth.Standard.Model.Bxml.Verbs;
using Xunit;

namespace Bandwidth.Standard.Test.Unit.Model.Bxml
{
public class TestRefer
{
[Fact]
public void ReferRoundTripTest()
{
var expected = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Response> <Refer referCompleteUrl=\"https://example.com/handleRefer\" referCompleteMethod=\"POST\" tag=\"refer-tag\"> <SipUri>sip:alice@atlanta.example.com</SipUri> </Refer></Response>";

var refer = new Refer()
.WithSipUri("sip:alice@atlanta.example.com")
.WithReferCompleteUrl("https://example.com/handleRefer")
.WithReferCompleteMethod("POST")
.WithTag("refer-tag");

var actual = new Response(refer).ToBXML();
Assert.Equal(expected, actual.Replace("\n", "").Replace("\r", ""));

const string referOnlyXml = "<Refer referCompleteUrl=\"https://example.com/handleRefer\" referCompleteMethod=\"POST\" tag=\"refer-tag\"><SipUri>sip:alice@atlanta.example.com</SipUri></Refer>";
var serializer = new XmlSerializer(typeof(Refer), "");
Refer deserializedRefer;
using (var reader = new StringReader(referOnlyXml))
{
deserializedRefer = (Refer)serializer.Deserialize(reader);
}

Assert.Equal("sip:alice@atlanta.example.com", deserializedRefer.SipUriElement.Uri);
var roundTrip = new Response(deserializedRefer).ToBXML();
Assert.Equal(expected, roundTrip.Replace("\n", "").Replace("\r", ""));
}

[Fact]
public void ReferSipUriMustStartWithSipScheme()
{
var refer = new Refer();
Assert.Throws<ArgumentException>(() => refer.WithSipUri("tel:+15551234567"));
}

[Fact]
public void ReferInvalidMethodThrows()
{
var refer = new Refer();
Assert.Throws<ArgumentException>(() => refer.WithReferCompleteMethod("DELETE"));
}

[Fact]
public void ReferWithSipUriObjectOverload()
{
var sipUri = new Refer.SipUri { Uri = "sip:alice@atlanta.example.com" };
var refer = new Refer().WithSipUri(sipUri);
Assert.Equal("sip:alice@atlanta.example.com", refer.SipUriElement.Uri);
}

[Fact]
public void ReferMinimalOnlySipUri()
{
var refer = new Refer().WithSipUri("sip:bob@biloxi.example.com");
var bxml = new Response(refer).ToBXML();
Assert.Contains("sip:bob@biloxi.example.com", bxml);
Assert.Contains("referCompleteMethod=\"POST\"", bxml);
}
Comment thread
atelegu marked this conversation as resolved.

[Fact]
public void ReferMissingSipUriProducesEmptyElement()
{
var refer = new Refer();
var bxml = new Response(refer).ToBXML();
// Documents that missing SipUri produces output without a SipUri element
Assert.DoesNotContain("<SipUri>", bxml);
}

[Fact]
public void SipUriIsNotIVerb()
{
// SipUri is a child element, not a verb; verify it does not implement IVerb
Assert.DoesNotContain(typeof(IVerb), typeof(Refer.SipUri).GetInterfaces());
}

[Fact]
public void ReferSipUriWithNullUriProducesEmptySipUriElement()
{
// Documents that a SipUri element with no URI text serializes as an empty element
var sipUri = new Refer.SipUri(); // Uri not set; required content is missing
var refer = new Refer().WithSipUri(sipUri);
var bxml = new Response(refer).ToBXML();
Assert.Contains("<SipUri />", bxml);
}
}
}
Loading
Loading