Documentation
¶
Index ¶
- Constants
- Variables
- func GenerateJWT(scope string, keyID string, secret string) (string, error)
- func New(o Options) (*smoochClient, error)
- type Action
- type ActionType
- type AppUser
- type Application
- type Client
- type Conversation
- type DisplaySettings
- type ErrorDetails
- type ErrorPayload
- type ImageRatio
- type Item
- type Logger
- type Menu
- type MenuItem
- type MenuPayload
- type Message
- type MessageType
- type Options
- type Payload
- type ResponsePayload
- type Role
- type Size
- type SmoochError
- type Source
- type WebhookEventHandler
Constants ¶
View Source
const ( RegionUS = "US" RegionEU = "EU" )
View Source
const ( MessageTypeText = MessageType("text") MessageTypeImage = MessageType("image") MessageTypeFile = MessageType("file") MessageTypeLocation = MessageType("location") MessageTypeCarousel = MessageType("carousel") MessageTypeList = MessageType("list") ActionTypePostback = ActionType("postback") ActionTypeReply = ActionType("reply") ActionTypeLocationRequest = ActionType("locationRequest") ActionTypeBuy = ActionType("buy") ActionTypeLink = ActionType("link") ActionTypeWebview = ActionType("webview") SourceTypeWeb = "web" SourceTypeIOS = "ios" SourceTypeAndroid = "android" SourceTypeMessenger = "messenger" SourceTypeViber = "viber" SourceTypeTelegram = "telegram" SourceTypeWeChat = "wechat" SourceTypeLine = "line" SourceTypeTwilio = "twilio" SourceTypeApi = "api" RoleAppUser = Role("appUser") RoleAppMaker = Role("appMaker") TriggerMessageAppUser = "message:appUser" TriggerMessageAppMaker = "message:appMaker" ImageRatioHorizontal = ImageRatio("horizontal") ImageRatioSquare = ImageRatio("square") SizeCompact = Size("compact") SizeLarge = Size("large") )
Variables ¶
Functions ¶
Types ¶
type Action ¶
type Action struct {
ID string `json:"_id,omitempty"`
Type ActionType `json:"type,omitempty"`
Text string `json:"text,omitempty"`
Default bool `json:"default,omitempty"`
Payload string `json:"payload,omitempty"`
URI string `json:"uri,omitempty"`
Amount int `json:"amount,omitempty"`
Currency string `json:"currency,omitempty"`
State string `json:"state,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
type ActionType ¶
type ActionType string
type Application ¶
type Application struct {
ID string `json:"_id,omitempty"`
}
type Client ¶
type Client interface {
Handler() http.Handler
AddWebhookEventHandler(handler WebhookEventHandler)
Send(userID string, message *Message) (*ResponsePayload, error)
VerifyRequest(r *http.Request) bool
}
type Conversation ¶
type DisplaySettings ¶
type DisplaySettings struct {
ImageAspectRatio ImageRatio `json:"imageAspectRatio,omitempty"`
}
type ErrorDetails ¶
type ErrorPayload ¶
type ErrorPayload struct {
Details ErrorDetails `json:"error"`
}
type ImageRatio ¶
type ImageRatio string
type Item ¶
type Item struct {
ID string `json:"_id,omitempty"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
Size Size `json:"size,omitempty"`
MediaURL string `json:"mediaUrl,omitempty"`
MediaType string `json:"mediaType,omitempty"`
Actions []*Action `json:"actions,omitempty"`
}
type MenuPayload ¶
type MenuPayload struct {
Menu Menu `json:"menu"`
}
type Message ¶
type Message struct {
ID string `json:"_id,omitempty"`
Type MessageType `json:"type"`
Text string `json:"text,omitempty"`
Role Role `json:"role"`
AuthorID string `json:"authorId,omitempty"`
Name string `json:"name,omitempty"`
Received time.Time `json:"received,omitempty"`
Source *Source `json:"source,omitempty"`
MediaUrl string `json:"mediaUrl,omitempty"`
Actions []*Action `json:"actions,omitempty"`
Items []*Item `json:"items,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
DisplaySettings *DisplaySettings `json:"displaySettings,omitempty"`
}
func (*Message) MarshalJSON ¶
func (*Message) UnmarshalJSON ¶
type MessageType ¶
type MessageType string
type Payload ¶
type Payload struct {
Trigger string `json:"trigger,omitempty"`
App Application `json:"app,omitempty"`
Messages []*Message `json:"messages,omitempty"`
AppUser AppUser `json:"appUser,omitempty"`
Conversation Conversation `json:"conversation,omitempty"`
Version string `json:"version,omitempty"`
}
type ResponsePayload ¶
type ResponsePayload struct {
Message *Message `json:"message,omitempty"`
ExtraMessages []*Message `json:"extraMessages,omitempty"`
Conversation *Conversation `json:"conversation,omitempty"`
}
type SmoochError ¶
type SmoochError struct {
// contains filtered or unexported fields
}
func (*SmoochError) Code ¶
func (e *SmoochError) Code() int
func (*SmoochError) Error ¶
func (e *SmoochError) Error() string
type WebhookEventHandler ¶
type WebhookEventHandler func(payload *Payload)
Click to show internal directories.
Click to hide internal directories.