webhookpubsub

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNullSecureStore specifies that a SecureStorage is required.
	ErrNullSecureStore = errors.New("secure store must not be null")
	// ErrNullHTTPClient specifies that a HTTP client is required.
	ErrNullHTTPClient = errors.New("http client must not be null")
	// ErrUnknownWebhookAction specifies that the given string does not represent
	// any known action.
	ErrUnknownWebhookAction = errors.New("action is unknown")
	// ErrInvalidArgs specifies that the provided args do not properly represent a
	// Webhook.
	ErrInvalidArgs = errors.New(
		"webhook info must be serialized as a stringified JSON",
	)
	// ErrInvalidArgType specifies that the provided arg is not of the expected
	// type.
	ErrInvalidArgType = errors.New("arg type must be string")
	// ErrInvalidTopic is returned whenever attempting to subscribe to an unknown
	// topic.
	ErrInvalidTopic = errors.New("topic is invalid")
)

Functions

func NewWebhookPubSubService

func NewWebhookPubSubService(
	store securestore.SecureStorage,
	httpClient *esplora.Client,
) (ports.SecurePubSub, error)

Types

type Webhook

type Webhook struct {
	ID         string        `json:"id"`
	ActionType WebhookAction `json:"action_type"`
	Endpoint   string        `json:"endpoint"`
	Secret     string        `json:"secret"`
}

func NewWebhook

func NewWebhook(actionType WebhookAction, endpoint, secret string) (*Webhook, error)

func NewWebhookFromBytes

func NewWebhookFromBytes(buf []byte) (*Webhook, error)

func (*Webhook) Id

func (h *Webhook) Id() string

func (*Webhook) IsSecured

func (h *Webhook) IsSecured() bool

func (*Webhook) NotifyAt

func (h *Webhook) NotifyAt() string

func (*Webhook) Serialize

func (h *Webhook) Serialize() []byte

func (*Webhook) Topic

func (h *Webhook) Topic() ports.Topic

type WebhookAction

type WebhookAction int
const (
	TradeSettled WebhookAction = iota
	AccountLowBalance
	AccountWithdraw
	AllActions
)

webhook action types

func WebhookActionFromString

func WebhookActionFromString(actionStr string) (WebhookAction, bool)

func (WebhookAction) Code

func (wa WebhookAction) Code() int

func (WebhookAction) Label

func (wa WebhookAction) Label() string

func (WebhookAction) String

func (wa WebhookAction) String() string

Jump to

Keyboard shortcuts

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