Add internal HTTP helpers to client.go:
- doRequest(ctx, method, path, body, result) for all API calls
- doGet, doPost, doPut, doDelete convenience methods
- Automatic authentication check before each request
- JSON marshaling of request body and unmarshaling of response
Retry logic with exponential backoff:
- Retries on HTTP 429 (Too Many Requests)
- Retries on HTTP 5xx (Server Errors)
- Retries on network errors (timeout, connection reset)
- Respects context cancellation during retry delays
- Configurable via RetryConfig (MaxRetries, BaseDelay, MaxDelay, Jitter)
Debug logging via slog for request/response tracking.
Closes checkvist-api-8u6
Add authentication methods to client.go:
- Authenticate(ctx) for explicit login
- AuthenticateWith2FA(ctx, token) for 2FA support
- refreshToken(ctx) for token renewal
- ensureAuthenticated(ctx) for auto-auth before requests
- CurrentUser(ctx) to get logged-in user info
- getToken() for thread-safe token access
Features:
- Token stored with expiry time (23h for safety margin)
- Auto-refresh when token expires within 1 hour
- Falls back to full authentication if refresh fails
- Thread-safe token access using RWMutex
- Sends token via X-Client-Token header
API endpoints used:
- POST /auth/login.json?version=2
- POST /auth/refresh_token.json?version=2
- GET /auth/curr_user.json
Closes checkvist-api-lpn