msteamsgraph

package
v0.17.6 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	HttpClient utils.HTTPDoer // HTTP client for sending requests
}

Client posts messages using the Microsoft Graph API.

func New

func New(opts ...Option) *Client

New returns a new Client with optional configuration.

func NewWithToken

func NewWithToken(token string, opts ...Option) *Client

NewWithToken returns a Teams client configured with a bearer token.

func (*Client) SendChannel

func (c *Client) SendChannel(ctx context.Context, teamID, channelID string, msg Message) (*Response, error)

SendChannel sends a message to a Teams channel via Microsoft Graph API.

teamID: ID of the team. channelID: ID of the channel inside the team.

type Error

type Error struct {
	Code       string `json:"code"`       // Error code
	Message    string `json:"message"`    // Error message
	InnerError any    `json:"innerError"` // Optional nested error
}

Error represents Graph API error details.

type ItemBody

type ItemBody struct {
	ContentType string `json:"contentType"` // e.g., "html"
	Content     string `json:"content"`     // Message body
}

ItemBody wraps the message content in HTML format.

type Message

type Message struct {
	Body ItemBody `json:"body"` // Body contains the message content.
}

Message represents the payload structure for a Teams message.

type Option

type Option func(*Client)

Option configures the Teams client.

func WithHeaders

func WithHeaders(headers map[string]string) Option

WithHeaders adds custom headers to the request.

func WithInsecureTLS

func WithInsecureTLS(skipInsecure bool) Option

WithInsecureTLS disables TLS certificate verification.

type Response

type Response struct {
	ID      string `json:"id,omitempty"`      // ID of the message
	WebURL  string `json:"webUrl,omitempty"`  // Web link to the posted message
	Error   *Error `json:"error,omitempty"`   // Optional error object
	Message string `json:"message,omitempty"` // Sometimes returned on failure
}

Response represents a simplified Graph API response.

func (*Response) ErrorOrMessage

func (r *Response) ErrorOrMessage() string

ErrorOrMessage returns a formatted error string from the Graph API response.

type Sender

type Sender interface {
	SendChannel(ctx context.Context, teamID, channelID string, msg Message) (*Response, error)
}

Sender defines methods to send messages via Microsoft Graph.

Jump to

Keyboard shortcuts

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