-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: remove stringified booleans (#544)
* Remove stringified booleans to match api specs * Implement proper converter for RealTimeData, fix expected JSON to match specs * Fix Json property ordering (broken by linter)
- Loading branch information
Showing
14 changed files
with
186 additions
and
213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
"https://acme.com/streams/music.mp3" | ||
], | ||
"level": "0", | ||
"bargeIn": "true", | ||
"bargeIn": true, | ||
"loop": "2" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,26 @@ | ||
using Newtonsoft.Json; | ||
using Vonage.Serialization; | ||
|
||
namespace Vonage.Conversions; | ||
|
||
public class ConversionRequest | ||
{ | ||
/// <summary> | ||
/// The ID you receive in the response to a request. * From the Verify API - use the event_id in the response to Verify Check. | ||
/// * From the SMS API - use the message-id * From the Text-To-Speech API - use the call-id * From the Text-To-Speech-Prompt API - use the call-id | ||
/// Set to true if your user replied to the message you sent. Otherwise, set to false. Note: for curl, use 0 and 1. | ||
/// </summary> | ||
[JsonProperty("message-id")] | ||
public string MessageId { get; set; } | ||
[JsonProperty("delivered", Order = 1)] | ||
public bool Delivered { get; set; } | ||
|
||
/// <summary> | ||
/// Set to true if your user replied to the message you sent. Otherwise, set to false. Note: for curl, use 0 and 1. | ||
/// The ID you receive in the response to a request. * From the Verify API - use the event_id in the response to Verify Check. | ||
/// * From the SMS API - use the message-id * From the Text-To-Speech API - use the call-id * From the Text-To-Speech-Prompt API - use the call-id | ||
/// </summary> | ||
[JsonProperty("delivered")] | ||
[JsonConverter(typeof(StringBoolConverter))] | ||
public bool Delivered { get; set; } | ||
[JsonProperty("message-id", Order = 0)] | ||
public string MessageId { get; set; } | ||
|
||
/// <summary> | ||
/// When the user completed your call-to-action (e.g. visited your website, installed your app) | ||
/// in UTC±00:00 format: yyyy-MM-dd HH:mm:ss. If you do not set this parameter, Vonage uses the time it receives this request. | ||
/// </summary> | ||
[JsonProperty("timestamp")] | ||
[JsonProperty("timestamp", Order = 2)] | ||
public string TimeStamp { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,41 @@ | ||
using System; | ||
using Newtonsoft.Json; | ||
using Vonage.Serialization; | ||
|
||
namespace Vonage.NumberInsights; | ||
|
||
/// <summary> | ||
/// Real time data about the number. | ||
/// </summary> | ||
public class RealTimeData | ||
{ | ||
/// <summary> | ||
/// Whether the end-user's phone number is active within an operator's network. | ||
/// Whether the end-user's phone number is active within an operator's network. | ||
/// </summary> | ||
[JsonProperty("active_status")] | ||
[JsonConverter(typeof(StringBoolConverter))] | ||
[JsonConverter(typeof(StatusConverter))] | ||
public bool ActiveStatus { get; set; } | ||
|
||
/// <summary> | ||
/// Whether the end-user's handset is turned on or off. | ||
/// Whether the end-user's handset is turned on or off. | ||
/// </summary> | ||
[JsonProperty("handset_status")] | ||
public string HandsetStatus { get; set; } | ||
} | ||
|
||
internal class StatusConverter : JsonConverter | ||
{ | ||
public override bool CanConvert(Type objectType) => objectType == typeof(bool); | ||
|
||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, | ||
JsonSerializer serializer) => | ||
(string) reader.Value == "active"; | ||
|
||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) | ||
{ | ||
if (bool.TryParse(value?.ToString(), out var boolValue)) | ||
{ | ||
writer.WriteValue(boolValue.ToString().ToLowerInvariant()); | ||
} | ||
else writer.WriteNull(); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.