Commit graph

7 commits

Author SHA1 Message Date
1fba43cf90 feat: add timezone support with automatic timestamp conversion
Add GetTimezone() API method and WithTimezone() client option.
When enabled, the client lazily fetches the server timezone on
first API call and converts all Timestamp fields in responses
using reflection-based struct walking.
2026-02-02 12:34:15 +01:00
96601980c3 fix: handle URLs already ending in /jsonrpc.php
NewClient() now detects when the provided URL already ends with
/jsonrpc.php and avoids appending it again. This prevents double-path
issues like /jsonrpc.php/jsonrpc.php.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 10:27:34 +01:00
f8daa20ddd feat: use random request IDs instead of sequential counter
Replace the atomic counter-based request ID generation with random
int64 values using math/rand/v2. This improves unpredictability and
avoids potential ID collisions across client instances or restarts.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 10:21:31 +01:00
192053952f Add WithAuthHeader for custom authentication header name
Support configuring a custom HTTP header name for authentication
(e.g., X-API-Auth instead of Authorization) for Kanboard servers
with specific proxy configurations that use alternative auth headers.

- Add headerName field to apiTokenAuth and basicAuth structs
- Add WithAuthHeader() fluent method to Client
- Auth methods pass custom header name when creating auth structs
- Add tests for custom header with API token, basic auth, and custom user

Closes kanboard-9wa

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 18:26:55 +01:00
10e2ecf47e Add optional API user support for token authentication
- Add user field to apiTokenAuth struct
- Add WithAPITokenUser(token, user) method for custom username
- Default to "jsonrpc" when no user specified (backward compatible)
- Add tests for custom user and empty user scenarios

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 17:55:31 +01:00
a56456cc00 Complete Client struct with fluent configuration
Add full client configuration with fluent builder pattern:

- WithTimeout(duration) - configurable request timeout
- WithLogger(slog.Logger) - optional debug logging
- DefaultTimeout constant (30 seconds)
- Default HTTP client with timeout on construction

All fluent methods return same client instance for chaining.
Client is thread-safe for concurrent use.

Closes: kanboard-api-uls
2026-01-15 18:14:22 +01:00
a486a73ce1 Implement JSON-RPC client foundation
Add core JSON-RPC 2.0 protocol implementation for Kanboard API:

- JSONRPCRequest/Response/Error structs with proper JSON tags
- Generic call() method for sending requests and parsing responses
- Thread-safe request ID generation using atomic.Int64
- Automatic /jsonrpc.php path appending to baseURL
- Support for subdirectory installations
- HTTP Basic Auth support (API token and username/password)
- Error handling for unauthorized/forbidden responses

Includes comprehensive tests with httptest mock server.

Closes: kanboard-api-2g1
2026-01-15 18:10:35 +01:00