msapi

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetErrorCode

func GetErrorCode(err error) string

GetErrorCode returns the

Types

type BotFrameworkClient

type BotFrameworkClient struct {
	Client
}

BotFrameworkClient represents client to MS Graph API

func NewBotFrameworkClient

func NewBotFrameworkClient(config Config) *BotFrameworkClient

NewBotFrameworkClient creates MS Graph API client

func (*BotFrameworkClient) PostAdaptiveCardActivity

func (c *BotFrameworkClient) PostAdaptiveCardActivity(ctx context.Context, botID, chatID, card, updateID string) (string, error)

PostAdaptiveCardActivity sends an activity to the chat, content is AdaptiveCard

type Chat

type Chat struct {
	ID       string `json:"id"`
	TenantID string `json:"tenantId"`
	WebURL   string `json:"webUrl"`
}

Chat represents chat resource

type Client

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

Client represents generic MS API client

type Config

type Config struct {
	// AppID application id (uuid, for bots must be underlying app id, not bot's id)
	AppID string `toml:"app_id"`
	// AppSecret application secret token
	AppSecret string `toml:"app_secret"`
	// TenantID ms tenant id
	TenantID string `toml:"tenant_id"`
	// Region bot framework api AP region
	Region string `toml:"region"`
	// TeamsAppID represents Teams App ID
	TeamsAppID string `toml:"teams_app_id"`
	// contains filtered or unexported fields
}

Config represents MS Graph API and Bot API config

func (*Config) SetBaseURLs

func (c *Config) SetBaseURLs(token, graph, bot string)

SetBaseURLs is used to point MS Graph API to test servers

type GraphClient

type GraphClient struct {
	Client
}

GraphClient represents client to MS Graph API

func NewGraphClient

func NewGraphClient(config Config) *GraphClient

NewGraphClient creates MS Graph API client

func (*GraphClient) GetAppForTeam

func (c *GraphClient) GetAppForTeam(ctx context.Context, app *TeamsApp, teamID string) (*InstalledApp, error)

GetAppForTeam returns installedApp for a given app and user This call requires the permission `TeamsAppInstallation.ReadWriteSelfForTeam.All`. This is overkill as we're only reading. Resource Specific Consent is not enabled by default (still in preview) and we cannot rely on it. https://docs.microsoft.com/en-us/microsoftteams/platform/graph-api/rsc/resource-specific-consent

func (*GraphClient) GetAppForUser

func (c *GraphClient) GetAppForUser(ctx context.Context, app *TeamsApp, userID string) (*InstalledApp, error)

GetAppForUser returns installedApp for a given app and user

func (*GraphClient) GetChatForInstalledApp

func (c *GraphClient) GetChatForInstalledApp(ctx context.Context, userID, installationID string) (Chat, error)

GetChatForInstalledApp returns a chat between user and installed app

func (*GraphClient) GetTeamsApp

func (c *GraphClient) GetTeamsApp(ctx context.Context, teamsAppID string) (*TeamsApp, error)

GetTeamsApp returns the list of installed team apps

func (*GraphClient) GetUserByEmail

func (c *GraphClient) GetUserByEmail(ctx context.Context, email string) (*User, error)

GetUserByEmail searches a user by email

func (*GraphClient) GetUserByID

func (c *GraphClient) GetUserByID(ctx context.Context, id string) (*User, error)

GetUserByID returns a user by ID

func (*GraphClient) InstallAppForUser

func (c *GraphClient) InstallAppForUser(ctx context.Context, userID, teamAppID string) error

InstallAppForUser returns installed apps for user

func (*GraphClient) UninstallAppForUser

func (c *GraphClient) UninstallAppForUser(ctx context.Context, userID, teamAppID string) error

UninstallAppForUser returns installed apps for user

type InstalledApp

type InstalledApp struct {
	ID       string   `json:"id"`
	TeamsApp TeamsApp `json:"teamsApp"`
}

InstalledApp represents teamsAppInstallation resource

type PostActivityResponse

type PostActivityResponse struct {
	ID string `json:"id"`
}

PostActivityResponse represents json response with a single id field

type TeamsApp

type TeamsApp struct {
	ID                 string `json:"id"`
	ExternalID         string `json:"externalId"`
	DisplayName        string `json:"displayName"`
	DistributionMethod string `json:"distributionMethod"`
}

TeamsApp represents teamsApp resource

type Token

type Token struct {
	AccessToken string `json:"access_token"`
	ExpiresIn   int64  `json:"expires_in"`
}

Token represents utility struct used for parsing GetToken resposne

type User

type User struct {
	ID       string `json:"id"`
	Name     string `json:"displayName"`
	Mail     string `json:"mail"`
	JobTitle string `json:"jobTitle"`
}

User represents user resource

Jump to

Keyboard shortcuts

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