syntax = "proto3";

option go_package ="./pb";

package pb;

// ------------------------------------
// Messages
// ------------------------------------

//--------------------------------disputes--------------------------------
message Disputes {
  int64 id = 1;
  int64 orderId = 2;
  int64 initiatorId = 3;
  string initiatorName = 4;
  int64 respondentId = 5;
  string reason = 6;
  repeated string evidence = 7;
  string status = 8;
  string result = 9;
  string respondentReason = 10;
  repeated string respondentEvidence = 11;
  string appealReason = 12;
  int64 appealedAt = 13;
  int64 resolvedBy = 14;
  int64 resolvedAt = 15;
  int64 createdAt = 16;
  int64 updatedAt = 17;
}

message AddDisputesReq {
  int64 orderId = 1;
  int64 initiatorId = 2;
  string initiatorName = 3;
  int64 respondentId = 4;
  string reason = 5;
  repeated string evidence = 6;
  string status = 7;
}

message AddDisputesResp {
  int64 id = 1;
}

message UpdateDisputesReq {
  int64 id = 1;
  optional string status = 2;
  optional string result = 3;
  optional string respondentReason = 4;
  repeated string respondentEvidence = 5;
  optional string appealReason = 6;
  optional int64 appealedAt = 7;
  optional int64 resolvedBy = 8;
  optional int64 resolvedAt = 9;
}

message UpdateDisputesResp {
}

message DelDisputesReq {
  int64 id = 1;
}

message DelDisputesResp {
}

message GetDisputesByIdReq {
  int64 id = 1;
}

message GetDisputesByIdResp {
  Disputes disputes = 1;
}

message SearchDisputesReq {
  int64 offset = 1;
  int64 limit = 2;
  optional int64 id = 3;
  optional int64 orderId = 4;
  optional int64 initiatorId = 5;
  optional int64 respondentId = 6;
  optional string status = 7;
}

message SearchDisputesResp {
  repeated Disputes disputes = 1;
}

//--------------------------------disputeTimeline--------------------------------
message DisputeTimeline {
  int64 id = 1;
  int64 disputeId = 2;
  string eventType = 3;
  int64 actorId = 4;
  string actorName = 5;
  string details = 6;
  int64 createdAt = 7;
}

message AddDisputeTimelineReq {
  int64 disputeId = 1;
  string eventType = 2;
  int64 actorId = 3;
  string actorName = 4;
  string details = 5;
}

message AddDisputeTimelineResp {
}

message SearchDisputeTimelineReq {
  int64 offset = 1;
  int64 limit = 2;
  optional int64 disputeId = 3;
}

message SearchDisputeTimelineResp {
  repeated DisputeTimeline timeline = 1;
}

// ------------------------------------
// Rpc Func
// ------------------------------------

service disputeService {
  //-----------------------disputes-----------------------
  rpc AddDisputes(AddDisputesReq) returns (AddDisputesResp);
  rpc UpdateDisputes(UpdateDisputesReq) returns (UpdateDisputesResp);
  rpc DelDisputes(DelDisputesReq) returns (DelDisputesResp);
  rpc GetDisputesById(GetDisputesByIdReq) returns (GetDisputesByIdResp);
  rpc SearchDisputes(SearchDisputesReq) returns (SearchDisputesResp);

  //-----------------------disputeTimeline-----------------------
  rpc AddDisputeTimeline(AddDisputeTimelineReq) returns (AddDisputeTimelineResp);
  rpc SearchDisputeTimeline(SearchDisputeTimelineReq) returns (SearchDisputeTimelineResp);
}
