/// <inheritdoc/> public async Task <ApiResponse <EmailTemplateResource> > GetEmailNotificationTemplate( string tenantId, string notificationType, CancellationToken cancellationToken = default) { if (string.IsNullOrEmpty(tenantId)) { throw new ArgumentNullException(nameof(tenantId)); } if (string.IsNullOrEmpty(notificationType)) { throw new ArgumentNullException(nameof(notificationType)); } string communicationType = "email"; Uri requestUri = this.ConstructUri($"/{tenantId}/marain/usernotifications/templates?notificationType={notificationType}&communicationType={communicationType}"); HttpRequestMessage request = this.BuildRequest(HttpMethod.Get, requestUri); HttpResponseMessage response = await this.SendRequestAndThrowOnFailure(request, cancellationToken).ConfigureAwait(false); using Stream contentStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); EmailTemplateResource result = await JsonSerializer.DeserializeAsync <EmailTemplateResource>(contentStream, this.SerializerOptions).ConfigureAwait(false); return(new ApiResponse <EmailTemplateResource>( response.StatusCode, result, WrapETagInImmutableDictionary(response))); }
async public Task TestEmailTemplate() { var scotchMode = ScotchMode.Replaying; var client = HttpClients.NewHttpClient("IntegrationTests/Cassettes/EmailTemplate.json", scotchMode); string tokenKey = "key"; string tokenSecret = "secret"; string host = "https://dvfoa3pu2rxx6.cloudfront.net/api/v1/"; OmnigageClient.Init(tokenKey, tokenSecret, host, client); EmailTemplateResource emailTemplate = new EmailTemplateResource(); emailTemplate.Subject = "Ahoy"; emailTemplate.Body = "Sample body"; await emailTemplate.Create(); EmailMessageResource emailMessage = new EmailMessageResource(); emailMessage.EmailTemplate = emailTemplate; await emailMessage.Create(); // The message instance should derive the subject/body from the template Assert.AreEqual(emailMessage.Subject, emailTemplate.Subject); Assert.AreEqual(emailMessage.Body, emailTemplate.Body); EmailResource email = new EmailResource(); email.To = "*****@*****.**"; email.EmailMessage = emailMessage; email.EmailId = new EmailIdResource { Id = "NbXW9TCHax9zfAeDhaY2bG" }; await email.Create(); }
/// <summary> /// To run this application, the following is required: /// /// - API token key/secret from Account -> Developer -> API Tokens /// - A verified Email ID UUID from Account -> Email -> Email IDs -> 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 Email ID (e.g., NbXW9TCHax9zfAeDhaY2bG) var emailId = ""; // Sample contact information to call var firstName = ""; var lastName = ""; var emailAddress = ""; // Initialize SDK OmnigageClient.Init(tokenKey, tokenSecret); var engagement = new EngagementResource(); engagement.Name = "Example Email Blast"; engagement.Direction = "outbound"; await engagement.Create(); var emailTemplate = new EmailTemplateResource(); emailTemplate.Subject = "Ahoy"; emailTemplate.Body = "Sample body"; await emailTemplate.Create(); var activity = new ActivityResource(); activity.Name = "Email Blast"; activity.Kind = ActivityKind.Email; activity.Engagement = engagement; activity.EmailTemplate = emailTemplate; activity.EmailId = new EmailIdResource { Id = emailId }; await activity.Create(); var envelope = new EnvelopeResource(); envelope.EmailAddress = emailAddress; envelope.Engagement = engagement; envelope.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 TestEmailVoiceEngagement() { var scotchMode = ScotchMode.Replaying; var client = HttpClients.NewHttpClient("IntegrationTests/Cassettes/EngagementEmailVoiceTests.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 Email Voice Blast (Voice Link)"; engagement.Direction = "outbound"; await engagement.Create(); EmailTemplateResource emailTemplate = new EmailTemplateResource(); emailTemplate.Subject = "Email Template"; emailTemplate.Body = "Email template with {{message-body}}."; await emailTemplate.Create(); EmailMessageResource emailMessage = new EmailMessageResource(); emailMessage.Subject = "Email Message"; emailMessage.Body = "Sample body"; emailMessage.IsDraft = true; await emailMessage.Create(); UploadResource upload1 = new UploadResource { FilePath = "Media/hello.mp3" }; await upload1.Create(); VoiceTemplateResource recording = new VoiceTemplateResource(); recording.Name = "Voice Link Recording"; recording.Kind = "audio"; recording.Upload = upload1; await recording.Create(); ActivityResource activity = new ActivityResource(); activity.Name = "Email Voice"; activity.Kind = ActivityKind.EmailVoice; activity.CallBackPhoneNumber = "+11231231234"; activity.Engagement = engagement; activity.VoiceTemplate = recording; activity.EmailTemplate = emailTemplate; activity.EmailMessage = emailMessage; activity.EmailId = new EmailIdResource { Id = "NbXW9TCHax9zfAeDhaY2bG" }; await activity.Create(); EnvelopeResource envelope = new EnvelopeResource(); envelope.EmailAddress = "*****@*****.**"; 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 OmnigageClient.PostBulkRequest("envelopes", EnvelopeResource.SerializeBulk(envelopes)); // Schedule engagement for processing engagement.Status = "scheduled"; await engagement.Update(); }
async public Task TestEmailEngagement() { var scotchMode = ScotchMode.Replaying; var client = HttpClients.NewHttpClient("IntegrationTests/Cassettes/EngagementEmailTests.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 Email Blast"; engagement.Direction = "outbound"; await engagement.Create(); EmailTemplateResource emailTemplate = new EmailTemplateResource(); emailTemplate.Subject = "Ahoy"; emailTemplate.Body = "Sample body"; await emailTemplate.Create(); ActivityResource activity = new ActivityResource(); activity.Name = "Email Blast"; activity.Kind = ActivityKind.Email; activity.Engagement = engagement; activity.EmailTemplate = emailTemplate; activity.EmailId = new EmailIdResource { Id = "NbXW9TCHax9zfAeDhaY2bG" }; await activity.Create(); EnvelopeResource envelope = new EnvelopeResource(); envelope.EmailAddress = "*****@*****.**"; 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 OmnigageClient.PostBulkRequest("envelopes", EnvelopeResource.SerializeBulk(envelopes)); // Schedule engagement for processing engagement.Status = "scheduled"; await engagement.Update(); }