Skip to content

Commit

Permalink
Make everything Sendable
Browse files Browse the repository at this point in the history
  • Loading branch information
petrpavlik committed Dec 18, 2024
1 parent 5e0a02c commit 0a33f65
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
22 changes: 11 additions & 11 deletions Sources/IndiePitcherSwift/dtos.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
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
case html
}

/// 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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -287,7 +287,7 @@ public struct SendEmailToContact: Codable {
public var delayUntilDate: Date?
}

public struct SendEmailToMailingList: Codable {
public struct SendEmailToMailingList: Codable, Sendable {

/// Initializer
/// - Parameters:
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sources/IndiePitcherSwift/errors.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
public struct IndiePitcherRequestError: Error, Equatable {
public struct IndiePitcherRequestError: Error, Equatable, Sendable {
var statusCode: UInt
var reason: String

Expand Down
8 changes: 4 additions & 4 deletions Sources/IndiePitcherSwift/responses.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import Foundation

/// Represents a response returning data.
public struct DataResponse<T: Codable>: Codable {
public struct DataResponse<T: Codable & Sendable>: Codable, Sendable {

public init(data: T) {
self.success = true
Expand All @@ -34,15 +34,15 @@ public struct EmptyResposne: Codable {
}

/// Represents a response returning paginated data.
public struct PagedDataResponse<T: Codable>: Codable {
public struct PagedDataResponse<T: Codable & Sendable>: Codable, Sendable {
public init(data: [T], metadata: PagedDataResponse<T>.PageMetadata) {
self.success = true
self.data = data
self.metadata = metadata
}

/// 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
Expand All @@ -67,7 +67,7 @@ public struct PagedDataResponse<T: Codable>: Codable {
public var metadata: PageMetadata
}

struct ErrorResponse: Codable {
struct ErrorResponse: Codable, Sendable {
var reason: String
var error: Bool
}

0 comments on commit 0a33f65

Please sign in to comment.