-
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.
Added submitConversion method and tests
- Loading branch information
BiBi
committed
Mar 14, 2019
1 parent
80d4f16
commit 41309f3
Showing
4 changed files
with
107 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Nexmo.Api.Test.Unit | ||
{ | ||
[TestClass] | ||
public class ConversionTest | ||
{ | ||
public void Should_submit() | ||
{ | ||
Conversion.ConversionType = "sms"; | ||
Conversion.SubmitConversion(new Conversion.ConversionRequest | ||
{ | ||
MessageId = "", | ||
Delivered = true, | ||
Timestamp = DateTime.UtcNow | ||
}); | ||
|
||
|
||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using Nexmo.Api.Request; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Nexmo.Api.Client | ||
{ | ||
public class Conversion | ||
{ | ||
public Credentials Credentials { get; set; } | ||
public Conversion(Credentials creds) | ||
{ | ||
Credentials = creds; | ||
} | ||
|
||
public void SubmitConversion (Api.Conversion.ConversionRequest request, Credentials creds = null) | ||
{ | ||
Api.Conversion.SubmitConversion(request, creds); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using Newtonsoft.Json; | ||
using Nexmo.Api.Request; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Nexmo.Api | ||
{ | ||
public static class Conversion | ||
{ | ||
/// <summary> | ||
/// possible values : "voice" or "sms" | ||
/// </summary> | ||
public static string ConversionType { get; set; } | ||
|
||
public class ConversionRequest | ||
{ | ||
/// <summary> | ||
/// The ID you receive in the response to a request. | ||
/// possible values: message-id for SMS API, call-id for TTS and TTSP APIs, | ||
/// event_id for Verify API. | ||
/// </summary> | ||
[JsonProperty("message-id")] | ||
public string MessageId { get; set; } | ||
/// <summary> | ||
/// Set to true if your user replied to the message you sent. | ||
/// Otherwise, set to false. | ||
/// </summary> | ||
[JsonProperty("delivered")] | ||
public bool Delivered { get; set; } | ||
/// <summary> | ||
/// When the user completed your call-to-action in UTC±00:00 | ||
/// format: yyyy-MM-dd HH:mm:ss. | ||
/// </summary> | ||
[JsonProperty("timestamp")] | ||
public DateTime Timestamp { get; set; } | ||
} | ||
|
||
/// <summary> | ||
/// Tells if a message or call was successful. | ||
/// </summary> | ||
/// <param name="request"></param> | ||
/// <param name="creds"></param> | ||
public static void SubmitConversion (ConversionRequest request, Credentials creds = null) | ||
{ | ||
var response = ApiRequest.DoPostRequest(new Uri($"https://api.nexmo.com/conversions/{ConversionType}"), request, creds); | ||
} | ||
} | ||
} |