|
| 1 | +package integration |
| 2 | + |
| 3 | +import ( |
| 4 | + "context" |
| 5 | + "fmt" |
| 6 | + "net/url" |
| 7 | + |
| 8 | + "github.com/chatbotkit/go-sdk/internal/httpclient" |
| 9 | + "github.com/chatbotkit/go-sdk/internal/params" |
| 10 | + "github.com/chatbotkit/go-sdk/types" |
| 11 | +) |
| 12 | + |
| 13 | +// MicrosoftteamsClient provides access to Microsoft Teams integration resources. |
| 14 | +type MicrosoftteamsClient struct { |
| 15 | + httpClient *httpclient.Client |
| 16 | +} |
| 17 | + |
| 18 | +// NewMicrosoftteamsClient creates a new MicrosoftteamsClient. |
| 19 | +func NewMicrosoftteamsClient(httpClient *httpclient.Client) *MicrosoftteamsClient { |
| 20 | + return &MicrosoftteamsClient{httpClient: httpClient} |
| 21 | +} |
| 22 | + |
| 23 | +// List retrieves a list of Microsoft Teams integrations. |
| 24 | +func (c *MicrosoftteamsClient) List(ctx context.Context, opts *types.MicrosoftteamsIntegrationListParams) (*types.MicrosoftteamsIntegrationListResponse, error) { |
| 25 | + query := url.Values{} |
| 26 | + if opts != nil { |
| 27 | + query = params.BuildListQuery(opts.Cursor, opts.Order, opts.Take, opts.Meta) |
| 28 | + } |
| 29 | + |
| 30 | + var result types.MicrosoftteamsIntegrationListResponse |
| 31 | + if err := c.httpClient.Get(ctx, "/api/v1/integration/microsoftteams/list", query, &result); err != nil { |
| 32 | + return nil, err |
| 33 | + } |
| 34 | + return &result, nil |
| 35 | +} |
| 36 | + |
| 37 | +// Fetch retrieves a Microsoft Teams integration by ID. |
| 38 | +func (c *MicrosoftteamsClient) Fetch(ctx context.Context, microsoftteamsID string) (*types.MicrosoftteamsIntegrationFetchResponse, error) { |
| 39 | + path := fmt.Sprintf("/api/v1/integration/microsoftteams/%s/fetch", microsoftteamsID) |
| 40 | + |
| 41 | + var result types.MicrosoftteamsIntegrationFetchResponse |
| 42 | + if err := c.httpClient.Get(ctx, path, nil, &result); err != nil { |
| 43 | + return nil, err |
| 44 | + } |
| 45 | + return &result, nil |
| 46 | +} |
| 47 | + |
| 48 | +// Create creates a Microsoft Teams integration. |
| 49 | +func (c *MicrosoftteamsClient) Create(ctx context.Context, req types.MicrosoftteamsIntegrationCreateRequest) (*types.MicrosoftteamsIntegrationCreateResponse, error) { |
| 50 | + var result types.MicrosoftteamsIntegrationCreateResponse |
| 51 | + if err := c.httpClient.Post(ctx, "/api/v1/integration/microsoftteams/create", req, &result); err != nil { |
| 52 | + return nil, err |
| 53 | + } |
| 54 | + return &result, nil |
| 55 | +} |
| 56 | + |
| 57 | +// Update updates a Microsoft Teams integration. |
| 58 | +func (c *MicrosoftteamsClient) Update(ctx context.Context, microsoftteamsID string, req types.MicrosoftteamsIntegrationUpdateRequest) (*types.MicrosoftteamsIntegrationUpdateResponse, error) { |
| 59 | + path := fmt.Sprintf("/api/v1/integration/microsoftteams/%s/update", microsoftteamsID) |
| 60 | + |
| 61 | + var result types.MicrosoftteamsIntegrationUpdateResponse |
| 62 | + if err := c.httpClient.Post(ctx, path, req, &result); err != nil { |
| 63 | + return nil, err |
| 64 | + } |
| 65 | + return &result, nil |
| 66 | +} |
| 67 | + |
| 68 | +// Delete deletes a Microsoft Teams integration. |
| 69 | +func (c *MicrosoftteamsClient) Delete(ctx context.Context, microsoftteamsID string) (*types.MicrosoftteamsIntegrationDeleteResponse, error) { |
| 70 | + path := fmt.Sprintf("/api/v1/integration/microsoftteams/%s/delete", microsoftteamsID) |
| 71 | + |
| 72 | + var result types.MicrosoftteamsIntegrationDeleteResponse |
| 73 | + if err := c.httpClient.Post(ctx, path, types.MicrosoftteamsIntegrationDeleteRequest{}, &result); err != nil { |
| 74 | + return nil, err |
| 75 | + } |
| 76 | + return &result, nil |
| 77 | +} |
| 78 | + |
| 79 | +// Setup sets up a Microsoft Teams integration. |
| 80 | +func (c *MicrosoftteamsClient) Setup(ctx context.Context, microsoftteamsID string) (*types.MicrosoftteamsIntegrationSetupResponse, error) { |
| 81 | + path := fmt.Sprintf("/api/v1/integration/microsoftteams/%s/setup", microsoftteamsID) |
| 82 | + |
| 83 | + var result types.MicrosoftteamsIntegrationSetupResponse |
| 84 | + if err := c.httpClient.Post(ctx, path, types.MicrosoftteamsIntegrationSetupRequest{}, &result); err != nil { |
| 85 | + return nil, err |
| 86 | + } |
| 87 | + return &result, nil |
| 88 | +} |
| 89 | + |
| 90 | +// Initiate initiates a Microsoft Teams integration conversation. |
| 91 | +func (c *MicrosoftteamsClient) Initiate(ctx context.Context, microsoftteamsID string, req types.TeamsInitiateRequest) (*types.TeamsInitiateResponse, error) { |
| 92 | + path := fmt.Sprintf("/api/v1/integration/microsoftteams/%s/initiate", microsoftteamsID) |
| 93 | + |
| 94 | + var result types.TeamsInitiateResponse |
| 95 | + if err := c.httpClient.Post(ctx, path, req, &result); err != nil { |
| 96 | + return nil, err |
| 97 | + } |
| 98 | + return &result, nil |
| 99 | +} |
0 commit comments