// Code generated by `make bundle-margin-notifications-proto`; DO NOT EDIT.

syntax = "proto3";

package flint.margin.user.v1.notifications;

import "google/protobuf/empty.proto";

// -- service.proto --------------------------------------------------------

// Manages email delivery preferences. Every method requires a margin-session
// bearer token for the selected trader account's current owner.
// Public fill history is available through AccountService.GetFills. Reading or
// dismissing fills in a client never suppresses email delivery.
service NotificationService {
  // Returns current settings without enabling email delivery.
  rpc GetSettings(google.protobuf.Empty) returns (Settings);
  // Sends a verification code. Requesting a code does not enable email or change
  // the currently verified destination when requesting a replacement.
  rpc RequestEmailVerification(RequestEmailVerificationRequest) returns (RequestEmailVerificationResponse);
  // Verifies a single-use code and enables the destination for new fills from
  // verification onward, replacing any previous destination without a backlog.
  rpc VerifyEmail(VerifyEmailRequest) returns (Settings);
  // Disables email and cancels pending verification for this account.
  // Re-enabling email requires fresh verification.
  rpc DisableEmail(google.protobuf.Empty) returns (Settings);
}

// -- messages.proto --------------------------------------------------------

// Settings belong to the owner and selected trader account in the authenticated
// margin session. Delegates cannot read or change notification settings.
message Settings {
  // Retired inbox-enrollment field; keep existing email settings field numbers.
  reserved 1;
  reserved "enrolled";
  // False when this server cannot send verification or fill emails.
  bool delivery_available = 2;
  // Verified destination only; empty when no email destination is enabled.
  string email_address = 3;
  bool email_enabled = 4;
}

message RequestEmailVerificationRequest {
  string email = 1;
}

message RequestEmailVerificationResponse {
  string challenge_id = 1;
  // Unix epoch milliseconds.
  uint64 expires_at_ms = 2;
  // Milliseconds before another verification email may be requested.
  uint64 retry_after_ms = 3;
}

message VerifyEmailRequest {
  string challenge_id = 1;
  string code = 2;
}
