package JntExpressMalaysia

import "io"

type OfferFeeFlag int
type GoodsType string
type ServiceType string
type PayType string
type ExpressType string
type QueryType string
type Language string
type PostalCodeSize string

const (
	OfferFeeFlagNo  OfferFeeFlag = 0
	OfferFeeFlagYes OfferFeeFlag = 1
)

const (
	GoodsTypeParcel   GoodsType = "PARCEL"
	GoodsTypeDocument GoodsType = "DOCUMENT"
)

const (
	ServiceTypePickup  ServiceType = "1"
	ServiceTypeDropOff ServiceType = "6"
)

const (
	ExpressTypeEZ ExpressType = "EZ"
)

const (
	PayTypePPPM PayType = "PP_PM"
)

const (
	QueryTypeBillCode QueryType = "1"
	QueryTypeOrderID  QueryType = "2"
)

const (
	LanguageChinese Language = "1"
	LanguageEnglish Language = "2"
)

const (
	PostalCodeSizeLessThanOrEqual3Kg PostalCodeSize = "1"
	PostalCodeSizeAbove3Kg           PostalCodeSize = "2"
)

/*
CreateShipmentRequest
----------------------
{
    "detail": [{
        "username": "TEST",
        "api_key": "TES123",
        "cuscode": "ITTEST0001",
        "password": "1234",
        "orderid": " TESTID000001 ",
        "shipper_name": "Mr.Blue",
        "shipper_addr": "TEST ADDRESS",
        "shipper_contact": "Mrs.Blue",
        "shipper_phone": "60123698745",
        "sender_zip": "59200",
        "receiver_name": "Mr.White",
        "receiver_addr": "TEST ADDRESS",
        "receiver_zip": "83000",
        "receiver_phone": "60123456789",
        "qty": "3",
        "weight": "50.12",
        "servicetype": "1",
        "item_name": "IPHONE12",
        "goodsdesc": "THIS IS REMARK",
        "goodsvalue": 520,
        "goodsType": "PARCEL",
        "payType": "PP_PM",
        "offerFeeFlag": 1,
        "expresstype": "EZ",
        "height": "5",
        "length": "5",
        "width": "5",
        "COD": "100"
    }]
}
----------------------
*/
type CreateShipmentRequest struct {
	Detail []CreateShipmentRequestDetail `json:"detail" mapstructure:"detail"`
}

type CreateShipmentRequestDetail struct {
	Username        string       `json:"username" mapstructure:"username"`
	ApiKey          string       `json:"api_key" mapstructure:"api_key"`
	CustomerCode    string       `json:"cuscode" mapstructure:"cuscode"`
	Password        string       `json:"password" mapstructure:"password"`
	OrderID         string       `json:"orderid" mapstructure:"orderid"`
	SenderName      string       `json:"shipper_name" mapstructure:"shipper_name"`
	SenderAddress   string       `json:"shipper_addr" mapstructure:"shipper_addr"`
	SenderContact   string       `json:"shipper_contact" mapstructure:"shipper_contact"`
	SenderPhone     string       `json:"shipper_phone" mapstructure:"shipper_phone"`
	SenderZip       string       `json:"sender_zip" mapstructure:"sender_zip"`
	ReceiverName    string       `json:"receiver_name" mapstructure:"receiver_name"`
	ReceiverAddress string       `json:"receiver_addr" mapstructure:"receiver_addr"`
	ReceiverZip     string       `json:"receiver_zip" mapstructure:"receiver_zip"`
	ReceiverPhone   string       `json:"receiver_phone" mapstructure:"receiver_phone"`
	Quantity        string       `json:"qty" mapstructure:"qty"`
	Weight          string       `json:"weight" mapstructure:"weight"`
	ServiceType     ServiceType  `json:"servicetype" mapstructure:"servicetype"`
	ItemName        string       `json:"item_name" mapstructure:"item_name"`
	GoodsDesc       string       `json:"goodsdesc" mapstructure:"goodsdesc"`
	GoodsValue      float64      `json:"goodsvalue" mapstructure:"goodsvalue"`
	GoodsType       GoodsType    `json:"goodsType" mapstructure:"goodsType"`
	PayType         PayType      `json:"payType" mapstructure:"payType"`
	OfferFeeFlag    OfferFeeFlag `json:"offerFeeFlag" mapstructure:"offerFeeFlag"`
	ExpressType     ExpressType  `json:"expresstype" mapstructure:"expresstype"`
	SendStartTime   string       `json:"sendstarttime,omitempty" mapstructure:"sendstarttime"`
	SendEndTime     string       `json:"sendendtime,omitempty" mapstructure:"sendendtime"`
	Height          string       `json:"height" mapstructure:"height"`
	Length          string       `json:"length" mapstructure:"length"`
	Width           string       `json:"width" mapstructure:"width"`
	COD             string       `json:"COD" mapstructure:"COD"`
}

/*
CreateShipmentResponse
----------------------
{
    "success": true,
    "desc": "success",
    "msg": null,
    "details": [{
        "awb_no": "630020260082",
        "orderid": "U1001",
        "status": "success",
        "reason": "",
        "msg": null,
        "data": {
            "price": "48.12",
            "code": "YPG-JHRdayoubian",
            "businesscode": "002",
            "handlingFee": "50.00",
            "taxes": "1.00",
            "insuranceFee": 5.20,
            "smartFlag": 0,
            "intelAnalysisKeyword": null
        }
    }]
}
----------------------
*/
type CreateShipmentResponse struct {
	Success bool                           `json:"success" mapstructure:"success"`
	Desc    string                         `json:"desc" mapstructure:"desc"`
	Msg     string                         `json:"msg" mapstructure:"msg"`
	Details []CreateShipmentResponseDetail `json:"details" mapstructure:"details"`
}

type CreateShipmentResponseDetail struct {
	AwbNo   string                           `json:"awb_no" mapstructure:"awb_no"`
	OrderID string                           `json:"orderid" mapstructure:"orderid"`
	Status  string                           `json:"status" mapstructure:"status"`
	Reason  string                           `json:"reason" mapstructure:"reason"`
	Msg     string                           `json:"msg" mapstructure:"msg"`
	Data    CreateShipmentResponseDetailData `json:"data" mapstructure:"data"`
}

type CreateShipmentResponseDetailData struct {
	Price        string  `json:"price" mapstructure:"price"`
	Code         string  `json:"code" mapstructure:"code"`
	BusinessCode string  `json:"businesscode" mapstructure:"businesscode"`
	HandlingFee  string  `json:"handlingFee" mapstructure:"handlingFee"`
	Taxes        string  `json:"taxes" mapstructure:"taxes"`
	InsuranceFee float64 `json:"insuranceFee" mapstructure:"insuranceFee"`
}

/*
CancelShipmentRequest
{
    "username": "TEST",
    "api_key": "TES123",
    "awb_no": "630020261448",
    "ordereid": "U1007",
    "remark": "Seller cancelled"
}
*/
type CancelShipmentRequest struct {
	Username string `json:"username" mapstructure:"username"`
	ApiKey   string `json:"api_key" mapstructure:"api_key"`
	AwbNo    string `json:"awb_no" mapstructure:"awb_no"`
	OrderID  string `json:"ordereid" mapstructure:"ordereid"`
	Remark   string `json:"remark" mapstructure:"remark"`
}

/*
CancelShipmentResponse
{
    "success": true,
    "desc": "success",
    "msg": null,
    "details": [{
        "awb_no": "630020261448",
        "orderid": null,
        "status": "success",
        "reason": "",
        "msg": null,
        "data": null
    }]
}
*/
type CancelShipmentResponse struct {
	AwbNo   string `json:"awb_no" mapstructure:"awb_no"`
	Status  string `json:"status" mapstructure:"status"`
	Reason  string `json:"reason" mapstructure:"reason"`
	Success bool   `json:"success" mapstructure:"success"`
}

/*
GetTrackingRequest
{
    "queryType": "1",
    "language": "2",
    "queryCodes": "630020238090"
}
*/
type GetTrackingRequest struct {
	QueryType  QueryType `json:"queryType" mapstructure:"queryType"`
	Language   Language  `json:"language" mapstructure:"language"`
	QueryCodes string    `json:"queryCodes" mapstructure:"queryCodes"`
}

/*
GetTrackingResponse
{
    "logisticproviderid": "JT",
    "responseitems": {
        "success": true,
        "reason": "",
        "data": [{
            "billcode": "630020238090",
            "details": [{
                "acceptTime": "2022-05-13 16:10:48.0",
                "city": "PERLIS",
                "scanstatus": "Delivered",
                "entrySiteCode": "600000",
                "employeePhone": "60178257407",
                "operatorPhone": "60178257407",
                "operatorName": "JOHN TAN"
            }, {
                "acceptTime": "2022-05-13 16:10:31.0",
                "city": "PERLIS",
                "scanstatus": "On Delivery",
                "entrySiteCode": "600000",
                "employeePhone": "60178257407",
                "operatorPhone": "60178257407",
                "operatorName": "JOHN TAN"
            }, {
                "remark": "Keadaan Khas",
                "acceptTime": "2022-05-13 16:10:25.0",
                "city": "PERLIS",
                "scanstatus": "On Hold",
                "entrySiteCode": "600000",
                "note": "Keadaan Khas",
                "operatorPhone": "60178257407",
                "operatorName": "JOHN TAN"
            }, {
                "remark": "Bungkusan sedang disiasat",
                "acceptTime": "2022-05-13 16:10:17.0",
                "city": "PERLIS",
                "scanstatus": "On Hold",
                "entrySiteCode": "600000",
                "note": "Bungkusan sedang disiasat",
                "operatorPhone": "60178257407",
                "operatorName": "JOHN TAN"
            }, {
                "acceptTime": "2022-05-13 16:09:36.0",
                "city": "PERLIS",
                "scanstatus": "Departure",
                "entrySiteCode": "600000",
                "nextSiteCode": "PHG900",
                "operatorPhone": "60178257407",
                "operatorName": "JOHN TAN"
            }, {
                "acceptTime": "2022-05-13 16:09:29.0",
                "city": "PERLIS",
                "scanstatus": "Picked Up",
                "entrySiteCode": "600000",
                "note": "ZFFS;JZ0;^W=|TJ=**|VW=0#",
                "operatorPhone": "60178257407",
                "operatorName": "JOHN TAN"
            }],
            "orderDetail": {
                "mailno": "630020238090",
                "sendername": "J&T Express Warehouse",
                "senderphone": "601****57407",
                "senderprov": "KUALA LUMPUR",
                "sendercity": "CHERAS",
                "senderarea": "CHERAS-KUL",
                "senderpostcode": "56700",
                "receivername": "MOHD ADAHA BIN KAR(2244)",
                "receiverphone": "601****57407",
                "receiverprov": "KELANTAN",
                "receivercity": "BACHOK",
                "receiverpostcode": "16090",
                "weight": "1",
                "expresstype": "EZ",
                "remark": "REMARK",
                "goodstype": "PARCEL",
                "paytype": "PP_PM",
                "servicetype": "1",
                "shippingfee": "0",
                "insurancemark": "0"
            }
        }]
    }
}
*/
type GetTrackingResponse struct {
	LogisticProviderID string                  `json:"logisticproviderid" mapstructure:"logisticproviderid"`
	ResponseItem       GetTrackingResponseItem `json:"responseitems" mapstructure:"responseitems"`
}

type GetTrackingResponseItem struct {
	Success bool                          `json:"success" mapstructure:"success"`
	Reason  string                        `json:"reason" mapstructure:"reason"`
	Data    []GetTrackingResponseItemData `json:"data" mapstructure:"data"`
}

type GetTrackingResponseItemData struct {
	BillCode    string                                 `json:"billcode" mapstructure:"billcode"`
	Details     []GetTrackingResponseItemDataDetail    `json:"details" mapstructure:"details"`
	OrderDetail GetTrackingResponseItemDataOrderDetail `json:"orderDetail" mapstructure:"orderDetail"`
}

type GetTrackingResponseItemDataDetail struct {
	AcceptTime    string `json:"acceptTime" mapstructure:"acceptTime"`
	City          string `json:"city" mapstructure:"city"`
	ScanStatus    string `json:"scanstatus" mapstructure:"scanstatus"`
	EntrySiteCode string `json:"entrySiteCode" mapstructure:"entrySiteCode"`
	Note          string `json:"note" mapstructure:"note"`
	OperatorPhone string `json:"operatorPhone" mapstructure:"operatorPhone"`
	OperatorName  string `json:"operatorName" mapstructure:"operatorName"`
	Remark        string `json:"remark" mapstructure:"remark"`
}

type GetTrackingResponseItemDataOrderDetail struct {
	MailNo           string `json:"mailno" mapstructure:"mailno"`
	SenderName       string `json:"sendername" mapstructure:"sendername"`
	SenderPhone      string `json:"senderphone" mapstructure:"senderphone"`
	SenderProvince   string `json:"senderprov" mapstructure:"senderprov"`
	SenderCity       string `json:"sendercity" mapstructure:"sendercity"`
	SenderArea       string `json:"senderarea" mapstructure:"senderarea"`
	SenderPostcode   string `json:"senderpostcode" mapstructure:"senderpostcode"`
	ReceiverName     string `json:"receivername" mapstructure:"receivername"`
	ReceiverPhone    string `json:"receiverphone" mapstructure:"receiverphone"`
	ReceiverProvince string `json:"receiverprov" mapstructure:"receiverprov"`
	ReceiverCity     string `json:"receivercity" mapstructure:"receivercity"`
	ReceivePostcode  string `json:"receiverpostcode" mapstructure:"receiverpostcode"`
	Weight           string `json:"weight" mapstructure:"weight"`
	ExpressType      string `json:"expresstype" mapstructure:"expresstype"`
	Remark           string `json:"remark" mapstructure:"remark"`
	GoodsType        string `json:"goodstype" mapstructure:"goodstype"`
	PayType          string `json:"paytype" mapstructure:"paytype"`
	ServiceType      string `json:"servicetype" mapstructure:"servicetype"`
	ShippingFee      string `json:"shippingfee" mapstructure:"shippingfee"`
	InsuranceMark    string `json:"insurancemark" mapstructure:"insurancemark"`
}

/*
GetWaybillRequest
{
    "username": "TEST",
    "api_key": "TES123",
    "awb_no": "630020261448",
    "ordereid": "U1007",
    "remark": "Seller cancelled"
}
*/
type GetWaybillRequest struct {
	Account      string `json:"account" mapstructure:"account"`
	Password     string `json:"password" mapstructure:"password"`
	CustomerCode string `json:"customercode" mapstructure:"customercode"`
	BillCode     string `json:"billcode" mapstructure:"billcode"`
}

type GetWaybillResponse struct {
	Data io.Reader
}

/*
GetPostalCodeRequest
{
	"size": "1"
}
*/
type GetPostalCodeRequest struct {
	Size PostalCodeSize `json:"size" mapstructure:"size"`
}

/*
GetPostalCodeResponse
{
    "code": 1,
    "msg": "请求成功",
    "version": null,
    "data": [{
        "postcode": "07007",
        "districtName": "LANGKAWI",
        "state": "KEDAH",
        "county": "LANGKAWI",
        "bigChar": "PEN-LGK004",
        "flag": 1,
        "sortingCode": null
    }, {
        "postcode": "07009",
        "districtName": "LANGKAWI",
        "state": "KEDAH",
        "county": "LANGKAWI",
        "bigChar": "PEN-LGK004",
        "flag": null,
        "sortingCode": null
    }]
}
*/
type GetPostalCodeResponse struct {
	Code    int                         `json:"code" mapstructure:"code"`
	Msg     string                      `json:"msg" mapstructure:"msg"`
	Success bool                        `json:"succ" mapstructure:"succ"`
	Fail    bool                        `json:"fail" mapstructure:"fail"`
	Data    []GetPostalCodeResponseData `json:"data" mapstructure:"data"`
}
type GetPostalCodeResponseData struct {
	Postcode     string `json:"postcode" mapstructure:"postcode"`
	DistrictName string `json:"districtName" mapstructure:"districtName"`
	State        string `json:"state" mapstructure:"state"`
	County       string `json:"county" mapstructure:"county"`
	BigChar      string `json:"bigChar" mapstructure:"bigChar"`
	SortingCode  string `json:"sortingCode" mapstructure:"sortingCode"`
}
