const long PhoneNumber = 31612345678; // your phone number here. static void Main(string[] args) { Client client = Client.CreateDefault(YourAccessKey); try { VerifyOptionalArguments optionalArguments = new VerifyOptionalArguments(); // optionalArguments.Originator = "MessageBird"; // optionalArguments.TokenLength = 8; // optionalArguments.Timeout = 60; MessageBird.Objects.Verify verify = client.CreateVerify(PhoneNumber, optionalArguments); Console.WriteLine("{0}", verify); } catch (ErrorException e) { // Either the request fails with error descriptions from the endpoint. if (e.HasErrors) { foreach (Error error in e.Errors) { Console.WriteLine("code: {0} description: '{1}' parameter: '{2}'", error.Code, error.Description, error.Parameter); } } // or fails without error information from the endpoint, in which case the reason contains a 'best effort' description. if (e.HasReason) { Console.WriteLine(e.Reason); } } Console.WriteLine("Press any key to continue..."); Console.ReadKey(); }
private const string RecipientEmail = "*****@*****.**"; // your email address here. private static void Main(string[] args) { var client = Client.CreateDefault(YourAccessKey); try { var optionalArguments = new VerifyOptionalArguments { Type = MessageType.Email, Originator = "*****@*****.**" }; var verify = client.CreateVerify(RecipientEmail, optionalArguments); Console.WriteLine("{0}", verify); } catch (ErrorException e) { // Either the request fails with error descriptions from the endpoint. if (e.HasErrors) { foreach (var error in e.Errors) { Console.WriteLine("code: {0} description: '{1}' parameter: '{2}'", error.Code, error.Description, error.Parameter); } } // or fails without error information from the endpoint, in which case the reason contains a 'best effort' description. if (e.HasReason) { Console.WriteLine(e.Reason); } } Console.WriteLine("Press any key to continue..."); Console.ReadKey(); }
// Alias for the old constructor so that it remains backwards compatible public Objects.Verify CreateVerify(string recipient, VerifyOptionalArguments arguments = null) { ParameterValidator.IsNotNullOrWhiteSpace(recipient, "recipient"); var verify = new Objects.Verify(recipient, arguments); return(CreateVerify(verify)); }
public Objects.Verify CreateVerify(long recipient, VerifyOptionalArguments arguments = null) { var verify = new Objects.Verify(recipient, arguments); var verifyResource = new Resources.Verify(verify); var result = restClient.Create(verifyResource); return(result.Object as Objects.Verify); }
public void CreateVerifyTest() { // arrange var server = FluentMockServer.Start(); int port = server.Ports[0]; var restClient = new RestClient(ENDPOINT + port, ACCESS_KEY, null); var verifyOptionalArguments = new VerifyOptionalArguments() { Template = TEMPLATE, Encoding = DATA_ENCODING, Originator = ORIGINATOR, Reference = REFERENCE, Type = MessageType.Tts, Timeout = TIMEOUT, TokenLength = TOKEN_LENGTH, Voice = VOICE, Language = LANGUAGE }; server .Given( WireMock.RequestBuilders.Request.Create().WithPath("/verify").UsingPost() ) .RespondWith( WireMock.ResponseBuilders.Response.Create() .WithStatusCode(201) .WithHeader("Content-Type", "application/json") .WithBody(CREATE_VERIFY_RESPONSE) ); // act var verify = new Verify(RECIPIENT, verifyOptionalArguments); var verifyResource = new VerifyWithUrl(verify); verifyResource.SetBaseUrl(ENDPOINT + port); restClient.Create(verifyResource); // assert var allRequests = server.LogEntries; var allRequestsEnumerator = allRequests.GetEnumerator(); allRequestsEnumerator.MoveNext(); var logEntry = allRequestsEnumerator.Current; Assert.IsNotNull(logEntry); Assert.AreEqual(EXPECTED_REQUEST, logEntry.RequestMessage.Body); allRequestsEnumerator.MoveNext(); Assert.IsNull(allRequestsEnumerator.Current); server.Dispose(); allRequestsEnumerator.Dispose(); }
/// <summary> /// Gets the configured settings for SMS messages. /// </summary> /// <returns>The Verify options for SMS messages.</returns> private VerifyOptionalArguments SetupOptionalArguments() { var messageBirdSettings = _configuration.GetSection("MessageBird"); var originator = messageBirdSettings.GetValue <string>("Originator"); // Company Name, i.e. PerSafe, ShipLogic, etc. var tokenLength = messageBirdSettings.GetValue <int>("TokenLength"); // Length of confirmation token. Either 4 or 6 var options = new VerifyOptionalArguments { Encoding = DataEncoding.Auto, Originator = originator, Reference = "Verify", Type = MessageType.Sms, Timeout = 180, TokenLength = tokenLength, Voice = Voice.Female, Language = Language.English, Template = $"template" }; return(options); }
// Alias for the old constructor so that it remains backwards compatible public Objects.Verify CreateVerify(string recipient, VerifyOptionalArguments arguments = null) { ParameterValidator.IsNotNullOrWhiteSpace(recipient, "recipient"); return(CreateVerify(Convert.ToInt64(recipient), arguments)); }
public Objects.Verify CreateVerify(long recipient, VerifyOptionalArguments arguments = null) { var verify = new Objects.Verify(recipient, arguments); return(CreateVerify(verify)); }