Skip to content

Commit cf9eae4

Browse files
committed
add methods for getting stocks and products reports, make tests run parallel
1 parent 0a3eadd commit cf9eae4

12 files changed

+231
-3
lines changed

ENDPOINTS.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,7 @@
154154
## Reports
155155
- [x] Report details
156156
- [x] Reports list
157-
- [ ] Products report
158-
- [ ] Prices report
157+
- [x] Products report
159158
- [ ] Stocks report
160159
- [ ] Report on products movement
161160
- [ ] Returns report

ozon/analytics_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import (
88
)
99

1010
func TestGetAnalyticsData(t *testing.T) {
11+
t.Parallel()
12+
1113
tests := []struct {
1214
statusCode int
1315
headers map[string]string
@@ -69,6 +71,8 @@ func TestGetAnalyticsData(t *testing.T) {
6971
}
7072

7173
func TestGetStocksOnWarehouses(t *testing.T) {
74+
t.Parallel()
75+
7276
tests := []struct {
7377
statusCode int
7478
headers map[string]string

ozon/fbo_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import (
88
)
99

1010
func TestGetFBOShipmentsList(t *testing.T) {
11+
t.Parallel()
12+
1113
tests := []struct {
1214
statusCode int
1315
headers map[string]string

ozon/fbs_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import (
88
)
99

1010
func TestListUnprocessedShipments(t *testing.T) {
11+
t.Parallel()
12+
1113
tests := []struct {
1214
statusCode int
1315
headers map[string]string
@@ -177,6 +179,8 @@ func TestListUnprocessedShipments(t *testing.T) {
177179
}
178180

179181
func TestGetFBSShipmentsList(t *testing.T) {
182+
t.Parallel()
183+
180184
tests := []struct {
181185
statusCode int
182186
headers map[string]string
@@ -286,6 +290,8 @@ func TestGetFBSShipmentsList(t *testing.T) {
286290
}
287291

288292
func TestPackOrder(t *testing.T) {
293+
t.Parallel()
294+
289295
tests := []struct {
290296
statusCode int
291297
headers map[string]string
@@ -345,6 +351,8 @@ func TestPackOrder(t *testing.T) {
345351
}
346352

347353
func TestValidateLabelingCodes(t *testing.T) {
354+
t.Parallel()
355+
348356
tests := []struct {
349357
statusCode int
350358
headers map[string]string

ozon/finance_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import (
88
)
99

1010
func TestReportOnSoldProducts(t *testing.T) {
11+
t.Parallel()
12+
1113
tests := []struct {
1214
statusCode int
1315
headers map[string]string
@@ -106,6 +108,8 @@ func TestReportOnSoldProducts(t *testing.T) {
106108
}
107109

108110
func TestGetTotalTransactionsSum(t *testing.T) {
111+
t.Parallel()
112+
109113
tests := []struct {
110114
statusCode int
111115
headers map[string]string

ozon/products_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import (
88
)
99

1010
func TestGetStocksInfo(t *testing.T) {
11+
t.Parallel()
12+
1113
tests := []struct {
1214
statusCode int
1315
headers map[string]string
@@ -79,6 +81,8 @@ func TestGetStocksInfo(t *testing.T) {
7981
}
8082

8183
func TestGetProductDetails(t *testing.T) {
84+
t.Parallel()
85+
8286
tests := []struct {
8387
statusCode int
8488
headers map[string]string
@@ -243,6 +247,8 @@ func TestGetProductDetails(t *testing.T) {
243247
}
244248

245249
func TestUpdateStocks(t *testing.T) {
250+
t.Parallel()
251+
246252
tests := []struct {
247253
statusCode int
248254
headers map[string]string
@@ -300,6 +306,8 @@ func TestUpdateStocks(t *testing.T) {
300306
}
301307

302308
func TestStocksInSellersWarehouse(t *testing.T) {
309+
t.Parallel()
310+
303311
tests := []struct {
304312
statusCode int
305313
headers map[string]string
@@ -353,6 +361,8 @@ func TestStocksInSellersWarehouse(t *testing.T) {
353361
}
354362

355363
func TestUpdatePrices(t *testing.T) {
364+
t.Parallel()
365+
356366
tests := []struct {
357367
statusCode int
358368
headers map[string]string
@@ -413,6 +423,8 @@ func TestUpdatePrices(t *testing.T) {
413423
}
414424

415425
func TestUpdateQuantityStockProducts(t *testing.T) {
426+
t.Parallel()
427+
416428
tests := []struct {
417429
statusCode int
418430
headers map[string]string
@@ -472,6 +484,8 @@ func TestUpdateQuantityStockProducts(t *testing.T) {
472484
}
473485

474486
func TestCreateOrUpdateProduct(t *testing.T) {
487+
t.Parallel()
488+
475489
tests := []struct {
476490
statusCode int
477491
headers map[string]string
@@ -587,6 +601,8 @@ func TestCreateOrUpdateProduct(t *testing.T) {
587601
}
588602

589603
func TestGetListOfProducts(t *testing.T) {
604+
t.Parallel()
605+
590606
tests := []struct {
591607
statusCode int
592608
headers map[string]string
@@ -646,6 +662,8 @@ func TestGetListOfProducts(t *testing.T) {
646662
}
647663

648664
func TestGetProductsRatingBySKU(t *testing.T) {
665+
t.Parallel()
666+
649667
tests := []struct {
650668
statusCode int
651669
headers map[string]string

ozon/promotions_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import (
88
)
99

1010
func TestGetAvailablePromotions(t *testing.T) {
11+
t.Parallel()
12+
1113
tests := []struct {
1214
statusCode int
1315
headers map[string]string
@@ -66,6 +68,8 @@ func TestGetAvailablePromotions(t *testing.T) {
6668
}
6769

6870
func TestAddToPromotion(t *testing.T) {
71+
t.Parallel()
72+
6973
tests := []struct {
7074
statusCode int
7175
headers map[string]string

ozon/rating_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import (
88
)
99

1010
func TestGetCurrentRatingInfo(t *testing.T) {
11+
t.Parallel()
12+
1113
tests := []struct {
1214
statusCode int
1315
headers map[string]string
@@ -68,6 +70,8 @@ func TestGetCurrentRatingInfo(t *testing.T) {
6870
}
6971

7072
func TestGetRatingInfoForPeriod(t *testing.T) {
73+
t.Parallel()
74+
7175
tests := []struct {
7276
statusCode int
7377
headers map[string]string

ozon/reports.go

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,3 +225,82 @@ func (c Reports) GetFinancial(params *GetFinancialReportParams) (*GetFinancialRe
225225

226226
return resp, nil
227227
}
228+
229+
type GetProductsReportParams struct {
230+
// Default: "DEFAULT"
231+
// Response language:
232+
// - RU — Russian
233+
// - EN — English
234+
Language string `json:"language" default:"DEFAULT"`
235+
236+
// Product identifier in the seller's system
237+
OfferId []string `json:"offer_id"`
238+
239+
// Search by record content, checks for availability
240+
Search string `json:"search"`
241+
242+
// Product identifier in the Ozon system, SKU
243+
SKU []int64 `json:"sku"`
244+
245+
// Default: "ALL"
246+
// Filter by product visibility
247+
Visibility string `json:"visibility" default:"ALL"`
248+
}
249+
250+
type GetProductsReportResponse struct {
251+
core.CommonResponse
252+
253+
// Method result
254+
Result struct {
255+
// Unique report identifier
256+
Code string `json:"code"`
257+
} `json:"result"`
258+
}
259+
260+
// Method for getting a report with products data. For example, Ozon ID, number of products, prices, status
261+
func (c Reports) GetProducts(params *GetProductsReportParams) (*GetProductsReportResponse, error) {
262+
url := "/v1/report/products/create"
263+
264+
resp := &GetProductsReportResponse{}
265+
266+
response, err := c.client.Request(http.MethodPost, url, params, resp)
267+
if err != nil {
268+
return nil, err
269+
}
270+
response.CopyCommonResponse(&resp.CommonResponse)
271+
272+
return resp, nil
273+
}
274+
275+
type GetStocksReportParams struct {
276+
// Default: "DEFAULT"
277+
// Response language:
278+
// - RU — Russian
279+
// - EN — English
280+
Language string `json:"language" default:"DEFAULT"`
281+
}
282+
283+
type GetStocksReportResponse struct {
284+
core.CommonResponse
285+
286+
// Method result
287+
Result struct {
288+
// Unique report identifier
289+
Code string `json:"code"`
290+
} `json:"result"`
291+
}
292+
293+
// Report with information about the number of available and reserved products in stock
294+
func (c Reports) GetStocks(params *GetStocksReportParams) (*GetStocksReportResponse, error) {
295+
url := "/v1/report/stock/create"
296+
297+
resp := &GetStocksReportResponse{}
298+
299+
response, err := c.client.Request(http.MethodPost, url, params, resp)
300+
if err != nil {
301+
return nil, err
302+
}
303+
response.CopyCommonResponse(&resp.CommonResponse)
304+
305+
return resp, nil
306+
}

0 commit comments

Comments
 (0)