async public Task TestTextTemplate() { var scotchMode = ScotchMode.Replaying; var client = HttpClients.NewHttpClient("IntegrationTests/Cassettes/TextTemplate.json", scotchMode); string tokenKey = "key"; string tokenSecret = "secret"; string host = "https://dvfoa3pu2rxx6.cloudfront.net/api/v1/"; OmnigageClient.Init(tokenKey, tokenSecret, host, client); TextTemplateResource textTemplate = new TextTemplateResource(); textTemplate.Name = "Text Template"; textTemplate.Body = "Sample body"; await textTemplate.Create(); TextMessageResource textMessage = new TextMessageResource(); textMessage.TextTemplate = textTemplate; await textMessage.Create(); // The message instance should derive the body from the template Assert.AreEqual(textMessage.Body, textTemplate.Body); TextResource text = new TextResource(); text.To = "+14076413749"; text.TextMessage = textMessage; text.PhoneNumber = new PhoneNumberResource { Id = "GncieHvbCKfMYXmeycoWZm" }; await text.Create(); }
/// <summary> /// To run this application, the following is required: /// /// - API token key/secret from Account -> Developer -> API Tokens /// - A verified Phone Number UUID from Account -> Telephony -> Phone Numbers -> Edit (in the URI) /// - Fill in variables to run example /// </summary> /// <param name="args"></param> async static Task Main(string[] args) { var tokenKey = ""; var tokenSecret = ""; // Set the Phone Number ID (e.g., GncieHvbCKfMYXmeycoWZm) var phoneNumberId = ""; // Sample contact information to call var firstName = ""; var lastName = ""; var phoneNumber = ""; // In E.164 format (such as +1xxxxxxxxx) // Initialize SDK OmnigageClient.Init(tokenKey, tokenSecret); var engagement = new EngagementResource { Name = "Example SMS Blast", Direction = "outbound" }; await engagement.Create(); var template = new TextTemplateResource { Name = "Text Template", Body = "Sample body" }; await template.Create(); var activity = new ActivityResource { Name = "SMS Blast", Kind = ActivityKind.Text, Engagement = engagement, TextTemplate = template, PhoneNumber = new PhoneNumberResource { Id = phoneNumberId } }; await activity.Create(); var envelope = new EnvelopeResource { PhoneNumber = phoneNumber, Engagement = engagement, Meta = new Dictionary <string, string> { { "first-name", firstName }, { "last-name", lastName } } }; // Push one or more envelopes into list List <EnvelopeResource> envelopes = new List <EnvelopeResource> { }; envelopes.Add(envelope); // Populate engagement queue await Client.PostBulkRequest("envelopes", EnvelopeResource.SerializeBulk(envelopes)); // Schedule engagement for processing engagement.Status = "scheduled"; await engagement.Update(); }
async public Task TestTextEngagement() { var scotchMode = ScotchMode.Replaying; var client = HttpClients.NewHttpClient("IntegrationTests/Cassettes/EngagementTextTests.json", scotchMode); string tokenKey = "key"; string tokenSecret = "secret"; string host = "https://dvfoa3pu2rxx6.cloudfront.net/api/v1/"; OmnigageClient.Init(tokenKey, tokenSecret, host, client); EngagementResource engagement = new EngagementResource(); engagement.Name = "Example Text Blast"; engagement.Direction = "outbound"; await engagement.Create(); TextTemplateResource textTemplate = new TextTemplateResource(); textTemplate.Name = "Text Template"; textTemplate.Body = "Sample body"; await textTemplate.Create(); ActivityResource activity = new ActivityResource(); activity.Name = "Text Blast"; activity.Kind = ActivityKind.Text; activity.Engagement = engagement; activity.TextTemplate = textTemplate; activity.PhoneNumber = new PhoneNumberResource { Id = "GncieHvbCKfMYXmeycoWZm" }; await activity.Create(); EnvelopeResource envelope = new EnvelopeResource(); envelope.PhoneNumber = "+14076413749"; envelope.Engagement = engagement; envelope.Meta = new Dictionary <string, string> { { "first-name", "Omnigage" }, { "last-name", "Demo" } }; // Push one or more envelopes into list List <EnvelopeResource> envelopes = new List <EnvelopeResource> { }; envelopes.Add(envelope); // Populate engagement queue await Client.PostBulkRequest("envelopes", EnvelopeResource.SerializeBulk(envelopes)); // Schedule engagement for processing engagement.Status = "scheduled"; await engagement.Update(); }