zgo

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: MIT Imports: 12 Imported by: 0

README

zgo

Zalo Go APIs

To do

Install

go get github.com/toanppp/zgo

Documentation

Index

Constants

View Source
const (
	TooManyRequest      = -32
	InvalidAccessToken  = -216
	InvalidRefreshToken = -14014
	ExpiredRefreshToken = -14020
)
View Source
const (
	AddUserToTag      = "add_user_to_tag"
	RemoveUserFromTag = "remove_user_from_tag"

	TagFinished = "Hoàn thành"
)
View Source
const (
	SrcOA = iota
	SrcUser
)

Variables

This section is empty.

Functions

func OptionHTTPClient

func OptionHTTPClient(client *http.Client) func(*zgo)

Types

type Conversation

type Conversation []Message

func (Conversation) Profile

func (c Conversation) Profile() Profile

type ErrorResp

type ErrorResp struct {
	ErrorName        string `json:"error_name"`
	ErrorReason      string `json:"error_reason"`
	RefDoc           string `json:"ref_doc"`
	ErrorDescription string `json:"error_description"`
	Error            int    `json:"error"`
}

type Event

type Event struct {
	OAID        string  `json:"oa_id"`
	UserIDByApp string  `json:"user_id_by_app"`
	EventName   string  `json:"event_name"`
	Tag         UserTag `json:"tag"`
	AppID       string  `json:"app_id"`
	Timestamp   string  `json:"timestamp"`
}

func (Event) CreatedAt

func (e Event) CreatedAt() time.Time

type GetAccessTokenResp

type GetAccessTokenResp struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
	ExpiresIn    string `json:"expires_in"`
	ErrorResp
}

type GetConversationReq

type GetConversationReq struct {
	UserID int64 `json:"user_id"`
	Offset int   `json:"offset"`
	Count  int   `json:"count"`
}

type GetConversationResp

type GetConversationResp struct {
	Data Conversation `json:"data"`
	ErrorResp
}
type Link struct {
	Title       string `json:"title" bson:"title"`
	URL         string `json:"url" bson:"url"`
	Thumb       string `json:"thumb" bson:"thumb"`
	Description string `json:"description" bson:"description"`
}

func (Link) String

func (l Link) String() string

type LinkDescription

type LinkDescription struct {
	Caption string `json:"caption"`
	Phone   string `json:"phone"`
}

type Message

type Message struct {
	Src             int    `json:"src" bson:"src"`
	Time            int64  `json:"time" bson:"time"`
	SentTime        string `json:"sent_time" bson:"sent_time"`
	FromID          string `json:"from_id" bson:"from_id"`
	FromDisplayName string `json:"from_display_name" bson:"from_display_name"`
	FromAvatar      string `json:"from_avatar" bson:"from_avatar"`
	ToID            string `json:"to_id" bson:"to_id"`
	ToDisplayName   string `json:"to_display_name" bson:"to_display_name"`
	ToAvatar        string `json:"to_avatar" bson:"to_avatar"`
	MessageID       string `json:"message_id" bson:"message_id"`
	Type            string `json:"type" bson:"type"`
	Message         string `json:"message" bson:"message"`
	Links           []Link `json:"links,omitempty" bson:"links"`
	Thumb           string `json:"thumb" bson:"thumb"`
	URL             string `json:"url" bson:"url"`
	Description     string `json:"description" bson:"description"`
}

type Option

type Option func(z *zgo)

type Profile

type Profile struct {
	UserID      string `json:"user_id"`
	DisplayName string `json:"display_name"`
}

type UserTag

type UserTag struct {
	UserIDs []string `json:"user_ids"`
	Name    string   `json:"name"`
}

type Zgo

type Zgo interface {
	GetAppID() string
	EventSignature(data string, timestamp string) string
	RefreshAccessToken(ctx context.Context, refreshToken string) (GetAccessTokenResp, error)
	GetConversation(ctx context.Context, accessToken string, reqData GetConversationReq) (GetConversationResp, error)
}

func New

func New(appID, appSecret, oaSecret string, opts ...Option) Zgo

Jump to

Keyboard shortcuts

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