use serde::{Deserialize, Serialize};
use serde_json::Value;
pub type TokenPurpose = String;
pub type ParentGroup = String;
pub type PermissionScope = String;
#[derive(Clone, Deserialize)]
#[non_exhaustive]
pub struct AuthResponse {
pub token: String,
#[serde(default)]
pub token_type: Option<String>,
#[serde(default)]
pub expires: Option<i64>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
impl std::fmt::Debug for AuthResponse {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("AuthResponse")
.field("token", &"[redacted]")
.field("token_type", &self.token_type)
.field("expires", &self.expires)
.field("extra", &self.extra)
.finish()
}
}
#[derive(Clone, Deserialize)]
#[non_exhaustive]
pub struct TokenResponse {
pub token: String,
pub token_type: TokenPurpose,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
impl std::fmt::Debug for TokenResponse {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("TokenResponse")
.field("token", &"[redacted]")
.field("token_type", &self.token_type)
.field("extra", &self.extra)
.finish()
}
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct UserResponse {
pub merchant_id: String,
pub name: String,
pub email: String,
pub role_id: String,
pub is_two_factor_auth_setup: bool,
pub profile_id: String,
pub entity_type: String,
pub version: String,
#[serde(default)]
pub verification_days_left: Option<i64>,
#[serde(default)]
pub recovery_codes_left: Option<i64>,
#[serde(default)]
pub theme_id: Option<String>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct LoginHistoryEntry {
pub id: String,
pub event_type: String,
pub auth_method: String,
pub created_at: String,
#[serde(default)]
pub failure_reason: Option<String>,
#[serde(default)]
pub ip_address: Option<String>,
#[serde(default)]
pub user_agent: Option<String>,
#[serde(default)]
pub country_code: Option<String>,
#[serde(default)]
pub city: Option<String>,
#[serde(default)]
pub latitude: Option<f64>,
#[serde(default)]
pub longitude: Option<f64>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct LoginHistoryResponse {
pub entries: Vec<LoginHistoryEntry>,
pub total_count: i64,
pub offset: i64,
pub limit: i64,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct UserSessionEntry {
pub id: String,
pub auth_method: String,
pub created_at: String,
pub last_seen_at: String,
pub expires_at: String,
pub is_current: bool,
#[serde(default)]
pub ip_address: Option<String>,
#[serde(default)]
pub user_agent: Option<String>,
#[serde(default)]
pub country_code: Option<String>,
#[serde(default)]
pub city: Option<String>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct UserSessionListResponse {
pub sessions: Vec<UserSessionEntry>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct UserSessionRevokeResponse {
pub revoked: bool,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Clone, Deserialize)]
#[non_exhaustive]
pub struct InviteUsersResponse {
pub email: String,
pub is_email_sent: bool,
#[serde(default)]
pub password: Option<String>,
#[serde(default)]
pub error: Option<String>,
#[serde(default)]
pub link_expires_at: Option<String>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
impl std::fmt::Debug for InviteUsersResponse {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("InviteUsersResponse")
.field("email", &self.email)
.field("is_email_sent", &self.is_email_sent)
.field("password", &self.password.as_ref().map(|_| "[redacted]"))
.field("error", &self.error)
.field("link_expires_at", &self.link_expires_at)
.field("extra", &self.extra)
.finish()
}
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct MinimalRoleInfo {
pub role_id: String,
pub role_name: String,
#[serde(default)]
pub entity_type: Option<String>,
#[serde(default)]
pub profile_id: Option<String>,
#[serde(default)]
pub project_id: Option<String>,
#[serde(default)]
pub can_impersonate: Option<bool>,
#[serde(default)]
pub expires_at: Option<String>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct UserInLineage {
pub user_id: String,
pub email: String,
pub roles: Vec<MinimalRoleInfo>,
#[serde(default)]
pub permission_overrides: Vec<PermissionOverride>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct ReInviteUserResponse {
pub link_expires_at: String,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct RoleEntityRef {
pub id: String,
#[serde(default)]
pub name: Option<String>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct GetUserRoleDetailsResponse {
pub role_id: String,
pub org: RoleEntityRef,
#[serde(default)]
pub merchant: Option<RoleEntityRef>,
#[serde(default)]
pub profile: Option<RoleEntityRef>,
#[serde(default)]
pub project: Option<RoleEntityRef>,
pub status: String,
pub entity_type: String,
pub role_name: String,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct ParentGroupInfo {
pub name: ParentGroup,
pub resources: Vec<String>,
pub scopes: Vec<PermissionScope>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Clone, Deserialize)]
#[non_exhaustive]
pub struct TotpSecret {
pub secret: String,
pub totp_url: String,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
impl std::fmt::Debug for TotpSecret {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("TotpSecret")
.field("secret", &"[redacted]")
.field("totp_url", &"[redacted]")
.field("extra", &self.extra)
.finish()
}
}
#[derive(Clone, Deserialize)]
#[non_exhaustive]
pub struct TotpResponse {
#[serde(default)]
pub secret: Option<TotpSecret>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
impl std::fmt::Debug for TotpResponse {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("TotpResponse")
.field("secret", &self.secret.as_ref().map(|_| "[redacted]"))
.field("extra", &self.extra)
.finish()
}
}
#[derive(Clone, Deserialize)]
#[non_exhaustive]
pub struct RecoveryCodesResponse {
pub recovery_codes: Vec<String>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
impl std::fmt::Debug for RecoveryCodesResponse {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("RecoveryCodesResponse")
.field("recovery_codes", &"[redacted]")
.field("recovery_codes_len", &self.recovery_codes.len())
.field("extra", &self.extra)
.finish()
}
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct PhoneOtpResponse {
pub message: String,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct PhoneOtpVerifyResponse {
pub verified: bool,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct DashboardOAuthProvidersResponse {
#[serde(default)]
pub available: Vec<String>,
#[serde(default)]
pub linked: Vec<String>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Clone, Deserialize)]
#[non_exhaustive]
pub struct DashboardOAuthStartResponse {
pub authorization_url: String,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
impl std::fmt::Debug for DashboardOAuthStartResponse {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("DashboardOAuthStartResponse")
.field("authorization_url", &"[redacted]")
.field("extra", &self.extra)
.finish()
}
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct UserPreferenceResponse {
pub key: String,
#[serde(default)]
pub value: Option<serde_json::Map<String, Value>>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct DashboardTourResponse {
pub scope: DashboardTourScope,
pub auto_offer: bool,
pub offer_source: String,
pub merchant_default: bool,
#[serde(default)]
pub progress: Option<TourProgress>,
pub access: DashboardTourAccess,
pub read_only: bool,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct DashboardTourScope {
pub merchant_id: String,
#[serde(default)]
pub profile_id: Option<String>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct DashboardTourAccess {
#[serde(default)]
pub current: Vec<TourAccessGroup>,
#[serde(default)]
pub acknowledged: Option<Vec<TourAccessGroup>>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct TourAccessGroup {
pub name: ParentGroup,
#[serde(default)]
pub scopes: Vec<PermissionScope>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[non_exhaustive]
pub struct TourProgress {
#[serde(default)]
pub completed: Vec<String>,
#[serde(default)]
pub skipped: Vec<String>,
#[serde(default)]
pub offer_handled_at: Option<String>,
#[serde(default)]
pub active: Option<TourActive>,
#[serde(default)]
pub baseline: Option<TourBaseline>,
}
impl TourProgress {
pub fn new() -> Self {
Self::default()
}
#[must_use]
pub fn completed(mut self, completed: Vec<String>) -> Self {
self.completed = completed;
self
}
#[must_use]
pub fn skipped(mut self, skipped: Vec<String>) -> Self {
self.skipped = skipped;
self
}
#[must_use]
pub fn offer_handled_at(mut self, offer_handled_at: impl Into<String>) -> Self {
self.offer_handled_at = Some(offer_handled_at.into());
self
}
#[must_use]
pub fn active(mut self, active: TourActive) -> Self {
self.active = Some(active);
self
}
#[must_use]
pub fn baseline(mut self, baseline: TourBaseline) -> Self {
self.baseline = Some(baseline);
self
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[non_exhaustive]
pub struct TourActive {
pub kind: String,
#[serde(default)]
pub step_id: Option<String>,
#[serde(default)]
pub baseline: Option<TourBaseline>,
}
impl TourActive {
pub fn new(kind: impl Into<String>) -> Self {
Self {
kind: kind.into(),
step_id: None,
baseline: None,
}
}
#[must_use]
pub fn step_id(mut self, step_id: impl Into<String>) -> Self {
self.step_id = Some(step_id.into());
self
}
#[must_use]
pub fn baseline(mut self, baseline: TourBaseline) -> Self {
self.baseline = Some(baseline);
self
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[non_exhaustive]
pub struct TourBaseline {
pub kind: String,
pub value: String,
}
impl TourBaseline {
pub fn new(kind: impl Into<String>, value: impl Into<String>) -> Self {
Self {
kind: kind.into(),
value: value.into(),
}
}
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct RolePaymentVisibilityPolicy {
#[serde(default)]
pub payment_methods: Option<String>,
#[serde(default)]
pub payment_processors: Option<String>,
#[serde(default)]
pub processor_exceptions: Vec<ProcessorVisibilityException>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct ProcessorVisibilityException {
pub processor: String,
pub access: String,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct RoleConnectorGrantResponse {
pub role_id: String,
pub restricted: bool,
#[serde(default)]
pub connectors: Vec<RoleConnectorGrantEntry>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct RoleConnectorGrantEntry {
pub merchant_connector_id: String,
pub created_by: String,
#[serde(default)]
pub reason: Option<String>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[non_exhaustive]
pub struct PermissionOverride {
pub area: ParentGroup,
pub level: String,
}
impl PermissionOverride {
pub fn new(area: impl Into<String>, level: impl Into<String>) -> Self {
Self {
area: area.into(),
level: level.into(),
}
}
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct ChangeMemberScopeResponse {
pub role_id: String,
pub entity_type: String,
#[serde(default)]
pub profile_ids: Vec<String>,
#[serde(default)]
pub project_ids: Vec<String>,
pub sessions_revoked: bool,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct UpdateMemberExpiryResponse {
#[serde(default)]
pub expires_at: Option<String>,
pub roles_updated: u64,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct TeamMemberDetailsResponse {
pub user_id: String,
pub email: String,
pub name: String,
#[serde(default)]
pub phone_number: Option<String>,
pub is_verified: bool,
pub status: String,
pub two_factor: String,
pub created_at: String,
#[serde(default)]
pub last_password_modified_at: Option<String>,
#[serde(default)]
pub roles: Vec<MinimalRoleInfo>,
pub can_reset_password: bool,
#[serde(default)]
pub pending_invitation: bool,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Clone, Deserialize)]
#[non_exhaustive]
pub struct InviteLinkResponse {
pub availability: String,
#[serde(default)]
pub link: Option<String>,
#[serde(default)]
pub expires_at: Option<String>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
impl std::fmt::Debug for InviteLinkResponse {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("InviteLinkResponse")
.field("availability", &self.availability)
.field("link", &self.link.as_ref().map(|_| "[redacted]"))
.field("expires_at", &self.expires_at)
.field("extra", &self.extra)
.finish()
}
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct TeamMemberContactProfileResponse {
pub tenant_id: String,
pub merchant_id: String,
pub user_id: String,
pub revision: String,
pub contacts: TeamMemberContacts,
#[serde(default)]
pub notes: Vec<TeamMemberNote>,
pub can_edit: bool,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[non_exhaustive]
pub struct TeamMemberContacts {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub discord_name: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub discord_id: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub telegram_username: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub contact_phone: Option<String>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub extra_channels: Vec<TeamMemberContactChannel>,
}
impl TeamMemberContacts {
pub fn new() -> Self {
Self::default()
}
#[must_use]
pub fn discord_name(mut self, discord_name: impl Into<String>) -> Self {
self.discord_name = Some(discord_name.into());
self
}
#[must_use]
pub fn discord_id(mut self, discord_id: impl Into<String>) -> Self {
self.discord_id = Some(discord_id.into());
self
}
#[must_use]
pub fn telegram_username(mut self, telegram_username: impl Into<String>) -> Self {
self.telegram_username = Some(telegram_username.into());
self
}
#[must_use]
pub fn contact_phone(mut self, contact_phone: impl Into<String>) -> Self {
self.contact_phone = Some(contact_phone.into());
self
}
#[must_use]
pub fn extra_channels(mut self, extra_channels: Vec<TeamMemberContactChannel>) -> Self {
self.extra_channels = extra_channels;
self
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[non_exhaustive]
pub struct TeamMemberContactChannel {
pub kind: String,
pub label: String,
pub value: String,
}
impl TeamMemberContactChannel {
pub fn new(
kind: impl Into<String>,
label: impl Into<String>,
value: impl Into<String>,
) -> Self {
Self {
kind: kind.into(),
label: label.into(),
value: value.into(),
}
}
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct TeamMemberNote {
pub note_id: String,
pub body: String,
pub created_by: TeamMemberNoteActor,
pub last_edited_by: TeamMemberNoteActor,
pub created_at: String,
pub last_edited_at: String,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct TeamMemberNoteActor {
pub user_id: String,
pub name: String,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Clone, Deserialize)]
#[non_exhaustive]
pub struct ResetTeamMemberPasswordResponse {
pub user_id: String,
pub temporary_password: String,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
impl std::fmt::Debug for ResetTeamMemberPasswordResponse {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("ResetTeamMemberPasswordResponse")
.field("user_id", &self.user_id)
.field("temporary_password", &"[redacted]")
.field("extra", &self.extra)
.finish()
}
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct MemberMethodAccessResponse {
pub user_id: String,
pub all_methods: bool,
#[serde(default)]
pub methods: Vec<String>,
pub revision: String,
pub can_edit: bool,
pub grant_all: bool,
#[serde(default)]
pub grantable: Vec<String>,
#[serde(default)]
pub options: Vec<MethodAccessOption>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct MethodAccessOption {
pub key: String,
pub label: String,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct MemberPermissionOverridesResponse {
pub user_id: String,
pub entity_type: String,
#[serde(default)]
pub roles: Vec<MemberPermissionRole>,
#[serde(default)]
pub areas: Vec<MemberPermissionArea>,
#[serde(default)]
pub overrides: Vec<PermissionOverride>,
pub revision: String,
pub can_edit: bool,
#[serde(default)]
pub refusal: Option<Value>,
pub can_raise: bool,
#[serde(default)]
pub modified_by: Option<String>,
#[serde(default)]
pub modified_at: Option<String>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct MemberPermissionRole {
pub role_id: String,
pub role_name: String,
#[serde(default)]
pub profile_id: Option<String>,
#[serde(default)]
pub project_id: Option<String>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct MemberPermissionArea {
pub area: ParentGroup,
#[serde(default)]
pub available_levels: Vec<String>,
pub role_level: String,
#[serde(default)]
pub override_level: Option<String>,
pub effective_level: String,
pub grantable_level: String,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[non_exhaustive]
pub struct InvitationLinkRestrictions {
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub ip_ranges: Vec<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub country_rule: Option<String>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub countries: Vec<String>,
}
impl InvitationLinkRestrictions {
pub fn new() -> Self {
Self::default()
}
#[must_use]
pub fn ip_ranges(mut self, ip_ranges: Vec<String>) -> Self {
self.ip_ranges = ip_ranges;
self
}
#[must_use]
pub fn countries(mut self, country_rule: impl Into<String>, countries: Vec<String>) -> Self {
self.country_rule = Some(country_rule.into());
self.countries = countries;
self
}
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct InvitationLinkResponse {
pub id: String,
pub name: String,
pub target: String,
#[serde(default)]
pub profile_id: Option<String>,
#[serde(default)]
pub project_id: Option<String>,
#[serde(default)]
pub target_name: Option<String>,
pub role_id: String,
pub role_name: String,
pub max_uses: i32,
pub use_count: i32,
pub remaining: i32,
pub expires_at: String,
#[serde(default)]
pub member_expires_at: Option<String>,
#[serde(default)]
pub restrictions: InvitationLinkRestrictions,
pub status: String,
pub created_by: String,
#[serde(default)]
pub created_by_name: Option<String>,
pub created_at: String,
pub modified_at: String,
#[serde(default)]
pub revoked_at: Option<String>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Clone, Deserialize)]
#[non_exhaustive]
pub struct CreateInvitationLinkResponse {
#[serde(flatten)]
pub link: InvitationLinkResponse,
pub token: String,
}
impl std::fmt::Debug for CreateInvitationLinkResponse {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("CreateInvitationLinkResponse")
.field("link", &self.link)
.field("token", &"[redacted]")
.finish()
}
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct ListInvitationLinksResponse {
#[serde(default)]
pub links: Vec<InvitationLinkResponse>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct InvitationLinkPreviewResponse {
pub status: String,
#[serde(default)]
pub merchant_name: Option<String>,
#[serde(default)]
pub target: Option<String>,
#[serde(default)]
pub target_name: Option<String>,
#[serde(default)]
pub role_id: Option<String>,
#[serde(default)]
pub role_name: Option<String>,
#[serde(default)]
pub expires_at: Option<String>,
#[serde(default)]
pub member_expires_at: Option<String>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct JoinInvitationLinkResponse {
pub outcome: String,
pub org_id: String,
pub merchant_id: String,
pub target: String,
#[serde(default)]
pub profile_id: Option<String>,
#[serde(default)]
pub project_id: Option<String>,
#[serde(default)]
pub target_name: Option<String>,
pub role_id: String,
pub role_name: String,
#[serde(default)]
pub member_expires_at: Option<String>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Clone, Deserialize)]
#[non_exhaustive]
pub struct JoinInvitationLinkPreAuthResponse {
#[serde(flatten)]
pub join: JoinInvitationLinkResponse,
pub token: String,
pub token_type: TokenPurpose,
}
impl std::fmt::Debug for JoinInvitationLinkPreAuthResponse {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("JoinInvitationLinkPreAuthResponse")
.field("join", &self.join)
.field("token", &"[redacted]")
.field("token_type", &self.token_type)
.finish()
}
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct RegisterThroughInvitationLinkResponse {
pub is_email_sent: bool,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[cfg(test)]
mod tests {
use super::*;
fn de<T: serde::de::DeserializeOwned>(json: &str) -> T {
serde_json::from_str(json).expect("fixture deserializes")
}
#[test]
fn auth_response_debug_redacts_the_token() {
let res: AuthResponse =
de(r#"{"token":"jwt-super-secret","token_type":"bearer","expires":3600}"#);
let rendered = format!("{res:?}");
assert!(!rendered.contains("jwt-super-secret"), "{rendered}");
assert!(rendered.contains("bearer"), "{rendered}");
assert!(rendered.contains("3600"), "{rendered}");
}
#[test]
fn auth_response_keeps_unknown_fields_in_extra() {
let res: AuthResponse = de(r#"{"token":"t","brand_new_field":"kept"}"#);
assert_eq!(res.extra["brand_new_field"], "kept");
assert_eq!(res.token_type, None);
}
#[test]
fn token_response_debug_redacts_the_token() {
let res: TokenResponse = de(r#"{"token":"spt-super-secret","token_type":"totp"}"#);
let rendered = format!("{res:?}");
assert!(!rendered.contains("spt-super-secret"), "{rendered}");
assert!(rendered.contains("totp"), "{rendered}");
}
#[test]
fn invite_users_response_debug_redacts_the_password() {
let res: InviteUsersResponse = de(
r#"{"email":"bob@example.com","is_email_sent":false,"password":"temp-pw-1234","error":"smtp down"}"#,
);
let rendered = format!("{res:?}");
assert!(!rendered.contains("temp-pw-1234"), "{rendered}");
assert!(rendered.contains("bob@example.com"), "{rendered}");
assert!(rendered.contains("smtp down"), "{rendered}");
assert!(rendered.contains("Some("), "{rendered}");
}
#[test]
fn invite_users_response_debug_shows_none_when_no_password() {
let res: InviteUsersResponse = de(r#"{"email":"bob@example.com","is_email_sent":true}"#);
assert!(format!("{res:?}").contains("password: None"));
}
#[test]
fn totp_secret_debug_redacts_the_secret_and_url() {
let res: TotpSecret = de(
r#"{"secret":"JBSWY3DPEHPK3PXP","totp_url":"otpauth://totp/x?secret=JBSWY3DPEHPK3PXP"}"#,
);
let rendered = format!("{res:?}");
assert!(!rendered.contains("JBSWY3DPEHPK3PXP"), "{rendered}");
assert!(!rendered.contains("otpauth"), "{rendered}");
}
#[test]
fn totp_response_debug_redacts_the_secret() {
let res: TotpResponse = de(
r#"{"secret":{"secret":"JBSWY3DPEHPK3PXP","totp_url":"otpauth://totp/x?secret=JBSWY3DPEHPK3PXP"}}"#,
);
let rendered = format!("{res:?}");
assert!(!rendered.contains("JBSWY3DPEHPK3PXP"), "{rendered}");
assert!(!rendered.contains("otpauth"), "{rendered}");
assert!(rendered.contains("Some("), "{rendered}");
}
#[test]
fn totp_response_debug_shows_none_when_already_enrolled() {
let res: TotpResponse = de(r#"{"secret":null}"#);
assert!(format!("{res:?}").contains("secret: None"));
}
#[test]
fn recovery_codes_response_debug_redacts_the_codes() {
let res: RecoveryCodesResponse =
de(r#"{"recovery_codes":["aaaa-bbbb","cccc-dddd","eeee-ffff"]}"#);
let rendered = format!("{res:?}");
assert!(!rendered.contains("aaaa-bbbb"), "{rendered}");
assert!(!rendered.contains("eeee-ffff"), "{rendered}");
assert!(rendered.contains("recovery_codes_len: 3"), "{rendered}");
}
#[test]
fn user_response_parses_optional_fields_and_keeps_extras() {
let res: UserResponse = de(
r#"{"merchant_id":"mer_1","name":"Ada","email":"ada@example.com","role_id":"role_1",
"is_two_factor_auth_setup":true,"profile_id":"pro_1","entity_type":"merchant",
"version":"v2","theme_id":"dark","new_api_field":7}"#,
);
assert_eq!(res.theme_id.as_deref(), Some("dark"));
assert_eq!(res.verification_days_left, None);
assert_eq!(res.extra["new_api_field"], 7);
}
#[test]
fn login_history_parses_null_geo_fields() {
let res: LoginHistoryResponse = de(
r#"{"entries":[{"id":"lh_1","event_type":"signin_failure","failure_reason":"totp_invalid",
"auth_method":"totp","ip_address":"127.0.0.1","user_agent":null,"country_code":null,
"city":null,"latitude":null,"longitude":null,"created_at":"2026-01-01T00:00:00Z"}],
"total_count":1,"offset":0,"limit":25}"#,
);
assert_eq!(res.total_count, 1);
assert_eq!(
res.entries[0].failure_reason.as_deref(),
Some("totp_invalid")
);
assert_eq!(res.entries[0].latitude, None);
assert_eq!(res.entries[0].ip_address.as_deref(), Some("127.0.0.1"));
}
#[test]
fn session_list_parses_the_current_flag() {
let res: UserSessionListResponse = de(
r#"{"sessions":[{"id":"ses_1","auth_method":"password","ip_address":null,
"user_agent":null,"country_code":null,"city":null,
"created_at":"2026-01-01T00:00:00Z","last_seen_at":"2026-01-02T00:00:00Z",
"expires_at":"2026-01-08T00:00:00Z","is_current":true}]}"#,
);
assert_eq!(res.sessions.len(), 1);
assert!(res.sessions[0].is_current);
assert_eq!(res.sessions[0].last_seen_at, "2026-01-02T00:00:00Z");
}
#[test]
fn user_in_lineage_parses_nested_roles() {
let res: UserInLineage = de(r#"{"user_id":"usr_1","email":"bob@example.com",
"roles":[{"role_id":"role_1","role_name":"Admin"}]}"#);
assert_eq!(res.roles[0].role_name, "Admin");
}
#[test]
fn parent_group_info_parses_scopes() {
let res: ParentGroupInfo = de(
r#"{"name":"Operations","resources":["payment","refund"],"scopes":["Read","Write"]}"#,
);
assert_eq!(res.name, "Operations");
assert_eq!(res.resources, vec!["payment", "refund"]);
assert_eq!(res.scopes, vec!["Read", "Write"]);
}
}