/courier-go

A Go package for communicating with the Courier REST API.

Primary LanguageGoMIT LicenseMIT

Courier Go SDK

This Go package helps you send notifications through Courier, the smartest way to design & deliver notifications. Design your notifications once using our drag & drop editor, then deliver to any channel through one API. Email, mobile push, SMS, Slack — you name it!

"Golang Gopher"

APIs supported:

  • Send API
  • Messages API
  • Profiles API

Official Courier API docs

For a full description of request and response payloads and properties, please see the official Courier API docs.

Installation

Add this line to your go package:

import "github.com/trycourier/courier-go"

Usage

func send() {
        var eventID = "example-event"
        var recipientID = "example-recipient"

        client := courier.CourierClient("<YOUR_AUTH_TOKEN>", nil)
        messageID, err := client.Send(
                context.Background(), 
                eventID,
                recipientID,
                map[string]string{"email": "foo@example.com"},
                map[string]string{"favoriteAdjective": "awesomeness"},
                "my-brand-id",
                nil,
                nil,
        })
        if err != nil {
                log.Fatalln(err)
	}
        log.Println(messageID)
}

If you need to use a base url other than the default https://api.courier.com, you can pass it in as the second paramter to the CourierClient:

client := courier.CourierClient("<AUTH_TOKEN>", "<BASE_URL>")

APIs

For a full description of request and response payloads and properties, please see the official Courier API docs.

Send API

  • Send(context, eventID string, recipientID string, profile interface{}, data interface{}, brand string, override interface{}, preferences interface{}): object [?]
  • SendToList(context, eventID string, listID string, pattern string, data interface{}, brand string, override interface{}): object [?]

Messages API

  • GetMessage(context, messageID string): object [?]
  • GetMessages(context, cursor string, event string, list string, messageId string, notification string, recipient string): object [?]
  • GetMessageHistory(context, messageID string, _type string): object [?]

Profiles API

  • GetProfile(id string): object [?]
  • MergeProfile(id string, profile byte[]): object [?]
  • UpdateProfile(id string, profile byte[]): object [?]

Staying Updated

To update this SDK to the latest version, use go get -u github.com/trycourier/courier-go.

License

The package is available as open source under the terms of the MIT License. MIT License