api

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package api implements the authenticated HTTP request layer for the Aura API. It handles OAuth token acquisition and refresh, URL construction, and error parsing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	ClientID     string
	ClientSecret string
	BaseURL      string
	APIVersion   string
	Timeout      time.Duration
	MaxRetry     int
	UserAgent    string // e.g. "aura-go-client/v1.8.0"; defaults to "aura-go-client" if empty
}

Config holds configuration for the API service.

type Error added in v1.6.0

type Error struct {
	StatusCode int           `json:"status_code"`
	Message    string        `json:"message"`
	Details    []ErrorDetail `json:"details,omitempty"`
}

Error represents an error response from the Aura API.

func (*Error) AllErrors added in v1.6.0

func (e *Error) AllErrors() []string

AllErrors returns all error messages as a slice.

func (*Error) Error added in v1.6.0

func (e *Error) Error() string

Error implements the error interface.

func (*Error) HasMultipleErrors added in v1.6.0

func (e *Error) HasMultipleErrors() bool

HasMultipleErrors returns true if there are multiple error details.

func (*Error) IsBadRequest added in v1.6.0

func (e *Error) IsBadRequest() bool

IsBadRequest returns true if the error is a 400.

func (*Error) IsNotFound added in v1.6.0

func (e *Error) IsNotFound() bool

IsNotFound returns true if the error is a 404.

func (*Error) IsUnauthorized added in v1.6.0

func (e *Error) IsUnauthorized() bool

IsUnauthorized returns true if the error is a 401.

type ErrorDetail added in v1.6.0

type ErrorDetail struct {
	Message string `json:"message"`
	Reason  string `json:"reason,omitempty"`
	Field   string `json:"field,omitempty"`
}

ErrorDetail represents individual error details.

type RequestService added in v1.6.0

type RequestService interface {
	Get(ctx context.Context, endpoint string) (*Response, error)
	Post(ctx context.Context, endpoint string, body string) (*Response, error)
	Put(ctx context.Context, endpoint string, body string) (*Response, error)
	Patch(ctx context.Context, endpoint string, body string) (*Response, error)
	Delete(ctx context.Context, endpoint string) (*Response, error)
}

RequestService defines the interface for making authenticated API requests. This is the middle layer that handles authentication and common API patterns.

func NewRequestService added in v1.6.0

func NewRequestService(cfg Config, logger *slog.Logger) RequestService

NewRequestService creates a new RequestService. It constructs its own HTTP transport layer internally — callers do not need to know about or create an httpclient.

type Response added in v1.6.0

type Response struct {
	StatusCode int
	Body       []byte
}

Response represents a response from the Aura API.

Jump to

Keyboard shortcuts

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