sdk

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package sdk provides core SDK interfaces for the Basecamp API client.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CredentialStore

type CredentialStore interface {
	// Load retrieves credentials for the given origin (e.g., "https://3.basecampapi.com").
	Load(origin string) (*Credentials, error)

	// Save stores credentials for the given origin.
	Save(origin string, creds *Credentials) error

	// Delete removes credentials for the given origin.
	Delete(origin string) error
}

CredentialStore provides persistent storage for OAuth credentials. Implementations can use keychain, file storage, or other backends.

type Credentials

type Credentials struct {
	AccessToken   string `json:"access_token"`
	RefreshToken  string `json:"refresh_token,omitempty"`
	ExpiresAt     int64  `json:"expires_at,omitempty"`
	TokenEndpoint string `json:"token_endpoint,omitempty"`
	OAuthType     string `json:"oauth_type,omitempty"` // "bc3" or "launchpad"
	Scope         string `json:"scope,omitempty"`
	UserID        string `json:"user_id,omitempty"`
}

Credentials holds OAuth tokens and metadata.

type EnvTokenSource

type EnvTokenSource struct {
	EnvVar string // Environment variable name (default: BASECAMP_TOKEN)
}

EnvTokenSource returns a token from an environment variable. Useful for CI/CD or testing where OAuth flow isn't available.

func (*EnvTokenSource) Refresh

func (s *EnvTokenSource) Refresh(ctx context.Context) error

Refresh is a no-op for environment tokens.

func (*EnvTokenSource) Token

func (s *EnvTokenSource) Token(ctx context.Context) (string, error)

Token returns the token from the environment variable.

type StaticTokenSource

type StaticTokenSource struct {
	AccessToken string
}

StaticTokenSource provides a fixed token. Useful for testing.

func (*StaticTokenSource) Refresh

func (s *StaticTokenSource) Refresh(ctx context.Context) error

Refresh is a no-op for static tokens.

func (*StaticTokenSource) Token

func (s *StaticTokenSource) Token(ctx context.Context) (string, error)

Token returns the static token.

type StoreError

type StoreError struct {
	Operation string // "load", "save", "delete"
	Origin    string
	Message   string
	Cause     error
}

StoreError indicates a credential storage error.

func (*StoreError) Error

func (e *StoreError) Error() string

func (*StoreError) Unwrap

func (e *StoreError) Unwrap() error

type TokenError

type TokenError struct {
	Message string
	Cause   error
}

TokenError indicates a token sourcing error.

func (*TokenError) Error

func (e *TokenError) Error() string

func (*TokenError) Unwrap

func (e *TokenError) Unwrap() error

type TokenSource

type TokenSource interface {
	// Token returns a valid access token.
	// Implementations should handle token refresh automatically.
	Token(ctx context.Context) (string, error)

	// Refresh forces a token refresh, invalidating any cached token.
	Refresh(ctx context.Context) error
}

TokenSource provides access tokens for API authentication. Implementations handle token acquisition, caching, and refresh.

Directories

Path Synopsis
Package errors provides SDK error types without CLI-specific hints.
Package errors provides SDK error types without CLI-specific hints.

Jump to

Keyboard shortcuts

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