smooch

package module
v0.0.0-...-511e15d Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2017 License: MIT Imports: 9 Imported by: 0

README

go-smooch

API wrapper based on smooch.io

I written this library too fast, so please don't worry about any sucks code. It will improved in future.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorResponse

type ErrorResponse struct {
	Error struct {
		Code        string `json:"code"`
		Description string `json:"description"`
	} `json:"error"`
}

type ListWebhooks

type ListWebhooks struct {
	Webhooks []struct {
		ID       string   `json:"_id"`
		Triggers []string `json:"triggers"`
		Secret   string   `json:"secret"`
		Target   string   `json:"target"`
	} `json:"webhooks"`
}

type MessageReceive

type MessageReceive struct {
	Trigger string `json:"trigger"`
	App     struct {
		ID string `json:"_id"`
	} `json:"app"`
	Messages []struct {
		ID       string  `json:"_id"`
		Type     string  `json:"type"`
		Text     string  `json:"text"`
		Role     string  `json:"role"`
		AuthorID string  `json:"authorId"`
		Name     string  `json:"name"`
		Received float64 `json:"received"`
		Source   struct {
			Type string `json:"type"`
		} `json:"source"`
	} `json:"messages"`
	AppUser struct {
		ID         string `json:"_id"`
		UserID     string `json:"userId"`
		Properties struct {
		} `json:"properties"`
		SignedUpAt time.Time `json:"signedUpAt"`
		Clients    []struct {
			Active   bool      `json:"active"`
			ID       string    `json:"id"`
			LastSeen time.Time `json:"lastSeen"`
			Platform string    `json:"platform"`
		} `json:"clients"`
	} `json:"appUser"`
}

type RequestMessage

type RequestMessage struct {
	Text string      `json:"text"`
	Role roleType    `json:"role"`
	Type messageType `json:"type"`
	Name string      `json:"name"`
}

type ResponseMessage

type ResponseMessage struct {
	Message struct {
		ID        string  `json:"_id"`
		AuthorID  string  `json:"authorId"`
		Role      string  `json:"role"`
		Type      string  `json:"type"`
		Name      string  `json:"name"`
		Text      string  `json:"text"`
		AvatarURL string  `json:"avatarUrl"`
		Received  float64 `json:"received"`
	} `json:"message"`
	Conversation struct {
		ID          string `json:"_id"`
		UnreadCount int    `json:"unreadCount"`
	} `json:"conversation"`
}

type Smooch

type Smooch struct {
	Req     *req.Req
	Headers req.Header
	// contains filtered or unexported fields
}

func NewSmooch

func NewSmooch() *Smooch

func (*Smooch) Auth

func (s *Smooch) Auth(keyID, secret string) error

func (*Smooch) ListWebhooks

func (s *Smooch) ListWebhooks() (*ListWebhooks, error)

func (*Smooch) SendMessage

func (s *Smooch) SendMessage(userID, text string) (*ResponseMessage, error)

func (*Smooch) SubscribeToWebhook

func (s *Smooch) SubscribeToWebhook(endpoint, host string) error

Jump to

Keyboard shortcuts

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