remove deprecated method Delete Polygon (#41)
This commit is contained in:
@@ -85,27 +85,3 @@ func (c Polygons) Link(ctx context.Context, params *LinkDeliveryMethodToPolygonP
|
|||||||
|
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type DeletePolygonParams struct {
|
|
||||||
// Polygons identifiers list
|
|
||||||
PolygonIds []int64 `json:"polygon_ids"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type DeletePolygonResponse struct {
|
|
||||||
core.CommonResponse
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete polygon
|
|
||||||
func (c Polygons) Delete(ctx context.Context, params *DeletePolygonParams) (*DeletePolygonResponse, error) {
|
|
||||||
url := "/v1/polygon/delete"
|
|
||||||
|
|
||||||
resp := &DeletePolygonResponse{}
|
|
||||||
|
|
||||||
response, err := c.client.Request(ctx, http.MethodPost, url, params, resp, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
response.CopyCommonResponse(&resp.CommonResponse)
|
|
||||||
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -109,48 +109,3 @@ func TestLinkDeliveryMethodToPolygon(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDeletePolygon(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
tests := []struct {
|
|
||||||
statusCode int
|
|
||||||
headers map[string]string
|
|
||||||
params *DeletePolygonParams
|
|
||||||
response string
|
|
||||||
}{
|
|
||||||
// Test Ok
|
|
||||||
{
|
|
||||||
http.StatusOK,
|
|
||||||
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
|
|
||||||
&DeletePolygonParams{
|
|
||||||
PolygonIds: []int64{1323},
|
|
||||||
},
|
|
||||||
`{}`,
|
|
||||||
},
|
|
||||||
// Test No Client-Id or Api-Key
|
|
||||||
{
|
|
||||||
http.StatusUnauthorized,
|
|
||||||
map[string]string{},
|
|
||||||
&DeletePolygonParams{},
|
|
||||||
`{
|
|
||||||
"code": 16,
|
|
||||||
"message": "Client-Id and Api-Key headers are required"
|
|
||||||
}`,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, test := range tests {
|
|
||||||
c := NewMockClient(core.NewMockHttpHandler(test.statusCode, test.response, test.headers))
|
|
||||||
|
|
||||||
ctx, _ := context.WithTimeout(context.Background(), testTimeout)
|
|
||||||
resp, err := c.Polygons().Delete(ctx, test.params)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if resp.StatusCode != test.statusCode {
|
|
||||||
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user