mirror of
https://github.com/retailcrm/api-client-go.git
synced 2024-11-22 04:46:03 +03:00
fixes DeliveryTracking method (#44)
This commit is contained in:
parent
3d71115827
commit
7fc96e5542
605
v5/client.go
605
v5/client.go
File diff suppressed because it is too large
Load Diff
@ -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()
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user