client

package
v1.7.2 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package client is the thin HTTP consumer SDK for the Hanzo Notify service. Targets the /v1/notify/* surface notifyd exposes; every method maps 1:1 to one HTTP endpoint with no client-side fan-out.

Auth is bearer-token: callers provide a Hanzo IAM JWT (via WithToken) which notifyd validates against IAM's JWKS.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Status int
	Body   string
}

APIError is returned for non-2xx HTTP responses. Routes layer encodes a JSON error envelope; this preserves the raw body for callers that want to inspect provider-specific failure detail.

func (*APIError) Error

func (e *APIError) Error() string

type Client

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

Client is the canonical HTTP consumer SDK.

func New

func New(baseURL string, opts ...Option) (*Client, error)

New returns a Client targeting baseURL (e.g. "https://notify.hanzo.ai"). baseURL is parsed once at construction; an invalid URL returns an error rather than panicking later in a Send call.

func (*Client) Message

func (c *Client) Message(ctx context.Context, id string) (*types.Message, error)

Message fetches the persisted record by id.

func (*Client) Providers

func (c *Client) Providers(ctx context.Context) ([]types.Provider, error)

Providers lists the configured providers for the authenticated tenant.

func (*Client) Send

func (c *Client) Send(ctx context.Context, req types.SendRequest, sync bool) (*types.SendResponse, error)

Send dispatches one notification. With sync=false (the default async mode) notifyd enqueues a hanzoai/tasks workflow and returns a task_id immediately; with sync=true notifyd blocks until the provider either accepts the message or returns an error.

func (*Client) Templates

func (c *Client) Templates(ctx context.Context) ([]types.Template, error)

Templates lists the configured templates for the authenticated tenant.

type Option

type Option func(*Client)

Option configures a Client at construction time.

func WithHTTPClient

func WithHTTPClient(h *http.Client) Option

WithHTTPClient swaps the underlying http.Client (e.g. for retries, tracing, or test fakes).

func WithToken

func WithToken(jwt string) Option

WithToken sets the IAM JWT used for the Authorization header.

Jump to

Keyboard shortcuts

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