Skip to content

Commit

Permalink
Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
mikwat committed Dec 22, 2023
1 parent 3a5fcae commit 972c6f8
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
MailerLite Swift SDK
====================
A basic Swift SDK for the [MailerLite API](https://developers.mailerlite.com/docs/).

## Usage

### Get a list of subscribers
```swift
import MailerLiteApiClient

Expand All @@ -18,6 +21,13 @@ mailerLite.send(ListSubscribers()) { result in
// TODO: handle error
}
}
```

### Upsert a subscriber
```swift
import MailerLiteApiClient

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

mailerLite.send(UpsertSubscriber(email: "dummy@example.com", fields: Subscriber.Fields(lastName: "Testerson"))) { result in
switch result {
Expand All @@ -32,5 +42,38 @@ mailerLite.send(UpsertSubscriber(email: "dummy@example.com", fields: Subscriber.
}
```

### Update a subscriber
```swift
import MailerLiteApiClient

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

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

## Contributing
Please help improve this SDK! Contributions welcome.

## License
[The MIT License (MIT)](LICENSE)

0 comments on commit 972c6f8

Please sign in to comment.