Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed Json Serialization to System.Text.Json #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
3 changes: 2 additions & 1 deletion CM.Voice.VoiceApi.Sdk/CM.Voice.VoiceApi.Sdk.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<Authors>mjepson</Authors>
<Version>1.0.0</Version>
<Description>SDK for use with the CM Voice API.</Description>
Expand All @@ -18,6 +18,7 @@

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="System.Text.Json" Version="5.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
10 changes: 5 additions & 5 deletions CM.Voice.VoiceApi.Sdk/Models/Events/Apps/CallQueuedEvent.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Newtonsoft.Json;
using System.Text.Json.Serialization;

namespace CM.Voice.VoiceApi.Sdk.Models.Events.Apps
{
Expand All @@ -14,25 +14,25 @@ public class CallQueuedEvent : BaseEvent
/// <summary>
/// The id (e.g. number) of the caller.
/// </summary>
[JsonProperty("caller", Order = 4)]
[JsonPropertyName("caller")]
public string Caller { get; set; }

/// <summary>
/// The id (e.g. number) of the callee.
/// </summary>
[JsonProperty("callee", Order = 5)]
[JsonPropertyName("callee")]
public string Callee { get; set; }

/// <summary>
/// True iff the PlaceCallInstruction was accepted.
/// </summary>
[JsonProperty("success", Order = 6)]
[JsonPropertyName("success")]
public bool Success { get; set; }

/// <summary>
/// True iff the PlaceCallInstruction was accepted.
/// </summary>
[JsonProperty("error", Order = 6, DefaultValueHandling = DefaultValueHandling.Ignore, NullValueHandling = NullValueHandling.Ignore)]
[JsonPropertyName("error")]
public string Error { get; set; }
}
}
10 changes: 5 additions & 5 deletions CM.Voice.VoiceApi.Sdk/Models/Events/BaseEvent.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Newtonsoft.Json;
using System;
using System;
using System.Text.Json.Serialization;

namespace CM.Voice.VoiceApi.Sdk.Models.Events
{
Expand All @@ -8,19 +8,19 @@ public abstract class BaseEvent
/// <summary>
/// The type of event.
/// </summary>
[JsonProperty("type", Order = 1, NullValueHandling = NullValueHandling.Ignore)]
[JsonPropertyName("type")]
public string Type => EventType;

/// <summary>
/// The ID of the call this event belongs to.
/// </summary>
[JsonProperty("call-id", Order = 2)]
[JsonPropertyName("call-id")]
public Guid CallId { get; set; }

/// <summary>
/// The ID of the instruction the event is a result of.
/// </summary>
[JsonProperty("instruction-id", Order = 3, NullValueHandling = NullValueHandling.Ignore)]
[JsonPropertyName("instruction-id")]
public string InstructionId { get; set; }

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Newtonsoft.Json;
using System.Text.Json.Serialization;

namespace CM.Voice.VoiceApi.Sdk.Models.Instructions.Apps
{
Expand All @@ -10,50 +10,50 @@ public abstract class BaseAppInstruction
/// <summary>
/// The ID of the instruction.
/// </summary>
[JsonProperty("instruction-id", Order = 3)]
[JsonPropertyName("instruction-id")]
public string InstructionId { get; set; }

/// <summary>
/// The number to dial.
/// </summary>
[JsonProperty("callee", Order = 4)]
[JsonPropertyName("callee")]
public string Callee { get; set; }

/// <summary>
/// The numbers to dial.
/// </summary>
[JsonProperty("callees", Order = 4)]
[JsonPropertyName("callees")]
public string[] Callees { get; set; }

/// <summary>
/// The caller id to show on the end user's phone.
/// </summary>
[JsonProperty("caller", Order = 5)]
[JsonPropertyName("caller")]
public string Caller { get; set; }

/// <summary>
/// The caller id is hidden iff anonymous = true.
/// </summary>
[JsonProperty("anonymous", Order = 6)]
[JsonPropertyName("anonymous")]
public bool Anonymous { get; set; }

/// <summary>
/// Iff true, the request is not rejected if (any of) the callees are invalid.
/// Please note that the invalid callees are not dialed, but the valid ones are.
/// </summary>
[JsonProperty("disable-callees-validation", Order = 7)]
[JsonPropertyName("disable-callees-validation")]
public bool DisableCalleesValidation { get; set; }

/// <summary>
/// Information on the voice to use if (any of) the prompt(s) is of type tts.
/// </summary>
[JsonProperty("voice", Order = 99, NullValueHandling = NullValueHandling.Ignore)]
[JsonPropertyName("voice")]
public Voice Voice { get; set; } = new Voice();

/// <summary>
/// The url to send the POST command to for further VoiceAPI flow.
/// </summary>
[JsonProperty("callback-url", Order = 100, NullValueHandling = NullValueHandling.Ignore)]
[JsonPropertyName("callback-url")]
public string CallbackUrl { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Newtonsoft.Json;
using System.Text.Json.Serialization;

namespace CM.Voice.VoiceApi.Sdk.Models.Instructions.Apps
{
Expand All @@ -10,43 +10,43 @@ public class NotificationInstruction : BaseAppInstruction
/// <summary>
/// The prompt, which is either the path and name of the file to play, or the string that needs to be tts-ed.
/// </summary>
[JsonProperty("prompt", Order = 7, NullValueHandling = NullValueHandling.Ignore)]
[JsonPropertyName("prompt")]
public string Prompt { get; set; }

/// <summary>
/// The type of the prompt, either file or tts.
/// </summary>
[JsonProperty("prompt-type", Order = 8, NullValueHandling = NullValueHandling.Ignore)]
[JsonPropertyName("prompt-type")]
public PromptType? PromptType { get; set; } = Models.PromptType.TTS;

/// <summary>
/// Determines the Voicemail detection flow.
/// </summary>
[JsonProperty("voicemail-response", Order = 9)]
[JsonPropertyName("voicemail-response")]
public VoicemailResponse VoicemailResponse { get; set; } = VoicemailResponse.Ignore;

/// <summary>
/// The number of times the code can be played. Min = 1, Max = 3.
/// </summary>
[JsonProperty("max-replays", Order = 11, NullValueHandling = NullValueHandling.Ignore)]
[JsonPropertyName("max-replays")]
public int? MaxReplays { get; set; }

/// <summary>
/// The code-prompt and code will replay automatically repeat if true, it will wait for a press on the "1" otherwise.
/// </summary>
[JsonProperty("auto-replay", Order = 12, NullValueHandling = NullValueHandling.Ignore)]
[JsonPropertyName("auto-replay")]
public bool? AutoReplay { get; set; }

/// <summary>
/// The prompt, which is either the path and name of the file to play, or the string that needs to be tts-ed.
/// </summary>
[JsonProperty("replay-prompt", Order = 13, NullValueHandling = NullValueHandling.Ignore)]
[JsonPropertyName("replay-prompt")]
public string ReplayPrompt { get; set; }

/// <summary>
/// The type of the prompt, either file or tts.
/// </summary>
[JsonProperty("replay-prompt-type", Order = 14, NullValueHandling = NullValueHandling.Ignore)]
[JsonPropertyName("replay-prompt-type")]
public PromptType? ReplayPromptType { get; set; }
}
}
28 changes: 14 additions & 14 deletions CM.Voice.VoiceApi.Sdk/Models/Instructions/Apps/OtpInstruction.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Newtonsoft.Json;
using System.Text.Json.Serialization;

namespace CM.Voice.VoiceApi.Sdk.Models.Instructions.Apps
{
Expand All @@ -10,79 +10,79 @@ public class OtpInstruction : BaseAppInstruction
/// <summary>
/// The prompt, which is either the path and name of the file to play, or the string that needs to be tts-ed.
/// </summary>
[JsonProperty("intro-prompt", Order = 7, NullValueHandling = NullValueHandling.Ignore)]
[JsonPropertyName("intro-prompt")]
public string IntroPrompt { get; set; }

/// <summary>
/// The type of the prompt, either file or tts.
/// </summary>
[JsonProperty("intro-prompt-type", Order = 8, NullValueHandling = NullValueHandling.Ignore)]
[JsonPropertyName("intro-prompt-type")]
public PromptType? IntroPromptType { get; set; } = PromptType.TTS;

/// <summary>
/// The prompt, which is either the path and name of the file to play, or the string that needs to be tts-ed.
/// </summary>
[JsonProperty("code-prompt", Order = 9, NullValueHandling = NullValueHandling.Ignore)]
[JsonPropertyName("code-prompt")]
public string CodePrompt { get; set; }

/// <summary>
/// The type of the prompt, either file or tts.
/// </summary>
[JsonProperty("code-prompt-type", Order = 10, NullValueHandling = NullValueHandling.Ignore)]
[JsonPropertyName("code-prompt-type")]
public PromptType? CodePromptType { get; set; } = PromptType.TTS;

/// <summary>
/// The OTP code.
/// </summary>
[JsonProperty("code", Order = 11, NullValueHandling = NullValueHandling.Ignore)]
[JsonPropertyName("code")]
public string Code { get; set; }

/// <summary>
/// The type of the prompt, either file or tts.
/// </summary>
[JsonProperty("code-type", Order = 12, NullValueHandling = NullValueHandling.Ignore)]
[JsonPropertyName("code-type")]
public CodeType? CodeType { get; set; } = Models.CodeType.TTS;

/// <summary>
/// The prompt, which is either the path and name of the file to play, or the string that needs to be tts-ed.
/// </summary>
[JsonProperty("replay-prompt", Order = 13, NullValueHandling = NullValueHandling.Ignore)]
[JsonPropertyName("replay-prompt")]
public string ReplayPrompt { get; set; }

/// <summary>
/// The type of the prompt, either file or tts.
/// </summary>
[JsonProperty("replay-prompt-type", Order = 14, NullValueHandling = NullValueHandling.Ignore)]
[JsonPropertyName("replay-prompt-type")]
public PromptType? ReplayPromptType { get; set; } = PromptType.TTS;

/// <summary>
/// The prompt, which is either the path and name of the file to play, or the string that needs to be tts-ed.
/// </summary>
[JsonProperty("outro-prompt", Order = 15, NullValueHandling = NullValueHandling.Ignore)]
[JsonPropertyName("outro-prompt")]
public string OutroPrompt { get; set; }

/// <summary>
/// The type of the prompt, either file or tts.
/// </summary>
[JsonProperty("outro-prompt-type", Order = 16, NullValueHandling = NullValueHandling.Ignore)]
[JsonPropertyName("outro-prompt-type")]
public PromptType? OutroPromptType { get; set; } = PromptType.TTS;

/// <summary>
/// The number of times the code can be played. Min = 1, Max = 3.
/// </summary>
[JsonProperty("max-replays", Order = 17, NullValueHandling = NullValueHandling.Ignore)]
[JsonPropertyName("max-replays")]
public int? MaxReplays { get; set; }

/// <summary>
/// The code-prompt and code will replay automatically repeat if true, it will wait for a press on the "1" otherwise.
/// </summary>
[JsonProperty("auto-replay", Order = 18, NullValueHandling = NullValueHandling.Ignore)]
[JsonPropertyName("auto-replay")]
public bool? AutoReplay { get; set; }

/// <summary>
/// Determines the Voicemail detection flow.
/// </summary>
[JsonProperty("voicemail-response", Order = 19)]
[JsonPropertyName("voicemail-response")]
public VoicemailResponse VoicemailResponse { get; set; } = VoicemailResponse.Ignore;
}
}
Loading