@@ -3,16 +3,16 @@ import Foundation
33public struct Message : Sendable , Equatable , Codable {
44 public let envelope : Envelope
55 public let content : Content
6- public let template : TemplateOptions
7- public let tracking : Tracking
8- public let delivery : DeliveryOptions
6+ public let template : TemplateOptions ?
7+ public let tracking : Tracking ?
8+ public let delivery : DeliveryOptions ?
99
1010 public init (
1111 envelope: Envelope ,
1212 content: Content ,
13- template: TemplateOptions = TemplateOptions ( ) ,
14- tracking: Tracking = Tracking ( ) ,
15- delivery: DeliveryOptions = DeliveryOptions ( )
13+ template: TemplateOptions ? = nil ,
14+ tracking: Tracking ? = nil ,
15+ delivery: DeliveryOptions ? = nil
1616 ) {
1717 self . envelope = envelope
1818 self . content = content
@@ -24,9 +24,9 @@ public struct Message: Sendable, Equatable, Codable {
2424 public func encode( to encoder: Encoder ) throws {
2525 try envelope. encode ( to: encoder)
2626 try content. encode ( to: encoder)
27- try template. encode ( to: encoder)
28- try tracking. encode ( to: encoder)
29- try delivery. encode ( to: encoder)
27+ if let template { try template. encode ( to: encoder) }
28+ if let tracking { try tracking. encode ( to: encoder) }
29+ if let delivery { try delivery. encode ( to: encoder) }
3030 }
3131
3232 public init ( from decoder: Decoder ) throws {
@@ -41,20 +41,14 @@ public struct Message: Sendable, Equatable, Codable {
4141 public init ( from: Recipient , to: Recipient , subject: String , textPart: String ) {
4242 self . init (
4343 envelope: Envelope ( from: from, to: [ to] ) ,
44- content: Content ( subject: subject, textPart: textPart) ,
45- template: TemplateOptions ( ) ,
46- tracking: Tracking ( ) ,
47- delivery: DeliveryOptions ( )
44+ content: Content ( subject: subject, textPart: textPart)
4845 )
4946 }
5047
5148 public init ( from: Recipient , to: Recipient , subject: String , htmlPart: String ) {
5249 self . init (
5350 envelope: Envelope ( from: from, to: [ to] ) ,
54- content: Content ( subject: subject, htmlPart: htmlPart) ,
55- template: TemplateOptions ( ) ,
56- tracking: Tracking ( ) ,
57- delivery: DeliveryOptions ( )
51+ content: Content ( subject: subject, htmlPart: htmlPart)
5852 )
5953 }
6054}
0 commit comments