syntax = "v1"

import "common.api"

type (
	PathId {
		Id int64 `path:"id"`
	}
	Dispute {
		Id        int64    `json:"id"`
		OrderId   int64    `json:"orderId"`
		Reason    string   `json:"reason"`
		Status    string   `json:"status"`
		Evidence  []string `json:"evidence"`
		Result    string   `json:"result,optional"`
		CreatedAt string   `json:"createdAt"`
	}
	DisputeListResp {
		Items []Dispute `json:"items"`
		Meta  PageMeta  `json:"meta"`
	}
	CreateDisputeReq {
		PathId
		Reason   string   `json:"reason"`
		Evidence []string `json:"evidence"`
	}
	DisputeResponseReq {
		PathId
		Reason   string   `json:"reason"`
		Evidence []string `json:"evidence"`
	}
	AppealReq {
		PathId
		Reason string `json:"reason"`
	}
)

@server (
	prefix: api/v1
	group:  dispute
)
service dispute-api {
	@doc "获取争议列表"
	@handler ListDisputes
	get /disputes (PageReq) returns (DisputeListResp)

	@doc "获取订单争议"
	@handler GetOrderDispute
	get /orders/:id/dispute (PathId) returns (Dispute)

	@doc "发起争议"
	@handler CreateDispute
	post /orders/:id/dispute (CreateDisputeReq) returns (EmptyResp)

	@doc "回应争议"
	@handler RespondDispute
	post /disputes/:id/response (DisputeResponseReq) returns (EmptyResp)

	@doc "申诉"
	@handler AppealDispute
	post /disputes/:id/appeal (AppealReq) returns (EmptyResp)
}
