The "auth routes" open question in GOALS.md conflated four unrelated things once the upstream routes and controllers were checked: logout and the passkey settings routes sit behind the same token_auth middleware as everything else this crate wraps, login needs a credential exchange since there's no token yet, refresh/refresh_react turned out to be the bulk sync-dump endpoint already parked as a separate open question, and connected_account is Gmail OAuth linking that belongs with Integrations. Adds logout, list_passkeys, delete_passkey (passkey registration is left out — it needs a WebAuthn ceremony a browser has to drive), and InvoiceNinjaClient::login as an associated function returning a lean LoginResponse that types only is_owner/is_admin/token and leaves the server's much larger nested payload in extra. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
35 lines
1.4 KiB
Rust
35 lines
1.4 KiB
Rust
use serde::{Deserialize, Serialize};
|
|
use serde_json::{Map, Value};
|
|
|
|
use super::CompanyToken;
|
|
|
|
/// Response of `POST /login` (via [`crate::InvoiceNinjaClient::login`]).
|
|
///
|
|
/// One entry per company the account can access. The full upstream payload
|
|
/// also nests the whole company (clients, invoices, designs, ...), the
|
|
/// user, and the account under each entry — this crate does not model that;
|
|
/// it stays reachable, losslessly, through [`LoginCompanyUser::extra`].
|
|
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
|
|
pub struct LoginResponse {
|
|
#[serde(default, deserialize_with = "super::common::null_to_default")]
|
|
pub data: Vec<LoginCompanyUser>,
|
|
}
|
|
|
|
/// One company membership returned by a login, carrying that company's API
|
|
/// token.
|
|
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
|
|
pub struct LoginCompanyUser {
|
|
#[serde(default, deserialize_with = "super::common::null_to_default")]
|
|
pub is_owner: bool,
|
|
#[serde(default, deserialize_with = "super::common::null_to_default")]
|
|
pub is_admin: bool,
|
|
/// The token to pass to [`InvoiceNinjaClient::new`](crate::InvoiceNinjaClient::new)
|
|
/// for this company. Only absent if the server ever omits the `token`
|
|
/// include; every server-side `first_load` request requests it.
|
|
#[serde(default)]
|
|
pub token: Option<CompanyToken>,
|
|
|
|
#[serde(flatten)]
|
|
pub extra: Map<String, Value>,
|
|
}
|