msteams

package
v0.15.2 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2025 License: Apache-2.0 Imports: 7 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(opts ...Option) *Client

New creates a new MS Teams client with functional options.

Use options like WithHeaders or WithInsecureTLS to customize behavior.

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 or non-200 is returned.

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 Option added in v0.9.4

type Option func(*Client)

Option configures a MSTeams client.

func WithHeaders added in v0.9.4

func WithHeaders(headers map[string]string) Option

WithHeaders sets additional HTTP headers for the MS Teams client.

func WithInsecureTLS added in v0.9.4

func WithInsecureTLS(skipInsecure bool) Option

WithInsecureTLS sets whether to skip TLS certificate verification.

type Sender

type Sender interface {
	// Send transmits the message to the given MS Teams webhook.
	//
	// Returns a confirmation or error on failure.
	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