Update January 15, 2025 (#140)
This commit is contained in:
@@ -749,6 +749,12 @@ type UpdatePricesPrice struct {
|
||||
// By default, the passed value is RUB, Russian ruble
|
||||
CurrencyCode string `json:"currency_code"`
|
||||
|
||||
// true, if Ozon takes into account
|
||||
// the minimum price when creating promotions.
|
||||
// If you don't pass anything,
|
||||
// the status of the price accounting remains the same
|
||||
MinPriceForAutoActionsEnabled bool `json:"min_price_for_auto_actions_enabled"`
|
||||
|
||||
// Minimum product price with all promotions applied
|
||||
MinPrice string `json:"min_price"`
|
||||
|
||||
@@ -2746,3 +2752,63 @@ func (c Products) ListEconomy(ctx context.Context, params *ListEconomyProductsPa
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
type UpdatePriceRelevanceTimerParams struct {
|
||||
// List of product identifiers
|
||||
ProductIds []string `json:"product_ids"`
|
||||
}
|
||||
|
||||
type UpdatePriceRelevanceTimerResponse struct {
|
||||
core.CommonResponse
|
||||
}
|
||||
|
||||
func (c Products) UpdatePriceRelevanceTimer(ctx context.Context, params *UpdatePriceRelevanceTimerParams) (*UpdatePriceRelevanceTimerResponse, error) {
|
||||
url := "/v1/product/action/timer/update"
|
||||
|
||||
resp := &UpdatePriceRelevanceTimerResponse{}
|
||||
|
||||
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 StatusPriceRelevanceTimerParams struct {
|
||||
// List of product identifiers
|
||||
ProductIds []string `json:"product_ids"`
|
||||
}
|
||||
|
||||
type StatusPriceRelevanceTimerResponse struct {
|
||||
core.CommonResponse
|
||||
|
||||
Statuses []PriceRelevanceTimerStatus `json:"statuses"`
|
||||
}
|
||||
|
||||
type PriceRelevanceTimerStatus struct {
|
||||
// Timer end time
|
||||
ExpiredAt time.Time `json:"expired_at"`
|
||||
|
||||
// true, if Ozon takes into account the minimum price when creating promotions
|
||||
MinPriceForAutoActionsEnabled bool `json:"min_price_for_auto_actions_enabled"`
|
||||
|
||||
// Product identifier
|
||||
ProductId int64 `json:"product_id"`
|
||||
}
|
||||
|
||||
// Get status of timer you've set
|
||||
func (c Products) StatusPriceRelevanceTimer(ctx context.Context, params *StatusPriceRelevanceTimerParams) (*StatusPriceRelevanceTimerResponse, error) {
|
||||
url := "/v1/product/action/timer/update"
|
||||
|
||||
resp := &StatusPriceRelevanceTimerResponse{}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
@@ -2740,3 +2740,107 @@ func TestListEconomy(t *testing.T) {
|
||||
compareJsonResponse(t, test.response, &ListEconomyProductsResponse{})
|
||||
}
|
||||
}
|
||||
|
||||
func TestUpdatePriceRelevanceTimer(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
statusCode int
|
||||
headers map[string]string
|
||||
params *UpdatePriceRelevanceTimerParams
|
||||
response string
|
||||
}{
|
||||
// Test Ok
|
||||
{
|
||||
http.StatusOK,
|
||||
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
|
||||
&UpdatePriceRelevanceTimerParams{
|
||||
ProductIds: []string{"string"},
|
||||
},
|
||||
`{}`,
|
||||
},
|
||||
// Test No Client-Id or Api-Key
|
||||
{
|
||||
http.StatusUnauthorized,
|
||||
map[string]string{},
|
||||
&UpdatePriceRelevanceTimerParams{},
|
||||
`{
|
||||
"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().UpdatePriceRelevanceTimer(ctx, test.params)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
continue
|
||||
}
|
||||
|
||||
if resp.StatusCode != test.statusCode {
|
||||
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
|
||||
}
|
||||
|
||||
compareJsonResponse(t, test.response, &UpdatePriceRelevanceTimerResponse{})
|
||||
}
|
||||
}
|
||||
|
||||
func TestStatusPriceRelevanceTimer(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
statusCode int
|
||||
headers map[string]string
|
||||
params *StatusPriceRelevanceTimerParams
|
||||
response string
|
||||
}{
|
||||
// Test Ok
|
||||
{
|
||||
http.StatusOK,
|
||||
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
|
||||
&StatusPriceRelevanceTimerParams{
|
||||
ProductIds: []string{"string"},
|
||||
},
|
||||
`{
|
||||
"statuses": [
|
||||
{
|
||||
"expired_at": "2019-08-24T14:15:22Z",
|
||||
"min_price_for_auto_actions_enabled": true,
|
||||
"product_id": 0
|
||||
}
|
||||
]
|
||||
}`,
|
||||
},
|
||||
// Test No Client-Id or Api-Key
|
||||
{
|
||||
http.StatusUnauthorized,
|
||||
map[string]string{},
|
||||
&StatusPriceRelevanceTimerParams{},
|
||||
`{
|
||||
"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().StatusPriceRelevanceTimer(ctx, test.params)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
continue
|
||||
}
|
||||
|
||||
if resp.StatusCode != test.statusCode {
|
||||
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
|
||||
}
|
||||
|
||||
compareJsonResponse(t, test.response, &StatusPriceRelevanceTimerResponse{})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -725,7 +725,7 @@ func (c Returns) FBSQuantity(ctx context.Context, params *GetFBSQuantityReturnsP
|
||||
}
|
||||
|
||||
type ListReturnsParams struct {
|
||||
// Filter
|
||||
// Filters. Use only one filter per request. Otherwise it returns an error
|
||||
Filter *ListReturnsFilter `json:"filter,omitempty"`
|
||||
|
||||
// Number of loaded returns. The maximum value is 500
|
||||
@@ -748,7 +748,7 @@ type ListReturnsFilter struct {
|
||||
// Filter by order identifier
|
||||
OrderId int64 `json:"order_id,omitempty"`
|
||||
|
||||
// Filter by shipment number
|
||||
// Filter by shipment number. Pass no more than 50 postings
|
||||
PostingNumbers []string `json:"posting_numbers,omitempty"`
|
||||
|
||||
// Filter by product name
|
||||
|
||||
Reference in New Issue
Block a user