sendblue

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 16, 2020 License: MIT Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

sendblue-go

Go client module for Sendblue

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrParse is returned when we are unable to parse a phone number
	// into the proper format. In this case, it's advised to show an
	// error message to the user and ask them to check their input.
	ErrParse = fmt.Errorf("sendblue: failed to parse phone number")
)

Functions

This section is empty.

Types

type Client

type Client struct {
	APIKey    string
	SecretKey string
	Client    *http.Client
}

A Client is used to send API requests to Sendblue.

func NewCustomClient

func NewCustomClient(client *http.Client, api, secret string) *Client

NewCustomClient creates a new client from a key pair and a custom client.

func NewDefaultClient

func NewDefaultClient(api, secret string) *Client

NewDefaultClient creates a new client from a key pair, using the default http.Client implementation.

func (*Client) SendMessage

func (c *Client) SendMessage(to, body string) (string, error)

SendMessage sends a message to a phone number `to` with a given `body`. Returns the phone number that the message was sent from and an error, if any.

type Message

type Message struct {
	Number  string `json:"number"`
	Content string `json:"content"`
}

A Message is sent or received from Sendblue.

func ReadWebhook

func ReadWebhook(r io.ReadCloser) (*Message, error)

ReadWebhook is a method used to process an incoming webhook from Sendblue.

type MessageResponse

type MessageResponse struct {
	Status        string `json:"status"`
	ErrorCode     string `json:"error_code"`
	FromNumber    string `json:"from_number"`
	MessageHandle string `json:"message_handle"`
}

A MessageResponse is returned from Sendblue after a message request was sent. This is used to check for any errors.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址