aboutsummaryrefslogtreecommitdiff
path: root/Emails.Transactional.Client/EmailTransactionRequest.cs
diff options
context:
space:
mode:
authorLibravatar vnugent <public@vaughnnugent.com>2023-01-12 17:47:40 -0500
committerLibravatar vnugent <public@vaughnnugent.com>2023-01-12 17:47:40 -0500
commitd797953c74798252d7153a20e788ed034c71b0ae (patch)
treebb295b619a4c0ed13d18691063ddaebd3961faf5 /Emails.Transactional.Client/EmailTransactionRequest.cs
parentd8ef5d21416c4a9deaa5cae7d3c8a11fae6a15f7 (diff)
Large project reorder and consolidation
Diffstat (limited to 'Emails.Transactional.Client/EmailTransactionRequest.cs')
-rw-r--r--Emails.Transactional.Client/EmailTransactionRequest.cs162
1 files changed, 0 insertions, 162 deletions
diff --git a/Emails.Transactional.Client/EmailTransactionRequest.cs b/Emails.Transactional.Client/EmailTransactionRequest.cs
deleted file mode 100644
index d6b1ebe..0000000
--- a/Emails.Transactional.Client/EmailTransactionRequest.cs
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
-* Copyright (c) 2022 Vaughn Nugent
-*
-* Library: VNLib
-* Package: Emails.Transactional.Client
-* File: EmailTransactionRequest.cs
-*
-* EmailTransactionRequest.cs is part of Emails.Transactional.Client which is part of the larger
-* VNLib collection of libraries and utilities.
-*
-* Emails.Transactional.Client is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published
-* by the Free Software Foundation, either version 2 of the License,
-* or (at your option) any later version.
-*
-* Emails.Transactional.Client is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with Emails.Transactional.Client. If not, see http://www.gnu.org/licenses/.
-*/
-
-using System;
-using System.Collections.Generic;
-using System.Text.Json.Serialization;
-
-namespace Emails.Transactional.Client
-{
- /// <summary>
- /// A transactional email request to send an email
- /// template.
- /// </summary>
- public class EmailTransactionRequest
- {
- /// <summary>
- /// The transactional send endpoint address
- /// </summary>
- [JsonIgnore]
- public Uri Endpoint { get; init; }
- /// <summary>
- /// A dictionary of email addresses/names of
- /// users to send this email to
- /// </summary>
- [JsonPropertyName("to")]
- public Dictionary<string, string> ToAddresses { get; set; }
- /// <summary>
- /// A dictionary of email addresses/names of
- /// users to carbon copy this email to
- /// </summary>
- [JsonPropertyName("cc")]
- public Dictionary<string, string> CcAddresses { get; set; }
- /// <summary>
- /// A dictionary of email addresses/names of
- /// users to blind carbon copy this email to
- /// </summary>
- [JsonPropertyName("bcc")]
- public Dictionary<string, string> BccAddresses { get; set; }
- /// <summary>
- /// A dictionary of variables to substitute into the liquid
- /// email template
- /// </summary>
- [JsonPropertyName("variables")]
- public Dictionary<string, string> Variables { get; set; }
-
- /// <summary>
- /// The subject of the email to send
- /// </summary>
- [JsonPropertyName("subject")]
- public string Subject { get; set; }
-
- /// <summary>
- /// The unique id of the email template to send
- /// </summary>
- [JsonPropertyName("template_id")]
- public string TemplateId { get; set; }
- /// <summary>
- /// The system from email name. NOTE: This is a protected value
- /// </summary>
- [JsonPropertyName("from_name")]
- public string FromName { get; set; }
- /// <summary>
- /// The system from email address. NOTE: This is a protected value
- /// </summary>
- [JsonPropertyName("from_address")]
- public string FromAddress { get; set; }
-
- /// <summary>
- /// Creates a new email transaction with the specified email template to send
- /// </summary>
- /// <param name="templateId">The id of the template to send</param>
- /// <exception cref="ArgumentNullException"></exception>
- public EmailTransactionRequest(string templateId)
- {
- this.TemplateId = templateId ?? throw new ArgumentNullException(nameof(templateId));
- }
- /// <summary>
- /// Creates a new email transaction with the specified email template
- /// and a single recipient
- /// </summary>
- /// <param name="templateId">The id of the template to send</param>
- /// <param name="toAddress">A singular recipient name</param>
- /// <param name="toName">A singlular recipient email address</param>
- /// <exception cref="ArgumentNullException"></exception>
- public EmailTransactionRequest(string templateId, string toName, string toAddress)
- {
- this.TemplateId = templateId ?? throw new ArgumentNullException(nameof(templateId));
- AddToAddress(toName, toAddress);
- }
- /// <summary>
- /// Adds a recipient to the To email address dictionary
- /// </summary>
- /// <param name="toName">The name of the user to send the email to</param>
- /// <param name="toAddress">The unique email address of the user to add to the recipient collection</param>
- public void AddToAddress(string toName, string toAddress)
- {
- ToAddresses ??= new(1);
- ToAddresses.Add(toAddress, toName);
- }
- /// <summary>
- /// Adds a recipient to the To email address dictionary
- /// </summary>
- /// <param name="toAddress">The unique email address of the user to add to the recipient collection</param>
- public void AddToAddress(string toAddress)
- {
- string name = toAddress.Split('@')[0];
- AddToAddress(name, toAddress);
- }
- /// <summary>
- /// Adds a carbon copy recipient to the current cc dictionary
- /// </summary>
- /// <param name="ccName">The name of the recipient</param>
- /// <param name="ccAddress">The unique email address of the bcc recipient</param>
- public void AddCcAddress(string ccName, string ccAddress)
- {
- CcAddresses ??= new(1);
- CcAddresses.Add(ccAddress, ccName);
- }
- /// <summary>
- /// Adds a blind carbon copy recipient to the current bcc dictionary
- /// </summary>
- /// <param name="bccName">The name of the recipient</param>
- /// <param name="bccAddress">The unique email address of the bcc recipient</param>
- public void AddBccAddress(string bccName, string bccAddress)
- {
- BccAddresses ??= new(1);
- BccAddresses.Add(bccAddress, bccName);
- }
- /// <summary>
- /// Adds a liquid template variable to be subsituted by the template
- /// renderer.
- /// </summary>
- /// <param name="varName">The unique name of the variable to add to the collection</param>
- /// <param name="varValue">The value if the variable that will be substituted into the template</param>
- public void AddVariable(string varName, string varValue)
- {
- Variables ??= new(1);
- Variables.Add(varName, varValue);
- }
- }
-}