client

package
v0.0.0-...-24479a9 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package client implements the minimal Ghostfolio HTTP boundary used by this sync-and-storage slice. Authored by: OpenCode

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client executes the Ghostfolio auth and activities-history requests for this slice.

Authored by: OpenCode

func New

func New(httpClient *http.Client) *Client

New creates a Ghostfolio API client backed by the provided HTTP client.

Example:

transportClient := client.New(http.DefaultClient)
_ = transportClient

Authored by: OpenCode

func (*Client) Authenticate

func (c *Client) Authenticate(ctx context.Context, origin string, accessToken string) (dto.AuthResponse, error)

Authenticate executes the anonymous-auth boundary for this slice.

Example:

response, err := transportClient.Authenticate(ctx, "https://ghostfol.io", "token")
if err != nil {
	panic(err)
}
_ = response.AuthToken

Authored by: OpenCode

func (*Client) FetchActivitiesHistory

func (c *Client) FetchActivitiesHistory(
	ctx context.Context,
	origin string,
	authToken string,
) (dto.ActivityPageResponse, error)

FetchActivitiesHistory executes the paginated activities retrieval boundary for this slice.

Example:

response, err := transportClient.FetchActivitiesHistory(ctx, "https://ghostfol.io", "jwt")
if err != nil {
	panic(err)
}
_ = len(response.Activities)

Authored by: OpenCode

func (*Client) FetchUser

func (c *Client) FetchUser(ctx context.Context, origin string, authToken string) (dto.UserResponse, error)

FetchUser executes the authenticated user boundary for this slice.

Example:

response, err := transportClient.FetchUser(ctx, "https://ghostfol.io", "jwt")
if err != nil {
	panic(err)
}
_ = response.Settings

Authored by: OpenCode

type FailureCategory

type FailureCategory string

FailureCategory identifies one Ghostfolio boundary failure class without embedding application outcome wording.

Authored by: OpenCode

const (
	// FailureRejectedToken indicates that the anonymous-auth boundary rejected the
	// supplied token.
	FailureRejectedToken FailureCategory = "auth_rejected"

	// FailureTimeout indicates that the Ghostfolio request exceeded its runtime
	// deadline before a boundary response was available.
	FailureTimeout FailureCategory = "deadline_exceeded"

	// FailureConnectivityProblem indicates that a transport-level reachability
	// problem prevented the request from completing.
	FailureConnectivityProblem FailureCategory = "transport_error"

	// FailureUnsuccessfulServerResponse indicates a reachable server returned a
	// non-success HTTP response that does not prove contract incompatibility.
	FailureUnsuccessfulServerResponse FailureCategory = "unexpected_http_status"

	// FailureIncompatibleServerContract indicates that a reachable server returned
	// unsupported or contradictory contract behavior.
	FailureIncompatibleServerContract FailureCategory = "contract_incompatible"
)

type RequestFailure

type RequestFailure struct {
	Category   FailureCategory
	Operation  string
	StatusCode int
	Detail     string
	Err        error
}

RequestFailure captures structured Ghostfolio boundary failure data without exposing secrets or raw payload details.

Authored by: OpenCode

func (*RequestFailure) Error

func (e *RequestFailure) Error() string

Error returns the safe error string for the categorized request failure.

Example:

err := &client.RequestFailure{Category: client.FailureTimeout, Detail: "ghostfolio request deadline exceeded"}
_ = err.Error()

Authored by: OpenCode

func (*RequestFailure) Unwrap

func (e *RequestFailure) Unwrap() error

Unwrap returns the underlying cause for the categorized request failure.

Example:

err := &client.RequestFailure{Err: context.DeadlineExceeded}
_ = err.Unwrap()

Authored by: OpenCode

Jump to

Keyboard shortcuts

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