Update March 11, 2025 (#154)
This commit is contained in:
@@ -164,6 +164,8 @@ type ChatHistoryParams struct {
|
||||
// The default value is `Backward`. You can set the number of messages in the limit parameter
|
||||
Direction string `json:"direction" default:"Backward"`
|
||||
|
||||
Filter *ChatHistoryFilter `json:"filter,omitempty"`
|
||||
|
||||
// Identifier of the message from which the chat history will be displayed.
|
||||
// Default value is the last visible message
|
||||
FromMessageId string `json:"from_message_id"`
|
||||
@@ -172,6 +174,10 @@ type ChatHistoryParams struct {
|
||||
Limit int64 `json:"limit" default:"50"`
|
||||
}
|
||||
|
||||
type ChatHistoryFilter struct {
|
||||
MessageIds []string `json:"message_ids"`
|
||||
}
|
||||
|
||||
type ChatHistoryResponse struct {
|
||||
core.CommonResponse
|
||||
|
||||
@@ -183,22 +189,33 @@ type ChatHistoryResponse struct {
|
||||
}
|
||||
|
||||
type ChatHistoryMessage struct {
|
||||
Context *ChatHistoryContext `json:"context,omitempty"`
|
||||
|
||||
// Message creation date
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
|
||||
// Array with message content in Markdown format
|
||||
Data []string `json:"data"`
|
||||
|
||||
IsImage bool `json:"is_image"`
|
||||
|
||||
// Indication of the read message
|
||||
IsRead bool `json:"is_read"`
|
||||
|
||||
// Message identifier
|
||||
MessageId string `json:"message_id"`
|
||||
|
||||
ModarateImageStatus string `json:"moderate_image_status"`
|
||||
|
||||
// Chat participant identifier
|
||||
User ChatHistoryMessageUser `json:"user"`
|
||||
}
|
||||
|
||||
type ChatHistoryContext struct {
|
||||
OrderNumber string `json:"order_number"`
|
||||
SKU string `json:"sku"`
|
||||
}
|
||||
|
||||
type ChatHistoryMessageUser struct {
|
||||
// Chat participant identifier
|
||||
Id string `json:"id"`
|
||||
@@ -214,7 +231,7 @@ type ChatHistoryMessageUser struct {
|
||||
|
||||
// Returns the history of chat messages. By default messages are shown from newest to oldest.
|
||||
func (c Chats) History(ctx context.Context, params *ChatHistoryParams) (*ChatHistoryResponse, error) {
|
||||
url := "/v2/chat/history"
|
||||
url := "/v3/chat/history"
|
||||
|
||||
resp := &ChatHistoryResponse{}
|
||||
|
||||
|
||||
@@ -212,16 +212,22 @@ func TestChatHistory(t *testing.T) {
|
||||
"has_next": true,
|
||||
"messages": [
|
||||
{
|
||||
"context": {
|
||||
"order_number": "123456789",
|
||||
"sku": "987654321"
|
||||
},
|
||||
"created_at": "2019-08-24T14:15:22Z",
|
||||
"data": [
|
||||
"Здравствуйте, у меня вопрос по вашему товару \"Стекло защитное для смартфонов\", артикул 11223. Подойдет ли он на данную [ модель ](https://www.ozon.ru/product/smartfon-samsung-galaxy-a03s-4-64-gb-chernyy) телефона?"
|
||||
],
|
||||
"is_image": true,
|
||||
"is_read": true,
|
||||
"message_id": "3000000000817031942",
|
||||
"moderate_image_status": "SUCCESS",
|
||||
"user": {
|
||||
"id": "115568",
|
||||
"type": "Сustomer"
|
||||
},
|
||||
"created_at": "2022-07-18T20:58:04.528Z",
|
||||
"is_read": true,
|
||||
"data": [
|
||||
"Здравствуйте, у меня вопрос по вашему товару \"Стекло защитное для смартфонов\", артикул 11223. Подойдет ли он на данную [ модель ](https://www.ozon.ru/product/smartfon-samsung-galaxy-a03s-4-64-gb-chernyy) телефона?"
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}`,
|
||||
|
||||
@@ -297,196 +297,6 @@ func (c Promotions) RemoveProduct(ctx context.Context, params *RemoveProductFrom
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
type ListHotSalePromotionsResponse struct {
|
||||
core.CommonResponse
|
||||
|
||||
// Method result
|
||||
Result []ListHotSalePromotionsResult `json:"result"`
|
||||
}
|
||||
|
||||
type ListHotSalePromotionsResult struct {
|
||||
// Promotion end date
|
||||
DateEnd string `json:"date_end"`
|
||||
|
||||
// Promotion start date
|
||||
DateStart string `json:"date_start"`
|
||||
|
||||
// Promotion description
|
||||
Description string `json:"description"`
|
||||
|
||||
// Promotion freeze date.
|
||||
//
|
||||
// If the field is filled, the seller can't increase prices, change the list of products,
|
||||
// or decrease the number of product units in the promotion.
|
||||
//
|
||||
// The seller can lower prices and increase the product units number in the promotion
|
||||
FreezeDate string `json:"freeze_date"`
|
||||
|
||||
// Hot Sale promotion identifier
|
||||
HotsaleId float64 `json:"hotsale_id"`
|
||||
|
||||
// Indication that you participate in this promotion
|
||||
IsParticipating bool `json:"is_participating"`
|
||||
|
||||
// Promotion name
|
||||
Title string `json:"title"`
|
||||
}
|
||||
|
||||
// List of available Hot Sale promotions
|
||||
func (c Promotions) ListHotSalePromotions(ctx context.Context) (*ListHotSalePromotionsResponse, error) {
|
||||
url := "/v1/actions/hotsales/list"
|
||||
|
||||
resp := &ListHotSalePromotionsResponse{}
|
||||
|
||||
response, err := c.client.Request(ctx, http.MethodPost, url, nil, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
response.CopyCommonResponse(&resp.CommonResponse)
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
type ProductsAvailableForHotSalePromotionParams struct {
|
||||
// Hot Sale promotion identifier
|
||||
HotSaleId float64 `json:"hotsale_id"`
|
||||
|
||||
// Number of elements in the response. Default value is 100
|
||||
Limit float64 `json:"limit"`
|
||||
|
||||
// Number of elements that will be skipped in the response. For example, if offset=10, the response will start with the 11th element found
|
||||
Offset float64 `json:"offset,omitempty"`
|
||||
}
|
||||
|
||||
type ProductsAvailableForHotSalePromotionResponse struct {
|
||||
core.CommonResponse
|
||||
|
||||
// Method result
|
||||
Result ProductsAvailableForHotSalePromotionResult `json:"result"`
|
||||
}
|
||||
|
||||
type ProductsAvailableForHotSalePromotionResult struct {
|
||||
// Products list
|
||||
Products []ProductsAvailableForHotSalePromotionResultProduct `json:"products"`
|
||||
|
||||
// Total number of products that are available for the promotion
|
||||
Total float64 `json:"total"`
|
||||
}
|
||||
|
||||
type ProductsAvailableForHotSalePromotionResultProduct struct {
|
||||
// Promotional product price
|
||||
ActionPrice float64 `json:"action_price"`
|
||||
|
||||
// Date when the product participates in the promotion in the YYYY-MM-DD format
|
||||
DateDayPromo string `json:"date_day_promo"`
|
||||
|
||||
// Product identifier
|
||||
Id float64 `json:"id"`
|
||||
|
||||
// Indication that product participates in the promotion
|
||||
IsActive bool `json:"is_active"`
|
||||
|
||||
// Maximum possible promotional price of the product
|
||||
MaxActionPrice float64 `json:"max_action_price"`
|
||||
|
||||
// Minimum number of product units in a stock discount type promotion
|
||||
MinStock float64 `json:"min_stock"`
|
||||
|
||||
// Number of product units in a stock discount type promotion
|
||||
Stock float64 `json:"stock"`
|
||||
}
|
||||
|
||||
// Method for getting a list of products that can participate or are already participating in the Hot Sale promotion
|
||||
func (c Promotions) ProductsAvailableForHotSalePromotion(ctx context.Context, params *ProductsAvailableForHotSalePromotionParams) (*ProductsAvailableForHotSalePromotionResponse, error) {
|
||||
url := "/v1/actions/hotsales/products"
|
||||
|
||||
resp := &ProductsAvailableForHotSalePromotionResponse{}
|
||||
|
||||
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 AddProductsToHotSaleParams struct {
|
||||
// Hot Sale promotion identifier
|
||||
HotSaleId float64 `json:"hotsale_id"`
|
||||
|
||||
// Products to be added to the promotion. The maximum number in one request is 100
|
||||
Products []AddProductsToHotSaleProduct `json:"products"`
|
||||
}
|
||||
|
||||
type AddProductsToHotSaleProduct struct {
|
||||
// Promotional product price
|
||||
ActionPrice float64 `json:"action_price"`
|
||||
|
||||
// Product identifier
|
||||
ProductId float64 `json:"product_id"`
|
||||
|
||||
// Number of product units in a stock discount type promotion
|
||||
Stock float64 `json:"stock"`
|
||||
}
|
||||
|
||||
type ProductsToHotSaleResponse struct {
|
||||
core.CommonResponse
|
||||
|
||||
// Method result
|
||||
Result ProductsToHotSaleResult `json:"result"`
|
||||
}
|
||||
|
||||
type ProductsToHotSaleResult struct {
|
||||
// List of products that haven't been added to the promotion
|
||||
Rejected []ProductsToHotSaleResultRejected `json:"rejected"`
|
||||
}
|
||||
|
||||
type ProductsToHotSaleResultRejected struct {
|
||||
//Product identifier
|
||||
ProductId float64 `json:"product_id"`
|
||||
|
||||
// Reason why the product hasn't been added to the promotion
|
||||
Reason string `json:"reason"`
|
||||
}
|
||||
|
||||
func (c Promotions) AddProductsToHotSale(ctx context.Context, params *AddProductsToHotSaleParams) (*ProductsToHotSaleResponse, error) {
|
||||
url := "/v1/actions/hotsales/activate"
|
||||
|
||||
resp := &ProductsToHotSaleResponse{}
|
||||
|
||||
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 RemoveProductsToHotSaleParams struct {
|
||||
// Hot Sale promotion identifier
|
||||
HotSaleId float64 `json:"hotsale_id"`
|
||||
|
||||
// List of products identifiers. Maximum number of values in one request is 100
|
||||
ProductIds []float64 `json:"product_ids"`
|
||||
}
|
||||
|
||||
// Remove product from the Hot Sale promotion
|
||||
func (c Promotions) RemoveProductsToHotSale(ctx context.Context, params *RemoveProductsToHotSaleParams) (*ProductsToHotSaleResponse, error) {
|
||||
url := "/v1/actions/hotsales/activate"
|
||||
|
||||
resp := &ProductsToHotSaleResponse{}
|
||||
|
||||
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 ListDiscountRequestsParams struct {
|
||||
// Discount request status
|
||||
Status ListDiscountRequestsStatus `json:"status" default:"UNKNOWN"`
|
||||
|
||||
@@ -354,248 +354,6 @@ func TestRemoveProduct(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestListHotSalePromotions(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
statusCode int
|
||||
headers map[string]string
|
||||
response string
|
||||
}{
|
||||
// Test Ok
|
||||
{
|
||||
http.StatusOK,
|
||||
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
|
||||
`{
|
||||
"result": [
|
||||
{
|
||||
"date_end": "string",
|
||||
"date_start": "string",
|
||||
"description": "string",
|
||||
"freeze_date": "string",
|
||||
"hotsale_id": 0,
|
||||
"is_participating": true,
|
||||
"title": "string"
|
||||
}
|
||||
]
|
||||
}`,
|
||||
},
|
||||
// Test No Client-Id or Api-Key
|
||||
{
|
||||
http.StatusUnauthorized,
|
||||
map[string]string{},
|
||||
`{
|
||||
"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.Promotions().ListHotSalePromotions(ctx)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
continue
|
||||
}
|
||||
|
||||
compareJsonResponse(t, test.response, &ListHotSalePromotionsResponse{})
|
||||
|
||||
if resp.StatusCode != test.statusCode {
|
||||
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestProductsAvailableForHotSalePromotion(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
statusCode int
|
||||
headers map[string]string
|
||||
params *ProductsAvailableForHotSalePromotionParams
|
||||
response string
|
||||
}{
|
||||
// Test Ok
|
||||
{
|
||||
http.StatusOK,
|
||||
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
|
||||
&ProductsAvailableForHotSalePromotionParams{
|
||||
HotSaleId: 0,
|
||||
Limit: 0,
|
||||
Offset: 0,
|
||||
},
|
||||
`{
|
||||
"result": {
|
||||
"products": [
|
||||
{
|
||||
"action_price": 0,
|
||||
"date_day_promo": "string",
|
||||
"id": 0,
|
||||
"is_active": true,
|
||||
"max_action_price": 0,
|
||||
"min_stock": 0,
|
||||
"stock": 0
|
||||
}
|
||||
],
|
||||
"total": 0
|
||||
}
|
||||
}`,
|
||||
},
|
||||
// Test No Client-Id or Api-Key
|
||||
{
|
||||
http.StatusUnauthorized,
|
||||
map[string]string{},
|
||||
&ProductsAvailableForHotSalePromotionParams{},
|
||||
`{
|
||||
"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.Promotions().ProductsAvailableForHotSalePromotion(ctx, test.params)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
continue
|
||||
}
|
||||
|
||||
compareJsonResponse(t, test.response, &ProductsAvailableForHotSalePromotionResponse{})
|
||||
|
||||
if resp.StatusCode != test.statusCode {
|
||||
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestAddProductsToHotSale(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
statusCode int
|
||||
headers map[string]string
|
||||
params *AddProductsToHotSaleParams
|
||||
response string
|
||||
}{
|
||||
// Test Ok
|
||||
{
|
||||
http.StatusOK,
|
||||
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
|
||||
&AddProductsToHotSaleParams{
|
||||
HotSaleId: 1234,
|
||||
Products: []AddProductsToHotSaleProduct{
|
||||
{
|
||||
ActionPrice: 12,
|
||||
ProductId: 111,
|
||||
Stock: 45,
|
||||
},
|
||||
},
|
||||
},
|
||||
`{
|
||||
"result": {
|
||||
"rejected": [
|
||||
{
|
||||
"product_id": 0,
|
||||
"reason": "string"
|
||||
}
|
||||
]
|
||||
}
|
||||
}`,
|
||||
},
|
||||
// Test No Client-Id or Api-Key
|
||||
{
|
||||
http.StatusUnauthorized,
|
||||
map[string]string{},
|
||||
&AddProductsToHotSaleParams{},
|
||||
`{
|
||||
"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.Promotions().AddProductsToHotSale(ctx, test.params)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
continue
|
||||
}
|
||||
|
||||
compareJsonResponse(t, test.response, &ProductsToHotSaleResponse{})
|
||||
|
||||
if resp.StatusCode != test.statusCode {
|
||||
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestRemoveProductsToHotSale(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
statusCode int
|
||||
headers map[string]string
|
||||
params *RemoveProductsToHotSaleParams
|
||||
response string
|
||||
}{
|
||||
// Test Ok
|
||||
{
|
||||
http.StatusOK,
|
||||
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
|
||||
&RemoveProductsToHotSaleParams{
|
||||
HotSaleId: 12345,
|
||||
ProductIds: []float64{111},
|
||||
},
|
||||
`{
|
||||
"result": {
|
||||
"rejected": [
|
||||
{
|
||||
"product_id": 0,
|
||||
"reason": "string"
|
||||
}
|
||||
]
|
||||
}
|
||||
}`,
|
||||
},
|
||||
// Test No Client-Id or Api-Key
|
||||
{
|
||||
http.StatusUnauthorized,
|
||||
map[string]string{},
|
||||
&RemoveProductsToHotSaleParams{},
|
||||
`{
|
||||
"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.Promotions().RemoveProductsToHotSale(ctx, test.params)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
continue
|
||||
}
|
||||
|
||||
compareJsonResponse(t, test.response, &ProductsToHotSaleResponse{})
|
||||
|
||||
if resp.StatusCode != test.statusCode {
|
||||
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestListDiscountRequests(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -480,6 +480,10 @@ type GetReturnsReportsFilter struct {
|
||||
type GetReturnsReportResponse struct {
|
||||
core.CommonResponse
|
||||
|
||||
Result GetReturnsReportResult `json:"result"`
|
||||
}
|
||||
|
||||
type GetReturnsReportResult struct {
|
||||
// Unique report identifier. The report is available for downloading within 3 days after making a request.
|
||||
Code string `json:"code"`
|
||||
}
|
||||
|
||||
@@ -380,7 +380,9 @@ func TestGetReturnsReport(t *testing.T) {
|
||||
},
|
||||
},
|
||||
`{
|
||||
"code": "REPORT_seller_products_924336_1720170405_a9ea2f27-a473-4b13-99f9-d0cfcb5b1a69"
|
||||
"result": {
|
||||
"code": "REPORT_seller_products_924336_1720170405_a9ea2f27-a473-4b13-99f9-d0cfcb5b1a69"
|
||||
}
|
||||
}`,
|
||||
},
|
||||
// Test No Client-Id or Api-Key
|
||||
|
||||
Reference in New Issue
Block a user