msteams

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 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 // HttpClient executes the underlying HTTP request.
}

Client sends messages to Microsoft Teams via webhook.

func New

func New(headers map[string]string, skipTLS bool) *Client

New creates a new MS Teams client with optional headers and TLS control.

Parameters:

  • headers: Optional HTTP headers (e.g. Authorization, Content-Type).
  • skipTLS: If true, disables TLS certificate validation.

Returns:

  • *Client: A ready-to-use Teams sender.

func (*Client) Send

func (c *Client) Send(ctx context.Context, message MSTeams, webhookURL string) (string, error)

Send delivers the provided message to the specified Teams webhook URL.

Parameters:

  • ctx: Request-scoped context.
  • message: Message payload with title and text.
  • webhookURL: Fully qualified MS Teams webhook endpoint.

Returns:

  • string: Success text if response is HTTP 200.
  • error: If marshalling, sending, or decoding fails.

type MSTeams

type MSTeams struct {
	Title string `json:"title"` // Title is the main heading of the message card.
	Text  string `json:"text"`  // Text is the body content of the message card.
}

MSTeams defines the payload structure for a Microsoft Teams message.

type Sender

type Sender interface {
	// Send transmits the message to the given MS Teams webhook.
	//
	// Parameters:
	//   - ctx: Context for timeout or cancellation.
	//   - message: Structured payload with title and text.
	//   - webhookURL: Microsoft Teams webhook destination.
	//
	// Returns:
	//   - string: Success confirmation message.
	//   - error: If sending or response fails.
	Send(ctx context.Context, message MSTeams, webhookURL string) (string, error)
}

Sender is implemented by types capable of sending Microsoft Teams messages.

Jump to

Keyboard shortcuts

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