syntax = "proto3";

package main;

import "google/protobuf/timestamp.proto";
import "google/api/annotations.proto";

option go_package = "git.vdhsn.com/barretthousen/barretthousen/src/auth/api/grpc";

service Auth {
  rpc CreateAccount(CreateAccountInput) returns (Account) {
    option (google.api.http) = {
      put: "/v1/user"
      body: "*"
    };
  }

  rpc Login(LoginInput) returns (LoginResult) {
    option (google.api.http) = {
      post: "/v1/user"
      body: "*"
    };
  }

  rpc VerifyAccount(VerificationParameters) returns (AccountVerifiedResult) {
    option (google.api.http) = {
      get: "/v1/user/verify"
    };
  }

  rpc GetAccount(AccountFilter) returns (Account) {
    option (google.api.http) = {
      get: "/v1/user"
    };
  }
}

message CreateAccountInput {
  string email = 1;
  string password = 2;
  string role = 3;
}

message LoginInput {
  string email = 1;
  string password = 2;
}

message LoginResult {
  string sessionId = 1;
  Account account = 2;
}

message AccountFilter {
  int32 id = 1;
  string email = 2;
}

message VerificationParameters {
  string token = 1;
  string email = 2;
}

message AccountVerifiedResult {}

message Account {
  int32 id = 1;
  string email = 2;
  string role = 3;
  google.protobuf.Timestamp createdTs = 4;
  google.protobuf.Timestamp verifiedTs = 5;
}
