syntax = "proto3";
package transaction;

service Transaction {
  rpc CreateTransaction(stream CreateTransactionPayload) returns (stream CreateTransactionResponse) {}
}

message TransactionState {
  message InputError {
    enum ErrorType {
      INVALID = 0;
      REQUIRED = 1;
    }
    string field = 1;
    string message = 2;
    ErrorType type = 3;
  }

  message ProcessingError {
    enum ErrorType {
      UNKNOWN = 0;
      INACTIVE_DEVELOPER = 100;
      INACTIVE_APPLICATION = 101;
    }
    string message = 1;
    string details = 2;
    ErrorType type = 3;
  }

  bool accepted = 1;
  repeated ProcessingError processingErrors = 2;
  repeated InputError inputErrors = 3;
}

message CreateTransactionPayload {
  string applicationKey = 1;
  string developerKey = 2;
  string trackingKey = 3; // unique public identifier for the transaction
  string parentTrackingKey = 4; // currently unused; in the future we use for connecting transactions
  string name = 5; // symbolic name for the transaction
  uint64 startedAt = 6; // transaction creation ts (milliseconds from unix epoch start)
  uint64 finishedAt = 7; // transaction completion ts
  map<string, string> metadata = 8; // various metadata
}

message CreateTransactionResponse {
  TransactionState state = 1;
  string trackingKey = 2;
  string callId = 3;
}
