From 258ff70be98db3167679aa1932ecc46b61093295 Mon Sep 17 00:00:00 2001 From: Michael Watts <103135+mikwat@users.noreply.github.com> Date: Thu, 21 Dec 2023 19:40:13 -0800 Subject: [PATCH] Change package name --- Package.swift | 12 ++-- README.md | 6 +- .../PlaygroundTests.swift | 64 +++++++++++++++++++ .../Requests/ListSubscribersTest.swift | 2 +- .../Requests/UpdateSubscriberTest.swift | 2 +- .../Requests/UpsertSubscriberTest.swift | 2 +- 6 files changed, 76 insertions(+), 12 deletions(-) create mode 100644 Tests/MailerLiteApiClientTests/PlaygroundTests.swift diff --git a/Package.swift b/Package.swift index 308f794..19619d6 100644 --- a/Package.swift +++ b/Package.swift @@ -4,23 +4,23 @@ import PackageDescription let package = Package( - name: "MailerLiteApiClient", + name: "MailerLiteAPIClient", platforms: [ .macOS(.v10_15), .iOS(.v15), .tvOS(.v15) ], products: [ // Products define the executables and libraries a package produces, making them visible to other packages. .library( - name: "MailerLiteApiClient", - targets: ["MailerLiteApiClient"]), + name: "MailerLiteAPIClient", + targets: ["MailerLiteAPIClient"]), ], targets: [ // Targets are the basic building blocks of a package, defining a module or a test suite. // Targets can depend on other targets in this package and products from dependencies. .target( - name: "MailerLiteApiClient"), + name: "MailerLiteAPIClient"), .testTarget( - name: "MailerLiteApiClientTests", - dependencies: ["MailerLiteApiClient"]), + name: "MailerLiteAPIClientTests", + dependencies: ["MailerLiteAPIClient"]), ] ) diff --git a/README.md b/README.md index 3175394..87c4a51 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ A basic Swift SDK for the [MailerLite API](https://developers.mailerlite.com/doc ### Get a list of subscribers ```swift -import MailerLiteApiClient +import MailerLiteAPIClient let mailerLite = MailerLiteAPIClient(apiKey: "your-api-key") @@ -25,7 +25,7 @@ mailerLite.send(ListSubscribers()) { result in ### Upsert a subscriber ```swift -import MailerLiteApiClient +import MailerLiteAPIClient let mailerLite = MailerLiteAPIClient(apiKey: "your-api-key") @@ -44,7 +44,7 @@ mailerLite.send(UpsertSubscriber(email: "dummy@example.com", fields: Subscriber. ### Update a subscriber ```swift -import MailerLiteApiClient +import MailerLiteAPIClient let mailerLite = MailerLiteAPIClient(apiKey: "your-api-key") diff --git a/Tests/MailerLiteApiClientTests/PlaygroundTests.swift b/Tests/MailerLiteApiClientTests/PlaygroundTests.swift new file mode 100644 index 0000000..217ab4b --- /dev/null +++ b/Tests/MailerLiteApiClientTests/PlaygroundTests.swift @@ -0,0 +1,64 @@ +// DO NOT COMMIT CHANGES TO THIS FILE + +import XCTest +@testable import MailerLiteAPIClient + +final class PlaygroundTests: XCTestCase { + let apiKey = """ +eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiI0IiwianRpIjoiZDUxOGRmYTEyZGIwMzNhMDQ2Nzk0ZmU0ZjA5NWU4MDc0YTk2YThkMDE1N2UzZTA2YzlhODM3OGM4MDNmZDA0OTlmZGZkM2UyZjMyM2Y1MzYiLCJpYXQiOjE3MDI5Mjg4NTcuNDk3MDg5LCJuYmYiOjE3MDI5Mjg4NTcuNDk3MDkxLCJleHAiOjQ4NTg2MDI0NTcuNDkyODU5LCJzdWIiOiI3NDAxMjYiLCJzY29wZXMiOltdfQ.a8KnpvjFu4SdMOCs0aFUUunF5_4h1NTehpKzRlVo3-uCXqnS8wBNblohrwEGInbyHj1bzutWAUXUVq7EAfImtAdm3hL4ocV6U08JI_i9ldoeGQDYSWtaC6Y1z5U_j7RhP4KlZ0v8tLgrCDdjuRfZq5LjfmTkLSNf0Ow4Pl4tAhDS0Cmb-VlZCQDgCn9ztyrNQH5ewHI7PgUFns2wdZW6CeYSErW_jFug3KhRuCB-0iHhq_s2EIBiiCKIf19vCruwzBKXKIConnNarSl6_Q2Gu2NkLeo01MMxyW1ID2h0b55LUqDEpaYLlcCYlDsRtt_otwuD0Bw3eDPeAMGbkyDa-wn5-475hNkRo8NdVfWtuiP9J9UnNg072Ezj4hqab5DmWhtAf8Uie6wGmaWJaY1y1X1Sc-okFKbMrtP1Al0u4DXeR0KAswGPTfgySxaMHDJZH50QC5Jhx1xDfl6eb3r2lko1ATgznuHzSOAgQudacxrOXU62jejxIjeroNcyIpOY3BqBineVU_adcgl2PwOk__hPdoFfJsFB2S1NjfkCs9Hr1nw41bTemApPIMTikka9nuJmd4cg6trpJiSyjAaN0SU5gAXDNeDZeuJSPe_FUVTXJpJXfgRmc_SKexy94Vpo2UwqX_NebrpSGv0xYNZqZL3mSmBvGXBXQQZUq42JnEo +""" + var apiClient: MailerLiteAPIClient! + var expectation: XCTestExpectation! + + override func setUp() async throws { + apiClient = MailerLiteAPIClient(apiKey: apiKey) + expectation = expectation(description: "Expectation") + } + +// func testListSubscribers() async throws { +// let response = await withCheckedContinuation { continuation in +// apiClient.send(ListSubscribers()) { response in +// continuation.resume(returning: response) +// } +// } +// +// do { +// let listResponse = try response.get() +// if let subscribers = listResponse.data { +// print("Found \(subscribers.count) subscribers") +// for subscriber in subscribers { +// print("Subscriber: \(subscriber)") +// } +// } else { +// print("No subscribers found") +// } +// +// print("Links: \(listResponse.links)") +// print("Meta: \(listResponse.meta)") +// } catch { +// print("Error: \(error)") +// } +// } + +// func testUpsertSubscribers() { +// apiClient.send(UpsertSubscriber(email: "elegant.joy3337-at-awattslife.com")) { result in +// switch result { +// case .success(let response): +// XCTFail("Success was not expected: \(response)") +// case .failure(let error): +// if let apiError = error as? APIClientError { +// switch apiError { +// case .response(let response): +// print("Error response: \(response)") +// default: +// print("Error: \(error.localizedDescription)") +// } +// } else { +// print("Error: \(error.localizedDescription)") +// } +// } +// self.expectation.fulfill() +// } +// wait(for: [expectation], timeout: 5.0) +// } +} diff --git a/Tests/MailerLiteApiClientTests/Requests/ListSubscribersTest.swift b/Tests/MailerLiteApiClientTests/Requests/ListSubscribersTest.swift index e6dec47..449451a 100644 --- a/Tests/MailerLiteApiClientTests/Requests/ListSubscribersTest.swift +++ b/Tests/MailerLiteApiClientTests/Requests/ListSubscribersTest.swift @@ -7,7 +7,7 @@ import Foundation import XCTest -@testable import MailerLiteApiClient +@testable import MailerLiteAPIClient final class ListSubscribersTest: XCTestCase { var apiClient: MailerLiteAPIClient! diff --git a/Tests/MailerLiteApiClientTests/Requests/UpdateSubscriberTest.swift b/Tests/MailerLiteApiClientTests/Requests/UpdateSubscriberTest.swift index 2af6123..c08a673 100644 --- a/Tests/MailerLiteApiClientTests/Requests/UpdateSubscriberTest.swift +++ b/Tests/MailerLiteApiClientTests/Requests/UpdateSubscriberTest.swift @@ -7,7 +7,7 @@ import Foundation import XCTest -@testable import MailerLiteApiClient +@testable import MailerLiteAPIClient final class UpdateSubscriberTest: XCTestCase { var apiClient: MailerLiteAPIClient! diff --git a/Tests/MailerLiteApiClientTests/Requests/UpsertSubscriberTest.swift b/Tests/MailerLiteApiClientTests/Requests/UpsertSubscriberTest.swift index 506f160..3b6ae15 100644 --- a/Tests/MailerLiteApiClientTests/Requests/UpsertSubscriberTest.swift +++ b/Tests/MailerLiteApiClientTests/Requests/UpsertSubscriberTest.swift @@ -7,7 +7,7 @@ import Foundation import XCTest -@testable import MailerLiteApiClient +@testable import MailerLiteAPIClient final class UpsertSubscriberTest: XCTestCase { var apiClient: MailerLiteAPIClient!