webhooks

package
v0.0.0-...-72c2bb7 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2020 License: MIT Imports: 16 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatSlackMessage

func FormatSlackMessage(groupName string, evt *Data) (string, error)

func FormatUnixTimeRemaining

func FormatUnixTimeRemaining(remaining int64) string

FormatUnixTimeRemaining takes in a time in unix and returns a string of hours/days remaining

func IntToString

func IntToString(in []int32) string

Types

type AWSSender

type AWSSender struct {
	Env    string
	Region string
	// contains filtered or unexported fields
}

AWSSender uses a pre-defined Lambda to handle sending webhooks

func NewAWSSender

func NewAWSSender(env, region string) *AWSSender

NewAWSSender creates an env/region specific sender of webhook events

func (*AWSSender) Init

func (s *AWSSender) Init() error

Init not necessary but other impl may need

func (*AWSSender) Send

func (s *AWSSender) Send(ctx context.Context, evt *Data) (*DataResponse, error)

Send the events using the env/region defined lambda function and get response

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client handles the transport of sending the events over an HTTPS connection

func NewClient

func NewClient() *Client

NewClient creates a secure HTTPS client for sending webhook events

func (*Client) SendEvent

func (c *Client) SendEvent(ctx context.Context, evt *Data) (int, error)

SendEvent depending on type (slack/custom/custom_signed etc)

type Data

type Data struct {
	Settings *am.WebhookEventSettings `json:"settings"`
	Event    []*am.Event              `json:"events"`
}

type DataResponse

type DataResponse struct {
	StatusCode    int    `json:"status_code"`
	DeliveredTime int64  `json:"delivery_time"`
	Data          *Data  `json:"data"`
	Error         string `json:"error"`
}

type LocalSender

type LocalSender struct {
	// contains filtered or unexported fields
}

func NewLocalSender

func NewLocalSender() *LocalSender

func (*LocalSender) Init

func (s *LocalSender) Init() error

func (*LocalSender) Send

func (s *LocalSender) Send(ctx context.Context, events *Data) (*DataResponse, error)

type SlackAccessory

type SlackAccessory struct {
	Type     string `json:"type"`
	ImageURL string `json:"image_url"`
	AltText  string `json:"alt_text"`
}

type SlackBlock

type SlackBlock struct {
	Blocks []*SlackSection `json:"blocks"`
}

func (*SlackBlock) AppendSection

func (b *SlackBlock) AppendSection(section *SlackSection)

type SlackField

type SlackField struct {
	Type  string `json:"type"`
	Text  string `json:"text,omitempty"`
	Emoji bool   `json:"emoji,omitempty"`
}

func NewSlackField

func NewSlackField(text string) *SlackField

func NewSlackFieldDivider

func NewSlackFieldDivider() *SlackField

type SlackImage

type SlackImage struct {
	Type     string           `json:"type"`
	Title    *SlackImageTitle `json:"title"`
	ImageURL string           `json:"image_url"`
	AltText  string           `json:"alt_text"`
}

type SlackImageTitle

type SlackImageTitle struct {
	Type string `json:"type"`
	Text string `json:"text,omitempty"`
}

type SlackSection

type SlackSection struct {
	Type      string          `json:"type"`
	Text      *SlackField     `json:"text"`
	Fields    []*SlackField   `json:"fields,omitempty"`
	Accessory *SlackAccessory `json:"accessory,omitempty"`
}

func NewSlackSection

func NewSlackSection(text string) *SlackSection

func (*SlackSection) AppendField

func (s *SlackSection) AppendField(field *SlackField)

func (*SlackSection) AppendFields

func (s *SlackSection) AppendFields(field []*SlackField)

type Webhooker

type Webhooker interface {
	Init() error
	Send(ctx context.Context, events *Data) (*DataResponse, error)
}

func New

func New(env, region string) Webhooker

Jump to

Keyboard shortcuts

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