Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aosasona/plunk.gleam
A library for interacting with Plunk (https://useplunk.com) in Gleam
https://github.com/aosasona/plunk.gleam
email gleam-lang plunk
Last synced: 3 months ago
JSON representation
A library for interacting with Plunk (https://useplunk.com) in Gleam
- Host: GitHub
- URL: https://github.com/aosasona/plunk.gleam
- Owner: aosasona
- Created: 2023-10-08T14:12:32.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2024-06-04T19:17:17.000Z (5 months ago)
- Last Synced: 2024-07-16T15:41:54.234Z (4 months ago)
- Topics: email, gleam-lang, plunk
- Language: Gleam
- Homepage: https://hexdocs.pm/plunk
- Size: 92.8 KB
- Stars: 7
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-gleam - plunk - [📚](https://hexdocs.pm/plunk/) - A Gleam library to send emails, manage contacts etc. using the Plunk API (Packages / Email)
README
# plunk
[![Package Version](https://img.shields.io/hexpm/v/plunk)](https://hex.pm/packages/plunk)
[![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/plunk/)## Installation
This library has been designed to be independent of whatever HTTP request library or runtime you choose or wish to use, and you can install for all targets by running:
```sh
gleam add plunk
```## Usage
```gleam
import gleam/erlang/os
import gleam/io
import gleam/json
import gleam/result
import gleam/hackney
import plunk
import plunk/event.{Event}pub fn main() {
let key =
os.get_env("PLUNK_API_KEY")
|> result.unwrap("")let assert Ok(resp) =
plunk.new(key)
|> event.track(Event(
event: "your-event",
email: "[email protected]",
data: [#("name", json.string("John"))],
))
|> hackney.sendlet assert Ok(e) = event.decode(resp)
io.debug(e)
}
```See [documentation](https://hexdocs.pm/plunk/) for each module on Hexdocs or go through the [test](./test/) folder for examples.
## Development
To run tests locally, you need to add your Plunk API key to the environment variables like this:
```sh
export PLUNK_API_KEY="sk_..."
```> NOTE: tests are designed to run only in the BEAM runtime (erlang target) as they depend on hackney