syntax = "proto3";

message TokenInfo {
  int64 ID = 1;
  string status = 2;
  string created_at = 3;
  string updated_at = 4;
  int64 user_id = 5;
  string access_token = 6;
  string refresh_token = 7;
  string source = 8;
  int64 expired_at = 9;

  // relations
  UserInfo user = 10;
}

message TokenUserReq {
  int64 user_id = 1;
}

message TokenReq {
  int64 ID = 1;
  int64 user_id = 2;
  string username = 3;
  string phone_number = 4;
  string email = 5;

  bool with_user = 6;

  optional Pagination page = 10;
}

message TokenListResp {
  optional Pagination page = 1;
  repeated TokenInfo data = 2;
}

service Core {
  // Token management
  // group: token
  rpc createToken (TokenInfo) returns (BaseIDResp);
  // group: token
  rpc updateToken (TokenInfo) returns (BaseResp);
  // group: token
  rpc getTokenList (TokenReq) returns (TokenListResp);
  // group: token
  rpc getToken (TokenReq) returns (TokenInfo);
  // group: token
  rpc deleteToken (IDsReq) returns (BaseResp);
  // group: token
  rpc blockUserAllToken (TokenUserReq) returns (BaseResp);
}