Skip to content

Commit

Permalink
Added submitConversion method and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
BiBi committed Mar 14, 2019
1 parent 80d4f16 commit 41309f3
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Nexmo.Api.Test.Integration/AccountTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ public void should_get_pricing()
Assert.AreEqual("Verizon Wireless", verizon.network);
}

[TestMethod]
public void should_get_prefix_pricing()
{
var pricing = Account.GetPrefixPricing("1","sms");
Assert.AreEqual("US", pricing.country);
}

[TestMethod]
public void should_set_settings()
{
Expand Down
26 changes: 26 additions & 0 deletions Nexmo.Api.Test.Integration/ConversionTest.cs
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
});


}
}
}
23 changes: 23 additions & 0 deletions Nexmo.Api/Client/Conversion.cs
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);
}
}
}
51 changes: 51 additions & 0 deletions Nexmo.Api/Conversion.cs
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);
}
}
}

0 comments on commit 41309f3

Please sign in to comment.