MailerLiteAPIClient

0.3.0

A basic Swift SDK for the MailerLite API.
mikwat/mailerlite-swift

What's New

v0.3.0

2024-03-23T15:42:15Z

What's Changed

  • Make MailerLiteAPIClient Sendable by @mikwat in #3

Full Changelog: v0.2.0...v0.3.0

MailerLite Swift SDK

A basic Swift SDK for the MailerLite API.

Usage

Get a list of subscribers

import MailerLiteAPIClient

let mailerLite = MailerLiteAPIClient(apiKey: "your-api-key")

do {
    let response = mailerLite.send(ListSubscribers())
    // TODO: handle response
    let data = response.data {
        print("Found \(data.count) subscribers")
    }
} catch {
    // TODO: handle error
}

Upsert a subscriber

import MailerLiteAPIClient

let mailerLite = MailerLiteAPIClient(apiKey: "your-api-key")

do {
    let response = mailerLite.send(UpsertSubscriber(email: "dummy@example.com", fields: Subscriber.Fields(lastName: "Testerson")))
    // TODO: handle response
    let data = response.data {
        print("Subscriber \(data.email) upserted")
    }
} catch {
    // TODO: handle error
    switch result {
}

Update a subscriber

import MailerLiteAPIClient

let mailerLite = MailerLiteAPIClient(apiKey: "your-api-key")

do {
    let response = mailerLite.send(UpdateSubscriber(
        id: "31897397363737859",
        fields: Subscriber.Fields(
            lastName: nil,
            name: "Dummy"
        ),
        groups: [
            "4243829086487936",
            "14133878422767533",
            "31985378335392975"
        ]
    )))
    // TODO: handle response
    let data = response.data {
        print("Subscriber \(data.id) updated")
    }
} catch {
    // TODO: handle error
}

Contributing

Please help improve this SDK! Contributions welcome.

License

The MIT License (MIT)

Description

  • Swift Tools 5.9.0
View More Packages from this Author

Dependencies

  • None
Last updated: Wed Apr 17 2024 07:27:49 GMT-0900 (Hawaii-Aleutian Daylight Time)