syntax = "proto3";

package twitch.fulton.example.twitchnami;

option go_package = "code.justin.tv/amzn/TwitchNamiTwirp";

message Balance {
  string currency = 1;
  int64 amount = 2;
  int64 exponent = 3;
}

enum Operation {
  ADD = 0;
  DEDUCT = 1;
}

enum WalletType {
  UNKNOWN = 0;
  GIFT_CARD = 1;
  CREATOR = 2;
}

message GetBalanceRequest {
  string user_id = 1;
  WalletType wallet_type = 2;
}

message GetBalanceResponse {
  repeated Balance user_balances = 1;
}

message UpdateWalletStatusRequest {
  string user_id = 1;
  WalletType wallet_type = 2;
  WalletStatus wallet_status = 3;
  string reason = 4;
}

message UpdateWalletStatusResponse {}

enum WalletStatus {
  ACTIVE = 0;
  FROZEN = 1;
}

message TransactRequest {
  string user_id = 1;
  WalletType wallet_type = 2;
  Operation operation = 3;
  Balance request_amount = 4;
  string ldap_email = 5;
  string reason = 6;
  string transaction_id = 7;
  string origin_id = 8;
}

enum TransactFailure {
  NONE = 0;
  INSUFFICIENT_FUNDS = 1;
  BALANCE_MAX_EXCEEDED = 2;
  TRANSACTION_COMMITTED = 3;
}

message TransactResponse {
  Balance user_balance = 1;
  Balance user_balance_with_hold = 2;
  TransactFailure failure = 3;
  string transaction_id = 4;
  string hold_id = 5;
}

service TwitchNami {
  rpc GetBalance (GetBalanceRequest) returns (GetBalanceResponse);
  rpc UpdateWalletStatus (UpdateWalletStatusRequest) returns (UpdateWalletStatusResponse);
  rpc Transact (TransactRequest) returns (TransactResponse);
}
