fixes DeliveryTracking method (#44)

This commit is contained in:
Akolzin Dmitry 2021-01-29 14:29:44 +03:00 committed by GitHub
parent 3d71115827
commit 7fc96e5542
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 345 additions and 307 deletions

File diff suppressed because it is too large Load Diff

View File

@ -5473,6 +5473,43 @@ func TestClient_ProductsProperties(t *testing.T) {
}
}
func TestClient_DeliveryTracking(t *testing.T) {
c := client()
defer gock.Off()
p := url.Values{
"statusUpdate": {`[{"deliveryId":"123","history":[{"code":"1","updatedAt":"2020-01-01T00:00:00:000"}]}]`},
}
gock.New(crmURL).
Post("/delivery/generic/subcode/tracking").
MatchType("url").
BodyString(p.Encode()).
Reply(200).
BodyString(`{"success": true}`)
g, status, err := c.DeliveryTracking([]DeliveryTrackingRequest{{
DeliveryID: "123",
History: []DeliveryHistoryRecord{{
Code: "1",
UpdatedAt: "2020-01-01T00:00:00:000",
}},
}}, "subcode")
if err.Error() != "" {
t.Errorf("%v", err.Error())
}
if status != http.StatusOK {
t.Errorf("%v", err.ApiError())
}
if g.Success != true {
t.Errorf("%v", err.ApiError())
}
}
func TestClient_DeliveryShipments(t *testing.T) {
c := client()

View File

@ -175,10 +175,10 @@ type ProductsPropertiesRequest struct {
// DeliveryTrackingRequest type
type DeliveryTrackingRequest struct {
DeliveryID string `url:"deliveryId,omitempty"`
TrackNumber string `url:"trackNumber,omitempty"`
History []DeliveryHistoryRecord `url:"history,omitempty,brackets"`
ExtraData map[string]string `url:"extraData,omitempty,brackets"`
DeliveryID string `json:"deliveryId,omitempty"`
TrackNumber string `json:"trackNumber,omitempty"`
History []DeliveryHistoryRecord `json:"history,omitempty,brackets"`
ExtraData map[string]string `json:"extraData,omitempty,brackets"`
}
// DeliveryShipmentsRequest type