Version: v4.0.0-...-0cb6e82 Latest Latest

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

Go to latest
Published: Aug 25, 2016 License: MIT Imports: 2 Imported by: 0




This section is empty.


This section is empty.


This section is empty.


type Address

type Address struct {
	Street1    string `json:"street_1"`
	Street2    string `json:"street_2,omitempty"`
	City       string `json:"city"`
	PostalCode string `json:"postal_code"`
	State   string `json:"state,omitempty"`
	Country string `json:"country"`

type Adjustment

type Adjustment struct {
	Name   string  `json:"name,omitempty"`
	Amount float64 `json:"amount,omitempty"`

type Button

type Button struct {
	Type    ButtonType `json:"type"`
	Title   string     `json:"title,omitempty"`
	URL     string     `json:"url,omitempty"`
	Payload string     `json:"payload,omitempty"`

func NewAccountLinkButton

func NewAccountLinkButton(url string) Button

NewAccountLinkButton creates a button used for account linking https://developers.facebook.com/docs/messenger-platform/account-linking/authentication

func NewAccountUnlinkButton

func NewAccountUnlinkButton() Button

NewAccountUnlinkButton creates a button used for account unlinking https://developers.facebook.com/docs/messenger-platform/account-linking/authentication

func NewPhoneNumberButton

func NewPhoneNumberButton(title string, phone string) Button

NewPhoneNumberButton creates a button used in ButtonTemplate that upon clicking opens a native dialer

func NewPostbackButton

func NewPostbackButton(title string, payload string) Button

NewPostbackButton creates a button used in ButtonTemplate that upon clicking sends a payload request to the server

func NewWebURLButton

func NewWebURLButton(title string, url string) Button

NewWebURLButton creates a button used in ButtonTemplate that redirects user to external address upon clicking the URL

type ButtonTemplate

type ButtonTemplate struct {
	Text    string   `json:"text,omitempty"`
	Buttons []Button `json:"buttons,omitempty"`

ButtonTemplate is a template

func (ButtonTemplate) SupportsButtons

func (ButtonTemplate) SupportsButtons() bool

func (ButtonTemplate) Type

type ButtonType

type ButtonType string

ButtonType defines the behavior of the button in the ButtonTemplate

const (
	ButtonTypeWebURL        ButtonType = "web_url"
	ButtonTypePostback      ButtonType = "postback"
	ButtonTypePhoneNumber   ButtonType = "phone_number"
	ButtonTypeAccountLink   ButtonType = "account_link"
	ButtonTypeAccountUnlink ButtonType = "account_unlink"

type GenericTemplate

type GenericTemplate struct {
	// Title is limited to 45 characters
	Title    string `json:"title"`
	ItemURL  string `json:"item_url,omitempty"`
	ImageURL string `json:"image_url,omitempty"`
	// Subtitle is limited to 80 characters
	Subtitle string   `json:"subtitle,omitempty"`
	Buttons  []Button `json:"buttons,omitempty"`

func (GenericTemplate) SupportsButtons

func (GenericTemplate) SupportsButtons() bool

func (GenericTemplate) Type

type Payload

type Payload struct {
	Elements []Template `json:"elements"`

func (*Payload) MarshalJSON

func (p *Payload) MarshalJSON() ([]byte, error)

type ReceiptElement

type ReceiptElement struct {
	Title    string  `json:"title"`
	Subtitle string  `json:"subtitle,omitempty"`
	Quantity float64 `json:"quantity,omitempty"`
	Price    float64 `json:"price,omitempty"`
	Currency string  `json:"currency,omitempty"`
	ImageURL string  `json:"image_url,omitempty"`

type ReceiptTemplate

type ReceiptTemplate struct {
	RecipientName string           `json:"recipient_name"`
	OrderNumber   string           `json:"order_number"`
	Currency      string           `json:"currency"`
	PaymentMethod string           `json:"payment_method"`
	Timestamp     string           `json:"timestamp,omitempty"`
	OrderURL      string           `json:"order_url,omitempty"`
	Elements      []ReceiptElement `json:"elements"`
	Address       Address          `json:"address,omitempty"`
	Summary       Summary          `json:"summary"`
	Adjustments   []Adjustment     `json:"adjustments,omitempty"`

func (ReceiptTemplate) SupportsButtons

func (ReceiptTemplate) SupportsButtons() bool

func (ReceiptTemplate) Type

type Summary

type Summary struct {
	Subtotal     float64 `json:"subtotal,omitempty"`
	ShippingCost float64 `json:"shipping_cost,omitempty"`
	TotalTax     float64 `json:"total_text,omitempty"`
	TotalCost    float64 `json:"total_cost"`

type Template

type Template interface {
	Type() TemplateType
	SupportsButtons() bool

type TemplateType

type TemplateType string
const TemplateTypeButton TemplateType = "button"
const TemplateTypeGeneric TemplateType = "generic"
const TemplateTypeReceipt TemplateType = "receipt"

Jump to

Keyboard shortcuts

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