Update December 4, 2024 (#125)
This commit is contained in:
@@ -152,7 +152,7 @@ type ReturnCommission struct {
|
|||||||
//
|
//
|
||||||
// Report is returned no later than the 5th day of the next month
|
// Report is returned no later than the 5th day of the next month
|
||||||
func (c Finance) ReportOnSoldProducts(ctx context.Context, params *ReportOnSoldProductsParams) (*ReportOnSoldProductsResponse, error) {
|
func (c Finance) ReportOnSoldProducts(ctx context.Context, params *ReportOnSoldProductsParams) (*ReportOnSoldProductsResponse, error) {
|
||||||
url := "/v1/finance/realization"
|
url := "/v2/finance/realization"
|
||||||
|
|
||||||
resp := &ReportOnSoldProductsResponse{}
|
resp := &ReportOnSoldProductsResponse{}
|
||||||
|
|
||||||
|
|||||||
@@ -13,13 +13,11 @@ type Products struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type GetStocksInfoParams struct {
|
type GetStocksInfoParams struct {
|
||||||
// Identifier of the last value on the page. Leave this field blank in the first request.
|
// Cursor for the next data sample
|
||||||
//
|
Cursor string `json:"cursor"`
|
||||||
// To get the next values, specify last_id from the response of the previous request.
|
|
||||||
LastId string `json:"last_id"`
|
|
||||||
|
|
||||||
// Number of values per page. Minimum is 1, maximum is 1000
|
// Limit on number of entries in a reply. Default value is 1000. Maximum value is 1000
|
||||||
Limit int64 `json:"limit"`
|
Limit int32 `json:"limit"`
|
||||||
|
|
||||||
// Filter by product
|
// Filter by product
|
||||||
Filter GetStocksInfoFilter `json:"filter"`
|
Filter GetStocksInfoFilter `json:"filter"`
|
||||||
@@ -34,20 +32,24 @@ type GetStocksInfoFilter struct {
|
|||||||
|
|
||||||
// Filter by product visibility
|
// Filter by product visibility
|
||||||
Visibility string `json:"visibility,omitempty"`
|
Visibility string `json:"visibility,omitempty"`
|
||||||
|
|
||||||
|
// Products at the “Economy” tariff
|
||||||
|
WithQuant GetStocksInfoFilterWithQuant `json:"with_quant"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetStocksInfoFilterWithQuant struct {
|
||||||
|
// Active economy products
|
||||||
|
Created bool `json:"created"`
|
||||||
|
|
||||||
|
// Economy products in all statuses
|
||||||
|
Exists bool `json:"exists"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetStocksInfoResponse struct {
|
type GetStocksInfoResponse struct {
|
||||||
core.CommonResponse
|
core.CommonResponse
|
||||||
|
|
||||||
// Method Result
|
// Cursor for the next data sample
|
||||||
Result GetStocksInfoResult `json:"result"`
|
Cursor string `json:"cursor"`
|
||||||
}
|
|
||||||
|
|
||||||
type GetStocksInfoResult struct {
|
|
||||||
// Identifier of the last value on the page
|
|
||||||
//
|
|
||||||
// To get the next values, specify the recieved value in the next request in the last_id parameter
|
|
||||||
LastId string `json:"last_id"`
|
|
||||||
|
|
||||||
// The number of unique products for which information about stocks is displayed
|
// The number of unique products for which information about stocks is displayed
|
||||||
Total int32 `json:"total"`
|
Total int32 `json:"total"`
|
||||||
@@ -76,6 +78,12 @@ type GetStocksInfoResultItemStock struct {
|
|||||||
|
|
||||||
// Warehouse type
|
// Warehouse type
|
||||||
Type string `json:"type" default:"ALL"`
|
Type string `json:"type" default:"ALL"`
|
||||||
|
|
||||||
|
// Packaging type
|
||||||
|
ShipmentType string `json:"shipment_type"`
|
||||||
|
|
||||||
|
// Product identifier in the Ozon system, SKU
|
||||||
|
SKU int64 `json:"sku"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns information about the quantity of products in stock:
|
// Returns information about the quantity of products in stock:
|
||||||
@@ -84,7 +92,7 @@ type GetStocksInfoResultItemStock struct {
|
|||||||
//
|
//
|
||||||
// * how many are reserved by customers.
|
// * how many are reserved by customers.
|
||||||
func (c Products) GetStocksInfo(ctx context.Context, params *GetStocksInfoParams) (*GetStocksInfoResponse, error) {
|
func (c Products) GetStocksInfo(ctx context.Context, params *GetStocksInfoParams) (*GetStocksInfoResponse, error) {
|
||||||
url := "/v3/product/info/stocks"
|
url := "/v4/product/info/stocks"
|
||||||
|
|
||||||
resp := &GetStocksInfoResponse{}
|
resp := &GetStocksInfoResponse{}
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ func TestGetStocksInfo(t *testing.T) {
|
|||||||
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
|
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
|
||||||
&GetStocksInfoParams{
|
&GetStocksInfoParams{
|
||||||
Limit: 100,
|
Limit: 100,
|
||||||
LastId: "",
|
Cursor: "",
|
||||||
Filter: GetStocksInfoFilter{
|
Filter: GetStocksInfoFilter{
|
||||||
OfferId: []string{"136834"},
|
OfferId: []string{"136834"},
|
||||||
ProductId: []int64{214887921},
|
ProductId: []int64{214887921},
|
||||||
@@ -32,28 +32,23 @@ func TestGetStocksInfo(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
`{
|
`{
|
||||||
"result": {
|
"cursor": "string",
|
||||||
"items": [
|
"items": [
|
||||||
{
|
{
|
||||||
"product_id": 214887921,
|
"offer_id": "string",
|
||||||
"offer_id": "136834",
|
"product_id": 123,
|
||||||
"stocks": [
|
"stocks": [
|
||||||
{
|
{
|
||||||
"type": "fbs",
|
"present": 0,
|
||||||
"present": 170,
|
"reserved": 0,
|
||||||
"reserved": 0
|
"shipment_type": "SHIPMENT_TYPE_GENERAL",
|
||||||
},
|
"sku": 0,
|
||||||
{
|
"type": "string"
|
||||||
"type": "fbo",
|
}
|
||||||
"present": 0,
|
]
|
||||||
"reserved": 0
|
}
|
||||||
}
|
],
|
||||||
]
|
"total": 0
|
||||||
}
|
|
||||||
],
|
|
||||||
"total": 1,
|
|
||||||
"last_id": "anVsbA=="
|
|
||||||
}
|
|
||||||
}`,
|
}`,
|
||||||
},
|
},
|
||||||
// Test No Client-Id or Api-Key
|
// Test No Client-Id or Api-Key
|
||||||
@@ -85,14 +80,14 @@ func TestGetStocksInfo(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if resp.StatusCode == http.StatusOK {
|
if resp.StatusCode == http.StatusOK {
|
||||||
if len(resp.Result.Items) > int(test.params.Limit) {
|
if len(resp.Items) > int(test.params.Limit) {
|
||||||
t.Errorf("Amount of items in response cannot be bigger than limit")
|
t.Errorf("Amount of items in response cannot be bigger than limit")
|
||||||
}
|
}
|
||||||
if len(resp.Result.Items) > 0 {
|
if len(resp.Items) > 0 {
|
||||||
if resp.Result.Items[0].ProductId == 0 {
|
if resp.Items[0].ProductId == 0 {
|
||||||
t.Errorf("Product id cannot be 0")
|
t.Errorf("Product id cannot be 0")
|
||||||
}
|
}
|
||||||
if resp.Result.Items[0].OfferId == "" {
|
if resp.Items[0].OfferId == "" {
|
||||||
t.Errorf("Offer id cannot be empty")
|
t.Errorf("Offer id cannot be empty")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user