minitel

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2019 License: MIT Imports: 9 Imported by: 0

README

minitel in Go


payload := minitel.Notification{
	Title: "Your DB is on fire!",
	Body: "...",
}

payload.Target.ID = "84838298-989d-4409-b148-6abef06df43f"
payload.Target.Type = minitel.App

payload.Action.Label = "View Invoice"
payload.Action.URL = "https://view.your.invoice/yolo"

client, err := minitel.New("https://user:pass@telex.heroku.com")
if err != nil {
	log.Fatal(err)
}
client.Notify(payload)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewContext

func NewContext(ctx context.Context, cli *Client) context.Context

NewContext returns a new Context that includes the Client

Types

type Action

type Action struct {
	Label string `json:"label"`
	URL   string `json:"url"`
}

Action portion of a Telex payload. Defined separately to ease construction via composite literals.

type Client

type Client struct {
	*http.Client
	// contains filtered or unexported fields
}

Client for communicating with telex.

func FromContext

func FromContext(ctx context.Context) (cli *Client, ok bool)

FromContext retrieves the Client value stored in ctx, if any.

func New

func New(URL string) (*Client, error)

New Telex client targeted at the telex service located at the provided URL.

func (*Client) Followup

func (c *Client) Followup(id, text string) (result Result, err error)

Followup adds some additional text to the previously created notification identified by id.

func (*Client) Notify

func (c *Client) Notify(n Notification) (result Result, err error)

Notify Telex.

type Notification

type Notification struct {
	Title string `json:"title"`
	Body  string `json:"body"`

	Target Target `json:"target"`
	Action Action `json:"action"`
}

Notification message accepted by Telex.

func (Notification) Validate

func (n Notification) Validate() error

Validate that a Notification contains everything it needs to.

type Result

type Result struct {
	ID string `json:"id"`
}

Result from telex containing the ID of the created notification.

type Target

type Target struct {
	Type Type   `json:"type"`
	ID   string `json:"id"`
}

Target portion of a Telex payload. Defined separately to ease construction via composite literals.

type Type

type Type string

Type of Notification.

const (
	App       Type = "app"
	User      Type = "user"
	Email     Type = "email"
	Dashboard Type = "dashboard"
)

Known Telex notification target ypes.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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