messenger

package
v0.0.0-...-ed9fe1d Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2018 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WebviewShareButtonShow = "show"
	WebviewShareButtonHide = "hide"
)

Constants for URLButton.WebviewShareButton fields

View Source
const MaxWebhookPayloadSize = 1024 * 1024 * 512

MaxWebhookPayloadSize is a maximum size of payload (512KB) in a single webhook call

Variables

This section is empty.

Functions

func NewVericationHandler

func NewVericationHandler(token string) web.Handler

func NewWebhookHandler

func NewWebhookHandler(hook Webhook) web.Handler

NewWebhookHandler return s new web.Handler to handle webhook request

Types

type AccountLinking

type AccountLinking struct {
	Status            AccountStatus `json:"status"`
	AuthorizationCode string        `json:"authorization_code"`
}

type AccountStatus

type AccountStatus string

AccountStatus is a enum type for account linking status.

const (
	AccountStatusLinked   AccountStatus = "linked"
	AccountStatusUnlinked AccountStatus = "unlinked"
)

AccountStatus constants

type Coordinates

type Coordinates struct {
	Lat  float64 `json:"lat"`
	Long float64 `json:"long"`
}

type GenericTemplatePayload

type GenericTemplatePayload struct {
	TemplateType string                           `json:"template_type"`
	Elements     []*GenericTemplatePayloadElement `json:"elements,omitempty"`
}

GenericTemplatePayload

type GenericTemplatePayloadElement

type GenericTemplatePayloadElement struct {
	Title         string        `json:"title"`
	Subtitle      string        `json:"subtitle,omitempty"`
	ImageURL      string        `json:"image_url,omitempty"`
	DefaultAction *URLButton    `json:"default_action,omitempty"`
	Buttons       []interface{} `json:"buttons,omitempty"`
}

type ReceivedAttachment

type ReceivedAttachment struct {
	Type    string                     `json:"type"`
	Payload *ReceivedAttachmentPayload `json:"payload"`
}

type ReceivedAttachmentPayload

type ReceivedAttachmentPayload struct {
	URL         string       `json:"url"`
	Coordinates *Coordinates `json:"coordinates"`
}

type ReceivedMessage

type ReceivedMessage struct {
	PageID      string
	SenderID    string
	RecipientID string
	UpdateTime  time.Time
	Timestamp   time.Time
	Content     interface{}
}

func Parse

func Parse(r io.Reader) ([]ReceivedMessage, error)

type ReceivedMessageContent

type ReceivedMessageContent struct {
	MID         string               `json:"mid"`
	Seq         int                  `json:"seq"`
	Text        string               `json:"text"`
	QuickReply  *ReceivedQuickReply  `json:"quick_reply"`
	Attachments []ReceivedAttachment `json:"attachments"`
}

type ReceivedQuickReply

type ReceivedQuickReply struct {
	Payload string `json:"payload"`
}

type Recipient

type Recipient struct {
	ID          string `json:"id,omitempty"`
	PhoneNumber string `json:"phone_number,omitempty"`
	Name        string `json:"name,omitempty"`
}

Recipient is a structure to specify a recipent in Send API

type SendAttachment

type SendAttachment struct {
	Type    string      `json:"type"`
	Payload interface{} `json:"payload"`
}

SendAttachment is an attachment structure for Send API

type SendMessage

type SendMessage struct {
	Recipient *Recipient          `json:"recipient"`
	Message   *SendMessageContent `json:"message"`
}

SendMessage is a message structure for Send API

type SendMessageContent

type SendMessageContent struct {
	Text       string           `json:"text,omitempty"`
	QuickReply []SendQuickReply `json:"quick_reply,omitempty"`
	Attachment *SendAttachment  `json:"attachment,omitempty"`
	Metadata   string           `json:"metadata,omitempty"`
}

SendMessageContent is a content structure in SendMessage

type SendPayload

type SendPayload struct {
	URL           string `json:url"`
	IsReusable    string `json:"is_reusable"`
	AttachementID string `json:"attachment_id"`
}

SendPayload is a payload structure for Send AP{

type SendQuickReply

type SendQuickReply struct {
	ContentType string `json:"content_type"`
	Title       string `json:"title"`
	Payload     string `json:"payload"`
	ImageURL    string `json:"image_url"`
}

SendQuickReply is a quick reply structure for Send API

type SendResponse

type SendResponse struct {
	RecipientID string `json:"recipient_id"`
	MessageID   string `json:"message_dd"`
}

SendResponse is a response structure for Send API

type Sender

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

Sender is a struct to send messages

func NewSender

func NewSender(client *http.Client, pageAccessToken string) *Sender

NewSender returns a new messenger API client to send messages

func (*Sender) Send

func (s *Sender) Send(ctx context.Context, msg *SendMessage) (*SendResponse, error)

Send sends a message

type URLButton

type URLButton struct {
	Type                string `json:"type"`
	Title               string `json:"title,omitempty"`
	URL                 string `json:"url"`
	WebviewHeightRatio  string `json:"webview_height_ratio,omitempty"`
	MessengerExtentions bool   `json:"messenger_extentions,omitempty"`
	FallbackURL         string `json:"fallback_url,omitempty"`
	WebviewShareButton  string `json:"webview_share_button,omitempty"`
}

URLButton is for url button structure described at https://developers.facebook.com/docs/messenger-platform/send-api-reference/url-button

type Webhook

type Webhook interface {
	Process(context.Context, *ReceivedMessage) error
}

Webhook is an interface to process messenger message in webhook

type WebhookFunc

type WebhookFunc func(context.Context, *ReceivedMessage) error

WebhookFunc is a simple interface generator for a webhook function

func (WebhookFunc) Process

func (f WebhookFunc) Process(ctx context.Context, messages *ReceivedMessage) error

Process implements Webhook#Process

Jump to

Keyboard shortcuts

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