Skip to content

kayode0x/plunk

Repository files navigation

Plunk with Go

GoDoc Go Report Card Coverage Status License

Go library for interacting with the Plunk API.

Logo

Features

The Plunk Go SDK includes the following features:

Transactional Emails: Use the SendTransactionalEmail method to send one or more emails to your subscribers.

Events: Trigger events and creates it if it doesn't exist. You can also delete events.

Contacts: Create, update, and delete contacts. You can also get a list of contacts, as well as the number of contacts in your account.

Easy integration: The Plunk Go SDK is easy to integrate into your Go applications, with a simple and intuitive API.

Getting started

To get started with the Plunk Go SDK, simply install it using the go get command:

go get github.com/kayode0x/plunk

Then, create a new Plunk object with your Plunk API key and start using the SDK to send and track emails.

Example Here's an example of how to use the Plunk Go SDK to send a simple email:

package main

import (
	"fmt"
	"github.com/kayode0x/plunk"
)

func main() {
	// create a new Plunk object with your API key
	p, _ := plunk.New("YOUR_API_KEY", nil)

    // optionally, you can set some configuration options.
    config := &plunk.Config{
        BaseUrl: "https://api.useplunk.com",
        Debug: true,
        Client: &http.Client{
            Timeout: 10 * time.Second,
        },
    }

    // create a new Plunk object with your API key and config
    p, err := plunk.New("YOUR_API_KEY", config)
    if err != nil {
        fmt.Printf("Error creating Plunk object: %v", err)
        return
    }

	// create a new email payload
	payload := TransactionalEmailPayload{
		To:      "[email protected]",
		Subject: "Test Subject",
		Body:    "Test Body",
	}

	// send the email
	response, err := plunk.SendTransactionalEmail(payload)
	if err != nil {
		fmt.Printf("Error sending email: %v", err)
		return
	}

	fmt.Printf("Email sent: %v", response)
}

Roadmap

  • Send transactional emails

  • Trigger events

  • CRUD contacts

  • Get contacts, and number of contacts.

  • Your awesome feature 😉

See the open issues for a full list of proposed features (and known issues).

Contributing

Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".

Don't forget to give the project a star! Thanks again!

  1. Fork the Project

  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)

  3. Commit your Changes (git commit -m 'Add some AmazingFeature')

  4. Push to the Branch (git push origin feature/AmazingFeature)

  5. Open a Pull Request

Testing

To run tests, you need a Plunk API key. You can get one by signing up for a free account at https://useplunk.com.

Add the environment variable PLUNK_SECRET_KEY in your .env file with your Plunk API key.

Then, run the tests using the following command:

go test -v

If you receive an error that says contact already exists, you can manually delete the contact from your Plunk account, and then run the tests again.

Support

Ping me here, or feel free to reach out on twitter @kayode0x. For Plunk specific issues, please reach out to Plunk.

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)