Skip to content

Commit

Permalink
feat(voice): add hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
Dovchik committed Jan 4, 2024
1 parent b33cc28 commit 2b482bc
Show file tree
Hide file tree
Showing 24 changed files with 671 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/Sinch/Voice/Calls/Actions/CallHeader.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Text;
using System.Text.Json.Serialization;

namespace Sinch.Voice.Calls.Actions
{
Expand All @@ -12,12 +13,14 @@ public sealed class CallHeader
/// <summary>
/// The call header key of the key value pair.
/// </summary>
[JsonPropertyName("key")]
public string Key { get; set; }


/// <summary>
/// The call header value of the key value pair.
/// </summary>
[JsonPropertyName("value")]
public string Value { get; set; }


Expand Down
4 changes: 4 additions & 0 deletions src/Sinch/Voice/Calls/Actions/ConnectConf.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Text;
using System.Text.Json.Serialization;

namespace Sinch.Voice.Calls.Actions
{
Expand All @@ -10,6 +11,7 @@ public sealed class ConnectConf : IAction
/// <summary>
/// The unique identifier of the conference. Shouldn&#39;t exceed 64 characters.
/// </summary>
[JsonPropertyName("conferenceId")]
#if NET7_0_OR_GREATER
public required string ConferenceId { get; set; }
#else
Expand All @@ -20,6 +22,7 @@ public sealed class ConnectConf : IAction
/// <summary>
/// Gets or Sets ConferenceDtmfOptions
/// </summary>
[JsonPropertyName("conferenceDtmfOptions")]
public ConferenceDtmfOptions ConferenceDtmfOptions { get; set; }


Expand All @@ -28,6 +31,7 @@ public sealed class ConnectConf : IAction
/// a conference while they&#39;re alone and waiting for other participants to join. If &#x60;moh&#x60; isn&#39;t
/// specified, the user will only hear silence while alone in the conference.
/// </summary>
[JsonPropertyName("moh")]
public MohClass Moh { get; set; }

public string Name { get; } = "connectConf";
Expand Down
4 changes: 4 additions & 0 deletions src/Sinch/Voice/Calls/Actions/ConnectMxp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ public sealed class ConnectMxp : IAction
public string Name { get; } = "connectMxp";

/// <inheritdoc cref="Destination" />
[JsonPropertyName("destination")]
public Destination Destination { get; set; }

/// <summary>
/// An optional parameter that allows you to specify or override call headers provided to the receiving Sinch SDK
/// client. Read more about call headers
/// <see href="https://developers.sinch.com/docs/voice/api-reference/voice/call-headers/">here</see>.
/// </summary>
[JsonPropertyName("callheaders")]
public List<CallHeader> Callheaders { get; set; }
}

Expand All @@ -32,6 +34,7 @@ public sealed class Destination
/// <summary>
/// The type of the definition.
/// </summary>
[JsonPropertyName("type")]
#if NET7_0_OR_GREATER
public required DestinationType Type { get; set; }
#else
Expand All @@ -41,6 +44,7 @@ public sealed class Destination
/// <summary>
/// The phone number or username of the desired call destination.
/// </summary>
[JsonPropertyName("endpoint")]
#if NET7_0_OR_GREATER
public required string Endpoint { get; set; }
#else
Expand Down
11 changes: 11 additions & 0 deletions src/Sinch/Voice/Calls/Actions/ConnectPstn.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Text;
using System.Text.Json.Serialization;

namespace Sinch.Voice.Calls.Actions
{
Expand All @@ -16,6 +17,7 @@ public class ConnectPstn : IAction
/// <summary>
/// Used to override where PSTN call is connected. If not specified, the extension the client called is used.
/// </summary>
[JsonPropertyName("number")]
public string Number { get; set; }


Expand All @@ -24,34 +26,39 @@ public class ConnectPstn : IAction
/// country code according to &#x60;ISO 3166-1 alpha-2&#x60;. If not specified, the default locale of &#x60;en-US&#x60;
/// is used.
/// </summary>
[JsonPropertyName("locale")]
public string Locale { get; set; }


/// <summary>
/// The max duration of the call in seconds (max 14400 seconds). If the call is still connected at that time, it will
/// be automatically disconnected.
/// </summary>
[JsonPropertyName("maxDuration")]
public int? MaxDuration { get; set; }


/// <summary>
/// The max duration the call will wait in ringing unanswered state before terminating with &#x60;&#x60;&#x60;
/// TIMEOUT/NO ANSWER&#x60;&#x60;&#x60; on PSTN leg and &#x60;&#x60;&#x60;NA/BUSY&#x60;&#x60;&#x60;on MXP leg.
/// </summary>
[JsonPropertyName("dialTimeout")]
public int? DialTimeout { get; set; }


/// <summary>
/// Used to override the CLI (or caller ID) of the client. The phone number of the person who initiated the call is
/// shown as the CLI. To set your own CLI, you may use your verified number or your Dashboard virtual number.
/// </summary>
[JsonPropertyName("cli")]
public string Cli { get; set; }


/// <summary>
/// If enabled, suppresses <see href="https://developers.sinch.com/docs/voice/api-reference/voice/voice/tag/Callbacks/#tag/Callbacks/operation/ace">ACE</see> and
/// <see href="https://developers.sinch.com/docs/voice/api-reference/voice/voice/tag/Callbacks/#tag/Callbacks/operation/dice">DICE</see> callbacks for the call.
/// </summary>
[JsonPropertyName("suppressCallbacks")]
public bool? SuppressCallbacks { get; set; }


Expand All @@ -63,18 +70,21 @@ public class ConnectPstn : IAction
/// the callout destination requires a conference PIN code or an extension. If there is a calling party, it will hear
/// progress while the DTMF is sent.
/// </summary>
[JsonPropertyName("dtmf")]
public string Dtmf { get; set; }


/// <summary>
/// The locale&#39;s tone to play while ringing.
/// </summary>
[JsonPropertyName("indications")]
public string Indications { get; set; }


/// <summary>
/// An optional property used to enable <see href="https://developers.sinch.com/docs/voice/api-reference/amd_v2">Answering Machine Detection (AMD).</see>
/// </summary>
[JsonPropertyName("amd")]
public Amd Amd { get; set; }


Expand Down Expand Up @@ -107,6 +117,7 @@ public class Amd
/// <summary>
/// Sets whether AMD is enabled.
/// </summary>
[JsonPropertyName("enabled")]
public bool? Enabled { get; set; }
}
}
8 changes: 8 additions & 0 deletions src/Sinch/Voice/Calls/Actions/ConnectSip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public sealed class ConnectSip : IAction
/// <summary>
/// Gets or Sets Destination
/// </summary>
[JsonPropertyName("destination")]
#if NET7_0_OR_GREATER
public required ConnectSipDestination Destination { get; set; }
#else
Expand All @@ -24,19 +25,22 @@ public sealed class ConnectSip : IAction
/// The max duration of the call in seconds (max 14400 seconds). If the call is still connected at that time, it will
/// be automatically disconnected.
/// </summary>
[JsonPropertyName("maxDuration")]
public int? MaxDuration { get; set; }


/// <summary>
/// Used to override the CLI (or caller ID) of the client. The phone number of the person who initiated the call is
/// shown as the CLI. To set your own CLI, you may use your verified number or your Dashboard virtual number.
/// </summary>
[JsonPropertyName("cli")]
public string Cli { get; set; }


/// <summary>
/// An optional parameter to specify the SIP transport protocol. If unspecified, UDP is used.
/// </summary>
[JsonPropertyName("transport")]
public Transport Transport { get; set; }


Expand All @@ -53,6 +57,7 @@ public sealed class ConnectSip : IAction
/// </see>
/// callbacks for the call.
/// </summary>
[JsonPropertyName("suppressCallbacks")]
public bool? SuppressCallbacks { get; set; }


Expand All @@ -64,6 +69,7 @@ public sealed class ConnectSip : IAction
/// </see>
/// to send with the call.
/// </summary>
[JsonPropertyName("callHeaders")]
public List<CallHeader> CallHeaders { get; set; }


Expand All @@ -72,6 +78,7 @@ public sealed class ConnectSip : IAction
/// if the SIP call is placed on hold. If &#x60;moh&#x60; isn&#39;t specified and the SIP call is placed on hold, the
/// user will only hear silence while during the holding period .
/// </summary>
[JsonPropertyName("moh")]
public MohClass Moh { get; set; }

public string Name { get; } = "connectSip";
Expand Down Expand Up @@ -114,6 +121,7 @@ public sealed class ConnectSipDestination
/// <summary>
/// The SIP address.
/// </summary>
[JsonPropertyName("endpoint")]
#if NET7_0_OR_GREATER
public required string Endpoint { get; set; }
#else
Expand Down
1 change: 1 addition & 0 deletions src/Sinch/Voice/Calls/Actions/IAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ namespace Sinch.Voice.Calls.Actions
[JsonDerivedType(typeof(RunMenu))]
public interface IAction
{
[JsonPropertyName("name")]
public string Name { get; }
}
}
5 changes: 5 additions & 0 deletions src/Sinch/Voice/Calls/Actions/Park.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Text;
using System.Text.Json.Serialization;

namespace Sinch.Voice.Calls.Actions
{
Expand All @@ -16,13 +17,15 @@ public sealed class Park : IAction
/// locale and language code or by specifying a particular voice. Supported languages and voices are detailed
/// <see href="https://developers.sinch.com/docs/voice/api-reference/voice/voice-locales">here</see>.
/// </summary>
[JsonPropertyName("locale")]
public string Locale { get; set; }


/// <summary>
/// That prompt that is played when the call is first answered. You can use text-to-speech using the &#x60;#tts[]&#x60;
/// element, SSML commands using the &#x60;#ssml[]&#x60; element.
/// </summary>
[JsonPropertyName("introPromt")]
public string IntroPrompt { get; set; }


Expand All @@ -31,12 +34,14 @@ public sealed class Park : IAction
/// reached. You can use text-to-speech using the &#x60;#tts[]&#x60; element, SSML commands using the &#x60;#ssml[]
/// &#x60; element.
/// </summary>
[JsonPropertyName("holdPrompt")]
public string HoldPrompt { get; set; }


/// <summary>
/// The maximum amount of time in seconds that the &#x60;holdPrompt&#x60; will be played.
/// </summary>
[JsonPropertyName("maxDuration")]
public int? MaxDuration { get; set; }


Expand Down
15 changes: 15 additions & 0 deletions src/Sinch/Voice/Calls/Actions/RunMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public sealed class RunMenu : IAction
/// input is pressed, the message will stop playing and accept the input. If &#x60;barge&#x60; is disabled, the user
/// must listen to the entire prompt before input is accepted. By default, barging is enabled.
/// </summary>
[JsonPropertyName("badge")]
public bool? Barge { get; set; }


Expand All @@ -35,26 +36,30 @@ public sealed class RunMenu : IAction
/// &#x60; to enable voice detection, the &#x60;locale&#x60;
/// property is required in order to select the input language.
/// </summary>
[JsonPropertyName("locale")]
public string Locale { get; set; }


/// <summary>
/// Selects the menu item from the &#x60;menus&#x60; array to play first.
/// </summary>
[JsonPropertyName("mainMenu")]
public string MainMenu { get; set; }


/// <summary>
/// Enables voice detection. If enabled, users can say their answers to prompts in addition to entering them using the
/// keypad.
/// </summary>
[JsonPropertyName("enableVoice")]
public bool? EnableVoice { get; set; }


/// <summary>
/// The list of menus available. The menu with the &#x60;id&#x60; value of &#x60;main&#x60; will always play first. If
/// no menu has an &#x60;id&#x60; value of &#x60;main&#x60;, an error is returned.
/// </summary>
[JsonPropertyName("menus")]
public List<Menu> Menus { get; set; }

public string Name { get; } = "runMenu";
Expand Down Expand Up @@ -87,6 +92,7 @@ public sealed class Menu
/// <summary>
/// The identifier of a menu. One menu must have the ID value of &#x60;main&#x60;.
/// </summary>
[JsonPropertyName("id")]
#if NET7_0_OR_GREATER
public required string Id { get; set; }
#else
Expand All @@ -105,6 +111,7 @@ public sealed class Menu
/// section for
/// more information.
/// </summary>
[JsonPropertyName("mainPrompt")]
public string MainPrompt { get; set; }


Expand All @@ -119,12 +126,14 @@ public sealed class Menu
/// section for
/// more information.
/// </summary>
[JsonPropertyName("repeatPrompt")]
public string RepeatPrompt { get; set; }


/// <summary>
/// The number of times that the &#x60;repeatPrompt&#x60; is played.
/// </summary>
[JsonPropertyName("repeats")]
public int? Repeats { get; set; }


Expand All @@ -137,25 +146,29 @@ public sealed class Menu
/// </see>
/// is triggered containing these digits.
/// </summary>
[JsonPropertyName("maxDigits")]
public int? MaxDigits { get; set; }


/// <summary>
/// Determines silence for the purposes of collecting a DTMF or voice response in milliseconds. If the timeout is
/// reached, the response is considered completed and will be submitted.
/// </summary>
[JsonPropertyName("timeoutMills")]
public int? TimeoutMills { get; set; }


/// <summary>
/// Sets a limit for the maximum amount of time allowed to collect voice input.
/// </summary>
[JsonPropertyName("maxTimeoutMills")]
public int? MaxTimeoutMills { get; set; }


/// <summary>
/// The set of options available in the menu.
/// </summary>
[JsonPropertyName("options")]
public List<Option> Options { get; set; }


Expand Down Expand Up @@ -188,6 +201,7 @@ public sealed class Option
/// <summary>
/// A DTMF digit the user can press to trigger the configured action.
/// </summary>
[JsonPropertyName("dtmf")]
#if NET7_0_OR_GREATER
public required string Dtmf { get; set; }
#else
Expand All @@ -198,6 +212,7 @@ public sealed class Option
/// <summary>
/// Determines which action is taken when the DTMF digit is pressed.
/// </summary>
[JsonPropertyName("action")]
#if NET7_0_OR_GREATER
public required DtmfAction Action { get; set; }
#else
Expand Down
1 change: 1 addition & 0 deletions src/Sinch/Voice/Calls/Instructions/IInstruction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace Sinch.Voice.Calls.Instructions
[JsonDerivedType(typeof(StopRecording))]
public interface IInstruction
{
[JsonPropertyName("name")]
public string Name { get; }
}
}
Loading

0 comments on commit 2b482bc

Please sign in to comment.