Skip to content

Commit f91cd69

Browse files
committed
Merge branch 'release/1.2.0'
2 parents 62834df + 1697646 commit f91cd69

9 files changed

Lines changed: 233 additions & 74 deletions

File tree

‎CM.Voice.VoiceApi.Sdk/Models/Instructions/Apps/BaseAppInstruction.cs‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using Newtonsoft.Json;
2-
using System;
32

43
namespace CM.Voice.VoiceApi.Sdk.Models.Instructions.Apps
54
{
@@ -46,10 +45,17 @@ public abstract class BaseAppInstruction
4645
[JsonProperty("disable-callees-validation", Order = 7)]
4746
public bool DisableCalleesValidation { get; set; }
4847

48+
/// <summary>
49+
/// Information on the voice to use if (any of) the prompt(s) is of type tts.
50+
/// </summary>
51+
[JsonProperty("voice", Order = 99, NullValueHandling = NullValueHandling.Ignore)]
52+
public Voice Voice { get; set; } = new Voice();
53+
4954
/// <summary>
5055
/// The url to send the POST command to for further VoiceAPI flow.
5156
/// </summary>
5257
[JsonProperty("callback-url", Order = 100, NullValueHandling = NullValueHandling.Ignore)]
5358
public string CallbackUrl { get; set; }
59+
5460
}
5561
}

‎CM.Voice.VoiceApi.Sdk/Models/Instructions/Apps/NotificationInstruction.cs‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using Newtonsoft.Json;
2-
using System;
32

43
namespace CM.Voice.VoiceApi.Sdk.Models.Instructions.Apps
54
{
@@ -18,12 +17,6 @@ public class NotificationInstruction : BaseAppInstruction
1817
/// The type of the prompt, either file or tts.
1918
/// </summary>
2019
[JsonProperty("prompt-type", Order = 8, NullValueHandling = NullValueHandling.Ignore)]
21-
public PromptType? PromptType { get; set; }
22-
23-
/// <summary>
24-
/// Information on the voice to use if the prompt is of type tts.
25-
/// </summary>
26-
[JsonProperty("voice", Order = 9, NullValueHandling = NullValueHandling.Ignore)]
27-
public Voice Voice { get; set; }
20+
public PromptType? PromptType { get; set; } = Models.PromptType.TTS;
2821
}
2922
}

‎CM.Voice.VoiceApi.Sdk/Models/Instructions/Apps/OtpInstruction.cs‎

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
using System;
2-
using Newtonsoft.Json;
1+
using Newtonsoft.Json;
32

43
namespace CM.Voice.VoiceApi.Sdk.Models.Instructions.Apps
54
{
65
/// <summary>
7-
/// Instruction to send an OTP (One Time Password) to the callee.
6+
/// Instruction to send a One Time Password (OTP) to the callee.
87
/// </summary>
98
public class OtpInstruction : BaseAppInstruction
109
{
@@ -18,7 +17,7 @@ public class OtpInstruction : BaseAppInstruction
1817
/// The type of the prompt, either file or tts.
1918
/// </summary>
2019
[JsonProperty("intro-prompt-type", Order = 8, NullValueHandling = NullValueHandling.Ignore)]
21-
public PromptType? IntroPromptType { get; set; }
20+
public PromptType? IntroPromptType { get; set; } = PromptType.TTS;
2221

2322
/// <summary>
2423
/// The prompt, which is either the path and name of the file to play, or the string that needs to be tts-ed.
@@ -30,7 +29,7 @@ public class OtpInstruction : BaseAppInstruction
3029
/// The type of the prompt, either file or tts.
3130
/// </summary>
3231
[JsonProperty("code-prompt-type", Order = 10, NullValueHandling = NullValueHandling.Ignore)]
33-
public PromptType? CodePromptType { get; set; }
32+
public PromptType? CodePromptType { get; set; } = PromptType.TTS;
3433

3534
/// <summary>
3635
/// The OTP code.
@@ -42,7 +41,7 @@ public class OtpInstruction : BaseAppInstruction
4241
/// The type of the prompt, either file or tts.
4342
/// </summary>
4443
[JsonProperty("code-type", Order = 12, NullValueHandling = NullValueHandling.Ignore)]
45-
public CodeType? CodeType { get; set; }
44+
public CodeType? CodeType { get; set; } = Models.CodeType.TTS;
4645

4746
/// <summary>
4847
/// The prompt, which is either the path and name of the file to play, or the string that needs to be tts-ed.
@@ -54,7 +53,7 @@ public class OtpInstruction : BaseAppInstruction
5453
/// The type of the prompt, either file or tts.
5554
/// </summary>
5655
[JsonProperty("replay-prompt-type", Order = 14, NullValueHandling = NullValueHandling.Ignore)]
57-
public PromptType? ReplayPromptType { get; set; }
56+
public PromptType? ReplayPromptType { get; set; } = PromptType.TTS;
5857
/// <summary>
5958
/// The prompt, which is either the path and name of the file to play, or the string that needs to be tts-ed.
6059
/// </summary>
@@ -65,7 +64,7 @@ public class OtpInstruction : BaseAppInstruction
6564
/// The type of the prompt, either file or tts.
6665
/// </summary>
6766
[JsonProperty("outro-prompt-type", Order = 16, NullValueHandling = NullValueHandling.Ignore)]
68-
public PromptType? OutroPromptType { get; set; }
67+
public PromptType? OutroPromptType { get; set; } = PromptType.TTS;
6968

7069
/// <summary>
7170
/// The number of times the code can be played. Min = 1, Max = 10.
@@ -78,11 +77,5 @@ public class OtpInstruction : BaseAppInstruction
7877
/// </summary>
7978
[JsonProperty("auto-replay", Order = 17, NullValueHandling = NullValueHandling.Ignore)]
8079
public bool? AutoReplay { get; set; }
81-
82-
/// <summary>
83-
/// Information on the voice to use if the prompt is of type tts.
84-
/// </summary>
85-
[JsonProperty("voice", Order = 18, NullValueHandling = NullValueHandling.Ignore)]
86-
public Voice Voice { get; set; }
8780
}
8881
}

‎CM.Voice.VoiceApi.Sdk/Models/Instructions/Apps/RequestDtmfInstruction.cs‎

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class RequestDtmfInstruction : BaseAppInstruction
1818
/// The type of the prompt, either file or tts.
1919
/// </summary>
2020
[JsonProperty("prompt-type", Order = 8, NullValueHandling = NullValueHandling.Ignore)]
21-
public PromptType? PromptType { get; set; }
21+
public PromptType? PromptType { get; set; } = Models.PromptType.TTS;
2222

2323
/// <summary>
2424
/// The prompt, which is either the path and name of the file to play, or the string that needs to be tts-ed.
@@ -30,7 +30,7 @@ public class RequestDtmfInstruction : BaseAppInstruction
3030
/// The type of the prompt, either file or tts.
3131
/// </summary>
3232
[JsonProperty("valid-prompt-type", Order = 10, NullValueHandling = NullValueHandling.Ignore)]
33-
public PromptType? ValidPromptType { get; set; }
33+
public PromptType? ValidPromptType { get; set; } = Models.PromptType.TTS;
3434

3535
/// <summary>
3636
/// The prompt, which is either the path and name of the file to play, or the string that needs to be tts-ed.
@@ -42,7 +42,7 @@ public class RequestDtmfInstruction : BaseAppInstruction
4242
/// The type of the prompt, either file or tts.
4343
/// </summary>
4444
[JsonProperty("invalid-prompt-type", Order = 12, NullValueHandling = NullValueHandling.Ignore)]
45-
public PromptType? InvalidPromptType { get; set; }
45+
public PromptType? InvalidPromptType { get; set; } = Models.PromptType.TTS;
4646

4747
/// <summary>
4848
/// The minimum number of digits for the dtmf input
@@ -79,11 +79,5 @@ public class RequestDtmfInstruction : BaseAppInstruction
7979
/// </summary>
8080
[JsonProperty("regex", Order = 18, NullValueHandling = NullValueHandling.Ignore)]
8181
public string DigitsRegex { get; set; }
82-
83-
/// <summary>
84-
/// Information on the voice to use if the prompt is of type tts.
85-
/// </summary>
86-
[JsonProperty("voice", Order = 19, NullValueHandling = NullValueHandling.Ignore)]
87-
public Voice Voice { get; set; }
8882
}
8983
}

‎CM.Voice.VoiceApi.Sdk/VoiceApiClient.cs‎

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,21 +64,18 @@ public VoiceApiClient(HttpClient httpClient, Guid apiKey, string url = "https://
6464
}
6565

6666
[Obsolete("See SendAsync")]
67-
public Task<VoiceApiResult<CallQueuedEvent>> SendInstruction(BaseAppInstruction instruction,
68-
CancellationToken cancellationToken = default(CancellationToken))
69-
{
70-
return SendAsync(instruction, cancellationToken);
71-
}
67+
public Task<VoiceApiResult<CallQueuedEvent>> SendInstruction(BaseAppInstruction instruction, CancellationToken cancellationToken = default(CancellationToken))
68+
=> SendAsync(instruction, cancellationToken);
7269

7370
private static string GetUrlSuffix(BaseAppInstruction instruction)
7471
{
7572
switch (instruction)
7673
{
77-
case NotificationInstruction notificationInstruction:
74+
case NotificationInstruction _:
7875
return "/Notification";
79-
case OtpInstruction otpInstruction:
76+
case OtpInstruction _:
8077
return "/OTP";
81-
case RequestDtmfInstruction requestDtmfInstruction:
78+
case RequestDtmfInstruction _:
8279
return "/DTMF";
8380

8481
default:

‎LICENSE.md‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2018 CM
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

‎README.md‎

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ https://docs.cmtelecom.com/voice-api-apps/v2.0
1717

1818
```cs
1919
var httpClient = new HttpClient();
20-
var client = new VoiceApiClient(httpClient, myApiKey);
20+
var voiceApiClient = new VoiceApiClient(httpClient, myApiKey);
2121
```
2222

2323
`httpClient` is requested as a parameter, such that you can use a single instance throughout your application, as is highly recommended.
2424
Ideally you would have it injected by Dependency Injection.
2525

26-
`apiKey` is your unique api key (or product token) which authorizes you on the CM platform. Always keep this key secret!
26+
`myApiKey` is your unique api key (or product token) which authorizes you on the CM platform. Always keep this key secret!
2727

2828
## Sending an instruction
2929

@@ -32,30 +32,22 @@ Before we can send an instruction, we need to create one.
3232
```cs
3333
var instruction = new NotificationInstruction
3434
{
35-
InstructionId = "My InstructionId",
3635
Caller = "+1234567890",
3736
Callee = "+9876543210",
38-
PromptType = PromptType.TTS,
39-
Prompt = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent eu laoreet augue. Fusce fermentum auctor pellentesque.",
40-
Voice = new Voice
41-
{
42-
Language = "nl-NL",
43-
Gender = Gender.Female,
44-
Number = 1
45-
}
37+
Prompt = "This is a test call."
4638
};
4739
```
4840

4941
This is an example Notification instruction, which will simply call the `Callee` while showing the `Caller`.
50-
When picked up, it will read the prompt using the specified voice and hang up.
42+
When picked up, it will read the prompt using the default voice (en-GB, Female, nr. 1) and hang up.
5143

5244
The other instructions are the `OtpInstruction` (for sending a One Time Password) and the `RequestDtmfInstruction` (for calling and requesting numerical input from the callee).
5345
More information on the various fields and their uses can be found in the docs (https://docs.cmtelecom.com/voice-api-apps/v2.0), as well as the list of possible voices.
5446

5547
To send the instruction, simply call `SendAsync()` on the client and the call should take place shortly after.
5648

5749
```cs
58-
var result = await client.SendAsync(instruction).ConfigureAwait(false);
50+
var result = await voiceApiClient.SendAsync(instruction).ConfigureAwait(false);
5951
```
6052

6153
Finally, the result will have a `HttpStatusCode`, `Content` (as string), a boolean indicating `Success` and a call `DeserializeEvent()` to Deserialize the result into a `CallQueuedEvent`

‎Tests/CallQueuedEventEqualityComparer.cs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using CM.Voice.VoiceApi.Sdk.Models.Events;
1+
using System;
2+
using CM.Voice.VoiceApi.Sdk.Models.Events;
23
using System.Collections.Generic;
34

45
namespace Tests

0 commit comments

Comments
 (0)