Documentation
¶
Overview ¶
Package api implements the New Expensify web API and device-session renewal.
Index ¶
- type Client
- func (c *Client) Authenticate(ctx context.Context) (config.Credentials, error)
- func (c *Client) Call(ctx context.Context, command string, params url.Values) (map[string]any, error)
- func (c *Client) Credentials() config.Credentials
- func (c *Client) Upload(ctx context.Context, command string, params url.Values, field, filePath string) (map[string]any, error)
- type Options
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
}
func (*Client) Authenticate ¶
Authenticate exchanges stored device credentials for a fresh session token.
func (*Client) Call ¶
func (c *Client) Call(ctx context.Context, command string, params url.Values) (map[string]any, error)
Call sends one command. An expired session is renewed and replayed once. Transport errors and server errors are never retried, since writes may succeed before a connection is lost.
func (*Client) Credentials ¶
func (c *Client) Credentials() config.Credentials
Credentials returns a snapshot of the current session, including renewals.
func (*Client) Upload ¶
func (c *Client) Upload(ctx context.Context, command string, params url.Values, field, filePath string) (map[string]any, error)
Upload sends a JPEG, PNG, or PDF receipt as streaming multipart data. A file is reopened on session renewal, and changes between attempts are rejected.
type Options ¶
type Options struct {
BaseURL string
HTTPClient *http.Client
Credentials config.Credentials
SaveCredentials func(config.Credentials) error
}
Options configures a client. SaveCredentials runs after successful renewal.