package card import ( "context" "encoding/json" "gitea.cdlsxd.cn/sdk/plugin/dctw/v1/api" "gitea.cdlsxd.cn/sdk/plugin/dctw/v1/core" "io/ioutil" "net/http" ) type Card api.Service const ( orderPath = "/internal/v1/card/order" queryPath = "/internal/v1/card/query" ) func (c *Card) Order(ctx context.Context, request *Order) (*OrderResp, error) { result, err := c.Request(ctx, request, orderPath) if err != nil { return nil, err } var response *OrderResp if err = json.Unmarshal(result, &response); err != nil { return nil, err } return response, nil } func (c *Card) Query(ctx context.Context, request *Query) (*QueryResp, error) { result, err := c.Request(ctx, request, queryPath) if err != nil { return nil, err } var response *QueryResp if err = json.Unmarshal(result, &response); err != nil { return nil, err } return response, nil } func (c *Card) Notify(_ context.Context, httpRequest *http.Request) (*Notify, error) { body, err := ioutil.ReadAll(httpRequest.Body) if err != nil { return nil, err } if err = c.VerifyDctW(httpRequest.Header.Get(core.SignKeyName), body); err != nil { return nil, err } var response *Notify if err = json.Unmarshal(body, &response); err != nil { return nil, err } return response, err }