syntax = "proto3";

package profile;

service ProfileService {
  rpc GetProfile (UserProfileRequest) returns (ProfileResponse);
  rpc UpdateAvatar (UpdateAvatarRequest) returns (ProfileResponse);
  rpc UpdateProfile (UpdateProfileRequest) returns (ProfileResponse);
  rpc UpdateContacts (UpdateContactsRequest) returns (ProfileResponse);
  rpc SetPassword (SetPasswordRequest) returns (SetPasswordResponse);
  rpc SendPasswordVerificationOtp (SendPasswordVerificationOtpRequest) returns (PasswordVerificationOtpResponse);
  rpc ChangePassword (ChangePasswordRequest) returns (SetPasswordResponse);
  rpc RemovePassword (RemovePasswordRequest) returns (SetPasswordResponse);
  rpc SoftDeleteProfile (UserProfileRequest) returns (SoftDeleteProfileResponse);
  rpc RequestAccountDeletion (UserProfileRequest) returns (AccountDeletionResponse);
  rpc CancelAccountDeletion (UserProfileRequest) returns (AccountDeletionCancelResponse);
  rpc GetAccountDeletionStatus (UserProfileRequest) returns (AccountDeletionStatusResponse);
  rpc SetE2EPublicKey (SetE2EPublicKeyRequest) returns (E2EPublicKeyResponse);
  rpc GetE2EPublicKey (UserProfileRequest) returns (E2EPublicKeyResponse);
}

message SetPasswordRequest {
  string userId = 1;
  string password = 2;
}

message SendPasswordVerificationOtpRequest {
  string userId = 1;
  string channel = 2;
}

message PasswordVerificationOtpResponse {
  bool sent = 1;
  string maskedTarget = 2;
}

message ChangePasswordRequest {
  string userId = 1;
  string newPassword = 2;
  optional string currentPassword = 3;
  optional string otpCode = 4;
  optional string otpChannel = 5;
  optional string totpCode = 6;
}

message RemovePasswordRequest {
  string userId = 1;
  optional string currentPassword = 2;
  optional string otpCode = 3;
  optional string otpChannel = 4;
  optional string totpCode = 5;
}

message SetPasswordResponse {
  bool hasPassword = 1;
}

message UserProfileRequest {
  string userId = 1;
}

message UpdateAvatarRequest {
  string userId = 1;
  optional string avatarUrl = 2;
  optional string avatarStorageKey = 3;
}

message UpdateProfileRequest {
  string userId = 1;
  optional string firstName = 2;
  optional string lastName = 3;
  optional string bio = 4;
  optional int32 age = 5;
  optional string gender = 6;
  optional string birthDate = 7;
}

message UpdateContactsRequest {
  string userId = 1;
  optional string email = 2;
  optional string phone = 3;
  optional string backupEmail = 4;
  optional string backupPhone = 5;
}

message ProfileResponse {
  string id = 1;
  string userId = 2;
  string displayName = 3;
  optional string avatarUrl = 4;
  optional bool hasAvatar = 14;
  optional string firstName = 5;
  optional string lastName = 6;
  optional string bio = 7;
  optional int32 age = 8;
  optional string gender = 9;
  optional string email = 10;
  optional string phone = 11;
  optional string backupEmail = 12;
  optional string backupPhone = 13;
  optional string birthDate = 15;
  bool hasPassword = 16;
  optional string deletionRequestedAt = 17;
  optional string e2ePublicKey = 18;
}

message SetE2EPublicKeyRequest {
  string userId = 1;
  string publicKey = 2;
}

message E2EPublicKeyResponse {
  string userId = 1;
  optional string e2ePublicKey = 2;
}

message AccountDeletionResponse {
  string userId = 1;
  string deletionRequestedAt = 2;
  string effectiveAt = 3;
  int32 graceDays = 4;
}

message AccountDeletionCancelResponse {
  string userId = 1;
  bool cancelled = 2;
}

message AccountDeletionStatusResponse {
  bool pending = 1;
  optional string deletionRequestedAt = 2;
  optional string effectiveAt = 3;
  int32 graceDays = 4;
}

message SoftDeleteProfileResponse {
  bool success = 1;
}
