Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
40dd5b86a8 | ||
|
|
e5f2007a8e | ||
|
|
40d9fc32cb | ||
|
|
b07968d280 | ||
|
|
699d210296 | ||
|
|
07d38a8456 | ||
|
|
0f1d0410bc | ||
|
|
6d4d97e3c8 | ||
|
|
85543f45b0 |
@@ -20,6 +20,21 @@ type GetAnalyticsDataParams struct {
|
||||
DateTo time.Time `json:"date_to"`
|
||||
|
||||
// Items Enum: "unknownDimension" "sku" "spu" "day" "week" "month" "year" "category1" "category2" "category3" "category4" "brand" "modelID"
|
||||
// Data grouping available to all sellers:
|
||||
// - unknownDimension—unknown,
|
||||
// - sku—product identifier,
|
||||
// - spu—product identifier,
|
||||
// - day—day,
|
||||
// - week—week,
|
||||
// - month—month.
|
||||
// Data grouping available to sellers with Premium subscription:
|
||||
// - year—year,
|
||||
// - category1—first level category,
|
||||
// - category2—second level category,
|
||||
// - category3—third level category,
|
||||
// - category4—fourth level category,
|
||||
// - brand—brand,
|
||||
// - modelID—model.
|
||||
Dimension []GetAnalyticsDataDimension `json:"dimension"`
|
||||
|
||||
// Filters
|
||||
@@ -31,6 +46,30 @@ type GetAnalyticsDataParams struct {
|
||||
Limit int64 `json:"limit"`
|
||||
|
||||
// Specify up to 14 metrics. If there are more, you will get an error with the InvalidArgument code
|
||||
// The list of metrics for which the report will be generated.
|
||||
//
|
||||
// Metrics available to all sellers:
|
||||
//
|
||||
// - revenue—ordered amount,
|
||||
// - ordered_units—ordered products.
|
||||
// Metrics available to sellers with Premium subscription:
|
||||
// - unknown_metric—unknown metric,
|
||||
// - hits_view_search—impressions in search and category,
|
||||
// - hits_view_pdp—impressions on the product description page,
|
||||
// - hits_view—total impressions,
|
||||
// - hits_tocart_search—added to cart from search or category,
|
||||
// - hits_tocart_pdp—added to cart from the product description page,
|
||||
// - hits_tocart—added to cart total,
|
||||
// - session_view_search—sessions with impressions in search or category,
|
||||
// - session_view_pdp—sessions with impressions on the product description page,
|
||||
// - session_view—sessions total,
|
||||
// - conv_tocart_search—conversion to cart from search or category,
|
||||
// - conv_tocart_pdp—conversion to cart from a product description page,
|
||||
// - conv_tocart—total conversion to cart,
|
||||
// - returns—returned products,
|
||||
// - cancellations—canceled products,
|
||||
// - delivered_units—delivered products,
|
||||
// - position_category—position in search and category.
|
||||
Metrics []GetAnalyticsDataFilterMetric `json:"metrics"`
|
||||
|
||||
// Number of elements that will be skipped in the response. For example, if `offset=10`, the response will start with the 11th element found
|
||||
@@ -95,6 +134,13 @@ type GetAnalyticsDataResultDimension struct {
|
||||
}
|
||||
|
||||
// Specify the period and metrics that are required. The response will contain analytical data grouped by the `dimensions` parameter.
|
||||
//
|
||||
// There are restrictions for sellers without Premium subscription:
|
||||
//
|
||||
// - data is available for the last 3 months,
|
||||
// - some of the data grouping methods and metrics aren't available.
|
||||
//
|
||||
// There are no restrictions for sellers with Premium subscription
|
||||
func (c Analytics) GetAnalyticsData(ctx context.Context, params *GetAnalyticsDataParams) (*GetAnalyticsDataResponse, error) {
|
||||
url := "/v1/analytics/data"
|
||||
|
||||
|
||||
111
ozon/barcodes.go
Normal file
111
ozon/barcodes.go
Normal file
@@ -0,0 +1,111 @@
|
||||
package ozon
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
core "github.com/diphantxm/ozon-api-client"
|
||||
)
|
||||
|
||||
type Barcodes struct {
|
||||
client *core.Client
|
||||
}
|
||||
|
||||
type GenerateBarcodesParams struct {
|
||||
// List of products for which you want to generate barcodes
|
||||
ProductIds []int64 `json:"product_ids"`
|
||||
}
|
||||
|
||||
type GenerateBarcodesResponse struct {
|
||||
core.CommonResponse
|
||||
|
||||
Errors []GenerateBarcodesError `json:"errors"`
|
||||
}
|
||||
|
||||
type GenerateBarcodesError struct {
|
||||
// Error code
|
||||
Code string `json:"code"`
|
||||
|
||||
// Error details
|
||||
Error string `json:"error"`
|
||||
|
||||
// Barcode that is failed to generate
|
||||
Barcode string `json:"barcode"`
|
||||
|
||||
// Product identifier for which the barcode generation failed
|
||||
ProductId int64 `json:"product_id"`
|
||||
}
|
||||
|
||||
// If a product doesn't have a barcode, you can create it using this method. If a barcode already exists,
|
||||
// but it isn't specified in your account, you can bind it using the `/v1/barcode/add` method.
|
||||
//
|
||||
// You can't generate barcodes for more than 100 products per request.
|
||||
// You can use the method no more than 20 times per minute.
|
||||
func (b *Barcodes) Generate(ctx context.Context, params *GenerateBarcodesParams) (*GenerateBarcodesResponse, error) {
|
||||
url := "/v1/barcode/generate"
|
||||
|
||||
resp := &GenerateBarcodesResponse{}
|
||||
|
||||
response, err := b.client.Request(ctx, http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
response.CopyCommonResponse(&resp.CommonResponse)
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
type BindBarcodesParams struct {
|
||||
// List of barcodes and products
|
||||
Barcodes []BindBarcode `json:"barcodes"`
|
||||
}
|
||||
|
||||
type BindBarcode struct {
|
||||
// Barcode. Maximum 100 characters
|
||||
Barcode string `json:"barcode"`
|
||||
|
||||
// Product identifier in the Ozon system, SKU
|
||||
SKU int64 `json:"sku"`
|
||||
}
|
||||
|
||||
type BindBarcodesResponse struct {
|
||||
core.CommonResponse
|
||||
|
||||
// Errors while binding barcodes
|
||||
Errors []BindBarcodesError `json:"errors"`
|
||||
}
|
||||
|
||||
type BindBarcodesError struct {
|
||||
// Error code
|
||||
Code string `json:"code"`
|
||||
|
||||
// Error details
|
||||
Error string `json:"error"`
|
||||
|
||||
// Barcode that is failed to generate
|
||||
Barcode string `json:"barcode"`
|
||||
|
||||
// SKU of the product for which the barcode binding failed
|
||||
SKU int64 `json:"sku"`
|
||||
}
|
||||
|
||||
// If a product has a barcode that isn't specified in your account,
|
||||
// bind it using this method. If a product doesn't have a barcode,
|
||||
// you can create it using the `/v1/barcode/generate` method.
|
||||
//
|
||||
// You can't bind barcodes to more than 100 products per request.
|
||||
// Each product can have up to 100 barcodes.
|
||||
// You can use the method no more than 20 times per minute.
|
||||
func (b *Barcodes) Bind(ctx context.Context, params *BindBarcodesParams) (*BindBarcodesResponse, error) {
|
||||
url := "/v1/barcode/add"
|
||||
|
||||
resp := &BindBarcodesResponse{}
|
||||
|
||||
response, err := b.client.Request(ctx, http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
response.CopyCommonResponse(&resp.CommonResponse)
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
141
ozon/barcodes_test.go
Normal file
141
ozon/barcodes_test.go
Normal file
@@ -0,0 +1,141 @@
|
||||
package ozon
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
core "github.com/diphantxm/ozon-api-client"
|
||||
)
|
||||
|
||||
func TestGenerateBarcodes(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
statusCode int
|
||||
headers map[string]string
|
||||
params *GenerateBarcodesParams
|
||||
response string
|
||||
}{
|
||||
// Test Ok
|
||||
{
|
||||
http.StatusOK,
|
||||
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
|
||||
&GenerateBarcodesParams{
|
||||
ProductIds: []int64{123456789},
|
||||
},
|
||||
`{
|
||||
"errors": [
|
||||
{
|
||||
"code": "code 200",
|
||||
"error": "no error",
|
||||
"barcode": "456",
|
||||
"product_id": 123456789
|
||||
}
|
||||
]
|
||||
}`,
|
||||
},
|
||||
// Test No Client-Id or Api-Key
|
||||
{
|
||||
http.StatusUnauthorized,
|
||||
map[string]string{},
|
||||
&GenerateBarcodesParams{},
|
||||
`{
|
||||
"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.Barcodes().Generate(ctx, test.params)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
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.Errors) != 0 {
|
||||
if resp.Errors[0].ProductId != test.params.ProductIds[0] {
|
||||
t.Errorf("Product ids are not equal")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestBindBarcodes(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
statusCode int
|
||||
headers map[string]string
|
||||
params *BindBarcodesParams
|
||||
response string
|
||||
}{
|
||||
// Test Ok
|
||||
{
|
||||
http.StatusOK,
|
||||
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
|
||||
&BindBarcodesParams{
|
||||
Barcodes: []BindBarcode{
|
||||
{
|
||||
Barcode: "some barcode",
|
||||
SKU: 123456789,
|
||||
},
|
||||
},
|
||||
},
|
||||
`{
|
||||
"errors": [
|
||||
{
|
||||
"code": "code 200",
|
||||
"error": "no error",
|
||||
"barcode": "some barcode",
|
||||
"sku": 123456789
|
||||
}
|
||||
]
|
||||
}`,
|
||||
},
|
||||
// Test No Client-Id or Api-Key
|
||||
{
|
||||
http.StatusUnauthorized,
|
||||
map[string]string{},
|
||||
&BindBarcodesParams{},
|
||||
`{
|
||||
"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.Barcodes().Bind(ctx, test.params)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
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.Errors) != 0 {
|
||||
if resp.Errors[0].Barcode != test.params.Barcodes[0].Barcode {
|
||||
t.Errorf("Barcodes are not equal")
|
||||
}
|
||||
if resp.Errors[0].SKU != test.params.Barcodes[0].SKU {
|
||||
t.Errorf("Barcodes are not equal")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,17 +12,14 @@ type Categories struct {
|
||||
}
|
||||
|
||||
type GetProductTreeParams struct {
|
||||
// Category identifier
|
||||
CategoryId int64 `json:"category_id"`
|
||||
|
||||
// Response language
|
||||
Language Language `json:"language" default:"DEFAULT"`
|
||||
Language Language `json:"language"`
|
||||
}
|
||||
|
||||
type GetProductTreeResponse struct {
|
||||
core.CommonResponse
|
||||
|
||||
// Category list
|
||||
// Categories list
|
||||
Result []GetProductTreeResult `json:"result"`
|
||||
}
|
||||
|
||||
@@ -30,19 +27,29 @@ type GetProductTreeResult struct {
|
||||
// Category identifier
|
||||
CategoryId int64 `json:"category_id"`
|
||||
|
||||
// Subcategory tree
|
||||
Children []GetProductTreeResponse `json:"children"`
|
||||
|
||||
// Category name
|
||||
Title string `json:"title"`
|
||||
CategoryName string `json:"category_name"`
|
||||
|
||||
// `true`, if you can't create products in the category. `false`, if you can
|
||||
Disabled bool `json:"disabled"`
|
||||
|
||||
// Product type identifier
|
||||
TypeId int64 `json:"type_id"`
|
||||
|
||||
// Product type name
|
||||
TypeName string `json:"type_name"`
|
||||
|
||||
// Subcategory tree
|
||||
Children []GetProductTreeResult `json:"children"`
|
||||
}
|
||||
|
||||
// Returns product categories in the tree view.
|
||||
//
|
||||
// New products can be created in the last level categories only.
|
||||
// This means that you need to match these particular categories with the categories of your site.
|
||||
// It is not possible to create categories by user request
|
||||
func (c Categories) Tree(ctx context.Context, params *GetProductTreeParams) (*GetProductTreeResponse, error) {
|
||||
url := "/v2/category/tree"
|
||||
// We don't create new categories by user request.
|
||||
func (c *Categories) Tree(ctx context.Context, params *GetProductTreeParams) (*GetProductTreeResponse, error) {
|
||||
url := "/v1/description-category/tree"
|
||||
|
||||
resp := &GetProductTreeResponse{}
|
||||
|
||||
@@ -56,14 +63,14 @@ func (c Categories) Tree(ctx context.Context, params *GetProductTreeParams) (*Ge
|
||||
}
|
||||
|
||||
type GetCategoryAttributesParams struct {
|
||||
// Filter by characteristics
|
||||
AttributeType AttributeType `json:"attribute_type" default:"ALL"`
|
||||
|
||||
// Category identifier
|
||||
CategoryId []int64 `json:"category_id"`
|
||||
CategoryId int64 `json:"category_id"`
|
||||
|
||||
// Response language
|
||||
Language Language `json:"language" default:"DEFAULT"`
|
||||
Language Language `json:"language"`
|
||||
|
||||
// Product type identifier
|
||||
TypeId int64 `json:"type_id"`
|
||||
}
|
||||
|
||||
type GetCategoryAttributesResponse struct {
|
||||
@@ -74,19 +81,6 @@ type GetCategoryAttributesResponse struct {
|
||||
}
|
||||
|
||||
type GetCategoryAttributesResult struct {
|
||||
// Array of product characteristics
|
||||
Attributes []GetCategoryAttributesResultAttribute `json:"attributes"`
|
||||
|
||||
// Category identifier
|
||||
CategoryId int64 `json:"category_id"`
|
||||
}
|
||||
|
||||
type GetCategoryAttributesResultAttribute struct {
|
||||
// Indication that the dictionary attribute values depend on the category:
|
||||
// - true — the attribute has its own set of values for each category.
|
||||
// - false — the attribute has the same set of values for all categories
|
||||
CategoryDependent bool `json:"category_dependent"`
|
||||
|
||||
// Characteristic description
|
||||
Description string `json:"description"`
|
||||
|
||||
@@ -99,26 +93,29 @@ type GetCategoryAttributesResultAttribute struct {
|
||||
// Characteristics group name
|
||||
GroupName string `json:"group_name"`
|
||||
|
||||
// Document generation task number
|
||||
// Number of document generation task
|
||||
Id int64 `json:"id"`
|
||||
|
||||
// Indicates that the attribute is aspect. An aspect attribute is a characteristic that distinguishes products of the same model.
|
||||
//
|
||||
// For example, clothes and shoes of the same model may have different colors and sizes. That is, color and size are aspect attributes.
|
||||
// For example, clothes or shoes of the same model may have different colors and sizes. That is, color and size are aspect attributes.
|
||||
//
|
||||
// Values description:
|
||||
// - true — the attribute is aspect and cannot be changed after the products are delivered to the warehouse or sold from the seller's warehouse.
|
||||
// - false — the attribute is not aspect and can be changed at any time
|
||||
//
|
||||
// - `true`—the attribute is aspect and can't be changed after the products are delivered to the warehouse or sold from the seller's warehouse.
|
||||
// - `false`—the attribute is not aspect and can be changed at any time
|
||||
IsAspect bool `json:"is_aspect"`
|
||||
|
||||
// Indicates that the characteristic is a set of values:
|
||||
// - true — the characteristic is a set of values,
|
||||
// - false — the characteristic consists of a single value
|
||||
//
|
||||
// - `true`—the characteristic is a set of values,
|
||||
// - `false`—the characteristic consists of a single value
|
||||
IsCollection bool `json:"is_collection"`
|
||||
|
||||
// Indicates that the characteristic is mandatory:
|
||||
// - true — a mandatory characteristic,
|
||||
// - false — you can leave the characteristic out
|
||||
//
|
||||
// - `true`—a mandatory characteristic,
|
||||
// - `false`—an optional characteristic
|
||||
IsRequired bool `json:"is_required"`
|
||||
|
||||
// Name
|
||||
@@ -128,15 +125,13 @@ type GetCategoryAttributesResultAttribute struct {
|
||||
Type string `json:"type"`
|
||||
}
|
||||
|
||||
// Getting characteristics for specified product category.
|
||||
// Getting characteristics for specified product category and type.
|
||||
//
|
||||
// Pass up to 20 category identifiers in the `category_id` list.
|
||||
//
|
||||
// You can check whether the attribute has a nested directory by the `dictionary_id` parameter.
|
||||
// The 0 value means there is no directory. If the value is different, then there are directories.
|
||||
// You can get them using the `/v2/category/attribute/values` method
|
||||
func (c Categories) Attributes(ctx context.Context, params *GetCategoryAttributesParams) (*GetCategoryAttributesResponse, error) {
|
||||
url := "/v3/category/attribute"
|
||||
// If the dictionary_id value is 0, there is no directory.
|
||||
// If the value is different, there are directories.
|
||||
// Get them using the `/v1/description-category/attribute/values` method.
|
||||
func (c *Categories) Attributes(ctx context.Context, params *GetCategoryAttributesParams) (*GetCategoryAttributesResponse, error) {
|
||||
url := "/v1/description-category/attribute"
|
||||
|
||||
resp := &GetCategoryAttributesResponse{}
|
||||
|
||||
@@ -157,39 +152,55 @@ type GetAttributeDictionaryParams struct {
|
||||
CategoryId int64 `json:"category_id"`
|
||||
|
||||
// Response language
|
||||
// The default language is Russian
|
||||
Language Language `json:"language" default:"DEFAULT"`
|
||||
Language Language `json:"language"`
|
||||
|
||||
// Identifier of the directory to start the response with.
|
||||
// If `last_value_id` is 10, the response will contain directories starting from the 11th
|
||||
LastValueId int64 `json:"last_value_id"`
|
||||
|
||||
// Number of values in the response:
|
||||
// - maximum — 5000
|
||||
// - minimum — 1
|
||||
//
|
||||
// - maximum—5000,
|
||||
// - minimum—1.
|
||||
Limit int64 `json:"limit"`
|
||||
|
||||
// Product type identifier
|
||||
TypeId int64 `json:"type_id"`
|
||||
}
|
||||
|
||||
type GetAttributeDictionaryResponse struct {
|
||||
core.CommonResponse
|
||||
|
||||
// Indication that only part of characteristic values was returned in the response:
|
||||
//
|
||||
// - true—make a request with a new last_value_id parameter value for getting the rest of characteristic values;
|
||||
// - false—all characteristic values were returned
|
||||
HasNext bool `json:"has_next"`
|
||||
|
||||
// Method result
|
||||
// Characteristic values
|
||||
Result []GetAttributeDictionaryResult `json:"result"`
|
||||
}
|
||||
|
||||
type GetAttributeDictionaryResult struct {
|
||||
Id int64 `json:"id"`
|
||||
Info string `json:"info"`
|
||||
// Characteristic value identifier
|
||||
Id int64 `json:"id"`
|
||||
|
||||
// Additional description
|
||||
Info string `json:"info"`
|
||||
|
||||
// Image link
|
||||
Picture string `json:"picture"`
|
||||
|
||||
// Product characteristic value
|
||||
Value string `json:"value"`
|
||||
}
|
||||
|
||||
// You can use the `/v3/category/attribute` method to check if an attribute has a nested directory.
|
||||
// If there are directories, get them using this method
|
||||
func (c Categories) AttributesDictionary(ctx context.Context, params *GetAttributeDictionaryParams) (*GetAttributeDictionaryResponse, error) {
|
||||
url := "/v2/category/attribute/values"
|
||||
// Returns characteristics value directory.
|
||||
//
|
||||
// To check if an attribute has a nested directory,
|
||||
// use the `/v1/description-category/attribute` method.
|
||||
func (c *Categories) AttributesDictionary(ctx context.Context, params *GetAttributeDictionaryParams) (*GetAttributeDictionaryResponse, error) {
|
||||
url := "/v1/description-category/attribute"
|
||||
|
||||
resp := &GetAttributeDictionaryResponse{}
|
||||
|
||||
|
||||
@@ -22,14 +22,17 @@ func TestGetProductTree(t *testing.T) {
|
||||
http.StatusOK,
|
||||
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
|
||||
&GetProductTreeParams{
|
||||
CategoryId: 17034410,
|
||||
Language: English,
|
||||
},
|
||||
`{
|
||||
"result": [
|
||||
{
|
||||
"category_id": 17034410,
|
||||
"title": "Развивающие игрушки",
|
||||
"children": []
|
||||
"category_id": 0,
|
||||
"category_name": "string",
|
||||
"children": [],
|
||||
"disabled": true,
|
||||
"type_id": 0,
|
||||
"type_name": "string"
|
||||
}
|
||||
]
|
||||
}`,
|
||||
@@ -58,14 +61,6 @@ func TestGetProductTree(t *testing.T) {
|
||||
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) > 0 {
|
||||
if resp.Result[0].CategoryId != test.params.CategoryId {
|
||||
t.Errorf("First category ids in request and response are not equal")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,25 +78,23 @@ func TestGetCategoryAttributes(t *testing.T) {
|
||||
http.StatusOK,
|
||||
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
|
||||
&GetCategoryAttributesParams{
|
||||
CategoryId: []int64{17034410},
|
||||
CategoryId: 12345,
|
||||
Language: English,
|
||||
TypeId: 2,
|
||||
},
|
||||
`{
|
||||
"result": [
|
||||
{
|
||||
"category_id": 17034410,
|
||||
"attributes": [
|
||||
{
|
||||
"id": 85,
|
||||
"name": "Бренд",
|
||||
"description": "Укажите наименование бренда, под которым произведен товар. Если товар не имеет бренда, используйте значение \"Нет бренда\"",
|
||||
"type": "String",
|
||||
"is_collection": false,
|
||||
"is_required": true,
|
||||
"group_id": 0,
|
||||
"group_name": "",
|
||||
"dictionary_id": 28732849
|
||||
}
|
||||
]
|
||||
"description": "string",
|
||||
"dictionary_id": 0,
|
||||
"group_id": 0,
|
||||
"group_name": "string",
|
||||
"id": 0,
|
||||
"is_aspect": true,
|
||||
"is_collection": true,
|
||||
"is_required": true,
|
||||
"name": "string",
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
}`,
|
||||
@@ -130,17 +123,6 @@ func TestGetCategoryAttributes(t *testing.T) {
|
||||
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) != len(test.params.CategoryId) {
|
||||
t.Errorf("Length of categories in request and response are not equal")
|
||||
}
|
||||
if len(resp.Result) > 0 {
|
||||
if resp.Result[0].CategoryId != test.params.CategoryId[0] {
|
||||
t.Errorf("Category ids in request and response are not equal")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,33 +140,23 @@ func TestGetAttributeDictionary(t *testing.T) {
|
||||
http.StatusOK,
|
||||
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
|
||||
&GetAttributeDictionaryParams{
|
||||
AttributeId: 10096,
|
||||
CategoryId: 17028968,
|
||||
LastValueId: 0,
|
||||
Limit: 3,
|
||||
AttributeId: 123456,
|
||||
CategoryId: 12,
|
||||
Language: English,
|
||||
LastValueId: 1,
|
||||
Limit: 5,
|
||||
TypeId: 6,
|
||||
},
|
||||
`{
|
||||
"has_next": true,
|
||||
"result": [
|
||||
{
|
||||
"id": 61571,
|
||||
"value": "белый",
|
||||
"info": "",
|
||||
"picture": ""
|
||||
},
|
||||
{
|
||||
"id": 61572,
|
||||
"value": "прозрачный",
|
||||
"info": "",
|
||||
"picture": ""
|
||||
},
|
||||
{
|
||||
"id": 61573,
|
||||
"value": "бежевый",
|
||||
"info": "",
|
||||
"picture": ""
|
||||
"id": 0,
|
||||
"info": "string",
|
||||
"picture": "string",
|
||||
"value": "string"
|
||||
}
|
||||
],
|
||||
"has_next": true
|
||||
]
|
||||
}`,
|
||||
},
|
||||
// Test No Client-Id or Api-Key
|
||||
|
||||
@@ -540,3 +540,50 @@ const (
|
||||
// pound sterling
|
||||
InvoiceCurrencyGBP InvoiceCurrency = "GBP"
|
||||
)
|
||||
|
||||
type ReportType string
|
||||
|
||||
const (
|
||||
// products report
|
||||
ReportTypeSellerProducts ReportType = "SELLER_PRODUCTS"
|
||||
|
||||
// transactions report
|
||||
ReportTypeSellerTransactions ReportType = "SELLER_TRANSACTIONS"
|
||||
|
||||
// product prices report
|
||||
ReportTypeSellerProductPrices ReportType = "SELLER_PRODUCT_PRICES"
|
||||
|
||||
// stocks report
|
||||
ReportTypeSellerStock ReportType = "SELLER_STOCK"
|
||||
|
||||
// products movement report
|
||||
ReportTypeSellerProductMovement ReportType = "SELLER_PRODUCT_MOVEMENT"
|
||||
|
||||
// returns report
|
||||
ReportTypeSellerReturns ReportType = "SELLER_RETURNS"
|
||||
|
||||
// shipments report
|
||||
ReportTypeSellerPostings ReportType = "SELLER_POSTINGS"
|
||||
|
||||
// financial report
|
||||
ReportTypeSellerFinance ReportType = "SELLER_FINANCE"
|
||||
)
|
||||
|
||||
type ReportInfoStatus string
|
||||
|
||||
const (
|
||||
ReportInfoWaiting ReportInfoStatus = "waiting"
|
||||
ReportInfoProcessing ReportInfoStatus = "processing"
|
||||
ReportInfoSuccess ReportInfoStatus = "success"
|
||||
ReportInfoFailed ReportInfoStatus = "failed"
|
||||
)
|
||||
|
||||
type SKUAvailability string
|
||||
|
||||
const (
|
||||
SKUAvailabilityHidden = "HIDDEN"
|
||||
SKUAvailabilityAvailable = "AVAILABLE"
|
||||
|
||||
// SKU is deleted
|
||||
SKUAvailabilityUnavailable = "UNAVAILABLE"
|
||||
)
|
||||
|
||||
@@ -306,7 +306,7 @@ type FBSRequirements struct {
|
||||
//
|
||||
// To pack the shipment, pass the CCD number for all listed SKUs.
|
||||
// If you do not have a CCD number, pass the value `is_gtd_absent` = true
|
||||
// via the `/v3/posting/fbs/ship/package` or `/v3/posting/fbs/ship` method
|
||||
// via the `/v3/posting/fbs/ship/package`
|
||||
ProductsRequiringGTD []string `json:"products_requiring_gtd"`
|
||||
|
||||
// Array of Ozon Product IDs (SKU) for which
|
||||
|
||||
@@ -21,12 +21,12 @@ type ReportOnSoldProductsResponse struct {
|
||||
core.CommonResponse
|
||||
|
||||
// Query result
|
||||
Result []ReportonSoldProductsResult `json:"result"`
|
||||
Result ReportonSoldProductsResult `json:"result"`
|
||||
}
|
||||
|
||||
type ReportonSoldProductsResult struct {
|
||||
// Report title page
|
||||
Header []ReportOnSoldProductsResultHeader `json:"header"`
|
||||
Header ReportOnSoldProductsResultHeader `json:"header"`
|
||||
|
||||
// Report table
|
||||
Rows []ReportOnSoldProductsResultRow `json:"rows"`
|
||||
@@ -272,7 +272,7 @@ type ListTransactionsFilter struct {
|
||||
Date ListTransactionsFilterDate `json:"date"`
|
||||
|
||||
// Operation type
|
||||
OperationType string `json:"operation_type"`
|
||||
OperationType []string `json:"operation_type"`
|
||||
|
||||
// Shipment number
|
||||
PostingNumber string `json:"posting_number"`
|
||||
|
||||
@@ -25,55 +25,51 @@ func TestReportOnSoldProducts(t *testing.T) {
|
||||
&ReportOnSoldProductsParams{
|
||||
Date: "2022-09",
|
||||
},
|
||||
`{
|
||||
"result": [
|
||||
{
|
||||
"header": [
|
||||
{
|
||||
"doc_date": "2022-09-22",
|
||||
"num": "string",
|
||||
"start_date": "2022-09-02",
|
||||
"stop_date": "2022-09-22",
|
||||
"contract_date": "2022-09-02",
|
||||
"contract_num": "string",
|
||||
"payer_name": "string",
|
||||
"payer_inn": "string",
|
||||
"payer_kpp": "string",
|
||||
"rcv_name": "string",
|
||||
"rcv_inn": "string",
|
||||
"rcv_kpp": "string",
|
||||
"doc_amount": 1,
|
||||
"vat_amount": 1,
|
||||
"currency_code": "string"
|
||||
}
|
||||
],
|
||||
"rows": [
|
||||
{
|
||||
"row_number": 0,
|
||||
"product_id": 0,
|
||||
"product_name": "string",
|
||||
"offer_id": "string",
|
||||
"barcode": "string",
|
||||
"price": 0,
|
||||
"commission_percent": 0,
|
||||
"price_sale": 0,
|
||||
"sale_qty": 0,
|
||||
"sale_amount": 0,
|
||||
"sale_discount": 0,
|
||||
"sale_commission": 0,
|
||||
"sale_price_seller": 0,
|
||||
"return_sale": 0,
|
||||
"return_qty": 0,
|
||||
"return_amount": 0,
|
||||
"return_discount": 0,
|
||||
"return_commission": 0,
|
||||
"return_price_seller": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}`,
|
||||
"",
|
||||
`{
|
||||
"result": {
|
||||
"header": {
|
||||
"doc_date": "2022-09-22",
|
||||
"num": "string",
|
||||
"start_date": "2022-09-02",
|
||||
"stop_date": "2022-09-22",
|
||||
"contract_date": "2022-09-02",
|
||||
"contract_num": "string",
|
||||
"payer_name": "string",
|
||||
"payer_inn": "string",
|
||||
"payer_kpp": "string",
|
||||
"rcv_name": "string",
|
||||
"rcv_inn": "string",
|
||||
"rcv_kpp": "string",
|
||||
"doc_amount": 1,
|
||||
"vat_amount": 1,
|
||||
"currency_code": "string"
|
||||
},
|
||||
"rows": [
|
||||
{
|
||||
"row_number": 0,
|
||||
"product_id": 0,
|
||||
"product_name": "string",
|
||||
"offer_id": "string",
|
||||
"barcode": "string",
|
||||
"price": 0,
|
||||
"commission_percent": 0,
|
||||
"price_sale": 0,
|
||||
"sale_qty": 0,
|
||||
"sale_amount": 0,
|
||||
"sale_discount": 0,
|
||||
"sale_commission": 0,
|
||||
"sale_price_seller": 0,
|
||||
"return_sale": 0,
|
||||
"return_qty": 0,
|
||||
"return_amount": 0,
|
||||
"return_discount": 0,
|
||||
"return_commission": 0,
|
||||
"return_price_seller": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
}`,
|
||||
"",
|
||||
},
|
||||
// Test No Client-Id or Api-Key
|
||||
{
|
||||
|
||||
@@ -31,6 +31,7 @@ type Client struct {
|
||||
chats *Chats
|
||||
certificates *Certificates
|
||||
strategies *Strategies
|
||||
barcodes *Barcodes
|
||||
}
|
||||
|
||||
func (c Client) Analytics() *Analytics {
|
||||
@@ -105,6 +106,10 @@ func (c Client) Strategies() *Strategies {
|
||||
return c.strategies
|
||||
}
|
||||
|
||||
func (c Client) Barcodes() *Barcodes {
|
||||
return c.barcodes
|
||||
}
|
||||
|
||||
func NewClient(httpClient core.HttpClient, clientId, apiKey string) *Client {
|
||||
coreClient := core.NewClient(httpClient, DefaultAPIBaseUrl, map[string]string{
|
||||
"Client-Id": clientId,
|
||||
@@ -131,6 +136,7 @@ func NewClient(httpClient core.HttpClient, clientId, apiKey string) *Client {
|
||||
chats: &Chats{client: coreClient},
|
||||
certificates: &Certificates{client: coreClient},
|
||||
strategies: &Strategies{client: coreClient},
|
||||
barcodes: &Barcodes{client: coreClient},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,5 +163,6 @@ func NewMockClient(handler http.HandlerFunc) *Client {
|
||||
chats: &Chats{client: coreClient},
|
||||
certificates: &Certificates{client: coreClient},
|
||||
strategies: &Strategies{client: coreClient},
|
||||
barcodes: &Barcodes{client: coreClient},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,27 +85,3 @@ func (c Polygons) Link(ctx context.Context, params *LinkDeliveryMethodToPolygonP
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
type DeletePolygonParams struct {
|
||||
// Polygons identifiers list
|
||||
PolygonIds []int64 `json:"polygon_ids"`
|
||||
}
|
||||
|
||||
type DeletePolygonResponse struct {
|
||||
core.CommonResponse
|
||||
}
|
||||
|
||||
// Delete polygon
|
||||
func (c Polygons) Delete(ctx context.Context, params *DeletePolygonParams) (*DeletePolygonResponse, error) {
|
||||
url := "/v1/polygon/delete"
|
||||
|
||||
resp := &DeletePolygonResponse{}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
@@ -109,48 +109,3 @@ func TestLinkDeliveryMethodToPolygon(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestDeletePolygon(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
statusCode int
|
||||
headers map[string]string
|
||||
params *DeletePolygonParams
|
||||
response string
|
||||
}{
|
||||
// Test Ok
|
||||
{
|
||||
http.StatusOK,
|
||||
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
|
||||
&DeletePolygonParams{
|
||||
PolygonIds: []int64{1323},
|
||||
},
|
||||
`{}`,
|
||||
},
|
||||
// Test No Client-Id or Api-Key
|
||||
{
|
||||
http.StatusUnauthorized,
|
||||
map[string]string{},
|
||||
&DeletePolygonParams{},
|
||||
`{
|
||||
"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.Polygons().Delete(ctx, test.params)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if resp.StatusCode != test.statusCode {
|
||||
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ type ProductDetails struct {
|
||||
BuyboxPrice string `json:"buybox_price"`
|
||||
|
||||
// Category identifier
|
||||
CategoryId int64 `json:"category_id"`
|
||||
DescriptionCategoryId int64 `json:"description_category_id"`
|
||||
|
||||
// Marketing color
|
||||
ColorImage string `json:"color_image"`
|
||||
@@ -420,6 +420,9 @@ type GetProductDetailsResponseItemError struct {
|
||||
}
|
||||
|
||||
// Get product details
|
||||
//
|
||||
// Check a minimum product price with all promotions applied in your personal account.
|
||||
// The min_price parameter from the method response is in development and returns 0
|
||||
func (c Products) GetProductDetails(ctx context.Context, params *GetProductDetailsParams) (*GetProductDetailsResponse, error) {
|
||||
url := "/v2/product/info"
|
||||
|
||||
@@ -641,12 +644,24 @@ type UpdatePricesPrice struct {
|
||||
OfferId string `json:"offer_id"`
|
||||
|
||||
// Price before discounts. Displayed strikethrough on the product description page.
|
||||
// Specified in rubles. The fractional part is separated by decimal point, up to two digits after the decimal point.
|
||||
// Specified in rubles.
|
||||
// The fractional part is separated by decimal point,
|
||||
// up to two digits after the decimal point.
|
||||
//
|
||||
// If there are no discounts on the product, pass 0 to this field and specify the correct price in the price field
|
||||
OldPrice string `json:"old_price"`
|
||||
|
||||
// Product price including discounts. This value is displayed on the product description page.
|
||||
//
|
||||
// If the current price of the product is from 400 to 10 000 rubles inclusive, the difference between the values of price and old_price fields should be more than 5%, but not less than 20 rubles.
|
||||
// If the old_price parameter value is greater than 0,
|
||||
// there should be a certain difference between price and old_price.
|
||||
// It depends on the price value
|
||||
//
|
||||
// < 400 - min diff. 20 rubles
|
||||
//
|
||||
// 400-10,000 - min diff. 5%
|
||||
//
|
||||
// > 10,000 - min diff. 500 rubles
|
||||
Price string `json:"price"`
|
||||
|
||||
// Attribute for enabling and disabling pricing strategies auto-application
|
||||
@@ -721,7 +736,7 @@ type CreateOrUpdateProductItem struct {
|
||||
Barcode string `json:"barcode"`
|
||||
|
||||
// Category identifier
|
||||
CategoryId int64 `json:"category_id"`
|
||||
DescriptionCategoryId int64 `json:"description_category_id"`
|
||||
|
||||
// Marketing color.
|
||||
//
|
||||
@@ -1363,7 +1378,7 @@ type GetDescriptionOfProductResult struct {
|
||||
Barcode string `json:"barcode"`
|
||||
|
||||
// Category identifier
|
||||
CategoryId int64 `json:"category_id"`
|
||||
DescriptionCategoryId int64 `json:"description_category_id"`
|
||||
|
||||
// Marketing color
|
||||
ColorImage string `json:"color_image"`
|
||||
@@ -2106,6 +2121,10 @@ type GetProductPriceInfoResultItemPriceIndexesSelfMarketplace struct {
|
||||
}
|
||||
|
||||
// You can specify up to 1000 products in the request
|
||||
//
|
||||
// Check minimum and maximum commissions for FBO pipeline in your personal account.
|
||||
// The `fbo_direct_flow_trans_max_amount` and `fbo_direct_flow_trans_min_amount` parameters
|
||||
// from the method response are in development and return 0
|
||||
func (c Products) GetProductPriceInfo(ctx context.Context, params *GetProductPriceInfoParams) (*GetProductPriceInfoResponse, error) {
|
||||
url := "/v4/product/info/prices"
|
||||
|
||||
@@ -2316,3 +2335,64 @@ func (c Products) UpdateCharacteristics(ctx context.Context, params *UpdateChara
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
type GetRelatedSKUsParams struct {
|
||||
// List of SKUs
|
||||
SKUs []string `json:"sku"`
|
||||
}
|
||||
|
||||
type GetRelatedSKUsResponse struct {
|
||||
core.CommonResponse
|
||||
|
||||
// Related SKUs information
|
||||
Items []GetRelatedSKUsItem `json:"items"`
|
||||
|
||||
// Errors
|
||||
Errors []GetRelatedSKUsError `json:"errors"`
|
||||
}
|
||||
|
||||
type GetRelatedSKUsItem struct {
|
||||
// Product availability attribute by SKU
|
||||
Availability SKUAvailability `json:"availability"`
|
||||
|
||||
// Date and time of deletion
|
||||
DeletedAt time.Time `json:"deleted_at"`
|
||||
|
||||
// Delivery scheme
|
||||
DeliverySchema string `json:"delivery_schema"`
|
||||
|
||||
// Product identifier
|
||||
ProductId int64 `json:"product_id"`
|
||||
|
||||
// Product identifier in the Ozon system, SKU
|
||||
SKU int64 `json:"sku"`
|
||||
}
|
||||
|
||||
type GetRelatedSKUsError struct {
|
||||
// Error code
|
||||
Code string `json:"code"`
|
||||
|
||||
// SKU, in which the error occurred
|
||||
SKU int `json:"sku"`
|
||||
|
||||
// Error text
|
||||
Message string `json:"message"`
|
||||
}
|
||||
|
||||
// You can pass any SKU in the request, even a deleted one.
|
||||
// The response will contain all SKUs related to the passed ones.
|
||||
//
|
||||
// In one request, you can pass up to 200 SKUs.
|
||||
func (c Products) GetRelatedSKUs(ctx context.Context, params *GetRelatedSKUsParams) (*GetRelatedSKUsResponse, error) {
|
||||
url := "/v1/product/related-sku/get"
|
||||
|
||||
resp := &GetRelatedSKUsResponse{}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ func TestGetProductDetails(t *testing.T) {
|
||||
"7533900005"
|
||||
],
|
||||
"buybox_price": "",
|
||||
"category_id": 17038062,
|
||||
"description_category_id": 17038062,
|
||||
"created_at": "2021-10-21T15:48:03.529178Z",
|
||||
"images": [
|
||||
"https://cdn1.ozone.ru/s3/multimedia-5/6088931525.jpg",
|
||||
@@ -286,7 +286,7 @@ func TestGetProductDetails(t *testing.T) {
|
||||
if resp.Result.OfferId == "" {
|
||||
t.Errorf("Offer id cannot be empty")
|
||||
}
|
||||
if resp.Result.CategoryId == 0 {
|
||||
if resp.Result.DescriptionCategoryId == 0 {
|
||||
t.Errorf("Category id cannot be 0")
|
||||
}
|
||||
if resp.Result.CurrencyCode == "" {
|
||||
@@ -658,21 +658,21 @@ func TestCreateOrUpdateProduct(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
Barcode: "112772873170",
|
||||
CategoryId: 17033876,
|
||||
CurrencyCode: "RUB",
|
||||
Depth: 10,
|
||||
DimensionUnit: "mm",
|
||||
Height: 250,
|
||||
Name: "Комплект защитных плёнок для X3 NFC. Темный хлопок",
|
||||
OfferId: "143210608",
|
||||
OldPrice: "1100",
|
||||
PremiumPrice: "900",
|
||||
Price: "1000",
|
||||
VAT: "0.1",
|
||||
Weight: 100,
|
||||
WeightUnit: "g",
|
||||
Width: 150,
|
||||
Barcode: "112772873170",
|
||||
DescriptionCategoryId: 17033876,
|
||||
CurrencyCode: "RUB",
|
||||
Depth: 10,
|
||||
DimensionUnit: "mm",
|
||||
Height: 250,
|
||||
Name: "Комплект защитных плёнок для X3 NFC. Темный хлопок",
|
||||
OfferId: "143210608",
|
||||
OldPrice: "1100",
|
||||
PremiumPrice: "900",
|
||||
Price: "1000",
|
||||
VAT: "0.1",
|
||||
Weight: 100,
|
||||
WeightUnit: "g",
|
||||
Width: 150,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1339,7 +1339,7 @@ func TestListProductsByIDs(t *testing.T) {
|
||||
"7533900005"
|
||||
],
|
||||
"buybox_price": "",
|
||||
"category_id": 93726157,
|
||||
"description_category_id": 93726157,
|
||||
"created_at": "2021-06-03T03:40:05.871465Z",
|
||||
"images": [],
|
||||
"has_discounted_item": true,
|
||||
@@ -1536,7 +1536,7 @@ func TestGetDescriptionOfProduct(t *testing.T) {
|
||||
{
|
||||
"id": 213761435,
|
||||
"barcode": "",
|
||||
"category_id": 17038062,
|
||||
"description_category_id": 17038062,
|
||||
"name": "Пленка защитная для Xiaomi Redmi Note 10 Pro 5G",
|
||||
"offer_id": "21470",
|
||||
"height": 10,
|
||||
@@ -2600,3 +2600,69 @@ func TestUpdateCharacteristics(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetRelatedSKUs(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
statusCode int
|
||||
headers map[string]string
|
||||
params *GetRelatedSKUsParams
|
||||
response string
|
||||
}{
|
||||
// Test Ok
|
||||
{
|
||||
http.StatusOK,
|
||||
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
|
||||
&GetRelatedSKUsParams{
|
||||
SKUs: []string{"321", "322"},
|
||||
},
|
||||
`{
|
||||
"items": [
|
||||
{
|
||||
"availability": "HIDDEN",
|
||||
"deleted_at": "2019-08-24T14:15:22Z",
|
||||
"delivery_schema": "fbs",
|
||||
"product_id": 123,
|
||||
"sku": 321
|
||||
}
|
||||
],
|
||||
"errors": [
|
||||
{
|
||||
"code": "test_code",
|
||||
"sku": 322,
|
||||
"message": "test_message"
|
||||
}
|
||||
]
|
||||
}`,
|
||||
},
|
||||
// Test No Client-Id or Api-Key
|
||||
{
|
||||
http.StatusUnauthorized,
|
||||
map[string]string{},
|
||||
&GetRelatedSKUsParams{},
|
||||
`{
|
||||
"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().GetRelatedSKUs(ctx, test.params)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if resp.StatusCode != test.statusCode {
|
||||
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
|
||||
}
|
||||
|
||||
if len(resp.Errors)+len(resp.Items) != len(test.params.SKUs) {
|
||||
t.Errorf("expected equal length of skus in request and response")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,21 +126,11 @@ type GetReportDetailResult struct {
|
||||
// Array with the filters specified when the seller created the report
|
||||
Params map[string]string `json:"params"`
|
||||
|
||||
// Report type:
|
||||
// - SELLER_PRODUCTS — products report,
|
||||
// - SELLER_TRANSACTIONS — transactions report,
|
||||
// - SELLER_PRODUCT_PRICES — product prices report,
|
||||
// - SELLER_STOCK — stocks report,
|
||||
// - SELLER_PRODUCT_MOVEMENT — products movement report,
|
||||
// - SELLER_RETURNS — returns report,
|
||||
// - SELLER_POSTINGS — shipments report,
|
||||
// - SELLER_FINANCE — financial report
|
||||
ReportType string `json:"report_type"`
|
||||
// Report type
|
||||
ReportType ReportType `json:"report_type"`
|
||||
|
||||
// Report generation status:
|
||||
// - success
|
||||
// - failed
|
||||
Status string `json:"status"`
|
||||
// Report generation status
|
||||
Status ReportInfoStatus `json:"status"`
|
||||
}
|
||||
|
||||
// Returns information about a created report by its identifier
|
||||
|
||||
Reference in New Issue
Block a user