bot

package module
v1.1.5-0...-b22ba9b Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2019 License: Apache-2.0 Imports: 30 Imported by: 0

README

bot-api-go-client

Installation

Install using the "go get" command:

go get github.com/MixinNetwork/bot-api-go-client

Documentation

Index

Constants

View Source
const (
	MessageCategoryPlainText             = "PLAIN_TEXT"
	MessageCategoryPlainImage            = "PLAIN_IMAGE"
	MessageCategoryPlainData             = "PLAIN_DATA"
	MessageCategoryPlainSticker          = "PLAIN_STICKER"
	MessageCategoryPlainLive             = "PLAIN_LIVE"
	MessageCategorySystemConversation    = "SYSTEM_CONVERSATION"
	MessageCategorySystemAccountSnapshot = "SYSTEM_ACCOUNT_SNAPSHOT"
	MessageCategoryMessageRecall         = "MESSAGE_RECALL"
)
View Source
const (
	ParticipantActionAdd    ParticipantAction = "ADD"
	ParticipantActionRemove                   = "REMOVE"
	ParticipantActionJoin                     = "JOIN"
	ParticipantActionExit                     = "EXIT"
)

Variables

View Source
var Nil = uuid.Nil

Functions

func Authorize

func Authorize(ctx context.Context, id string, scopes []string, uid, sid, key string) ([]byte, error)

func CancelAuthorization

func CancelAuthorization(ctx context.Context, clientId string, uid, sid, key string) ([]byte, error)

func Chunked

func Chunked(source []interface{}, size int) [][]interface{}

func CreateTransfer

func CreateTransfer(ctx context.Context, in *TransferInput, uid, sid, sessionKey, pin, pinToken string) error

func EncryptPIN

func EncryptPIN(ctx context.Context, pin, pinToken, sessionId, privateKey string, iterator uint64) (string, error)

func ExitConversation

func ExitConversation(ctx context.Context, id string, uid, sid, key string) ([]byte, error)

func FetchUsers

func FetchUsers(ctx context.Context, ids []string, uid, sid, key string) ([]byte, error)

func GetProvisioning

func GetProvisioning(ctx context.Context, id, uid, sid, key string) ([]byte, error)

func GetProvisioningId

func GetProvisioningId(ctx context.Context, device, uid, sid, key string) (id string, err error)

func JoinConversation

func JoinConversation(ctx context.Context, codeId string, uid, sid, key string) ([]byte, error)

func ManageParticipants

func ManageParticipants(ctx context.Context, id, action string, req []*ParticipantRequest, uid, sid, key string) ([]byte, error)

func MuteConversation

func MuteConversation(ctx context.Context, id string, uid, sid, key string) ([]byte, error)

func OAuthGetAccessToken

func OAuthGetAccessToken(ctx context.Context, clientId, clientSecret string, authorizationCode string, codeVerifier string) (string, string, error)

func PostMessage

func PostMessage(ctx context.Context, conversationId, recipientId, messageId, category, data string, clientId, sessionId, secret string) error

func PostMessages

func PostMessages(ctx context.Context, messages []*MessageRequest, clientId, sessionId, secret string) error

func ReadAuthorization

func ReadAuthorization(ctx context.Context, id string, uid, sid, key string) ([]byte, error)

func ReadAuthorizations

func ReadAuthorizations(ctx context.Context, uid, sid, key string) ([]byte, error)

func ReadConversation

func ReadConversation(ctx context.Context, id string, uid, sid, key string) ([]byte, error)

func ReadUser

func ReadUser(ctx context.Context, id string, uid, sid, key string) ([]byte, error)

func Request

func Request(ctx context.Context, method, path string, body []byte, accessToken string) ([]byte, error)

func RorateConversationQrcode

func RorateConversationQrcode(ctx context.Context, id string, uid, sid, key string) ([]byte, error)

func SearchUser

func SearchUser(ctx context.Context, q string, uid, sid, key string) ([]byte, error)

func SignAuthenticationToken

func SignAuthenticationToken(uid, sid, privateKey, method, uri, body string) (string, error)

func UniqueConversationId

func UniqueConversationId(userId, recipientId string) string

func UpdateConversation

func UpdateConversation(ctx context.Context, id string, req *ConversationRequest, uid, sid, key string) ([]byte, error)

func UpdatePin

func UpdatePin(ctx context.Context, oldEncryptedPin, encryptedPin, uid, sid, sessionKey string) error

func UuidFromBytes

func UuidFromBytes(input []byte) (uuid.UUID, error)

func UuidFromString

func UuidFromString(id string) (uuid.UUID, error)

func UuidNewV4

func UuidNewV4() uuid.UUID

func VerifyProvisioning

func VerifyProvisioning(ctx context.Context, id, uid, sid, key string) ([]byte, error)

Types

type Address

type Address struct {
	AddressId   string `json:"address_id"`
	AssetId     string `json:"asset_id"`
	Label       string `json:"label"`
	PublicKey   string `json:"public_key,omitempty"`
	AccountName string `json:"account_name,omitempty"`
	AccountTag  string `json:"account_tag,omitempty"`
	Fee         string `json:"fee"`
	Reserve     string `json:"reserve"`
	UpdatedAt   string `json:"updated_at"`
}

func CreateAddress

func CreateAddress(ctx context.Context, in *AddressInput, uid, sid, sessionKey, pin, pinToken string) (*Address, error)

type AddressInput

type AddressInput struct {
	AssetId     string
	Label       string
	PublicKey   string
	AccountName string
	AccountTag  string
}

type Asset

type Asset struct {
	AssetId     string `json:"asset_id"`
	ChainId     string `json:"chain_id"`
	Symbol      string `json:"symbol"`
	Name        string `json:"name"`
	IconURL     string `json:"icon_url"`
	PriceBTC    string `json:"price_btc"`
	PriceUSD    string `json:"price_usd"`
	Balance     string `json:"balance"`
	PublicKey   string `json:"public_key"`
	AccountName string `json:"account_name"`
	AccountTag  string `json:"account_tag"`
}

func AssetList

func AssetList(ctx context.Context, accessToken string) ([]Asset, error)

func AssetShow

func AssetShow(ctx context.Context, assetId string, accessToken string) (*Asset, error)

type Attachment

type Attachment struct {
	Type         string `json:"type"`
	AttachmentId string `json:"attachment_id"`
	ViewURL      string `json:"view_url"`
	UploadUrl    string `json:"upload_url"`
}

func AttachemntShow

func AttachemntShow(ctx context.Context, uid, sid, key, id string) (*Attachment, error)

func CreateAttachment

func CreateAttachment(ctx context.Context, uid, sid, key string) (*Attachment, error)

type BlazeClient

type BlazeClient struct {
	// contains filtered or unexported fields
}

func NewBlazeClient

func NewBlazeClient(uid, sid, key string) *BlazeClient

func (*BlazeClient) Loop

func (b *BlazeClient) Loop(ctx context.Context, listener BlazeListener) error

func (*BlazeClient) SendAppButton

func (b *BlazeClient) SendAppButton(ctx context.Context, conversationId, recipientId, label, action, color string) error

func (*BlazeClient) SendContact

func (b *BlazeClient) SendContact(ctx context.Context, conversationId, recipientId, contactId string) error

func (*BlazeClient) SendMessage

func (b *BlazeClient) SendMessage(ctx context.Context, conversationId, recipientId, messageId, category, content, representativeId string) error

func (*BlazeClient) SendPlainText

func (b *BlazeClient) SendPlainText(ctx context.Context, msg MessageView, content string) error

func (*BlazeClient) SendRawMessage

func (b *BlazeClient) SendRawMessage(ctx context.Context, params map[string]interface{}) error

type BlazeListener

type BlazeListener interface {
	OnMessage(ctx context.Context, msg MessageView, userId string) error
}

type BlazeMessage

type BlazeMessage struct {
	Id     string                 `json:"id"`
	Action string                 `json:"action"`
	Params map[string]interface{} `json:"params,omitempty"`
	Data   json.RawMessage        `json:"data,omitempty"`
	Error  *Error                 `json:"error,omitempty"`
}

type Conversation

type Conversation struct {
	ConversationId string    `json:"conversation_id"`
	CreatorId      string    `json:"creator_id"`
	Category       string    `json:"category"`
	Name           string    `json:"name"`
	IconURL        string    `json:"icon_url"`
	Announcement   string    `json:"announcement"`
	CreatedAt      time.Time `json:"created_at"`

	Participants []Participant `json:"participants"`
}

func ConversationShow

func ConversationShow(ctx context.Context, conversationId string, accessToken string) (*Conversation, error)

func CreateConversation

func CreateConversation(ctx context.Context, name, category, conversationId string, participants []Participant, uid, sid, key string) (*Conversation, error)

type ConversationRequest

type ConversationRequest struct {
	ConversationId string         `json:"conversation_id"`
	Category       string         `json:"category"`
	Name           string         `json:"name"`
	IconBase64     string         `json:"icon_base64"`
	Announcement   string         `json:"announcement"`
	Duration       string         `json:"duration"`
	Participants   []*Participant `json:"participants"`
}

type Error

type Error struct {
	Status      int    `json:"status"`
	Code        int    `json:"code"`
	Description string `json:"description"`
	// contains filtered or unexported fields
}

func AuthorizationError

func AuthorizationError(ctx context.Context) Error

func BadDataError

func BadDataError(ctx context.Context) Error

func BlazeServerError

func BlazeServerError(ctx context.Context, err error) Error

func ForbiddenError

func ForbiddenError(ctx context.Context) Error

func ServerError

func ServerError(ctx context.Context, err error) Error

func (Error) Error

func (sessionError Error) Error() string

type LiveMessageData

type LiveMessageData struct {
	Width    int    `json:"width"`
	Height   int    `json:"height"`
	ThumbUrl string `json:"thumb_url"`
	Url      string `json:"url"`
}

type MessageRequest

type MessageRequest struct {
	ConversationId   string `json:"conversation_id"`
	RecipientId      string `json:"recipient_id"`
	MessageId        string `json:"message_id"`
	Category         string `json:"category"`
	Data             string `json:"data"`
	RepresentativeId string `json:"representative_id"`
	QuoteMessageId   string `json:"quote_message_id"`
}

type MessageView

type MessageView struct {
	ConversationId   string    `json:"conversation_id"`
	UserId           string    `json:"user_id"`
	MessageId        string    `json:"message_id"`
	Category         string    `json:"category"`
	Data             string    `json:"data"`
	RepresentativeId string    `json:"representative_id"`
	QuoteMessageId   string    `json:"quote_message_id"`
	Status           string    `json:"status"`
	Source           string    `json:"source"`
	CreatedAt        time.Time `json:"created_at"`
	UpdatedAt        time.Time `json:"updated_at"`
}

type Participant

type Participant struct {
	UserId    string    `json:"user_id"`
	Role      string    `json:"role"`
	CreatedAt time.Time `json:"created_at"`
}

type ParticipantAction

type ParticipantAction string

type ParticipantRequest

type ParticipantRequest struct {
	UserId    string    `json:"user_id"`
	Role      string    `json:"role"`
	CreatedAt time.Time `json:"created_at"`
}

type RawTransaction

type RawTransaction struct {
	Type            string    `json:"type"`
	SnapshotId      string    `json:"snapshot_id"`
	OpponentKey     string    `json:"opponent_key"`
	AssetId         string    `json:"asset_id"`
	Amount          string    `json:"amount"`
	TraceId         string    `json:"trace_id"`
	Memo            string    `json:"memo"`
	State           string    `json:"state"`
	CreatedAt       time.Time `json:"created_at"`
	TransactionHash string    `json:"transaction_hash"`
	SnapshotHash    string    `json:"snapshot_hash"`
	SnapshotAt      time.Time `json:"snapshot_at"`
}

func CreateTransaction

func CreateTransaction(ctx context.Context, in *TransferInput, uid, sid, sessionKey, pin, pinToken string) (*RawTransaction, error)

type RecallMessage

type RecallMessage struct {
	MessageId string `json:"message_id"`
}

type TransferInput

type TransferInput struct {
	AssetId     string
	RecipientId string
	Amount      number.Decimal
	TraceId     string
	Memo        string
	OpponentKey string
}

type TransferView

type TransferView struct {
	Type          string    `json:"type"`
	SnapshotId    string    `json:"snapshot_id"`
	CounterUserId string    `json:"counter_user_id"`
	AssetId       string    `json:"asset_id"`
	Amount        string    `json:"amount"`
	TraceId       string    `json:"trace_id"`
	Memo          string    `json:"memo"`
	CreatedAt     time.Time `json:"created_at"`
}

type User

type User struct {
	UserId         string `json:"user_id"`
	SessionId      string `json:"session_id"`
	PinToken       string `json:"pin_token"`
	IdentityNumber string `json:"identity_number"`
	Phone          string `json:"phone"`
	FullName       string `json:"full_name"`
	AvatarURL      string `json:"avatar_url"`
	DeviceStatus   string `json:"device_status"`
	CreatedAt      string `json:"created_at"`
}

func CreateUser

func CreateUser(ctx context.Context, sessionSecret, fullName, uid, sid, sessionKey string) (*User, error)

func UpdatePreference

func UpdatePreference(ctx context.Context, uid, sid, privateKey string, messageSource, conversationSource, currency string, threshold float64) (*User, error)

func UserMe

func UserMe(ctx context.Context, accessToken string) (*User, error)

type Withdrawal

type Withdrawal struct {
	Type            string    `json:"type"`
	SnapshotId      string    `json:"snapshot_id"`
	Receiver        string    `json:"receiver"`
	TransactionHash string    `json:"transaction_hash"`
	AssetId         string    `json:"asset_id"`
	Amount          string    `json:"amount"`
	TraceId         string    `json:"trace_id"`
	Memo            string    `json:"memo"`
	CreatedAt       time.Time `json:"created_at"`
}

func CreateWithdrawal

func CreateWithdrawal(ctx context.Context, in *WithdrawalInput, uid, sid, sessionKey, pin, pinToken string) (*Withdrawal, error)

type WithdrawalInput

type WithdrawalInput struct {
	AddressId string
	Amount    number.Decimal
	TraceId   string
	Memo      string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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