template

package
v0.0.0-...-fe24182 Latest Latest
Warning

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

Go to latest
Published: May 6, 2018 License: MIT Imports: 2 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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 DefaultAction

type DefaultAction struct {
	Type                string `json:"type"`
	URL                 string `json:"url",omitempty`
	MessengerExtensions bool   `json:"messenger_extensions",omitempty`
	WebviewHeightRatio  string `json:"webview_height_ratio",omitempty`
	FallbackURL         string `json:"fallback_url",omitempty`
}

type DefaultActionGeneric

type DefaultActionGeneric struct {
	Type ButtonType `json:"type,omitempty"` // Must be "web_url"
	URL  string     `json:"url,omitempty"`
}

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"`
	DefaultActionGeneric *DefaultActionGeneric `json:"default_action,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 ListButton

type ListButton struct {
	Title               string `json:"title"`
	Type                string `json:"type",omitempty`
	URL                 string `json:"url",omitempty`
	MessengerExtensions bool   `json:"messenger_extensions",omitempty`
	WebviewHeightRatio  string `json:"webview_height_ratio",omitempty`
	FallbackURL         string `json:"fallback_url",omitempty`
}

type ListElement

type ListElement struct {
	Title         string `json:"title"`
	ImageURL      string `json:"image_url,omitempty"`
	Subtitle      string `json:"subtitle,omitempty"`
	DefaultAction `json:"default_action,omitempty"`
	Buttons       []ListButton `json:"buttons,omitempty"`
}

type ListTemplate

type ListTemplate struct {
	Elements []ListElement `json:"elements"`
	Buttons  []Button      `json:"buttons,omitempty"`
}

func (ListTemplate) SupportsButtons

func (ListTemplate) SupportsButtons() bool

func (ListTemplate) Type

func (ListTemplate) Type() TemplateType

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 TemplateTypeList TemplateType = "list"
const TemplateTypeReceipt TemplateType = "receipt"

Jump to

Keyboard shortcuts

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