Skip to content

Commit

Permalink
Made Personalization more usable
Browse files Browse the repository at this point in the history
  • Loading branch information
bygri committed Sep 11, 2017
1 parent ad2a6d6 commit dd565b8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
21 changes: 14 additions & 7 deletions Sources/SendGridProvider/Models/Personalization.swift
Expand Up @@ -11,30 +11,37 @@ public struct Personalization {
/*
The email copy recipients
*/
public let cc: [EmailAddress] = []
public let cc: [EmailAddress]
/*
The email blind copy recipients
*/
public let bcc: [EmailAddress] = []
public let bcc: [EmailAddress]
/*
The email subject, overriding that of the Email, if set
*/
public let subject: String? = nil
public let subject: String?
/*
Custom headers
*/
public let headers: [String: String] = [:]
public var headers: [String: String] = [:]
/*
Custom substitutions in the format ["tag": "value"]
*/
public let substitutions: [String: String] = [:]
public var substitutions: [String: String] = [:]
/*
Date to send the email, or `nil` if email to be sent immediately
*/
public let sendAt: Date? = nil
public var sendAt: Date? = nil

public init(to: [EmailAddress]) {
public init(to: [EmailAddress], cc: [EmailAddress], bcc: [EmailAddress], subject: String?) {
self.to = to
self.cc = cc
self.bcc = bcc
self.subject = subject
}

public init(to: [EmailAddress]) {
self.init(to: to, cc: [], bcc: [], subject: nil)
}

}
14 changes: 8 additions & 6 deletions Sources/SendGridProvider/Models/SendGridEmail.swift
Expand Up @@ -56,27 +56,27 @@ public final class SendGridEmail {
/*
Date to send the email, or `nil` if email to be sent immediately
*/
public let sendAt: Date? = nil
public var sendAt: Date? = nil

/*
Include this email in a named batch
*/
public let batchId: String? = nil
public var batchId: String? = nil

/*
Determines how to handle unsubscribe links
*/
public let unsubscribeHandling: UnsubscribeHandling = .default
public var unsubscribeHandling: UnsubscribeHandling = .default

/*
IP pool to send from
*/
public let ipPoolName: String? = nil
public var ipPoolName: String? = nil

/*
Bypass unsubscriptions and suppressions - use only in emergency
*/
public let bypassListManagement: Bool = false
public var bypassListManagement: Bool = false

/*
Footer to add to email in variety of content types
Expand Down Expand Up @@ -121,7 +121,7 @@ public final class SendGridEmail {
/*
Email body content. Can only be empty if `templateId` is set
*/
public var content: [EmailBody] = []
public let content: [EmailBody]

private init(from: EmailAddressRepresentable, subject: String?, templateId: String?, body: EmailBodyRepresentable?) {
personalizations = []
Expand All @@ -130,6 +130,8 @@ public final class SendGridEmail {
self.templateId = templateId
if let body = body {
self.content = [body.emailBody]
} else {
self.content = []
}
}

Expand Down

0 comments on commit dd565b8

Please sign in to comment.