diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 740c8dc..7e451d2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,16 +7,9 @@ on: push: { branches: [ main ] } jobs: - lint: - runs-on: ubuntu-latest - container: swift:jammy - steps: - - name: Check out SendGridKit - uses: actions/checkout@v4 - - name: Run format lint check - run: swift format lint --strict --recursive --parallel . - unit-tests: uses: vapor/ci/.github/workflows/run-unit-tests.yml@main + with: + with_linting: true secrets: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file diff --git a/.swift-format b/.swift-format deleted file mode 100644 index 360ca2c..0000000 --- a/.swift-format +++ /dev/null @@ -1,70 +0,0 @@ -{ - "fileScopedDeclarationPrivacy": { - "accessLevel": "private" - }, - "indentation": { - "spaces": 4 - }, - "indentConditionalCompilationBlocks": true, - "indentSwitchCaseLabels": false, - "lineBreakAroundMultilineExpressionChainComponents": false, - "lineBreakBeforeControlFlowKeywords": false, - "lineBreakBeforeEachArgument": false, - "lineBreakBeforeEachGenericRequirement": false, - "lineLength": 100, - "maximumBlankLines": 1, - "multiElementCollectionTrailingCommas": true, - "noAssignmentInExpressions": { - "allowedFunctions": [ - "XCTAssertNoThrow" - ] - }, - "prioritizeKeepingFunctionOutputTogether": false, - "respectsExistingLineBreaks": true, - "rules": { - "AllPublicDeclarationsHaveDocumentation": false, - "AlwaysUseLiteralForEmptyCollectionInit": false, - "AlwaysUseLowerCamelCase": true, - "AmbiguousTrailingClosureOverload": true, - "BeginDocumentationCommentWithOneLineSummary": false, - "DoNotUseSemicolons": true, - "DontRepeatTypeInStaticProperties": true, - "FileScopedDeclarationPrivacy": true, - "FullyIndirectEnum": true, - "GroupNumericLiterals": true, - "IdentifiersMustBeASCII": true, - "NeverForceUnwrap": false, - "NeverUseForceTry": false, - "NeverUseImplicitlyUnwrappedOptionals": false, - "NoAccessLevelOnExtensionDeclaration": true, - "NoAssignmentInExpressions": true, - "NoBlockComments": true, - "NoCasesWithOnlyFallthrough": true, - "NoEmptyTrailingClosureParentheses": true, - "NoLabelsInCasePatterns": true, - "NoLeadingUnderscores": false, - "NoParensAroundConditions": true, - "NoPlaygroundLiterals": true, - "NoVoidReturnOnFunctionSignature": true, - "OmitExplicitReturns": false, - "OneCasePerLine": true, - "OneVariableDeclarationPerLine": true, - "OnlyOneTrailingClosureArgument": true, - "OrderedImports": true, - "ReplaceForEachWithForLoop": true, - "ReturnVoidInsteadOfEmptyTuple": true, - "TypeNamesShouldBeCapitalized": true, - "UseEarlyExits": false, - "UseExplicitNilCheckInConditions": true, - "UseLetInEveryBoundCaseVariable": true, - "UseShorthandTypeNames": true, - "UseSingleLinePropertyGetter": true, - "UseSynthesizedInitializer": true, - "UseTripleSlashForDocumentationComments": true, - "UseWhereClausesInForLoops": false, - "ValidateDocumentationComments": false - }, - "spacesAroundRangeFormationOperators": false, - "tabWidth": 8, - "version": 1 -} \ No newline at end of file diff --git a/Package.swift b/Package.swift index 5f10c6d..802e92f 100644 --- a/Package.swift +++ b/Package.swift @@ -10,7 +10,7 @@ let package = Package( .library(name: "SendGridKit", targets: ["SendGridKit"]) ], dependencies: [ - .package(url: "https://github.com/swift-server/async-http-client.git", from: "1.22.0") + .package(url: "https://github.com/swift-server/async-http-client.git", from: "1.23.0") ], targets: [ .target( diff --git a/Sources/SendGridKit/SendGridClient.swift b/Sources/SendGridKit/SendGridClient.swift index bbdcc75..dc8ffa9 100644 --- a/Sources/SendGridKit/SendGridClient.swift +++ b/Sources/SendGridKit/SendGridClient.swift @@ -30,14 +30,10 @@ public struct SendGridClient: Sendable { public init(httpClient: HTTPClient, apiKey: String, forEU: Bool = false) { self.httpClient = httpClient self.apiKey = apiKey - self.apiURL = - forEU - ? "https://api.eu.sendgrid.com/v3/mail/send" : "https://api.sendgrid.com/v3/mail/send" + self.apiURL = forEU ? "https://api.eu.sendgrid.com/v3/mail/send" : "https://api.sendgrid.com/v3/mail/send" } - public func send( - email: SendGridEmail - ) async throws { + public func send(email: SendGridEmail) async throws { var headers = HTTPHeaders() headers.add(name: "Authorization", value: "Bearer \(apiKey)") headers.add(name: "Content-Type", value: "application/json") @@ -53,7 +49,6 @@ public struct SendGridClient: Sendable { if (200...299).contains(response.status.code) { return } // `JSONDecoder` will handle empty body by throwing decoding error - throw try await decoder.decode( - SendGridError.self, from: response.body.collect(upTo: 1024 * 1024)) + throw try await decoder.decode(SendGridError.self, from: response.body.collect(upTo: 1024 * 1024)) } } diff --git a/Tests/SendGridKitTests/SendGridTestsKit.swift b/Tests/SendGridKitTests/SendGridTestsKit.swift index 9081339..954a1f1 100644 --- a/Tests/SendGridKitTests/SendGridTestsKit.swift +++ b/Tests/SendGridKitTests/SendGridTestsKit.swift @@ -81,16 +81,17 @@ struct SendGridKitTests { let integer: Int let double: Double } - let dynamicTemplateData = DynamicTemplateData( - text: "Hello, World!", integer: 42, double: 3.14) + let dynamicTemplateData = DynamicTemplateData(text: "Hello, World!", integer: 42, double: 3.14) // TODO: Replace the addresses with real email addresses let personalization = Personalization( to: [EmailAddress("TO-ADDRESS")], subject: "Test Email", - dynamicTemplateData: dynamicTemplateData) + dynamicTemplateData: dynamicTemplateData + ) let email = SendGridEmail( personalizations: [personalization], from: EmailAddress("FROM-ADDRESS"), - content: [EmailContent("Hello, World!")]) + content: [EmailContent("Hello, World!")] + ) try await withKnownIssue { try await client.send(email: email)