Documentation
¶
Index ¶
- Constants
- func AppDataTableFunctionSchema(name string) (appsdk.FunctionSchema, bool)
- func AppDataTableFunctionSchemas() []appsdk.FunctionSchema
- func AppNotebookFunctionSchema(name string) (appsdk.FunctionSchema, bool)
- func AppNotebookFunctionSchemas() []appsdk.FunctionSchema
- func CallNative[T any](ctx context.Context, c *Client, accessToken, method string, params any) (*T, error)
- type AlfTaskVersion
- type AppDataTableColumn
- type AppDataTableSchema
- type AppNotebookVersion
- type AutoRegisterConfig
- type AutoRegisterResult
- type AutoRegistrar
- type CachedToken
- type Client
- func (c *Client) CallAppFunction(ctx context.Context, accessToken, appID, method string, params any, ...) (json.RawMessage, error)
- func (c *Client) CallNativeFunction(ctx context.Context, accessToken, method string, params any) (json.RawMessage, error)
- func (c *Client) CreateAppDataTable(ctx context.Context, accessToken string, params CreateAppDataTableParams) (*CreateAppDataTableResponse, error)
- func (c *Client) CreateAppDataTableSchema(ctx context.Context, accessToken string, params CreateAppDataTableSchemaParams) (*CreateAppDataTableSchemaResponse, error)
- func (c *Client) CreateProxyAPI(accessToken string) *ProxyAPI
- func (c *Client) GetAlfTaskVersions(ctx context.Context, accessToken, appID string) (*GetAlfTaskVersionsResponse, error)
- func (c *Client) GetAppDataTableSchema(ctx context.Context, accessToken string, params GetAppDataTableSchemaParams) (*GetAppDataTableSchemaResponse, error)
- func (c *Client) GetAppNotebookVersions(ctx context.Context, accessToken, appID string) (*GetAppNotebookVersionsResponse, error)
- func (c *Client) IssueToken(ctx context.Context, secret string, opts ...IssueTokenOptions) (*IssueTokenResponse, error)
- func (c *Client) RefreshToken(ctx context.Context, refreshToken string) (*IssueTokenResponse, error)
- func (c *Client) RegisterAlfTasks(ctx context.Context, accessToken, appID string) (*RegisterAlfTasksResponse, error)
- func (c *Client) RegisterAppNotebooks(ctx context.Context, accessToken, appID string) (*RegisterAppNotebooksResponse, error)
- func (c *Client) RegisterExtension(ctx context.Context, accessToken, appID, extensionName, systemVersion string) (*RegisterExtensionResponse, error)
- func (c *Client) UnregisterExtension(ctx context.Context, accessToken, appID, extensionName, systemVersion string) (*RegisterExtensionResponse, error)
- func (c *Client) UpsertAppDataTableRows(ctx context.Context, accessToken string, params UpsertAppDataTableRowsParams) (*UpsertAppDataTableRowsResponse, error)
- type CreateAppDataTableParams
- type CreateAppDataTableResponse
- type CreateAppDataTableSchemaParams
- type CreateAppDataTableSchemaResponse
- type GetAlfTaskVersionsResponse
- type GetAppDataTableSchemaParams
- type GetAppDataTableSchemaResponse
- type GetAppNotebookVersionsResponse
- type InMemoryTokenCache
- func (c *InMemoryTokenCache) Clear(_ context.Context) error
- func (c *InMemoryTokenCache) Delete(_ context.Context, key string) error
- func (c *InMemoryTokenCache) Get(_ context.Context, key string) (*CachedToken, error)
- func (c *InMemoryTokenCache) Set(_ context.Context, key string, token CachedToken, ttl time.Duration) error
- func (c *InMemoryTokenCache) Stats() (size int, keys []string)
- type IssueTokenOptions
- type IssueTokenResponse
- type Option
- type ProxyAPI
- type ProxyMessage
- type RegisterAlfTasksResponse
- type RegisterAppNotebooksResponse
- type RegisterExtensionResponse
- type TokenCache
- type TokenManager
- func (m *TokenManager) ClearCache(ctx context.Context) error
- func (m *TokenManager) Client() *Client
- func (m *TokenManager) GetAppToken(ctx context.Context) (*TokenResponse, error)
- func (m *TokenManager) GetChannelToken(ctx context.Context, channelID string) (*TokenResponse, error)
- func (m *TokenManager) InvalidateAppToken(ctx context.Context) error
- func (m *TokenManager) InvalidateChannelToken(ctx context.Context, channelID string) error
- func (m *TokenManager) RefreshToken(ctx context.Context, refreshToken string) (*TokenResponse, error)
- type TokenManagerConfig
- type TokenManagerError
- type TokenManagerLogger
- type TokenResponse
- type UpsertAppDataTableRowsParams
- type UpsertAppDataTableRowsResponse
- type WriteGroupMessageParams
- type WriteGroupMessageResult
- type WriteMessageDTO
Constants ¶
View Source
const ( DefaultAutoRegisterMaxAttempts = 3 DefaultAutoRegisterInitialBackoff = time.Second DefaultAutoRegisterMaxBackoff = 5 * time.Second )
View Source
const ( FunctionCreateAppDataTable = "createAppDataTable" FunctionCreateAppDataTableSchema = "createAppDataTableSchema" FunctionGetAppDataTableSchema = "getAppDataTableSchema" FunctionUpsertAppDataTableRows = "upsertAppDataTableRows" FunctionRegisterAppNotebooks = "registerAppNotebooks" FunctionGetAppNotebookVersions = "getAppNotebookVersions" )
View Source
const DefaultAppStoreURL = "https://app-store.channel.io"
View Source
const FunctionWriteGroupMessage = "writeGroupMessage"
Variables ¶
This section is empty.
Functions ¶
func AppDataTableFunctionSchema ¶
func AppDataTableFunctionSchema(name string) (appsdk.FunctionSchema, bool)
func AppDataTableFunctionSchemas ¶
func AppDataTableFunctionSchemas() []appsdk.FunctionSchema
func AppNotebookFunctionSchema ¶
func AppNotebookFunctionSchema(name string) (appsdk.FunctionSchema, bool)
func AppNotebookFunctionSchemas ¶
func AppNotebookFunctionSchemas() []appsdk.FunctionSchema
Types ¶
type AlfTaskVersion ¶
type AppDataTableColumn ¶
type AppDataTableSchema ¶
type AppDataTableSchema struct {
ChannelID string `json:"channelId,omitempty"`
AppID string `json:"appId,omitempty"`
TableName string `json:"tableName"`
Columns []AppDataTableColumn `json:"columns"`
PrimaryKeyColumns []string `json:"primaryKeyColumns,omitempty"`
}
type AppNotebookVersion ¶
type AutoRegisterConfig ¶
type AutoRegisterConfig struct {
App *appsdk.App
Targets []appsdk.ExtensionRegistration
AppID string
AppSecret string
AppStoreURL string
Client *Client
TokenManager *TokenManager
OnResult func([]AutoRegisterResult)
MaxAttempts int
InitialBackoff time.Duration
MaxBackoff time.Duration
}
type AutoRegisterResult ¶
type AutoRegistrar ¶
type AutoRegistrar struct {
// contains filtered or unexported fields
}
func NewAutoRegistrar ¶
func NewAutoRegistrar(config AutoRegisterConfig) *AutoRegistrar
func (*AutoRegistrar) Register ¶
func (r *AutoRegistrar) Register(ctx context.Context) []AutoRegisterResult
type CachedToken ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) CallAppFunction ¶
func (*Client) CallNativeFunction ¶ added in v0.15.0
func (c *Client) CallNativeFunction(ctx context.Context, accessToken, method string, params any) (json.RawMessage, error)
CallNativeFunction invokes a public AppStore Native Function and returns its raw JSON result. Use a channel-scoped token for Channel operations and an app token for app-owned operations.
func (*Client) CreateAppDataTable ¶
func (c *Client) CreateAppDataTable(ctx context.Context, accessToken string, params CreateAppDataTableParams) (*CreateAppDataTableResponse, error)
func (*Client) CreateAppDataTableSchema ¶
func (c *Client) CreateAppDataTableSchema(ctx context.Context, accessToken string, params CreateAppDataTableSchemaParams) (*CreateAppDataTableSchemaResponse, error)
func (*Client) CreateProxyAPI ¶ added in v0.15.0
CreateProxyAPI creates a typed Channel-operation client for a channel-scoped token.
func (*Client) GetAlfTaskVersions ¶
func (*Client) GetAppDataTableSchema ¶
func (c *Client) GetAppDataTableSchema(ctx context.Context, accessToken string, params GetAppDataTableSchemaParams) (*GetAppDataTableSchemaResponse, error)
func (*Client) GetAppNotebookVersions ¶
func (*Client) IssueToken ¶
func (c *Client) IssueToken(ctx context.Context, secret string, opts ...IssueTokenOptions) (*IssueTokenResponse, error)
func (*Client) RefreshToken ¶
func (*Client) RegisterAlfTasks ¶
func (*Client) RegisterAppNotebooks ¶
func (*Client) RegisterExtension ¶
func (*Client) UnregisterExtension ¶
func (*Client) UpsertAppDataTableRows ¶
func (c *Client) UpsertAppDataTableRows(ctx context.Context, accessToken string, params UpsertAppDataTableRowsParams) (*UpsertAppDataTableRowsResponse, error)
type CreateAppDataTableParams ¶
type CreateAppDataTableParams struct {
AppID string `json:"appId"`
TableName string `json:"tableName"`
Columns []AppDataTableColumn `json:"columns"`
PrimaryKeyColumns []string `json:"primaryKeyColumns,omitempty"`
}
type CreateAppDataTableResponse ¶
type CreateAppDataTableResponse struct {
RequestID string `json:"requestId"`
}
type CreateAppDataTableSchemaParams ¶
type CreateAppDataTableSchemaParams struct {
ChannelID string `json:"channelId"`
AppID string `json:"appId"`
TableName string `json:"tableName"`
Columns []AppDataTableColumn `json:"columns"`
PrimaryKeyColumns []string `json:"primaryKeyColumns,omitempty"`
}
type CreateAppDataTableSchemaResponse ¶
type CreateAppDataTableSchemaResponse struct {
RequestID string `json:"requestId"`
Schema *AppDataTableSchema `json:"schema,omitempty"`
}
type GetAlfTaskVersionsResponse ¶
type GetAlfTaskVersionsResponse struct {
Success bool `json:"success"`
ErrorMessage string `json:"errorMessage,omitempty"`
Tasks []AlfTaskVersion `json:"tasks"`
}
type GetAppDataTableSchemaResponse ¶
type GetAppDataTableSchemaResponse struct {
Schema *AppDataTableSchema `json:"schema,omitempty"`
}
type GetAppNotebookVersionsResponse ¶
type GetAppNotebookVersionsResponse struct {
Success bool `json:"success"`
ErrorMessage string `json:"errorMessage,omitempty"`
Notebooks []AppNotebookVersion `json:"notebooks"`
}
type InMemoryTokenCache ¶
type InMemoryTokenCache struct {
// contains filtered or unexported fields
}
func NewInMemoryTokenCache ¶
func NewInMemoryTokenCache() *InMemoryTokenCache
func (*InMemoryTokenCache) Delete ¶
func (c *InMemoryTokenCache) Delete(_ context.Context, key string) error
func (*InMemoryTokenCache) Get ¶
func (c *InMemoryTokenCache) Get(_ context.Context, key string) (*CachedToken, error)
func (*InMemoryTokenCache) Set ¶
func (c *InMemoryTokenCache) Set(_ context.Context, key string, token CachedToken, ttl time.Duration) error
func (*InMemoryTokenCache) Stats ¶
func (c *InMemoryTokenCache) Stats() (size int, keys []string)
type IssueTokenOptions ¶
type IssueTokenOptions struct {
ChannelID string
}
type IssueTokenResponse ¶
type ProxyAPI ¶ added in v0.15.0
type ProxyAPI struct {
// contains filtered or unexported fields
}
ProxyAPI exposes typed Channel operations using one channel-scoped access token. Create it with Client.CreateProxyAPI after obtaining the token from TokenManager.
func (*ProxyAPI) WriteGroupMessage ¶ added in v0.15.0
func (p *ProxyAPI) WriteGroupMessage(ctx context.Context, params WriteGroupMessageParams) (*WriteGroupMessageResult, error)
WriteGroupMessage writes a message with the installed app's bot profile.
type ProxyMessage ¶ added in v0.15.0
type RegisterAppNotebooksResponse ¶
type RegisterAppNotebooksResponse struct {
Success bool `json:"success"`
ErrorMessage string `json:"errorMessage,omitempty"`
SyncRunID string `json:"syncRunId,omitempty"`
Status string `json:"status,omitempty"`
TotalNotebooks int `json:"totalNotebooks"`
CreatedCount int `json:"createdCount"`
UpdatedCount int `json:"updatedCount"`
DeletedCount int `json:"deletedCount"`
}
type TokenCache ¶
type TokenManager ¶
type TokenManager struct {
// contains filtered or unexported fields
}
func NewTokenManager ¶
func NewTokenManager(config TokenManagerConfig) *TokenManager
func (*TokenManager) ClearCache ¶
func (m *TokenManager) ClearCache(ctx context.Context) error
func (*TokenManager) Client ¶
func (m *TokenManager) Client() *Client
func (*TokenManager) GetAppToken ¶
func (m *TokenManager) GetAppToken(ctx context.Context) (*TokenResponse, error)
func (*TokenManager) GetChannelToken ¶
func (m *TokenManager) GetChannelToken(ctx context.Context, channelID string) (*TokenResponse, error)
func (*TokenManager) InvalidateAppToken ¶
func (m *TokenManager) InvalidateAppToken(ctx context.Context) error
func (*TokenManager) InvalidateChannelToken ¶
func (m *TokenManager) InvalidateChannelToken(ctx context.Context, channelID string) error
func (*TokenManager) RefreshToken ¶
func (m *TokenManager) RefreshToken(ctx context.Context, refreshToken string) (*TokenResponse, error)
type TokenManagerConfig ¶
type TokenManagerConfig struct {
AppID string
AppSecret string
AppStoreURL string
Client *Client
Cache TokenCache
RefreshBuffer time.Duration
Debug bool
Logger TokenManagerLogger
}
type TokenManagerError ¶
func (*TokenManagerError) Error ¶
func (e *TokenManagerError) Error() string
func (*TokenManagerError) Unwrap ¶
func (e *TokenManagerError) Unwrap() error
type TokenManagerLogger ¶
type TokenResponse ¶
type TokenResponse = IssueTokenResponse
type WriteGroupMessageParams ¶ added in v0.15.0
type WriteGroupMessageParams struct {
ChannelID string `json:"channelId"`
GroupID string `json:"groupId"`
RootMessageID string `json:"rootMessageId,omitempty"`
Broadcast bool `json:"broadcast,omitempty"`
DTO WriteMessageDTO `json:"dto"`
}
type WriteGroupMessageResult ¶ added in v0.15.0
type WriteGroupMessageResult struct {
Message ProxyMessage `json:"message"`
}
type WriteMessageDTO ¶ added in v0.15.0
type WriteMessageDTO struct {
Blocks []map[string]any `json:"blocks,omitempty"`
PlainText string `json:"plainText,omitempty"`
Buttons []map[string]any `json:"buttons,omitempty"`
Files []map[string]any `json:"files,omitempty"`
WebPage map[string]any `json:"webPage,omitempty"`
Form map[string]any `json:"form,omitempty"`
Options []string `json:"options,omitempty"`
RequestID string `json:"requestId,omitempty"`
BotName string `json:"botName,omitempty"`
ManagerID string `json:"managerId,omitempty"`
UserID string `json:"userId,omitempty"`
CustomPayload map[string]any `json:"customPayload,omitempty"`
}
Click to show internal directories.
Click to hide internal directories.