From 0a33f65c55d4280fc308e12f1981def6498e3950 Mon Sep 17 00:00:00 2001 From: Petr Pavlik Date: Wed, 18 Dec 2024 18:09:03 -0400 Subject: [PATCH] Make everything Sendable --- Sources/IndiePitcherSwift/dtos.swift | 22 +++++++++++----------- Sources/IndiePitcherSwift/errors.swift | 2 +- Sources/IndiePitcherSwift/responses.swift | 8 ++++---- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Sources/IndiePitcherSwift/dtos.swift b/Sources/IndiePitcherSwift/dtos.swift index 003096b..5dbafb7 100644 --- a/Sources/IndiePitcherSwift/dtos.swift +++ b/Sources/IndiePitcherSwift/dtos.swift @@ -8,7 +8,7 @@ import Foundation /// The format of the email body -public enum EmailBodyFormat: String, Codable { +public enum EmailBodyFormat: String, Codable, Sendable { /// The body format is a markdown text case markdown /// The body format is html text @@ -16,7 +16,7 @@ public enum EmailBodyFormat: String, Codable { } /// Represents a custom contact property. -public enum CustomContactPropertyValue: Codable, Equatable { +public enum CustomContactPropertyValue: Codable, Equatable, Sendable { /// A string property case string(String) /// A number property @@ -78,7 +78,7 @@ public enum CustomContactPropertyValue: Codable, Equatable { } /// A contact in the mailing list -public struct Contact: Codable { +public struct Contact: Codable, Sendable { public init(email: String, userId: String? = nil, avatarUrl: String? = nil, name: String? = nil, hardBouncedAt: Date? = nil, subscribedToLists: [String], customProperties: [String : CustomContactPropertyValue], languageCode: String? = nil) { self.email = email self.userId = userId @@ -109,7 +109,7 @@ public struct Contact: Codable { } /// The payload to create a new contact -public struct CreateContact: Codable { +public struct CreateContact: Codable, Sendable { /// Initializer /// - Parameters: @@ -155,7 +155,7 @@ public struct CreateContact: Codable { } /// The payload to create multiple contacts using a single API call -public struct CreateMultipleContacts: Codable { +public struct CreateMultipleContacts: Codable, Sendable { /// Initializer /// - Parameter contacts: The list of contacts to create @@ -168,7 +168,7 @@ public struct CreateMultipleContacts: Codable { } /// The payload to update a contact in the mailing list. The email is required to identify the contact. -public struct UpdateContact: Codable { +public struct UpdateContact: Codable, Sendable { /// Initializer /// - Parameters: @@ -210,7 +210,7 @@ public struct UpdateContact: Codable { } /// Payload of send transactional email request. -public struct SendEmail: Codable { +public struct SendEmail: Codable, Sendable { /// Initializer /// - Parameters: @@ -239,7 +239,7 @@ public struct SendEmail: Codable { } /// Send an email to one of more registered contacts. -public struct SendEmailToContact: Codable { +public struct SendEmailToContact: Codable, Sendable { /// Initializer /// - Parameters: @@ -287,7 +287,7 @@ public struct SendEmailToContact: Codable { public var delayUntilDate: Date? } -public struct SendEmailToMailingList: Codable { +public struct SendEmailToMailingList: Codable, Sendable { /// Initializer /// - Parameters: @@ -326,7 +326,7 @@ public struct SendEmailToMailingList: Codable { } /// Represents a mailing list contacts can subscribe to, such as `Monthly newsletter` or `Onboarding`. -public struct MailingList: Codable { +public struct MailingList: Codable, Sendable { public init(name: String, title: String, numSubscribers: Int) { self.name = name @@ -345,7 +345,7 @@ public struct MailingList: Codable { } /// A portal session that allows a contact to manage their email list subscriptions when redirected to returned `url`. A session is valid for 30 minutes. -public struct MailingListPortalSession: Codable { +public struct MailingListPortalSession: Codable, Sendable { public init(url: URL, expiresAt: Date, returnURL: URL) { self.url = url self.expiresAt = expiresAt diff --git a/Sources/IndiePitcherSwift/errors.swift b/Sources/IndiePitcherSwift/errors.swift index 08c10bc..8ee74e9 100644 --- a/Sources/IndiePitcherSwift/errors.swift +++ b/Sources/IndiePitcherSwift/errors.swift @@ -1,4 +1,4 @@ -public struct IndiePitcherRequestError: Error, Equatable { +public struct IndiePitcherRequestError: Error, Equatable, Sendable { var statusCode: UInt var reason: String diff --git a/Sources/IndiePitcherSwift/responses.swift b/Sources/IndiePitcherSwift/responses.swift index 3945981..3bd962e 100644 --- a/Sources/IndiePitcherSwift/responses.swift +++ b/Sources/IndiePitcherSwift/responses.swift @@ -8,7 +8,7 @@ import Foundation /// Represents a response returning data. -public struct DataResponse: Codable { +public struct DataResponse: Codable, Sendable { public init(data: T) { self.success = true @@ -34,7 +34,7 @@ public struct EmptyResposne: Codable { } /// Represents a response returning paginated data. -public struct PagedDataResponse: Codable { +public struct PagedDataResponse: Codable, Sendable { public init(data: [T], metadata: PagedDataResponse.PageMetadata) { self.success = true self.data = data @@ -42,7 +42,7 @@ public struct PagedDataResponse: Codable { } /// Paging metadata - public struct PageMetadata: Codable { + public struct PageMetadata: Codable, Sendable { public init(page: Int, per: Int, total: Int) { self.page = page self.per = per @@ -67,7 +67,7 @@ public struct PagedDataResponse: Codable { public var metadata: PageMetadata } -struct ErrorResponse: Codable { +struct ErrorResponse: Codable, Sendable { var reason: String var error: Bool }