diff --git a/ozon/fbs.go b/ozon/fbs.go index 5c0e3fb..e54ce3d 100644 --- a/ozon/fbs.go +++ b/ozon/fbs.go @@ -106,6 +106,9 @@ type FBSPosting struct { // Analytics data AnalyticsData FBSPostingAnalyticsData `json:"analytics_data"` + // Available actions and shipment information + AvailableActions []string `json:"available_actions"` + // Shipment barcodes Barcodes FBSBarcode `json:"barcodes"` @@ -912,6 +915,9 @@ type GetShipmentDataByIdentifierResult struct { // Analytics data AnalyticsData GetShipmentDataByIdentifierResultAnalyticsData `json:"analytics_data"` + // Available actions and shipment information + AvailableActions []string `json:"available_actions"` + // Shipment barcodes Barcodes FBSBarcode `json:"barcodes"` @@ -3051,3 +3057,32 @@ func (c FBS) GetCancellationReasons(ctx context.Context) (*GetCancellationReason return resp, nil } + +type SetShippingDateParams struct { + // New shipping date + NewCutoffDate time.Time `json:"new_cutoff_date"` + + // Shipment number + PostingNumber string `json:"posting_number"` +} + +type SetShippingDateResponse struct { + core.CommonResponse + + // true if the new date is set + Result bool `json:"result"` +} + +func (c FBS) SetShippingDate(ctx context.Context, params *SetShippingDateParams) (*SetShippingDateResponse, error) { + url := "/v1/posting/cutoff/set" + + resp := &SetShippingDateResponse{} + + 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 +} diff --git a/ozon/fbs_test.go b/ozon/fbs_test.go index 61db15f..bb4b9ff 100644 --- a/ozon/fbs_test.go +++ b/ozon/fbs_test.go @@ -3080,3 +3080,53 @@ func TestGetCancellationReasons(t *testing.T) { } } } + +func TestSetShippingDate(t *testing.T) { + t.Parallel() + + tests := []struct { + statusCode int + headers map[string]string + params *SetShippingDateParams + response string + }{ + // Test Ok + { + http.StatusOK, + map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"}, + &SetShippingDateParams{ + NewCutoffDate: core.TimeFromString(t, "2006-01-02T15:04:05Z", "2019-08-24T14:15:22Z"), + }, + `{ + "result": true + }`, + }, + // Test No Client-Id or Api-Key + { + http.StatusUnauthorized, + map[string]string{}, + &SetShippingDateParams{}, + `{ + "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.FBS().SetShippingDate(ctx, test.params) + if err != nil { + t.Error(err) + continue + } + + compareJsonResponse(t, test.response, &SetShippingDateResponse{}) + + if resp.StatusCode != test.statusCode { + t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode) + } + } +} diff --git a/ozon/products.go b/ozon/products.go index 971a5c9..e7ac2eb 100644 --- a/ozon/products.go +++ b/ozon/products.go @@ -1762,67 +1762,6 @@ func (c Products) RemoveProductWithoutSKU(ctx context.Context, params *RemovePro return resp, nil } -type ListGeoRestrictionsParams struct { - // Filter. To get all geo-restrictions, leave names blank and specify true in the only_visible parameter - Filter ListGeoRestrictionsFilter `json:"filter"` - - // Order number of geo-restriction from which to output data in the response. - // - // If you specify 23 in this parameter, the first item in the restrictions list will output order_number = 24. - // If you want to get all geo-restrictions, pass 0 in this parameter - LastOrderNumber int64 `json:"last_order_number"` - - // Number of items in the response - Limit int64 `json:"limit"` -} - -type ListGeoRestrictionsFilter struct { - // List with city names - Names []string `json:"names"` - - // Value visibility. We recommend always passing true in this parameter - OnlyVisible bool `json:"only_visible"` -} - -type ListGeoRestrictionsResponse struct { - core.CommonResponse - - // Restrictions - Restrictions []ListGeoRestrictionsRestriction `json:"restrictions"` -} - -type ListGeoRestrictionsRestriction struct { - // Geo-restriction identifier - Id string `json:"id"` - - // Item visibility - IsVisible bool `json:"is_visible"` - - // City name - Name string `json:"name"` - - // Geo-restriction order number. - // - // If you specify 23 in the last_order_number parameter in the request, - // the first item in the restrictions list will have order_number = 24 - OrderNumber int64 `json:"order_number"` -} - -// Deprecated: Get a list of geo-restrictions for services -func (c Products) ListGeoRestrictions(ctx context.Context, params *ListGeoRestrictionsParams) (*ListGeoRestrictionsResponse, error) { - url := "/v1/products/geo-restrictions-catalog-by-filter" - - resp := &ListGeoRestrictionsResponse{} - - 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 -} - type UploadActivationCodesParams struct { // Digital activation codes DigitalCodes []string `json:"digital_codes"` diff --git a/ozon/products_test.go b/ozon/products_test.go index ffb2545..c2f372c 100644 --- a/ozon/products_test.go +++ b/ozon/products_test.go @@ -2140,79 +2140,6 @@ func TestRemoveProductWithoutSKU(t *testing.T) { } } -func TestListGeoRestrictions(t *testing.T) { - t.Parallel() - - tests := []struct { - statusCode int - headers map[string]string - params *ListGeoRestrictionsParams - response string - }{ - // Test Ok - { - http.StatusOK, - map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"}, - &ListGeoRestrictionsParams{ - Filter: ListGeoRestrictionsFilter{ - OnlyVisible: true, - }, - LastOrderNumber: 0, - Limit: 3, - }, - `{ - "restrictions": [ - { - "id": "world", - "name": "Весь Мир", - "is_visible": true, - "order_number": 1 - }, - { - "id": "42fb1c32-0cfe-5c96-9fb5-7f8e8449f28c", - "name": "Все города РФ", - "is_visible": true, - "order_number": 2 - }, - { - "id": "moscow", - "name": "Москва", - "is_visible": true, - "order_number": 3 - } - ] - }`, - }, - // Test No Client-Id or Api-Key - { - http.StatusUnauthorized, - map[string]string{}, - &ListGeoRestrictionsParams{}, - `{ - "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.Products().ListGeoRestrictions(ctx, test.params) - if err != nil { - t.Error(err) - continue - } - - compareJsonResponse(t, test.response, &ListGeoRestrictionsResponse{}) - - if resp.StatusCode != test.statusCode { - t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode) - } - } -} - func TestUploadActivationCodes(t *testing.T) { t.Parallel()