-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update Vonage package, adapt breaking change * Update Vonage package to v6.3.2 * Add snippets for VerifyV2 * Add fallback workflow snippet * Rename fallback workflow snippet as StartVerificationRequestWithFallback.cs
- Loading branch information
Showing
11 changed files
with
269 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Vonage; | ||
using Vonage.Request; | ||
|
||
namespace DotnetCliCodeSnippets.VerifyV2; | ||
|
||
public class CancelRequest : ICodeSnippet | ||
{ | ||
public async Task Execute() | ||
{ | ||
var appId = Environment.GetEnvironmentVariable("VONAGE_APP_ID") ?? "VONAGE_APP_ID"; | ||
var privateKeyPath = Environment.GetEnvironmentVariable("VONAGE_PRIVATE_KEY_PATH") ?? "VONAGE_PRIVATE_KEY_PATH"; | ||
var requestId = Guid.Parse(Environment.GetEnvironmentVariable("REQUEST_ID") ?? "REQUEST_ID"); | ||
var credentials = Credentials.FromAppIdAndPrivateKeyPath(appId, privateKeyPath); | ||
var client = new VonageClient(credentials); | ||
var request = Vonage.VerifyV2.Cancel.CancelRequest.Parse(requestId); | ||
var response = await client.VerifyV2Client.CancelAsync(request); | ||
var message = response.Match( | ||
success => "Request has been cancelled", | ||
failure => $"Request couldn't be cancelled: {failure.GetFailureMessage()}"); | ||
Console.WriteLine(message); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
DotNetCliCodeSnippets/VerifyV2/StartVerificationRequestEmail.cs
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,30 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Vonage; | ||
using Vonage.Request; | ||
using Vonage.VerifyV2.StartVerification; | ||
using Vonage.VerifyV2.StartVerification.Email; | ||
|
||
namespace DotnetCliCodeSnippets.VerifyV2; | ||
|
||
public class StartVerificationRequestEmail : ICodeSnippet | ||
{ | ||
public async Task Execute() | ||
{ | ||
var to = Environment.GetEnvironmentVariable("TO_EMAIL") ?? "TO_EMAIL"; | ||
var brandName = Environment.GetEnvironmentVariable("VONAGE_BRAND_NAME") ?? "VONAGE_BRAND_NAME"; | ||
var appId = Environment.GetEnvironmentVariable("VONAGE_APP_ID") ?? "VONAGE_APP_ID"; | ||
var privateKeyPath = Environment.GetEnvironmentVariable("VONAGE_PRIVATE_KEY_PATH") ?? "VONAGE_PRIVATE_KEY_PATH"; | ||
var credentials = Credentials.FromAppIdAndPrivateKeyPath(appId, privateKeyPath); | ||
var client = new VonageClient(credentials); | ||
var request = StartVerificationRequest.Build() | ||
.WithBrand(brandName) | ||
.WithWorkflow(EmailWorkflow.Parse(to)) | ||
.Create(); | ||
var response = await client.VerifyV2Client.StartVerificationAsync(request); | ||
var message = response.Match( | ||
success => $"Request verification succeeded - {success.RequestId}", | ||
failure => $"Request verification failed: {failure.GetFailureMessage()}"); | ||
Console.WriteLine(message); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
DotNetCliCodeSnippets/VerifyV2/StartVerificationRequestSilentAuth.cs
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,30 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Vonage; | ||
using Vonage.Request; | ||
using Vonage.VerifyV2.StartVerification; | ||
using Vonage.VerifyV2.StartVerification.SilentAuth; | ||
|
||
namespace DotnetCliCodeSnippets.VerifyV2; | ||
|
||
public class StartVerificationRequestSilentAuth : ICodeSnippet | ||
{ | ||
public async Task Execute() | ||
{ | ||
var to = Environment.GetEnvironmentVariable("TO_NUMBER") ?? "TO_NUMBER"; | ||
var brandName = Environment.GetEnvironmentVariable("VONAGE_BRAND_NAME") ?? "VONAGE_BRAND_NAME"; | ||
var appId = Environment.GetEnvironmentVariable("VONAGE_APP_ID") ?? "VONAGE_APP_ID"; | ||
var privateKeyPath = Environment.GetEnvironmentVariable("VONAGE_PRIVATE_KEY_PATH") ?? "VONAGE_PRIVATE_KEY_PATH"; | ||
var credentials = Credentials.FromAppIdAndPrivateKeyPath(appId, privateKeyPath); | ||
var client = new VonageClient(credentials); | ||
var request = StartVerificationRequest.Build() | ||
.WithBrand(brandName) | ||
.WithWorkflow(SilentAuthWorkflow.Parse(to)) | ||
.Create(); | ||
var response = await client.VerifyV2Client.StartVerificationAsync(request); | ||
var message = response.Match( | ||
success => $"Request verification succeeded - {success.RequestId}", | ||
failure => $"Request verification failed: {failure.GetFailureMessage()}"); | ||
Console.WriteLine(message); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
DotNetCliCodeSnippets/VerifyV2/StartVerificationRequestSms.cs
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,30 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Vonage; | ||
using Vonage.Request; | ||
using Vonage.VerifyV2.StartVerification; | ||
using Vonage.VerifyV2.StartVerification.Sms; | ||
|
||
namespace DotnetCliCodeSnippets.VerifyV2; | ||
|
||
public class StartVerificationRequestSms : ICodeSnippet | ||
{ | ||
public async Task Execute() | ||
{ | ||
var to = Environment.GetEnvironmentVariable("TO_NUMBER") ?? "TO_NUMBER"; | ||
var brandName = Environment.GetEnvironmentVariable("VONAGE_BRAND_NAME") ?? "VONAGE_BRAND_NAME"; | ||
var appId = Environment.GetEnvironmentVariable("VONAGE_APP_ID") ?? "VONAGE_APP_ID"; | ||
var privateKeyPath = Environment.GetEnvironmentVariable("VONAGE_PRIVATE_KEY_PATH") ?? "VONAGE_PRIVATE_KEY_PATH"; | ||
var credentials = Credentials.FromAppIdAndPrivateKeyPath(appId, privateKeyPath); | ||
var client = new VonageClient(credentials); | ||
var request = StartVerificationRequest.Build() | ||
.WithBrand(brandName) | ||
.WithWorkflow(SmsWorkflow.Parse(to)) | ||
.Create(); | ||
var response = await client.VerifyV2Client.StartVerificationAsync(request); | ||
var message = response.Match( | ||
success => $"Request verification succeeded - {success.RequestId}", | ||
failure => $"Request verification failed: {failure.GetFailureMessage()}"); | ||
Console.WriteLine(message); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
DotNetCliCodeSnippets/VerifyV2/StartVerificationRequestVoice.cs
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,30 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Vonage; | ||
using Vonage.Request; | ||
using Vonage.VerifyV2.StartVerification; | ||
using Vonage.VerifyV2.StartVerification.Voice; | ||
|
||
namespace DotnetCliCodeSnippets.VerifyV2; | ||
|
||
public class StartVerificationRequestVoice : ICodeSnippet | ||
{ | ||
public async Task Execute() | ||
{ | ||
var to = Environment.GetEnvironmentVariable("TO_NUMBER") ?? "TO_NUMBER"; | ||
var brandName = Environment.GetEnvironmentVariable("VONAGE_BRAND_NAME") ?? "VONAGE_BRAND_NAME"; | ||
var appId = Environment.GetEnvironmentVariable("VONAGE_APP_ID") ?? "VONAGE_APP_ID"; | ||
var privateKeyPath = Environment.GetEnvironmentVariable("VONAGE_PRIVATE_KEY_PATH") ?? "VONAGE_PRIVATE_KEY_PATH"; | ||
var credentials = Credentials.FromAppIdAndPrivateKeyPath(appId, privateKeyPath); | ||
var client = new VonageClient(credentials); | ||
var request = StartVerificationRequest.Build() | ||
.WithBrand(brandName) | ||
.WithWorkflow(VoiceWorkflow.Parse(to)) | ||
.Create(); | ||
var response = await client.VerifyV2Client.StartVerificationAsync(request); | ||
var message = response.Match( | ||
success => $"Request verification succeeded - {success.RequestId}", | ||
failure => $"Request verification failed: {failure.GetFailureMessage()}"); | ||
Console.WriteLine(message); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
DotNetCliCodeSnippets/VerifyV2/StartVerificationRequestWhatsApp.cs
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,30 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Vonage; | ||
using Vonage.Request; | ||
using Vonage.VerifyV2.StartVerification; | ||
using Vonage.VerifyV2.StartVerification.WhatsApp; | ||
|
||
namespace DotnetCliCodeSnippets.VerifyV2; | ||
|
||
public class StartVerificationRequestWhatsApp : ICodeSnippet | ||
{ | ||
public async Task Execute() | ||
{ | ||
var to = Environment.GetEnvironmentVariable("TO_NUMBER") ?? "TO_NUMBER"; | ||
var brandName = Environment.GetEnvironmentVariable("VONAGE_BRAND_NAME") ?? "VONAGE_BRAND_NAME"; | ||
var appId = Environment.GetEnvironmentVariable("VONAGE_APP_ID") ?? "VONAGE_APP_ID"; | ||
var privateKeyPath = Environment.GetEnvironmentVariable("VONAGE_PRIVATE_KEY_PATH") ?? "VONAGE_PRIVATE_KEY_PATH"; | ||
var credentials = Credentials.FromAppIdAndPrivateKeyPath(appId, privateKeyPath); | ||
var client = new VonageClient(credentials); | ||
var request = StartVerificationRequest.Build() | ||
.WithBrand(brandName) | ||
.WithWorkflow(WhatsAppWorkflow.Parse(to)) | ||
.Create(); | ||
var response = await client.VerifyV2Client.StartVerificationAsync(request); | ||
var message = response.Match( | ||
success => $"Request verification succeeded - {success.RequestId}", | ||
failure => $"Request verification failed: {failure.GetFailureMessage()}"); | ||
Console.WriteLine(message); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
DotNetCliCodeSnippets/VerifyV2/StartVerificationRequestWhatsAppInteractive.cs
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,30 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Vonage; | ||
using Vonage.Request; | ||
using Vonage.VerifyV2.StartVerification; | ||
using Vonage.VerifyV2.StartVerification.WhatsAppInteractive; | ||
|
||
namespace DotnetCliCodeSnippets.VerifyV2; | ||
|
||
public class StartVerificationRequestWhatsAppInteractive : ICodeSnippet | ||
{ | ||
public async Task Execute() | ||
{ | ||
var to = Environment.GetEnvironmentVariable("TO_NUMBER") ?? "TO_NUMBER"; | ||
var brandName = Environment.GetEnvironmentVariable("VONAGE_BRAND_NAME") ?? "VONAGE_BRAND_NAME"; | ||
var appId = Environment.GetEnvironmentVariable("VONAGE_APP_ID") ?? "VONAGE_APP_ID"; | ||
var privateKeyPath = Environment.GetEnvironmentVariable("VONAGE_PRIVATE_KEY_PATH") ?? "VONAGE_PRIVATE_KEY_PATH"; | ||
var credentials = Credentials.FromAppIdAndPrivateKeyPath(appId, privateKeyPath); | ||
var client = new VonageClient(credentials); | ||
var request = StartVerificationRequest.Build() | ||
.WithBrand(brandName) | ||
.WithWorkflow(WhatsAppInteractiveWorkflow.Parse(to)) | ||
.Create(); | ||
var response = await client.VerifyV2Client.StartVerificationAsync(request); | ||
var message = response.Match( | ||
success => $"Request verification succeeded - {success.RequestId}", | ||
failure => $"Request verification failed: {failure.GetFailureMessage()}"); | ||
Console.WriteLine(message); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
DotNetCliCodeSnippets/VerifyV2/StartVerificationRequestWithFallback.cs
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,34 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Vonage; | ||
using Vonage.Request; | ||
using Vonage.VerifyV2.StartVerification; | ||
using Vonage.VerifyV2.StartVerification.SilentAuth; | ||
using Vonage.VerifyV2.StartVerification.Sms; | ||
using Vonage.VerifyV2.StartVerification.WhatsApp; | ||
|
||
namespace DotnetCliCodeSnippets.VerifyV2; | ||
|
||
public class StartVerificationRequestWithFallback: ICodeSnippet | ||
{ | ||
public async Task Execute() | ||
{ | ||
var to = Environment.GetEnvironmentVariable("TO_NUMBER") ?? "TO_NUMBER"; | ||
var brandName = Environment.GetEnvironmentVariable("VONAGE_BRAND_NAME") ?? "VONAGE_BRAND_NAME"; | ||
var appId = Environment.GetEnvironmentVariable("VONAGE_APP_ID") ?? "VONAGE_APP_ID"; | ||
var privateKeyPath = Environment.GetEnvironmentVariable("VONAGE_PRIVATE_KEY_PATH") ?? "VONAGE_PRIVATE_KEY_PATH"; | ||
var credentials = Credentials.FromAppIdAndPrivateKeyPath(appId, privateKeyPath); | ||
var client = new VonageClient(credentials); | ||
var request = StartVerificationRequest.Build() | ||
.WithBrand(brandName) | ||
.WithWorkflow(SmsWorkflow.Parse(to)) | ||
.WithFallbackWorkflow(WhatsAppWorkflow.Parse(to)) | ||
.WithFallbackWorkflow(SilentAuthWorkflow.Parse(to)) | ||
.Create(); | ||
var response = await client.VerifyV2Client.StartVerificationAsync(request); | ||
var message = response.Match( | ||
success => $"Request verification succeeded - {success.RequestId}", | ||
failure => $"Request verification failed: {failure.GetFailureMessage()}"); | ||
Console.WriteLine(message); | ||
} | ||
} |
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,28 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Vonage; | ||
using Vonage.Request; | ||
|
||
namespace DotnetCliCodeSnippets.VerifyV2; | ||
|
||
public class VerifyCodeRequest : ICodeSnippet | ||
{ | ||
public async Task Execute() | ||
{ | ||
var appId = Environment.GetEnvironmentVariable("VONAGE_APP_ID") ?? "VONAGE_APP_ID"; | ||
var privateKeyPath = Environment.GetEnvironmentVariable("VONAGE_PRIVATE_KEY_PATH") ?? "VONAGE_PRIVATE_KEY_PATH"; | ||
var requestId = Guid.Parse(Environment.GetEnvironmentVariable("REQUEST_ID") ?? "REQUEST_ID"); | ||
var verificationCode = Environment.GetEnvironmentVariable("VERIFICATION_CODE") ?? "VERIFICATION_CODE"; | ||
var credentials = Credentials.FromAppIdAndPrivateKeyPath(appId, privateKeyPath); | ||
var client = new VonageClient(credentials); | ||
var request = Vonage.VerifyV2.VerifyCode.VerifyCodeRequest.Build() | ||
.WithRequestId(requestId) | ||
.WithCode(verificationCode) | ||
.Create(); | ||
var response = await client.VerifyV2Client.VerifyCodeAsync(request); | ||
var message = response.Match( | ||
success => "Code verification succeeded.", | ||
failure => $"Code verification failed: {failure.GetFailureMessage()}"); | ||
Console.WriteLine(message); | ||
} | ||
} |