3pl/partnerapi/globalcare/model_response.go

93 lines
2.5 KiB
Go
Raw Normal View History

2022-08-15 04:51:07 +00:00
package globalcare
2022-09-05 08:07:26 +00:00
import (
"encoding/json"
2022-10-10 03:45:16 +00:00
"git.selly.red/Selly-Modules/3pl/util/base64"
2022-09-05 08:07:26 +00:00
)
2022-08-28 07:16:27 +00:00
2022-08-15 04:51:07 +00:00
// CommonResponse ...
type CommonResponse struct {
2022-08-28 07:16:27 +00:00
Data string `json:"data"`
Signature string `json:"signature"`
}
// DecodeCreateOrderSuccess ...
func (r *CommonResponse) DecodeCreateOrderSuccess() (res CreateOrderResponseDecoded, err error) {
2022-09-05 07:33:39 +00:00
err = r.Decode(&res)
2022-08-28 07:16:27 +00:00
return res, err
}
// DecodeGetOrderSuccess ...
func (r *CommonResponse) DecodeGetOrderSuccess() (res GetOrderResponseDecoded, err error) {
2022-09-05 07:33:39 +00:00
err = r.Decode(&res)
2022-08-28 07:16:27 +00:00
return res, err
}
// DecodeError ...
func (r *CommonResponse) DecodeError() (res ResponseError, err error) {
2022-09-05 07:33:39 +00:00
err = r.Decode(&res)
2022-08-28 07:16:27 +00:00
return res, err
}
// Decode ...
func (r *CommonResponse) Decode(resultPointer interface{}) error {
2022-09-05 08:07:26 +00:00
b := base64.Decode(r.Data)
return json.Unmarshal(b, resultPointer)
2022-08-28 07:16:27 +00:00
}
// CreateOrderResponseDecoded ...
type CreateOrderResponseDecoded struct {
StatusCode int `json:"statusCode"`
Result CreateOrderResult `json:"result"`
}
// CreateOrderResult ...
type CreateOrderResult struct {
OrderCode string `json:"orderCode"`
PaymentLink string `json:"paymentLink"`
Fees int `json:"fees"`
StatusId int `json:"statusId"`
}
// ResponseError ...
type ResponseError struct {
StatusCode int `json:"statusCode"`
Message string `json:"message"`
}
// GetOrderResponseDecoded ...
type GetOrderResponseDecoded struct {
StatusCode int `json:"statusCode"`
Result GetOrderResult `json:"result"`
}
// GetOrderResult ...
type GetOrderResult struct {
ProviderTitle string `json:"providerTitle"`
BeginDate string `json:"beginDate"`
EndDate string `json:"endDate"`
Amount string `json:"amount"`
CertLink string `json:"certLink"`
StatusId int `json:"statusId"`
StatusTitle string `json:"statusTitle"`
Buyer BuyerInfo `json:"buyer"`
InsuredInfo InsuranceInfo `json:"insuredInfo"`
}
// InsuranceInfo ...
type InsuranceInfo struct {
TypeId int `json:"typeId"`
TypeName string `json:"typeName"`
CarOccupantAccidentInsurance int `json:"carOccupantAccidentInsurance"`
}
// BuyerInfo ...
type BuyerInfo struct {
BuyerName string `json:"buyerName"`
BuyerPrivateId interface{} `json:"buyerPrivateId"`
BuyerPhone string `json:"buyerPhone"`
BuyerAddress string `json:"buyerAddress"`
BuyerEmail string `json:"buyerEmail"`
2022-08-15 04:51:07 +00:00
}