// user contains FlatBuffers payloads used by the authenticated gateway
// self-service boundary for User Service.
namespace user;

table GetMyAccountRequest {
}

table UpdateMyProfileRequest {
  display_name:string;
}

table UpdateMySettingsRequest {
  preferred_language:string;
  time_zone:string;
}

table ActorRef {
  type:string;
  id:string;
}

table EntitlementSnapshot {
  plan_code:string;
  is_paid:bool;
  source:string;
  actor:ActorRef;
  reason_code:string;
  starts_at_ms:int64;
  ends_at_ms:int64;
  updated_at_ms:int64;
}

table ActiveSanction {
  sanction_code:string;
  scope:string;
  reason_code:string;
  actor:ActorRef;
  applied_at_ms:int64;
  expires_at_ms:int64;
}

table ActiveLimit {
  limit_code:string;
  value:int64;
  reason_code:string;
  actor:ActorRef;
  applied_at_ms:int64;
  expires_at_ms:int64;
}

table AccountView {
  user_id:string;
  email:string;
  user_name:string;
  display_name:string;
  preferred_language:string;
  time_zone:string;
  declared_country:string;
  entitlement:EntitlementSnapshot;
  active_sanctions:[ActiveSanction];
  active_limits:[ActiveLimit];
  created_at_ms:int64;
  updated_at_ms:int64;
}

table AccountResponse {
  account:AccountView;
}

table ErrorBody {
  code:string;
  message:string;
}

table ErrorResponse {
  error:ErrorBody;
}

table DeviceSessionView {
  device_session_id:string;
  user_id:string;
  status:string;
  client_public_key:string;
  created_at_ms:int64;
  revoked_at_ms:int64;
  last_seen_at_ms:int64;
}

table ListMySessionsRequest {
}

table ListMySessionsResponse {
  items:[DeviceSessionView];
}

table RevokeMySessionRequest {
  device_session_id:string;
}

table RevokeMySessionResponse {
  session:DeviceSessionView;
}

table RevokeAllMySessionsRequest {
}

table DeviceSessionRevocationSummaryView {
  user_id:string;
  revoked_count:int32;
}

table RevokeAllMySessionsResponse {
  summary:DeviceSessionRevocationSummaryView;
}

root_type AccountResponse;
