From 7f705a4eb54a65567aeba1657671892a21aa8809 Mon Sep 17 00:00:00 2001 From: Kirill Date: Fri, 10 Jan 2025 20:51:55 +0300 Subject: [PATCH] Update December 11, 2024 (#128) --- ozon/products.go | 32 ++++++++++++++++++++++++++++---- ozon/products_test.go | 35 ++++++++++++++++++++--------------- 2 files changed, 48 insertions(+), 19 deletions(-) diff --git a/ozon/products.go b/ozon/products.go index 210fcd3..ae50441 100644 --- a/ozon/products.go +++ b/ozon/products.go @@ -1321,11 +1321,35 @@ type CheckImageUploadingStatusParams struct { ProductId []int64 `json:"product_id"` } -// Check products images uploading status -func (c Products) CheckImageUploadingStatus(ctx context.Context, params *CheckImageUploadingStatusParams) (*ProductInfoResponse, error) { - url := "/v1/product/pictures/info" +type CheckImageUploadingStatusResponse struct { + core.CommonResponse - resp := &ProductInfoResponse{} + // Product images + Items []CheckImageUploadingStatusItem `json:"items"` +} + +type CheckImageUploadingStatusItem struct { + // Product identifier + ProductId int64 `json:"product_id"` + + // Main image link + PrimaryPhoto []string `json:"primary_photo"` + + // Links to product photos + Photo []string `json:"photo"` + + // Links to uploaded color samples + ColorPhoto []string `json:"color_photo"` + + // 360 images links + Photo360 []string `json:"photo_360"` +} + +// Check products images uploading status +func (c Products) CheckImageUploadingStatus(ctx context.Context, params *CheckImageUploadingStatusParams) (*CheckImageUploadingStatusResponse, error) { + url := "/v2/product/pictures/info" + + resp := &CheckImageUploadingStatusResponse{} response, err := c.client.Request(ctx, http.MethodPost, url, params, resp, nil) if err != nil { diff --git a/ozon/products_test.go b/ozon/products_test.go index e1bb509..4a26067 100644 --- a/ozon/products_test.go +++ b/ozon/products_test.go @@ -1290,18 +1290,23 @@ func TestCheckImageUploadingStatus(t *testing.T) { ProductId: []int64{123456}, }, `{ - "result": { - "pictures": [ - { - "is_360": true, - "is_color": true, - "is_primary": true, - "product_id": 123456, - "state": "string", - "url": "string" - } - ] - } + "items": [ + { + "product_id": 123456, + "primary_photo": [ + "string" + ], + "photo": [ + "string" + ], + "color_photo": [ + "string" + ], + "photo_360": [ + "string" + ] + } + ] }`, }, // Test No Client-Id or Api-Key @@ -1326,15 +1331,15 @@ func TestCheckImageUploadingStatus(t *testing.T) { continue } - compareJsonResponse(t, test.response, &ProductInfoResponse{}) + compareJsonResponse(t, test.response, &CheckImageUploadingStatusResponse{}) if resp.StatusCode != test.statusCode { t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode) } if resp.StatusCode == http.StatusOK { - if len(resp.Result.Pictures) > 0 { - if resp.Result.Pictures[0].ProductId != test.params.ProductId[0] { + if len(resp.Items) > 0 { + if resp.Items[0].ProductId != test.params.ProductId[0] { t.Errorf("Product ids in request and response are not equal") } }