diff --git a/src/Sinch/Verification/Common/Identity.cs b/src/Sinch/Verification/Common/Identity.cs
index 5fc8beef..d268abcd 100644
--- a/src/Sinch/Verification/Common/Identity.cs
+++ b/src/Sinch/Verification/Common/Identity.cs
@@ -5,19 +5,33 @@ namespace Sinch.Verification.Common
{
public class Identity
{
+ ///
+ /// Creates an Identity with phone number.
+ ///
+ /// an E.164-compatible phone number
+ ///
+ public static Identity Number(string phoneNumber)
+ {
+ return new Identity()
+ {
+ Type = IdentityType.Number,
+ Endpoint = phoneNumber
+ };
+ }
+
///
/// Currently only number type is supported.
///
[JsonPropertyName("type")]
public IdentityType Type { get; set; }
-
+
///
/// For type number use an E.164-compatible phone number.
///
[JsonPropertyName("endpoint")]
public string Endpoint { get; set; }
}
-
+
[JsonConverter(typeof(EnumRecordJsonConverter))]
public record IdentityType(string Value) : EnumRecord(Value)
{
diff --git a/src/Sinch/Verification/SinchVerification.cs b/src/Sinch/Verification/SinchVerification.cs
index b338237e..29eb721c 100644
--- a/src/Sinch/Verification/SinchVerification.cs
+++ b/src/Sinch/Verification/SinchVerification.cs
@@ -4,6 +4,7 @@
using System.Threading.Tasks;
using Sinch.Core;
using Sinch.Logger;
+using Sinch.Verification.Common;
using Sinch.Verification.Report.Request;
using Sinch.Verification.Report.Response;
using Sinch.Verification.Start.Request;
@@ -14,13 +15,52 @@ namespace Sinch.Verification
public interface ISinchVerification
{
///
- /// This method is used by the mobile and web Verification SDKs to start a verification.
- /// It can also be used to request a verification from your backend, by making an request.
+ /// Starts an SMS Verification. Verification by SMS message with a PIN code.
///
///
///
///
- Task Start(VerificationStartRequest request,
+ Task StartSms(StartSmsVerificationRequest request,
+ CancellationToken cancellationToken = default);
+
+ ///
+ /// Starts an SMS Verification for the specified E.164-compatible phone number. Verification by SMS message with a PIN
+ /// code.
+ ///
+ /// A E.164-compatible phone number
+ ///
+ ///
+ Task StartSms(string phoneNumber,
+ CancellationToken cancellationToken = default);
+
+ ///
+ /// Starts a Flash Call verification. Verification by placing a flashcall (missed call) and detecting the incoming
+ /// calling number (CLI).
+ ///
+ ///
+ ///
+ ///
+ Task StartFlashCall(StartFlashCallVerificationRequest request,
+ CancellationToken cancellationToken = default);
+
+ ///
+ /// Starts a Phone Call verification.Verification by placing a PSTN call to the user's phone and playing an
+ /// announcement, asking the user to press a particular digit to verify the phone number
+ ///
+ ///
+ ///
+ ///
+ Task StartPhoneCall(StartPhoneCallVerificationRequest request,
+ CancellationToken cancellationToken = default);
+
+ ///
+ /// Starts a Data verification. Verification by accessing internal infrastructure of mobile carriers to verify if given
+ /// verification attempt was originated from device with matching phone number.
+ ///
+ ///
+ ///
+ ///
+ Task StartSeamless(StartDataVerificationRequest request,
CancellationToken cancellationToken = default);
///
@@ -37,7 +77,7 @@ Task ReportIdentity(string endpoint, VerifyReportRe
CancellationToken cancellationToken = default);
///
- /// Report the received verification code to verify it, using the Verification ID of the Verification request.
+ /// Report the received verification code to verify it, using the Verification ID of the Verification request.
///
///
///
@@ -49,9 +89,9 @@ Task ReportId(string id, VerifyReportRequest reques
internal class SinchVerification : ISinchVerification
{
- private readonly ILoggerAdapter _logger;
private readonly Uri _baseAddress;
private readonly IHttp _http;
+ private readonly ILoggerAdapter _logger;
public SinchVerification(ILoggerAdapter logger, Uri baseAddress, IHttp http)
{
@@ -60,16 +100,85 @@ public SinchVerification(ILoggerAdapter logger, Uri baseAddre
_http = http;
}
- ///
- public Task Start(VerificationStartRequest request,
+ private Task Start(StartVerificationRequest request,
CancellationToken cancellationToken = default)
{
- var uri = new Uri(_baseAddress, $"verification/v1/verifications");
+ var uri = new Uri(_baseAddress, "verification/v1/verifications");
_logger?.LogDebug("Starting verification...");
- return _http.Send(uri, HttpMethod.Post, request,
- cancellationToken: cancellationToken);
+ return _http.Send(uri, HttpMethod.Post, request,
+ cancellationToken);
}
+ ///
+ public async Task StartSms(StartSmsVerificationRequest request,
+ CancellationToken cancellationToken = default)
+ {
+ var result = await Start(new StartVerificationRequest
+ {
+ Custom = request.Custom,
+ Identity = request.Identity,
+ Method = request.Method,
+ Reference = request.Reference
+ }, cancellationToken);
+ return result as StartSmsVerificationResponse;
+ }
+
+ ///
+ public async Task StartSms(string phoneNumber,
+ CancellationToken cancellationToken = default)
+ {
+ var result = await Start(new StartVerificationRequest
+ {
+ Identity = Identity.Number(phoneNumber),
+ Method = VerificationMethodEx.Sms
+ }, cancellationToken);
+ return result as StartSmsVerificationResponse;
+ }
+
+ ///
+ public async Task StartFlashCall(StartFlashCallVerificationRequest request,
+ CancellationToken cancellationToken = default)
+ {
+ var result = await Start(new StartVerificationRequest
+ {
+ Custom = request.Custom,
+ Identity = request.Identity,
+ Method = request.Method,
+ Reference = request.Reference,
+ FlashCallOptions = request.FlashCallOptions
+ }, cancellationToken);
+ return result as StartFlashCallVerificationResponse;
+ }
+
+ ///
+ public async Task StartPhoneCall(StartPhoneCallVerificationRequest request,
+ CancellationToken cancellationToken = default)
+ {
+ var result = await Start(new StartVerificationRequest
+ {
+ Custom = request.Custom,
+ Identity = request.Identity,
+ Method = request.Method,
+ Reference = request.Reference
+ }, cancellationToken);
+ return result as StartPhoneCallVerificationResponse;
+ }
+
+ ///
+ public async Task StartSeamless(StartDataVerificationRequest request,
+ CancellationToken cancellationToken = default)
+ {
+ var result = await Start(new StartVerificationRequest
+ {
+ Custom = request.Custom,
+ Identity = request.Identity,
+ Method = request.Method,
+ Reference = request.Reference
+ }, cancellationToken);
+ return result as StartDataVerificationResponse;
+ }
+
+
public Task ReportIdentity(string endpoint, VerifyReportRequest request,
CancellationToken cancellationToken = default)
{
@@ -96,16 +205,16 @@ private Task Report(VerifyReportRequest request,
FlashCallVerificationReportRequest flashCallVerificationReportRequest =>
_http.Send(uri, HttpMethod.Put,
flashCallVerificationReportRequest,
- cancellationToken: cancellationToken),
+ cancellationToken),
SmsVerificationReportRequest smsVerificationRequest => _http
.Send(
uri, HttpMethod.Put,
smsVerificationRequest,
- cancellationToken: cancellationToken),
+ cancellationToken),
PhoneCallVerificationReportRequest phoneRequest => _http
.Send(uri, HttpMethod.Put,
phoneRequest,
- cancellationToken: cancellationToken),
+ cancellationToken),
_ => throw new ArgumentOutOfRangeException(nameof(request))
};
}
diff --git a/src/Sinch/Verification/Start/Request/StartDataVerificationRequest.cs b/src/Sinch/Verification/Start/Request/StartDataVerificationRequest.cs
new file mode 100644
index 00000000..a4ea8576
--- /dev/null
+++ b/src/Sinch/Verification/Start/Request/StartDataVerificationRequest.cs
@@ -0,0 +1,14 @@
+using System.Text.Json.Serialization;
+using Sinch.Verification.Common;
+
+namespace Sinch.Verification.Start.Request
+{
+ public class StartDataVerificationRequest : StartVerificationRequestBase
+ {
+ ///
+ /// The type of the verification request. Set to Seamless
+ ///
+ [JsonInclude]
+ public override VerificationMethodEx Method { get; } = VerificationMethodEx.Seamless;
+ }
+}
diff --git a/src/Sinch/Verification/Start/Request/StartFlashCallVerificationRequest.cs b/src/Sinch/Verification/Start/Request/StartFlashCallVerificationRequest.cs
new file mode 100644
index 00000000..b757c065
--- /dev/null
+++ b/src/Sinch/Verification/Start/Request/StartFlashCallVerificationRequest.cs
@@ -0,0 +1,23 @@
+using System.Text.Json.Serialization;
+using Sinch.Verification.Common;
+
+namespace Sinch.Verification.Start.Request
+{
+ public class StartFlashCallVerificationRequest : StartVerificationRequestBase
+ {
+ ///
+ /// The type of the verification request. Set to SMS.
+ ///
+ [JsonInclude]
+ public override VerificationMethodEx Method { get; } = VerificationMethodEx.FlashCall;
+
+ ///
+ /// An optional object for flashCall verifications.
+ /// It allows you to specify dial time out parameter for flashCall.
+ /// FlashCallOptions object can be specified optionally, and only
+ /// if the verification request was triggered from your backend (no SDK client)
+ /// through an Application signed request.
+ ///
+ public FlashCallOptions FlashCallOptions { get; set; }
+ }
+}
diff --git a/src/Sinch/Verification/Start/Request/StartPhoneCallVerificationRequest.cs b/src/Sinch/Verification/Start/Request/StartPhoneCallVerificationRequest.cs
new file mode 100644
index 00000000..c463d5dd
--- /dev/null
+++ b/src/Sinch/Verification/Start/Request/StartPhoneCallVerificationRequest.cs
@@ -0,0 +1,14 @@
+using System.Text.Json.Serialization;
+using Sinch.Verification.Common;
+
+namespace Sinch.Verification.Start.Request
+{
+ public class StartPhoneCallVerificationRequest : StartVerificationRequestBase
+ {
+ ///
+ /// The type of the verification request. Set to Phone Call
+ ///
+ [JsonInclude]
+ public override VerificationMethodEx Method { get; } = VerificationMethodEx.Callout;
+ }
+}
diff --git a/src/Sinch/Verification/Start/Request/StartSmsVerificationRequest.cs b/src/Sinch/Verification/Start/Request/StartSmsVerificationRequest.cs
new file mode 100644
index 00000000..630fee28
--- /dev/null
+++ b/src/Sinch/Verification/Start/Request/StartSmsVerificationRequest.cs
@@ -0,0 +1,14 @@
+using System.Text.Json.Serialization;
+using Sinch.Verification.Common;
+
+namespace Sinch.Verification.Start.Request
+{
+ public sealed class StartSmsVerificationRequest : StartVerificationRequestBase
+ {
+ ///
+ /// The type of the verification request. Set to SMS.
+ ///
+ [JsonInclude]
+ public override VerificationMethodEx Method { get; } = VerificationMethodEx.Sms;
+ }
+}
diff --git a/src/Sinch/Verification/Start/Request/VerificationStartRequest.cs b/src/Sinch/Verification/Start/Request/StartVerificationRequest.cs
similarity index 97%
rename from src/Sinch/Verification/Start/Request/VerificationStartRequest.cs
rename to src/Sinch/Verification/Start/Request/StartVerificationRequest.cs
index 4dc9be84..2b27b5d4 100644
--- a/src/Sinch/Verification/Start/Request/VerificationStartRequest.cs
+++ b/src/Sinch/Verification/Start/Request/StartVerificationRequest.cs
@@ -2,7 +2,7 @@
namespace Sinch.Verification.Start.Request
{
- public class VerificationStartRequest
+ public class StartVerificationRequest
{
///
/// Specifies the type of endpoint that will be verified and the particular endpoint.
diff --git a/src/Sinch/Verification/Start/Request/StartVerificationRequestBase.cs b/src/Sinch/Verification/Start/Request/StartVerificationRequestBase.cs
new file mode 100644
index 00000000..e2860eb1
--- /dev/null
+++ b/src/Sinch/Verification/Start/Request/StartVerificationRequestBase.cs
@@ -0,0 +1,27 @@
+using System.Text.Json.Serialization;
+using Sinch.Verification.Common;
+
+namespace Sinch.Verification.Start.Request
+{
+ public abstract class StartVerificationRequestBase
+ {
+ [JsonInclude]
+ public abstract VerificationMethodEx Method { get; }
+
+ ///
+ /// Specifies the type of endpoint that will be verified and the particular endpoint.
+ /// `number` is currently the only supported endpoint type.
+ ///
+ public Identity Identity { get; set; }
+
+ ///
+ /// Used to pass your own reference in the request for tracking purposes.
+ ///
+ public string Reference { get; set; }
+
+ ///
+ /// Can be used to pass custom data in the request.
+ ///
+ public string Custom { get; set; }
+ }
+}
diff --git a/src/Sinch/Verification/Start/Response/PhoneCallVerificationStartResponse.cs b/src/Sinch/Verification/Start/Response/PhoneCallVerificationStartResponse.cs
deleted file mode 100644
index d9fec661..00000000
--- a/src/Sinch/Verification/Start/Response/PhoneCallVerificationStartResponse.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace Sinch.Verification.Start.Response
-{
- public class PhoneCallVerificationStartResponse : VerificationStartResponseBase, IVerificationStartResponse
- {
-
- }
-}
diff --git a/src/Sinch/Verification/Start/Response/DataVerificationStartResponse.cs b/src/Sinch/Verification/Start/Response/StartDataVerificationResponse.cs
similarity index 77%
rename from src/Sinch/Verification/Start/Response/DataVerificationStartResponse.cs
rename to src/Sinch/Verification/Start/Response/StartDataVerificationResponse.cs
index 725a6417..f028a988 100644
--- a/src/Sinch/Verification/Start/Response/DataVerificationStartResponse.cs
+++ b/src/Sinch/Verification/Start/Response/StartDataVerificationResponse.cs
@@ -1,6 +1,6 @@
namespace Sinch.Verification.Start.Response
{
- public class DataVerificationStartResponse : VerificationStartResponseBase, IVerificationStartResponse
+ public class StartDataVerificationResponse : VerificationStartResponseBase, IStartVerificationResponse
{
///
/// The response contains the target URI.
diff --git a/src/Sinch/Verification/Start/Response/FlashCallVerificationStartResponse.cs b/src/Sinch/Verification/Start/Response/StartFlashCallVerificationResponse.cs
similarity index 91%
rename from src/Sinch/Verification/Start/Response/FlashCallVerificationStartResponse.cs
rename to src/Sinch/Verification/Start/Response/StartFlashCallVerificationResponse.cs
index a4b0f0fd..7ad259d7 100644
--- a/src/Sinch/Verification/Start/Response/FlashCallVerificationStartResponse.cs
+++ b/src/Sinch/Verification/Start/Response/StartFlashCallVerificationResponse.cs
@@ -1,6 +1,6 @@
namespace Sinch.Verification.Start.Response
{
- public class FlashCallVerificationStartResponse : VerificationStartResponseBase, IVerificationStartResponse
+ public class StartFlashCallVerificationResponse : VerificationStartResponseBase, IStartVerificationResponse
{
///
/// The response contains the cliFilter and interceptionTimeout properties.
diff --git a/src/Sinch/Verification/Start/Response/StartPhoneCallVerificationResponse.cs b/src/Sinch/Verification/Start/Response/StartPhoneCallVerificationResponse.cs
new file mode 100644
index 00000000..dc092672
--- /dev/null
+++ b/src/Sinch/Verification/Start/Response/StartPhoneCallVerificationResponse.cs
@@ -0,0 +1,7 @@
+namespace Sinch.Verification.Start.Response
+{
+ public class StartPhoneCallVerificationResponse : VerificationStartResponseBase, IStartVerificationResponse
+ {
+
+ }
+}
diff --git a/src/Sinch/Verification/Start/Response/SmsVerificationStartResponse.cs b/src/Sinch/Verification/Start/Response/StartSmsVerificationResponse.cs
similarity index 87%
rename from src/Sinch/Verification/Start/Response/SmsVerificationStartResponse.cs
rename to src/Sinch/Verification/Start/Response/StartSmsVerificationResponse.cs
index 1c2ee39a..228166b6 100644
--- a/src/Sinch/Verification/Start/Response/SmsVerificationStartResponse.cs
+++ b/src/Sinch/Verification/Start/Response/StartSmsVerificationResponse.cs
@@ -1,6 +1,6 @@
namespace Sinch.Verification.Start.Response
{
- public class SmsVerificationStartResponse : VerificationStartResponseBase, IVerificationStartResponse
+ public class StartSmsVerificationResponse : VerificationStartResponseBase, IStartVerificationResponse
{
///
/// The response contains the template of the SMS to be expected and intercepted.
diff --git a/src/Sinch/Verification/Start/Response/VerificationStartResponseBase.cs b/src/Sinch/Verification/Start/Response/VerificationStartResponseBase.cs
index 9b5ef5ff..18dc4401 100644
--- a/src/Sinch/Verification/Start/Response/VerificationStartResponseBase.cs
+++ b/src/Sinch/Verification/Start/Response/VerificationStartResponseBase.cs
@@ -14,29 +14,33 @@ public abstract class VerificationStartResponseBase
///
public string Id { get; set; }
- ///
- /// The value of the method used for the Verification.
- ///
- public VerificationMethodEx Method { get; set; }
-
///
/// Available methods and actions which can be done after a successful Verification
///
[JsonPropertyName("_links")]
public List Links { get; set; }
+
+ ///
+ /// The value of the method used for the Verification.
+ ///
+ public VerificationMethodEx Method { get; set; }
}
///
/// A marker interface for VerificationResponse items.
///
+ // Note about JsonDerivedType - it works if class has an interface property, but don't work if you try to deserialize interface itself. So, httpContent.ReadAsJson() will not work.
+ // So I'm using JsonConverter for that
[JsonConverter(typeof(VerificationResponseConverter))]
- public interface IVerificationStartResponse
+ public interface IStartVerificationResponse
{
+ [JsonPropertyName("method")]
+ public VerificationMethodEx Method { get; set; }
}
- public class VerificationResponseConverter : JsonConverter
+ public class VerificationResponseConverter : JsonConverter
{
- public override IVerificationStartResponse Read(ref Utf8JsonReader reader, Type typeToConvert,
+ public override IStartVerificationResponse Read(ref Utf8JsonReader reader, Type typeToConvert,
JsonSerializerOptions options)
{
var elem = JsonElement.ParseValue(ref reader);
@@ -44,35 +48,44 @@ public override IVerificationStartResponse Read(ref Utf8JsonReader reader, Type
var method = descriptor.Value.GetString();
if (VerificationMethodEx.Seamless.Value == method)
- {
- return elem.Deserialize(options);
- }
+ return elem.Deserialize(options);
if (VerificationMethodEx.Sms.Value == method)
- {
return
- elem.Deserialize(
+ elem.Deserialize(
options);
- }
if (VerificationMethodEx.FlashCall.Value == method)
- {
- return elem.Deserialize(options);
- }
+ return elem.Deserialize(options);
if (VerificationMethodEx.Callout.Value == method)
- {
- return elem.Deserialize(options);
- }
+ return elem.Deserialize(options);
throw new JsonException(
$"Failed to match verification method object, got prop `{descriptor.Name}` with value `{method}`");
}
- public override void Write(Utf8JsonWriter writer, IVerificationStartResponse value,
+ public override void Write(Utf8JsonWriter writer, IStartVerificationResponse value,
JsonSerializerOptions options)
{
- JsonSerializer.Serialize(writer, value, options);
+ switch (value)
+ {
+ case StartFlashCallVerificationResponse startFlashCallVerificationResponse:
+ JsonSerializer.Serialize(writer, startFlashCallVerificationResponse, options);
+ break;
+ case StartPhoneCallVerificationResponse startPhoneCallVerificationResponse:
+ JsonSerializer.Serialize(writer, startPhoneCallVerificationResponse, options);
+ break;
+ case StartSmsVerificationResponse startSmsVerificationResponse:
+ JsonSerializer.Serialize(writer, startSmsVerificationResponse, options);
+ break;
+ case StartDataVerificationResponse startDataVerificationResponse:
+ JsonSerializer.Serialize(writer, startDataVerificationResponse, options);
+ break;
+ default:
+ throw new ArgumentOutOfRangeException(nameof(value),
+ $"Cannot find a matching class for the interface {nameof(IStartVerificationResponse)}");
+ }
}
}
}
diff --git a/tests/Sinch.Tests/Verification/VerificationTests.cs b/tests/Sinch.Tests/Verification/VerificationTests.cs
index 9acf69c1..58a4fd34 100644
--- a/tests/Sinch.Tests/Verification/VerificationTests.cs
+++ b/tests/Sinch.Tests/Verification/VerificationTests.cs
@@ -46,10 +46,10 @@ public void DeserializeVerificationStartResponse()
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
};
- var smsResponse = JsonSerializer.Deserialize(jData, _jsonSerializerOptions);
+ var smsResponse = JsonSerializer.Deserialize(jData, _jsonSerializerOptions);
- smsResponse.Should().BeOfType().Which.Should().BeEquivalentTo(
- new SmsVerificationStartResponse()
+ smsResponse.Should().BeOfType().Which.Should().BeEquivalentTo(
+ new StartSmsVerificationResponse()
{
Id = "1234567890",
Method = VerificationMethodEx.Sms,
diff --git a/tests/Sinch.Tests/e2e/Verification/VerificationStartTests.cs b/tests/Sinch.Tests/e2e/Verification/VerificationStartTests.cs
index 6a3df868..44cdb5b5 100644
--- a/tests/Sinch.Tests/e2e/Verification/VerificationStartTests.cs
+++ b/tests/Sinch.Tests/e2e/Verification/VerificationStartTests.cs
@@ -10,9 +10,17 @@ namespace Sinch.Tests.e2e.Verification
{
public class VerificationStartTests : VerificationTestBase
{
- private List _links = new List()
+ private readonly string _id = "123";
+
+ private readonly Identity _identity = new()
+ {
+ Endpoint = "+48000000",
+ Type = IdentityType.Number
+ };
+
+ private readonly List _links = new()
{
- new()
+ new Links
{
Method = "put",
Href = "href",
@@ -20,115 +28,135 @@ public class VerificationStartTests : VerificationTestBase
}
};
- private string _id = "123";
-
- private Identity _identity = new Identity()
- {
- Endpoint = "+48000000",
- Type = IdentityType.Number
- };
-
[Fact]
public async Task StartSmsVerification()
{
- var response = await VerificationClient.Verification.Start(new VerificationStartRequest()
+ var startVerificationRequest = new StartVerificationRequest
{
Custom = "456",
Reference = "123",
Method = VerificationMethodEx.Sms,
- Identity = new Identity()
+ Identity = new Identity
{
Endpoint = "+49000000",
Type = IdentityType.Number
+ }
+ };
+ var startSmsVerificationResponse = new StartSmsVerificationResponse
+ {
+ Id = "1234567890",
+ Method = VerificationMethodEx.Sms,
+ Sms = new SmsInfo
+ {
+ Template = "Your verification code is {{CODE}}",
+ InterceptionTimeout = 32
},
- });
-
- response.Should().BeOfType().Which.Should().BeEquivalentTo(
- new SmsVerificationStartResponse()
+ Links = new List
{
- Id = "1234567890",
- Method = VerificationMethodEx.Sms,
- Sms = new SmsInfo()
- {
- Template = "Your verification code is {{CODE}}",
- InterceptionTimeout = 32,
- },
- Links = new List()
+ new()
{
- new()
- {
- Method = "GET",
- Href = "some_string_value",
- Rel = "status"
- }
+ Method = "GET",
+ Href = "some_string_value",
+ Rel = "status"
}
- });
+ }
+ };
+
+ var response = await VerificationClient.Verification.StartSms(new StartSmsVerificationRequest
+ {
+ Custom = startVerificationRequest.Custom,
+ Reference = startVerificationRequest.Reference,
+ Identity = startVerificationRequest.Identity
+ });
+ response.Should().BeEquivalentTo(startSmsVerificationResponse);
}
[Fact]
public async Task StartFlashCallVerification()
{
- var response = await VerificationClient.Verification.Start(new VerificationStartRequest()
+ var startVerificationRequest = new StartVerificationRequest
{
Identity = _identity,
Method = VerificationMethodEx.FlashCall,
- FlashCallOptions = new FlashCallOptions()
+ FlashCallOptions = new FlashCallOptions
{
- DialTimeout = 12,
+ DialTimeout = 12
}
- });
- response.Should().BeOfType().Which.Should().BeEquivalentTo(
- new FlashCallVerificationStartResponse()
+ };
+ var startFlashCallVerificationResponse = new StartFlashCallVerificationResponse
+ {
+ Id = _id,
+ Method = VerificationMethodEx.FlashCall,
+ FlashCall = new FlashCallDetails
{
- Id = _id,
- Method = VerificationMethodEx.FlashCall,
- FlashCall = new FlashCallDetails()
- {
- InterceptionTimeout = 50,
- CliFilter = "cli-filter",
- ReportTimeout = 5,
- DenyCallAfter = 72,
- },
- Links = _links
- });
+ InterceptionTimeout = 50,
+ CliFilter = "cli-filter",
+ ReportTimeout = 5,
+ DenyCallAfter = 72
+ },
+ Links = _links
+ };
+
+ var response = await VerificationClient.Verification.StartFlashCall(new StartFlashCallVerificationRequest
+ {
+ Identity = startVerificationRequest.Identity,
+ Reference = startVerificationRequest.Reference,
+ FlashCallOptions = startVerificationRequest.FlashCallOptions,
+ Custom = startVerificationRequest.Custom
+ });
+ response.Should().BeEquivalentTo(startFlashCallVerificationResponse);
}
[Fact]
public async Task StartPhoneCallVerification()
{
- var response = await VerificationClient.Verification.Start(new VerificationStartRequest()
+ var startVerificationRequest = new StartVerificationRequest
{
Identity = _identity,
+ Method = VerificationMethodEx.Callout
+ };
+ var startPhoneCallVerificationResponse = new StartPhoneCallVerificationResponse
+ {
+ Id = _id,
Method = VerificationMethodEx.Callout,
+ Links = _links
+ };
+
+ var response = await VerificationClient.Verification.StartPhoneCall(new StartPhoneCallVerificationRequest
+ {
+ Identity = startVerificationRequest.Identity,
+ Reference = startVerificationRequest.Reference,
+ Custom = startVerificationRequest.Custom
});
- response.Should().BeOfType().Which.Should().BeEquivalentTo(
- new PhoneCallVerificationStartResponse()
- {
- Id = _id,
- Method = VerificationMethodEx.Callout,
- Links = _links
- });
+ response.Should().BeEquivalentTo(startPhoneCallVerificationResponse);
}
[Fact]
public async Task StartSeamlessVerification()
{
- var response = await VerificationClient.Verification.Start(new VerificationStartRequest()
+ var startVerificationRequest = new StartVerificationRequest
{
Identity = _identity,
+ Method = VerificationMethodEx.Seamless
+ };
+ var startDataVerificationResponse = new StartDataVerificationResponse
+ {
+ Id = _id,
Method = VerificationMethodEx.Seamless,
- });
- response.Should().BeOfType().Which.Should().BeEquivalentTo(
- new DataVerificationStartResponse()
+ Links = _links,
+ Seamless = new Seamless
{
- Id = _id,
- Method = VerificationMethodEx.Seamless,
- Links = _links,
- Seamless = new Seamless()
- {
- TargetUri = "uri-target"
- }
- });
+ TargetUri = "uri-target"
+ }
+ };
+
+ var response = await VerificationClient.Verification.StartSeamless(new StartDataVerificationRequest
+ {
+ Identity = startVerificationRequest.Identity,
+ Reference = startVerificationRequest.Reference,
+ Custom = startVerificationRequest.Custom
+ });
+ response.Should().BeEquivalentTo(startDataVerificationResponse);
}
}
}