Task 6: fluxer-api REST client #6

Closed
opened 2026-11-11 08:01:22 +00:00 by charles · 0 comments
Owner

Files:

  • Create: crates/fluxer-api/src/{lib.rs,client.rs,error.rs,auth.rs,instance.rs,messages.rs,users.rs,ratelimit.rs}
  • Test: crates/fluxer-api/tests/{auth.rs,messages.rs,ratelimit.rs} (wiremock)

Interfaces:

  • Produces: ApiClient::new(instance: Url, installation_id: Uuid) -> ApiClient; fn with_token(&self, token: SecretString) -> ApiClient; async fn discover(&self) -> Result<WellKnown> (GET {instance}/api/.well-known/fluxer); async fn login(&self, req: &LoginRequest) -> Result<LoginResponse> (POST /auth/login); async fn login_totp(&self, &MfaTotpRequest) -> Result<AuthToken> (POST /auth/login/mfa/totp); async fn logout(&self) (POST /auth/logout, 204); async fn me(&self) -> Result<UserPrivate> (GET /users/@me); async fn messages(&self, channel: Snowflake, q: &MessagesQuery) -> Result<Vec<Message>> (GET /channels/{id}/messages, newest first); async fn send_message(&self, channel, &SendMessageRequest) -> Result<Message>; async fn edit_message, async fn delete_message (204), async fn typing(&self, channel) (POST /channels/{id}/typing, 204 or 200 JSON ignored), async fn ack(&self, channel, message) (POST /channels/{cid}/messages/{mid}/ack).
  • ApiError enum: Unauthorized, CaptchaRequired { site_key: Option<String> } (error body code matching the fork's CaptchaRequiredError, see fork:fluxer_api/src/api/middleware/CaptchaMiddleware.ts:76-94), IpAuthorizationRequired, RateLimited { retry_after: Duration }, Http { status, code: Option<String>, message }, Transport(reqwest::Error), Decode(serde_json::Error).
  • Rate limiting: on 429 read retry-after (seconds, float) → wait once and retry idempotent GETs; non-idempotent calls surface RateLimited.

Plan: https://git.forked.io/charles/fluxer-native/src/branch/foundation/docs/superpowers/plans/2026-11-11-foundation.md (section "Task 6")

**Files:** - Create: `crates/fluxer-api/src/{lib.rs,client.rs,error.rs,auth.rs,instance.rs,messages.rs,users.rs,ratelimit.rs}` - Test: `crates/fluxer-api/tests/{auth.rs,messages.rs,ratelimit.rs}` (wiremock) **Interfaces:** - Produces: `ApiClient::new(instance: Url, installation_id: Uuid) -> ApiClient`; `fn with_token(&self, token: SecretString) -> ApiClient`; `async fn discover(&self) -> Result<WellKnown>` (`GET {instance}/api/.well-known/fluxer`); `async fn login(&self, req: &LoginRequest) -> Result<LoginResponse>` (`POST /auth/login`); `async fn login_totp(&self, &MfaTotpRequest) -> Result<AuthToken>` (`POST /auth/login/mfa/totp`); `async fn logout(&self)` (`POST /auth/logout`, 204); `async fn me(&self) -> Result<UserPrivate>` (`GET /users/@me`); `async fn messages(&self, channel: Snowflake, q: &MessagesQuery) -> Result<Vec<Message>>` (`GET /channels/{id}/messages`, newest first); `async fn send_message(&self, channel, &SendMessageRequest) -> Result<Message>`; `async fn edit_message`, `async fn delete_message` (204), `async fn typing(&self, channel)` (`POST /channels/{id}/typing`, 204 or 200 JSON ignored), `async fn ack(&self, channel, message)` (`POST /channels/{cid}/messages/{mid}/ack`). - `ApiError` enum: `Unauthorized`, `CaptchaRequired { site_key: Option<String> }` (error body `code` matching the fork's `CaptchaRequiredError`, see `fork:fluxer_api/src/api/middleware/CaptchaMiddleware.ts:76-94`), `IpAuthorizationRequired`, `RateLimited { retry_after: Duration }`, `Http { status, code: Option<String>, message }`, `Transport(reqwest::Error)`, `Decode(serde_json::Error)`. - Rate limiting: on 429 read `retry-after` (seconds, float) → wait once and retry idempotent GETs; non-idempotent calls surface `RateLimited`. --- Plan: https://git.forked.io/charles/fluxer-native/src/branch/foundation/docs/superpowers/plans/2026-11-11-foundation.md (section "Task 6")
charles added this to the Foundation milestone 2026-11-11 08:01:22 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
charles/fluxer-native#6
No description provided.