Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a1c92ae26f | ||
|
|
08180d901c | ||
|
|
838f28d3d9 | ||
|
|
226f40275a | ||
|
|
4139692ac3 | ||
|
|
3507be6ec2 | ||
|
|
9990719060 | ||
|
|
18470fcae5 |
@@ -57,7 +57,7 @@
|
||||
- [x] List of accordance types (version 2)
|
||||
- [x] Directory of document types
|
||||
- [x] List of certified categories
|
||||
- [ ] Adding certificates for products
|
||||
- [x] Adding certificates for products
|
||||
- [x] Link the certificate to the product
|
||||
- [x] Delete certificate
|
||||
- [x] Certificate information
|
||||
|
||||
@@ -56,7 +56,7 @@ func (c Client) newRequest(method string, url string, body interface{}) (*http.R
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func (c Client) Request(method string, path string, req, resp interface{}) (*Response, error) {
|
||||
func (c Client) Request(method string, path string, req, resp interface{}, options map[string]string) (*Response, error) {
|
||||
httpReq, err := c.newRequest(method, path, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -55,7 +55,7 @@ func TestRequest(t *testing.T) {
|
||||
c := NewMockClient(NewMockHttpHandler(test.statusCode, test.response, test.headers))
|
||||
|
||||
respStruct := &TestRequestResponse{}
|
||||
resp, err := c.Request(http.MethodPost, "/", test.params, respStruct)
|
||||
resp, err := c.Request(http.MethodPost, "/", test.params, respStruct, nil)
|
||||
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
|
||||
@@ -19,7 +19,7 @@ type GetAnalyticsDataParams struct {
|
||||
DateTo time.Time `json:"date_to"`
|
||||
|
||||
// Items Enum: "unknownDimension" "sku" "spu" "day" "week" "month" "year" "category1" "category2" "category3" "category4" "brand" "modelID"
|
||||
Dimension []string `json:"dimension"`
|
||||
Dimension []GetAnalyticsDataDimension `json:"dimension"`
|
||||
|
||||
// Filters
|
||||
Filters []struct {
|
||||
@@ -27,9 +27,7 @@ type GetAnalyticsDataParams struct {
|
||||
Key string `json:"key"`
|
||||
|
||||
// Comparison operation
|
||||
//
|
||||
// Enum: "EQ" "GT" "GTE" "LT" "LTE"
|
||||
Operation string `json:"operation"`
|
||||
Operation GetAnalyticsDataFilterOperation `json:"operation"`
|
||||
|
||||
// Value for comparison
|
||||
Value string `json:"value"`
|
||||
@@ -41,11 +39,7 @@ 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
|
||||
//
|
||||
// Items Enum: "unknown_metric" "hits_view_search" "hits_view_pdp" "hits_view" "hits_tocart_search" "hits_tocart_pdp" "hits_tocart" "session_view_search"
|
||||
// "session_view_pdp" "session_view" "conv_tocart_search" "conv_tocart_pdp" "conv_tocart" "revenue" "returns" "cancellations" "ordered_units" "delivered_units"
|
||||
// "adv_view_pdp" "adv_view_search_category" "adv_view_all" "adv_sum_all" "position_category" "postings" "postings_premium"
|
||||
Metrics []string `json:"metrics"`
|
||||
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
|
||||
Offset int64 `json:"offset"`
|
||||
@@ -57,12 +51,10 @@ type GetAnalyticsDataParams struct {
|
||||
// Report sorting settings
|
||||
type GetAnalyticsDataSort struct {
|
||||
// Metric by which the method result will be sorted
|
||||
Key string `json:"key"`
|
||||
Key GetAnalyticsDataFilterMetric `json:"key"`
|
||||
|
||||
// Sorting type
|
||||
// - ASC — in ascending order,
|
||||
// - DESC — in descending order.
|
||||
Order string `json:"order"`
|
||||
Order Order `json:"order"`
|
||||
}
|
||||
|
||||
type GetAnalyticsDataResponse struct {
|
||||
@@ -99,7 +91,7 @@ func (c Analytics) GetAnalyticsData(params *GetAnalyticsDataParams) (*GetAnalyti
|
||||
|
||||
resp := &GetAnalyticsDataResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -118,10 +110,7 @@ type GetStocksOnWarehousesParams struct {
|
||||
Offset int64 `json:"offset"`
|
||||
|
||||
// Warehouse type filter:
|
||||
// - EXPRESS_DARK_STORE — Ozon warehouses with Fresh delivery.
|
||||
// - NOT_EXPRESS_DARK_STORE — Ozon warehouses without Fresh delivery.
|
||||
// - ALL — all Ozon warehouses.
|
||||
WarehouseType string `json:"warehouse_type"`
|
||||
WarehouseType WarehouseType `json:"warehouse_type"`
|
||||
}
|
||||
|
||||
type GetStocksOnWarehousesResponse struct {
|
||||
@@ -161,7 +150,7 @@ func (c Analytics) GetStocksOnWarehouses(params *GetStocksOnWarehousesParams) (*
|
||||
|
||||
resp := &GetStocksOnWarehousesResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -23,12 +23,12 @@ func TestGetAnalyticsData(t *testing.T) {
|
||||
&GetAnalyticsDataParams{
|
||||
DateFrom: core.TimeFromString(t, "2006-01-02", "2020-09-01"),
|
||||
DateTo: core.TimeFromString(t, "2006-01-02", "2021-10-15"),
|
||||
Dimension: []string{"sku", "day"},
|
||||
Metrics: []string{"hits_view_search"},
|
||||
Dimension: []GetAnalyticsDataDimension{SKUDimension, DayDimension},
|
||||
Metrics: []GetAnalyticsDataFilterMetric{AdvViewAll},
|
||||
Sort: []GetAnalyticsDataSort{
|
||||
{
|
||||
Key: "hits_view_search",
|
||||
Order: "DESC",
|
||||
Key: HistViewPDP,
|
||||
Order: Descending,
|
||||
},
|
||||
},
|
||||
Limit: 1000,
|
||||
|
||||
@@ -45,7 +45,7 @@ func (c Brands) List(params *ListCertifiedBrandsParams) (*ListCertifiedBrandsRes
|
||||
|
||||
resp := &ListCertifiedBrandsResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ func (c Cancellations) GetInfo(params *GetCancellationInfoParams) (*GetCancellat
|
||||
|
||||
resp := &GetCancellationInfoResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -152,7 +152,7 @@ func (c Cancellations) List(params *ListCancellationsParams) (*ListCancellations
|
||||
|
||||
resp := &ListCancellationsResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -180,7 +180,7 @@ func (c Cancellations) Approve(params *ApproveRejectCancellationsParams) (*Appro
|
||||
|
||||
resp := &ApproveRejectCancellationsResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -197,7 +197,7 @@ func (c Cancellations) Reject(params *ApproveRejectCancellationsParams) (*Approv
|
||||
|
||||
resp := &ApproveRejectCancellationsResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ type GetProductTreeParams struct {
|
||||
CategoryId int64 `json:"category_id"`
|
||||
|
||||
// Response language
|
||||
Language string `json:"language" default:"DEFAULT"`
|
||||
Language Language `json:"language" default:"DEFAULT"`
|
||||
}
|
||||
|
||||
type GetProductTreeResponse struct {
|
||||
@@ -43,7 +43,7 @@ func (c Categories) Tree(params *GetProductTreeParams) (*GetProductTreeResponse,
|
||||
|
||||
resp := &GetProductTreeResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -54,13 +54,13 @@ func (c Categories) Tree(params *GetProductTreeParams) (*GetProductTreeResponse,
|
||||
|
||||
type GetCategoryAttributesParams struct {
|
||||
// Filter by characteristics
|
||||
AttributeType string `json:"attribute_type" default:"ALL"`
|
||||
AttributeType AttributeType `json:"attribute_type" default:"ALL"`
|
||||
|
||||
// Category identifier
|
||||
CategoryId []int64 `json:"category_id"`
|
||||
|
||||
// Response language
|
||||
Language string `json:"language" default:"DEFAULT"`
|
||||
Language Language `json:"language" default:"DEFAULT"`
|
||||
}
|
||||
|
||||
type GetCategoryAttributesResponse struct {
|
||||
@@ -133,7 +133,7 @@ func (c Categories) Attributes(params *GetCategoryAttributesParams) (*GetCategor
|
||||
|
||||
resp := &GetCategoryAttributesResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -151,7 +151,7 @@ type GetAttributeDictionaryParams struct {
|
||||
|
||||
// Response language
|
||||
// The default language is Russian
|
||||
Language string `json:"language" default:"DEFAULT"`
|
||||
Language Language `json:"language" default:"DEFAULT"`
|
||||
|
||||
LastValueId int64 `json:"last_value_id"`
|
||||
|
||||
@@ -184,7 +184,7 @@ func (c Categories) AttributesDictionary(params *GetAttributeDictionaryParams) (
|
||||
|
||||
resp := &GetAttributeDictionaryResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ func (c Certificates) ListOfAccordanceTypes() (*ListOfAccordanceTypesResponse, e
|
||||
|
||||
resp := &ListOfAccordanceTypesResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodGet, url, nil, resp)
|
||||
response, err := c.client.Request(http.MethodGet, url, nil, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -70,7 +70,7 @@ func (c Certificates) DirectoryOfDocumentTypes() (*DirectoryOfDocumentTypesRespo
|
||||
|
||||
resp := &DirectoryOfDocumentTypesResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodGet, url, nil, resp)
|
||||
response, err := c.client.Request(http.MethodGet, url, nil, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -112,7 +112,7 @@ func (c Certificates) ListOfCertifiedCategories(params *ListOfCertifiedCategorie
|
||||
|
||||
resp := &ListOfCertifiedCategoriesResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -142,7 +142,7 @@ func (c Certificates) LinkToProduct(params *LinkCertificateToProductParams) (*Li
|
||||
|
||||
resp := &LinkCertificateToProductResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -177,7 +177,7 @@ func (c Certificates) Delete(params *DeleteCertificateParams) (*DeleteCertificat
|
||||
|
||||
resp := &DeleteCertificateResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -237,7 +237,7 @@ func (c Certificates) GetInfo(params *GetCertificateInfoParams) (*GetCertificate
|
||||
|
||||
resp := &GetCertificateInfoResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -316,7 +316,7 @@ func (c Certificates) List(params *ListCertificatesParams) (*ListCertificatesRes
|
||||
|
||||
resp := &ListCertificatesResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -343,7 +343,7 @@ func (c Certificates) ProductStatuses() (*ProductStatusesResponse, error) {
|
||||
|
||||
resp := &ProductStatusesResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, nil, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, nil, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -391,7 +391,7 @@ func (c Certificates) ListProductsForCertificate(params *ListProductsForCertific
|
||||
|
||||
resp := &ListProductsForCertificateResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -432,7 +432,7 @@ func (c Certificates) UnlinkFromProduct(params *UnlinkFromProductParams) (*Unlin
|
||||
|
||||
resp := &UnlinkFromProductResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -460,7 +460,7 @@ func (c Certificates) PossibleRejectReasons() (*PossibleRejectReasonsResponse, e
|
||||
|
||||
resp := &PossibleRejectReasonsResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, nil, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, nil, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -487,7 +487,53 @@ func (c Certificates) PossibleStatuses() (*PossibleStatusesResponse, error) {
|
||||
|
||||
resp := &PossibleStatusesResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, nil, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, nil, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
response.CopyCommonResponse(&resp.CommonResponse)
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
type AddCertificatesForProductsParams struct {
|
||||
// Array of certificates for the product. Valid extensions are jpg, jpeg, png, pdf
|
||||
Files []byte `json:"files"`
|
||||
|
||||
// Certificate name. No more than 100 characters
|
||||
Name string `json:"name"`
|
||||
|
||||
// Certificate number. No more than 100 characters
|
||||
Number string `json:"number"`
|
||||
|
||||
// Certificate type. To get the list of types, use the GET `/v1/product/certificate/types` method
|
||||
TypeCode string `json:"type_code"`
|
||||
|
||||
// Accordance type. To get the list of types, use the GET `/v1/product/certificate/accordance-types` method
|
||||
AccordanceTypeCode string `json:"accordance_type_code"`
|
||||
|
||||
// Issue date of the certificate
|
||||
IssueDate time.Time `json:"issue_date"`
|
||||
|
||||
// Expiration date of the certificate. Can be empty for permanent certificates
|
||||
ExpireDate time.Time `json:"expire_date"`
|
||||
}
|
||||
|
||||
type AddCertificatesForProductsResponse struct {
|
||||
core.CommonResponse
|
||||
|
||||
Id int `json:"id"`
|
||||
}
|
||||
|
||||
// Adding certificates for products
|
||||
func (c Certificates) AddForProducts(params *AddCertificatesForProductsParams) (*AddCertificatesForProductsResponse, error) {
|
||||
url := "/v1/product/certificate/create"
|
||||
|
||||
resp := &AddCertificatesForProductsResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, nil, resp, map[string]string{
|
||||
"Content-Type": "multipart/form-data",
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package ozon
|
||||
import (
|
||||
"net/http"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
core "github.com/diphantxm/ozon-api-client"
|
||||
)
|
||||
@@ -652,3 +653,55 @@ func TestPossibleStatuses(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestAddCertificatesForProducts(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
statusCode int
|
||||
headers map[string]string
|
||||
params *AddCertificatesForProductsParams
|
||||
response string
|
||||
}{
|
||||
// Test Ok
|
||||
{
|
||||
http.StatusOK,
|
||||
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
|
||||
&AddCertificatesForProductsParams{
|
||||
Files: []byte{10, 15, 2, 0},
|
||||
Name: "Certificate name",
|
||||
Number: "10a-d5s9-4asdf2",
|
||||
TypeCode: "declaration",
|
||||
AccordanceTypeCode: "gost",
|
||||
IssueDate: time.Now(),
|
||||
ExpireDate: time.Now(),
|
||||
},
|
||||
`{
|
||||
"id": 50058
|
||||
}`,
|
||||
},
|
||||
// Test No Client-Id or Api-Key
|
||||
{
|
||||
http.StatusUnauthorized,
|
||||
map[string]string{},
|
||||
&AddCertificatesForProductsParams{},
|
||||
`{
|
||||
"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))
|
||||
|
||||
resp, err := c.Certificates().AddForProducts(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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ func (c Chats) List(params *ListChatsParams) (*ListChatsResponse, error) {
|
||||
|
||||
resp := &ListChatsResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -112,7 +112,7 @@ func (c Chats) SendMessage(params *SendMessageParams) (*SendMessageResponse, err
|
||||
|
||||
resp := &SendMessageResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -145,7 +145,7 @@ func (c Chats) SendFile(params *SendFileParams) (*SendFileResponse, error) {
|
||||
|
||||
resp := &SendFileResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -214,7 +214,7 @@ func (c Chats) History(params *ChatHistoryParams) (*ChatHistoryResponse, error)
|
||||
|
||||
resp := &ChatHistoryResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -320,7 +320,7 @@ func (c Chats) Update(params *UpdateChatParams) (*UpdateChatResponse, error) {
|
||||
|
||||
resp := &UpdateChatResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -350,7 +350,7 @@ func (c Chats) Create(params *CreateNewChatParams) (*CreateNewChatResponse, erro
|
||||
|
||||
resp := &CreateNewChatResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -380,7 +380,7 @@ func (c Chats) MarkAsRead(params *MarkAsReadParams) (*MarkAsReadResponse, error)
|
||||
|
||||
resp := &MarkAsReadResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
315
ozon/common.go
Normal file
315
ozon/common.go
Normal file
@@ -0,0 +1,315 @@
|
||||
package ozon
|
||||
|
||||
type Order string
|
||||
|
||||
const (
|
||||
Ascending Order = "ASC"
|
||||
Descending Order = "DESC"
|
||||
)
|
||||
|
||||
type GetAnalyticsDataFilterOperation string
|
||||
|
||||
const (
|
||||
Equal GetAnalyticsDataFilterOperation = "EQ"
|
||||
Greater GetAnalyticsDataFilterOperation = "GT"
|
||||
GreaterEqual GetAnalyticsDataFilterOperation = "GTE"
|
||||
Lesser GetAnalyticsDataFilterOperation = "LT"
|
||||
LesserEqual GetAnalyticsDataFilterOperation = "LTE"
|
||||
)
|
||||
|
||||
type GetAnalyticsDataFilterMetric string
|
||||
|
||||
const (
|
||||
UnknownMetric GetAnalyticsDataFilterMetric = "unknown_metric"
|
||||
HitsViewSearch GetAnalyticsDataFilterMetric = "hits_view_search"
|
||||
HistViewPDP GetAnalyticsDataFilterMetric = "hits_view_pdp"
|
||||
HitsView GetAnalyticsDataFilterMetric = "hist_view"
|
||||
HitsToCartSearch GetAnalyticsDataFilterMetric = "hits_tocart_search"
|
||||
HitsToCartPDP GetAnalyticsDataFilterMetric = "hits_tocart_pdp"
|
||||
SessionViewSearch GetAnalyticsDataFilterMetric = "session_view_search"
|
||||
SessionViewPDP GetAnalyticsDataFilterMetric = "session_view_pdp"
|
||||
SessionView GetAnalyticsDataFilterMetric = "session_view"
|
||||
ConvToCartSearch GetAnalyticsDataFilterMetric = "conv_tocart_search"
|
||||
ConvToCartPDP GetAnalyticsDataFilterMetric = "conv_tocart_pdp"
|
||||
ConvToCart GetAnalyticsDataFilterMetric = "conv_tocart"
|
||||
Revenue GetAnalyticsDataFilterMetric = "revenue"
|
||||
ReturnsMetric GetAnalyticsDataFilterMetric = "returns"
|
||||
CancellationsMetric GetAnalyticsDataFilterMetric = "cancellations"
|
||||
OrderedUnits GetAnalyticsDataFilterMetric = "ordered_units"
|
||||
DeliveredUnits GetAnalyticsDataFilterMetric = "delivered_units"
|
||||
AdvViewPDP GetAnalyticsDataFilterMetric = "adv_view_pdp"
|
||||
AdvViewSearchCategory GetAnalyticsDataFilterMetric = "adv_view_search_category"
|
||||
AdvViewAll GetAnalyticsDataFilterMetric = "adv_view_all"
|
||||
AdvSumAll GetAnalyticsDataFilterMetric = "adv_sum_all"
|
||||
PositionCategory GetAnalyticsDataFilterMetric = "position_category"
|
||||
PostingsMetric GetAnalyticsDataFilterMetric = "postings"
|
||||
PostingsPremium GetAnalyticsDataFilterMetric = "postings_premium"
|
||||
)
|
||||
|
||||
type WarehouseType string
|
||||
|
||||
const (
|
||||
// Ozon warehouses with Fresh delivery
|
||||
ExpressDarkStore WarehouseType = "EXPRESS_DARK_STORE"
|
||||
|
||||
// Ozon warehouses without Fresh delivery
|
||||
NotExressDarkStore WarehouseType = "NOT_EXPRESS_DARK_STORE"
|
||||
|
||||
// All Ozon warehouses
|
||||
ALLWarehouseType WarehouseType = "ALL"
|
||||
)
|
||||
|
||||
type Language string
|
||||
|
||||
const (
|
||||
Default Language = "DEFAULT"
|
||||
Russian Language = "RU"
|
||||
English Language = "EN"
|
||||
Turkish Language = "TR"
|
||||
Chinese Language = "ZH_HANS"
|
||||
)
|
||||
|
||||
type AttributeType string
|
||||
|
||||
const (
|
||||
All AttributeType = "ALL"
|
||||
Required AttributeType = "REQUIRED"
|
||||
Optional AttributeType = "OPTIONAL"
|
||||
)
|
||||
|
||||
type ListDiscountRequestsStatus string
|
||||
|
||||
const (
|
||||
New ListDiscountRequestsStatus = "NEW"
|
||||
Seen ListDiscountRequestsStatus = "SEEN"
|
||||
Approved ListDiscountRequestsStatus = "APPROVED"
|
||||
PartlyApproved ListDiscountRequestsStatus = "PARTLY_APPROVED"
|
||||
Declined ListDiscountRequestsStatus = "DECLINED"
|
||||
AutoDeclined ListDiscountRequestsStatus = "AUTO_DECLINED"
|
||||
DeclinedByUser ListDiscountRequestsStatus = "DECLINED_BY_USER"
|
||||
Coupon ListDiscountRequestsStatus = "COUPON"
|
||||
Purchased ListDiscountRequestsStatus = "PURCHASED"
|
||||
)
|
||||
|
||||
type WorkingDay string
|
||||
|
||||
const (
|
||||
Mon WorkingDay = "1"
|
||||
Tue WorkingDay = "2"
|
||||
Wed WorkingDay = "3"
|
||||
Thu WorkingDay = "4"
|
||||
Fri WorkingDay = "5"
|
||||
Sat WorkingDay = "6"
|
||||
Sun WorkingDay = "7"
|
||||
)
|
||||
|
||||
type GetAnalyticsDataDimension string
|
||||
|
||||
const (
|
||||
UnknownDimension GetAnalyticsDataDimension = "unknownDimension"
|
||||
SKUDimension GetAnalyticsDataDimension = "sku"
|
||||
SPUDimension GetAnalyticsDataDimension = "spu"
|
||||
DayDimension GetAnalyticsDataDimension = "day"
|
||||
WeekDimension GetAnalyticsDataDimension = "week"
|
||||
MonthDimension GetAnalyticsDataDimension = "month"
|
||||
YearDimension GetAnalyticsDataDimension = "year"
|
||||
Category1Dimension GetAnalyticsDataDimension = "category1"
|
||||
Category2Dimension GetAnalyticsDataDimension = "category2"
|
||||
Category3Dimension GetAnalyticsDataDimension = "category3"
|
||||
Category4Dimension GetAnalyticsDataDimension = "category4"
|
||||
BrandDimension GetAnalyticsDataDimension = "brand"
|
||||
ModelIDDimension GetAnalyticsDataDimension = "modelID"
|
||||
)
|
||||
|
||||
type SupplyRequestState string
|
||||
|
||||
const (
|
||||
// request draft. Only for supplies via vDC
|
||||
Draft SupplyRequestState = "DRAFT"
|
||||
|
||||
// selecting supply options. Only for supplies via vDC
|
||||
SupplyVariantsArranging SupplyRequestState = "SUPPLY_VARIANTS_ARRANGING"
|
||||
|
||||
// no supply options, the request is archived. Only for supplies via vDC
|
||||
HasNoSupplyVariantsArchive SupplyRequestState = "HAS_NO_SUPPLY_VARIANTS_ARCHIVE"
|
||||
|
||||
// no supply options. Only for supplies via vDC
|
||||
HasNoSupplyVariantsNew SupplyRequestState = "HAS_NO_SUPPLY_VARIANTS_NEW"
|
||||
|
||||
// supply being approved. Only for supplies via vDC
|
||||
SupplyVariantsConfirmation SupplyRequestState = "SUPPLY_VARIANTS_CONFIRMATION"
|
||||
|
||||
// time reservation
|
||||
TimeslotBooking SupplyRequestState = "TIMESLOT_BOOKING"
|
||||
|
||||
// filling in the data
|
||||
DATA_FILLING SupplyRequestState = "DATA_FILLING"
|
||||
|
||||
// ready for shipment
|
||||
ReadyToSupply SupplyRequestState = "READY_TO_SUPPLY"
|
||||
|
||||
// accepted at the shipping point
|
||||
AcceptedAtSupplyWarehouse SupplyRequestState = "ACCEPTED_AT_SUPPLY_WAREHOUSE"
|
||||
|
||||
// on the way
|
||||
InTransit SupplyRequestState = "IN_TRANSIT"
|
||||
|
||||
// acceptance at the warehouse
|
||||
AcceptanceAtStorageWarehouse SupplyRequestState = "ACCEPTANCE_AT_STORAGE_WAREHOUSE"
|
||||
|
||||
// acts being approved
|
||||
ReportsConfirmationAwaiting SupplyRequestState = "REPORTS_CONFIRMATION_AWAITING"
|
||||
|
||||
// dispute
|
||||
ReportRejected SupplyRequestState = "REPORT_REJECTED"
|
||||
|
||||
// completed
|
||||
Completed SupplyRequestState = "COMPLETED"
|
||||
|
||||
// refused acceptance
|
||||
RejectedAtSupplyWarehouse SupplyRequestState = "REJECTED_AT_SUPPLY_WAREHOUSE"
|
||||
|
||||
// cancelled
|
||||
Cancelled SupplyRequestState = "CANCELLED"
|
||||
|
||||
// overdue
|
||||
Overdue SupplyRequestState = "OVERDUE"
|
||||
)
|
||||
|
||||
type ShipmentStatus string
|
||||
|
||||
const (
|
||||
// acceptance is in progress
|
||||
AcceptanceInProgress ShipmentStatus = "acceptance_in_progress"
|
||||
|
||||
// arbitration
|
||||
Arbitration ShipmentStatus = "arbitration"
|
||||
|
||||
// awaiting confirmation
|
||||
AwaitingApprove ShipmentStatus = "awaiting_approve"
|
||||
|
||||
// awaiting shipping
|
||||
AwaitingDeliver ShipmentStatus = "awaiting_deliver"
|
||||
|
||||
// awaiting packaging
|
||||
AwaitingPackaging ShipmentStatus = "awaiting_packaging"
|
||||
|
||||
// created
|
||||
AwaitingVerification ShipmentStatus = "awaiting_verification"
|
||||
|
||||
// cancelled
|
||||
CancelledSubstatus ShipmentStatus = "cancelled"
|
||||
|
||||
// delivered
|
||||
Delivered ShipmentStatus = "delivered"
|
||||
|
||||
// delivery is in progress
|
||||
Delivering ShipmentStatus = "delivering"
|
||||
|
||||
// picked up by driver
|
||||
DriverPickup ShipmentStatus = "driver_pickup"
|
||||
|
||||
// not accepted at the sorting center
|
||||
NotAccepted ShipmentStatus = "not_accepted"
|
||||
|
||||
// sent by the seller
|
||||
SentBySeller ShipmentStatus = "sent_by_seller"
|
||||
)
|
||||
|
||||
type ShipmentSubstatus string
|
||||
|
||||
const (
|
||||
// acceptance in progress
|
||||
PostingAcceptanceInProgress ShipmentStatus = "posting_acceptance_in_progress"
|
||||
|
||||
// arbitrage
|
||||
PostingInArbitration ShipmentStatus = "posting_in_arbitration"
|
||||
|
||||
// created
|
||||
PostingCreated ShipmentStatus = "posting_created"
|
||||
|
||||
// in the freight
|
||||
PostingInCarriage ShipmentStatus = "posting_in_carriage"
|
||||
|
||||
// not added to the freight
|
||||
PostingNotInCarriage ShipmentStatus = "posting_not_in_carriage"
|
||||
|
||||
// registered
|
||||
PostingRegistered ShipmentStatus = "posting_registered"
|
||||
|
||||
// is handed over to the delivery service
|
||||
PostingTransferringToDelivery ShipmentStatus = "posting_transferring_to_delivery"
|
||||
|
||||
// waiting for passport data
|
||||
PostingAwaitingPassportData ShipmentStatus = "posting_awaiting_passport_data"
|
||||
|
||||
// created
|
||||
PostingCreatedSubstatus ShipmentStatus = "posting_created"
|
||||
|
||||
// awaiting registration
|
||||
PostingAwaitingRegistration ShipmentStatus = "posting_awaiting_registration"
|
||||
|
||||
// registration error
|
||||
PostingRegistrationError ShipmentStatus = "posting_registration_error"
|
||||
|
||||
// created
|
||||
PostingSplitPending ShipmentStatus = "posting_split_pending"
|
||||
|
||||
// canceled
|
||||
PostingCancelled ShipmentStatus = "posting_canceled"
|
||||
|
||||
// customer delivery arbitrage
|
||||
PostingInClientArbitration ShipmentStatus = "posting_in_client_arbitration"
|
||||
|
||||
// delivered
|
||||
PostingDelivered ShipmentStatus = "posting_delivered"
|
||||
|
||||
// recieved
|
||||
PostingReceived ShipmentStatus = "posting_received"
|
||||
|
||||
// presumably delivered
|
||||
PostingConditionallyDelivered ShipmentStatus = "posting_conditionally_delivered"
|
||||
|
||||
// courier on the way
|
||||
PostingInCourierService ShipmentStatus = "posting_in_courier_service"
|
||||
|
||||
// at the pick-up point
|
||||
PostingInPickupPoint ShipmentStatus = "posting_in_pickup_point"
|
||||
|
||||
// on the way to the city
|
||||
PostingOnWayToCity ShipmentStatus = "posting_on_way_to_city"
|
||||
|
||||
// on the way to the pick-up point
|
||||
PostingOnWayToPickupPoint ShipmentStatus = "posting_on_way_to_pickup_point"
|
||||
|
||||
// returned to the warehouse
|
||||
PostingReturnedToWarehouse ShipmentStatus = "posting_returned_to_warehouse"
|
||||
|
||||
// is handed over to the courier
|
||||
PostingTransferredToCourierService ShipmentStatus = "posting_transferred_to_courier_service"
|
||||
|
||||
// handed over to the driver
|
||||
PostingDriverPickup ShipmentStatus = "posting_driver_pick_up"
|
||||
|
||||
// not accepted at the sorting center
|
||||
PostingNotInSortCenter ShipmentStatus = "posting_not_in_sort_center"
|
||||
|
||||
// sent by the seller
|
||||
SentBySellerSubstatus ShipmentStatus = "sent_by_seller"
|
||||
)
|
||||
|
||||
type TPLIntegrationType string
|
||||
|
||||
const (
|
||||
// delivery by the Ozon logistics
|
||||
OzonTPLType TPLIntegrationType = "ozon"
|
||||
|
||||
// delivery by a third-party service, Ozon registers the order
|
||||
AggregatorTPLType TPLIntegrationType = "aggregator"
|
||||
|
||||
// delivery by a third-party service, the seller registers the order
|
||||
TrackingTPLType TPLIntegrationType = "3pl_tracking"
|
||||
|
||||
// delivery by the seller
|
||||
NonIntegratedTPLType TPLIntegrationType = "non_integrated"
|
||||
)
|
||||
215
ozon/fbo.go
215
ozon/fbo.go
@@ -164,7 +164,7 @@ func (c FBO) GetShipmentsList(params *GetFBOShipmentsListParams) (*GetFBOShipmen
|
||||
|
||||
resp := &GetFBOShipmentsListResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -173,7 +173,7 @@ func (c FBO) GetShipmentsList(params *GetFBOShipmentsListParams) (*GetFBOShipmen
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
type GetShipmentDetailsParams struct{
|
||||
type GetShipmentDetailsParams struct {
|
||||
// Shipment number
|
||||
PostingNumber string `json:"posting_number"`
|
||||
|
||||
@@ -184,7 +184,7 @@ type GetShipmentDetailsParams struct{
|
||||
With GetShipmentDetailsWith `json:"with"`
|
||||
}
|
||||
|
||||
type GetShipmentDetailsWith struct{
|
||||
type GetShipmentDetailsWith struct {
|
||||
// Specify true to add analytics data to the response
|
||||
AnalyticsData bool `json:"analytics_data"`
|
||||
|
||||
@@ -192,19 +192,19 @@ type GetShipmentDetailsWith struct{
|
||||
FinancialData bool `json:"financial_data"`
|
||||
}
|
||||
|
||||
type GetShipmentDetailsResponse struct{
|
||||
type GetShipmentDetailsResponse struct {
|
||||
core.CommonResponse
|
||||
|
||||
// Method result
|
||||
Result struct{
|
||||
Result struct {
|
||||
// Additional data
|
||||
AdditionalData []struct{
|
||||
Key string `json:"key"`
|
||||
AdditionalData []struct {
|
||||
Key string `json:"key"`
|
||||
Value string `json:"value"`
|
||||
} `json:"additional_data"`
|
||||
|
||||
// Analytical data
|
||||
AnalyticsData struct{
|
||||
AnalyticsData struct {
|
||||
// Delivery city
|
||||
City string `json:"Delivery city"`
|
||||
|
||||
@@ -224,7 +224,7 @@ type GetShipmentDetailsResponse struct{
|
||||
|
||||
// Delivery region
|
||||
Region string `json:"region"`
|
||||
|
||||
|
||||
// Warehouse identifier
|
||||
WarehouseId int64 `json:"warehouse_id"`
|
||||
|
||||
@@ -267,7 +267,202 @@ func (c FBO) GetShipmentDetails(params *GetShipmentDetailsParams) (*GetShipmentD
|
||||
|
||||
resp := &GetShipmentDetailsResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
response.CopyCommonResponse(&resp.CommonResponse)
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
type ListSupplyRequestsParams struct {
|
||||
// Number of the page returned in the request
|
||||
Page int32 `json:"page"`
|
||||
|
||||
// Number of elements on the page
|
||||
PageSize int32 `json:"page_size"`
|
||||
|
||||
// Filter on status of a supply by request
|
||||
States []SupplyRequestState `json:"states"`
|
||||
}
|
||||
|
||||
type ListSupplyRequestsResponse struct {
|
||||
core.CommonResponse
|
||||
|
||||
// Indicates that the response contains not the entire array of supply requests:
|
||||
// - true — make a new request with a different page and page_size values to get information on the remaining requests;
|
||||
// - false — the entire array of requests for the filter specified in the request was returned in the response
|
||||
HasNext bool `json:"has_next"`
|
||||
|
||||
// Supply requests list
|
||||
SupplyOrders []SupplyRequestCommonResponse `json:"supply_orders"`
|
||||
|
||||
// Total requests number
|
||||
TotalSupplyOrdersCount int32 `json:"total_supply_orders_count"`
|
||||
}
|
||||
|
||||
type SupplyRequestCommonResponse struct {
|
||||
// Supply request creation date
|
||||
CreatedAt string `json:"created_at"`
|
||||
|
||||
// Local time supply interval
|
||||
LocalTimeslot struct {
|
||||
// Interval start
|
||||
From string `json:"from"`
|
||||
|
||||
// Interval end
|
||||
To string `json:"to"`
|
||||
} `json:"local_timeslot"`
|
||||
|
||||
// Date from which you want to bring the supply to the warehouse. Only for supplies via vDC
|
||||
PreferredSupplyDataFrom string `json:"preferred_supply_data_from"`
|
||||
|
||||
// Date by which you want to bring the supply to the warehouse. Only for supplies via vDC
|
||||
PreferredSupplyDataTo string `json:"preferred_supply_data_to"`
|
||||
|
||||
// Status of a supply by request
|
||||
State string `json:"state"`
|
||||
|
||||
// Supply request identifier
|
||||
SupplyOrderId int64 `json:"supply_order_id"`
|
||||
|
||||
// Supply request number
|
||||
SupplyOrderNumber string `json:"supply_order_number"`
|
||||
|
||||
// Supply warehouse
|
||||
SupplyWarehouse struct {
|
||||
// Warehouse address
|
||||
Address string `json:address"`
|
||||
|
||||
// Warehouse name
|
||||
Name string `json:"name"`
|
||||
|
||||
// Warehouse identifier
|
||||
WarehouseId int64 `json:"warehouse_id"`
|
||||
} `json:"supply_warehouse"`
|
||||
|
||||
// time_left_to_prepare_supply
|
||||
TimeLeftToPrepareSupply int64 `json:"time_left_to_prepare_supply"`
|
||||
|
||||
// Time in seconds left to select the supply option. Only for supplies via vDC
|
||||
TimeLeftToSelectSupplyVariant int64 `json:"time_left_to_select_supply_variant"`
|
||||
|
||||
// total_items_count
|
||||
TotalItemsCount int32 `json:"total_items_count"`
|
||||
|
||||
// Total number of items in the request
|
||||
TotalQuantity int32 `json:"total_quantity"`
|
||||
}
|
||||
|
||||
// Method for getting a list of supply requests to the Ozon warehouse.
|
||||
// Requests with supply both to a specific warehouse and via a virtual
|
||||
// distribution center (vDC) are taken into account
|
||||
func (c FBO) ListSupplyRequests(params *ListSupplyRequestsParams) (*ListSupplyRequestsResponse, error) {
|
||||
url := "/v1/supply-order/list"
|
||||
|
||||
resp := &ListSupplyRequestsResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
response.CopyCommonResponse(&resp.CommonResponse)
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
type GetSupplyRequestInfoParams struct {
|
||||
// Supply request identifier
|
||||
SupplyOrderId int64 `json:"supply_order_id"`
|
||||
}
|
||||
|
||||
type GetSupplyRequestInfoResponse struct {
|
||||
core.CommonResponse
|
||||
|
||||
SupplyRequestCommonResponse
|
||||
|
||||
// Driver and car information
|
||||
VehicleInfo struct {
|
||||
// Driver name
|
||||
DriverName string `json:"driver_name"`
|
||||
|
||||
// Driver phone number
|
||||
DriverPhone string `json:"driver_phone"`
|
||||
|
||||
// Car model
|
||||
VehicleModel string `json:"vehicle_model"`
|
||||
|
||||
// Car number
|
||||
VehicleNumber string `json:"vehicle_number"`
|
||||
} `json:"vehicle_info"`
|
||||
}
|
||||
|
||||
// Method for getting detailed information on a supply request.
|
||||
// Requests with supply both to a specific warehouse and via a
|
||||
// virtual distribution center (vDC) are taken into account
|
||||
func (c FBO) GetSupplyRequestInfo(params *GetSupplyRequestInfoParams) (*GetSupplyRequestInfoResponse, error) {
|
||||
url := "/v1/supply-order/get"
|
||||
|
||||
resp := &GetSupplyRequestInfoResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
response.CopyCommonResponse(&resp.CommonResponse)
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
type ListProductsInSupplyRequestParams struct {
|
||||
// Number of the page returned in the query
|
||||
Page int32 `json:"page"`
|
||||
|
||||
// Number of elements on the page
|
||||
PageSize int32 `json:"page_size"`
|
||||
|
||||
// Supply request identifier
|
||||
SupplyOrderId int64 `json:"supply_order_id"`
|
||||
}
|
||||
|
||||
type ListProductsInSupplyRequestResponse struct {
|
||||
core.CommonResponse
|
||||
|
||||
// Indicates that the response contains not the entire array of supply requests:
|
||||
// - true — make a new request with a different page and page_size values to get the remaining products;
|
||||
// - false — the entire array of product was returned in the response
|
||||
HasNext bool `json:"has_next"`
|
||||
|
||||
// Products list
|
||||
Items []struct {
|
||||
// Link to product image
|
||||
IconPath string `json:"icon_path"`
|
||||
|
||||
// Product name
|
||||
Name string `json:"name"`
|
||||
|
||||
// Product ID
|
||||
OfferId string `json:"offer_id"`
|
||||
|
||||
// Product quantity
|
||||
Quantity int64 `json:"quantity"`
|
||||
|
||||
// Product identifier in the Ozon system, SKU
|
||||
SKU int64 `json:"sku"`
|
||||
} `json:"items"`
|
||||
|
||||
// Total number of products in the request
|
||||
TotalItemsCount int32 `json:"total_items_count"`
|
||||
}
|
||||
|
||||
// List of products in the sullpy request
|
||||
func (c FBO) ListProductsInSupplyRequest(params *ListProductsInSupplyRequestParams) (*ListProductsInSupplyRequestResponse, error) {
|
||||
url := "/v1/supply-order/items"
|
||||
|
||||
resp := &ListProductsInSupplyRequestResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
205
ozon/fbo_test.go
205
ozon/fbo_test.go
@@ -277,3 +277,208 @@ func TestGetShipmentDetails(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestListSupplyRequests(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
statusCode int
|
||||
headers map[string]string
|
||||
params *ListSupplyRequestsParams
|
||||
response string
|
||||
}{
|
||||
// Test Ok
|
||||
{
|
||||
http.StatusOK,
|
||||
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
|
||||
&ListSupplyRequestsParams{
|
||||
Page: 0,
|
||||
PageSize: 0,
|
||||
States: []SupplyRequestState{AcceptanceAtStorageWarehouse},
|
||||
},
|
||||
`{
|
||||
"has_next": true,
|
||||
"supply_orders": [
|
||||
{
|
||||
"created_at": "string",
|
||||
"local_timeslot": {
|
||||
"from": "string",
|
||||
"to": "string"
|
||||
},
|
||||
"preferred_supply_date_from": "string",
|
||||
"preferred_supply_date_to": "string",
|
||||
"state": "string",
|
||||
"supply_order_id": 0,
|
||||
"supply_order_number": "string",
|
||||
"supply_warehouse": {
|
||||
"address": "string",
|
||||
"name": "string",
|
||||
"warehouse_id": 0
|
||||
},
|
||||
"time_left_to_prepare_supply": 0,
|
||||
"time_left_to_select_supply_variant": 0,
|
||||
"total_items_count": 0,
|
||||
"total_quantity": 0
|
||||
}
|
||||
],
|
||||
"total_supply_orders_count": 0
|
||||
}`,
|
||||
},
|
||||
// Test No Client-Id or Api-Key
|
||||
{
|
||||
http.StatusUnauthorized,
|
||||
map[string]string{},
|
||||
&ListSupplyRequestsParams{},
|
||||
`{
|
||||
"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))
|
||||
|
||||
resp, err := c.FBO().ListSupplyRequests(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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetSupplyRequestInfo(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
statusCode int
|
||||
headers map[string]string
|
||||
params *GetSupplyRequestInfoParams
|
||||
response string
|
||||
}{
|
||||
// Test Ok
|
||||
{
|
||||
http.StatusOK,
|
||||
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
|
||||
&GetSupplyRequestInfoParams{
|
||||
SupplyOrderId: 0,
|
||||
},
|
||||
`{
|
||||
"created_at": "string",
|
||||
"local_timeslot": {
|
||||
"from": "string",
|
||||
"to": "string"
|
||||
},
|
||||
"preferred_supply_date_from": "string",
|
||||
"preferred_supply_date_to": "string",
|
||||
"seller_warehouse": {
|
||||
"address": "string",
|
||||
"name": "string",
|
||||
"warehouse_id": 0
|
||||
},
|
||||
"state": "string",
|
||||
"supply_order_id": 0,
|
||||
"supply_order_number": "string",
|
||||
"supply_warehouse": {
|
||||
"address": "string",
|
||||
"name": "string",
|
||||
"warehouse_id": 0
|
||||
},
|
||||
"time_left_to_prepare_supply": 0,
|
||||
"time_left_to_select_supply_variant": 0,
|
||||
"total_items_count": 0,
|
||||
"total_quantity": 0,
|
||||
"vehicle_info": {
|
||||
"driver_name": "string",
|
||||
"driver_phone": "string",
|
||||
"vehicle_model": "string",
|
||||
"vehicle_number": "string"
|
||||
}
|
||||
}`,
|
||||
},
|
||||
// Test No Client-Id or Api-Key
|
||||
{
|
||||
http.StatusUnauthorized,
|
||||
map[string]string{},
|
||||
&GetSupplyRequestInfoParams{},
|
||||
`{
|
||||
"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))
|
||||
|
||||
resp, err := c.FBO().GetSupplyRequestInfo(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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestListProductsInSupplyRequest(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
statusCode int
|
||||
headers map[string]string
|
||||
params *ListProductsInSupplyRequestParams
|
||||
response string
|
||||
}{
|
||||
// Test Ok
|
||||
{
|
||||
http.StatusOK,
|
||||
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
|
||||
&ListProductsInSupplyRequestParams{
|
||||
Page: 0,
|
||||
PageSize: 0,
|
||||
SupplyOrderId: 0,
|
||||
},
|
||||
`{
|
||||
"has_next": true,
|
||||
"items": [
|
||||
{
|
||||
"icon_path": "string",
|
||||
"name": "string",
|
||||
"offer_id": "string",
|
||||
"quantity": 0,
|
||||
"sku": 0
|
||||
}
|
||||
],
|
||||
"total_items_count": 0
|
||||
}`,
|
||||
},
|
||||
// Test No Client-Id or Api-Key
|
||||
{
|
||||
http.StatusUnauthorized,
|
||||
map[string]string{},
|
||||
&ListProductsInSupplyRequestParams{},
|
||||
`{
|
||||
"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))
|
||||
|
||||
resp, err := c.FBO().ListProductsInSupplyRequest(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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
105
ozon/fbs.go
105
ozon/fbs.go
@@ -209,7 +209,7 @@ func (c FBS) ListUnprocessedShipments(params *ListUnprocessedShipmentsParams) (*
|
||||
|
||||
resp := &ListUnprocessedShipmentsResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -308,7 +308,7 @@ func (c FBS) GetFBSShipmentsList(params *GetFBSShipmentsListParams) (*GetFBSShip
|
||||
|
||||
resp := &GetFBSShipmentsListResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -377,7 +377,7 @@ func (c FBS) PackOrder(params *PackOrderParams) (*PackOrderResponse, error) {
|
||||
|
||||
resp := &PackOrderResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -443,7 +443,7 @@ func (c FBS) ValidateLabelingCodes(params *ValidateLabelingCodesParams) (*Valida
|
||||
|
||||
resp := &ValidateLabelingCodesResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -539,7 +539,7 @@ func (c FBS) GetShipmentDataByBarcode(params *GetShipmentDataByBarcodeParams) (*
|
||||
|
||||
resp := &GetShipmentDataByBarcodeResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -754,14 +754,13 @@ type GetShipmentDataByIdentifierResponse struct {
|
||||
ShipmentDate time.Time `json:"shipment_date"`
|
||||
|
||||
// Shipment status
|
||||
Status string `json:"status"`
|
||||
Status ShipmentStatus `json:"status"`
|
||||
|
||||
// Type of integration with the delivery service:
|
||||
// - ozon — delivery by the Ozon logistics.
|
||||
// - aggregator — delivery by a third-party service, Ozon registers the order.
|
||||
// - 3pl_tracking — delivery by a third-party service, the seller registers the order.
|
||||
// - non_integrated — delivery by the seller
|
||||
TPLIntegrationType string `json:"tpl_integration_type"`
|
||||
// Shipment substatus
|
||||
Substatus ShipmentSubstatus `json:"substatus"`
|
||||
|
||||
// Type of integration with the delivery service
|
||||
TPLIntegrationType TPLIntegrationType `json:"tpl_integration_type"`
|
||||
|
||||
// Shipment tracking number
|
||||
TrackingNumber string `json:"tracking_number"`
|
||||
@@ -791,7 +790,7 @@ func (c FBS) GetShipmentDataByIdentifier(params *GetShipmentDataByIdentifierPara
|
||||
|
||||
resp := &GetShipmentDataByIdentifierResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -835,7 +834,7 @@ func (c FBS) AddTrackingNumbers(params *AddTrackingNumbersParams) (*AddTrackingN
|
||||
|
||||
resp := &AddTrackingNumbersResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -955,7 +954,7 @@ func (c FBS) ListOfShipmentCertificates(params *ListOfShipmentCertificatesParams
|
||||
|
||||
resp := &ListOfShipmentCertificatesResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -987,7 +986,7 @@ func (c FBS) SignShipmentCertificate(params *SignShipmentCertificateParams) (*Si
|
||||
|
||||
resp := &SignShipmentCertificateResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1023,7 +1022,7 @@ func (c FBS) ChangeStatusToDelivering(params *ChangeStatusToParams) (*ChangeStat
|
||||
|
||||
resp := &ChangeStatusToResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1038,7 +1037,7 @@ func (c FBS) ChangeStatusToLastMile(params *ChangeStatusToParams) (*ChangeStatus
|
||||
|
||||
resp := &ChangeStatusToResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1053,7 +1052,7 @@ func (c FBS) ChangeStatusToDelivered(params *ChangeStatusToParams) (*ChangeStatu
|
||||
|
||||
resp := &ChangeStatusToResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1068,7 +1067,7 @@ func (c FBS) ChangeStatusToSendBySeller(params *ChangeStatusToParams) (*ChangeSt
|
||||
|
||||
resp := &ChangeStatusToResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1095,7 +1094,7 @@ func (c FBS) PassShipmentToShipping(params *PassShipmentToShippingParams) (*Pass
|
||||
|
||||
resp := &PassShipmentToShippingResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1132,6 +1131,7 @@ type CancelShipmentResponse struct {
|
||||
// - 665 — the customer did not pick the order;
|
||||
// - 666 — delivery is not available in the region;
|
||||
// - 667 — order was lost by the delivery service.
|
||||
//
|
||||
// For presumably delivered orders only the last 3 reasons are available.
|
||||
//
|
||||
// If cancel_reason_id parameter value is 402, fill the cancel_reason_message field
|
||||
@@ -1140,7 +1140,7 @@ func (c FBS) CancelShipment(params *CancelShipmentParams) (*CancelShipmentRespon
|
||||
|
||||
resp := &CancelShipmentResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1185,7 +1185,7 @@ func (c FBS) CreateAct(params *CreateActParams) (*CreateActResponse, error) {
|
||||
|
||||
resp := &CreateActResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1225,7 +1225,9 @@ func (c FBS) GetLabeling(params *GetLabelingParams) (*GetLabelingResponse, error
|
||||
|
||||
resp := &GetLabelingResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, map[string]string{
|
||||
"Content-Type": "application/pdf",
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1257,7 +1259,9 @@ func (c FBS) PrintLabeling(params *PrintLabelingParams) (*PrintLabelingResponse,
|
||||
|
||||
resp := &PrintLabelingResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, map[string]string{
|
||||
"Content-Type": "application/pdf",
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1285,11 +1289,13 @@ type CreateTaskForGeneratingLabelResponse struct {
|
||||
//
|
||||
// To get labels created as a result of the method, use the /v1/posting/fbs/package-label/get method
|
||||
func (c FBS) CreateTaskForGeneratingLabel(params *CreateTaskForGeneratingLabelParams) (*CreateTaskForGeneratingLabelResponse, error) {
|
||||
url := "/v2/posting/fbs/package-label"
|
||||
url := "/v1/posting/fbs/package-label/create"
|
||||
|
||||
resp := &CreateTaskForGeneratingLabelResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, map[string]string{
|
||||
"Content-Type": "application/pdf",
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1341,7 +1347,7 @@ func (c FBS) GetDropOffPointRestrictions(params *GetDropOffPointRestrictionsPara
|
||||
|
||||
resp := &GetDropOffPointRestrictionsResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1375,13 +1381,14 @@ type CheckProductItemsDataResponse struct {
|
||||
// Asynchronous method:
|
||||
// - for checking the availability of product items in the “Chestny ZNAK” labeling system
|
||||
// - for saving product items data
|
||||
//
|
||||
// To get the checks results, use the `/v4/fbs/posting/product/exemplar/status method`
|
||||
//
|
||||
// If necessary, specify the number of the cargo customs declaration in the gtd parameter. If it is missing, pass the value `is_gtd_absent` = true
|
||||
//
|
||||
// If you have multiple identical products in a shipment, specify one `product_id` and `exemplars` array for each product in the shipment
|
||||
//
|
||||
// Always pass a complete set of product items data
|
||||
// # Always pass a complete set of product items data
|
||||
//
|
||||
// For example, you have 10 product items in your system.
|
||||
// You have passed them for checking and saving. Then they added another 60 product items to your system.
|
||||
@@ -1391,7 +1398,7 @@ func (c FBS) CheckproductItemsData(params *CheckProductItemsDataParams) (*CheckP
|
||||
|
||||
resp := &CheckProductItemsDataResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1428,7 +1435,7 @@ func (c FBS) GetProductItemsCheckStatuses(params *GetProductItemsCheckStatusesPa
|
||||
|
||||
resp := &GetProductItemsCheckStatusesResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1466,7 +1473,7 @@ func (c FBS) RescheduleShipmentDeliveryDate(params *RescheduleShipmentDeliveryDa
|
||||
|
||||
resp := &RescheduleShipmentDeliveryDateResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1505,7 +1512,7 @@ func (c FBS) DateAvailableForDeliverySchedule(params *DateAvailableForDeliverySc
|
||||
|
||||
resp := &DateAvailableForDeliveryScheduleResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1538,7 +1545,7 @@ func (c FBS) ListManufacturingCountries(params *ListManufacturingCountriesParams
|
||||
|
||||
resp := &ListManufacturingCountriesResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1574,7 +1581,7 @@ func (c FBS) SetManufacturingCountry(params *SetManufacturingCountryParams) (*Se
|
||||
|
||||
resp := &SetManufacturingCountryResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1627,7 +1634,7 @@ func (c FBS) PartialPackOrder(params *PartialPackOrderParams) (*PartialPackOrder
|
||||
|
||||
resp := &PartialPackOrderResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1716,7 +1723,7 @@ func (c FBS) AvailableFreightsList(params *AvailableFreightsListParams) (*Availa
|
||||
|
||||
resp := &AvailableFreightsListResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1752,7 +1759,7 @@ func (c FBS) GenerateAct(params *GenerateActParams) (*GenerateActResponse, error
|
||||
|
||||
resp := &GenerateActResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1791,7 +1798,7 @@ func (c FBS) GetDigitalAct(params *GetDigitalActParams) (*GetDigitalActResponse,
|
||||
|
||||
resp := &GetDigitalActResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1824,7 +1831,7 @@ func (c FBS) PackageUnitLabel(params *PackageUnitLabelsParams) (*PackageUnitLabe
|
||||
|
||||
resp := &PackageUnitLabelsResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1852,7 +1859,7 @@ func (c FBS) OpenDisputeOverShipment(params *OpenDisputeOverShipmentParams) (*Op
|
||||
|
||||
resp := &OpenDisputeOverShipmentResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1894,7 +1901,7 @@ func (c FBS) ShipmentCancellationReasons(params *ShipmentCancellationReasonsPara
|
||||
|
||||
resp := &ShipmentCancellationReasonsResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1930,7 +1937,7 @@ func (c FBS) ShipmentsCancellationReasons() (*ShipmentsCancellationReasonsRespon
|
||||
|
||||
resp := &ShipmentsCancellationReasonsResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, nil, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, nil, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1968,7 +1975,7 @@ func (c FBS) AddWeightForBulkProduct(params *AddWeightForBulkProductParams) (*Ad
|
||||
|
||||
resp := &AddWeightForBulkProductResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -2012,7 +2019,7 @@ func (c FBS) CancelSending(params *CancelSendingParams) (*CancelSendingResponse,
|
||||
|
||||
resp := &CancelSendingResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -2078,7 +2085,7 @@ func (c FBS) ListShipmentInCertificate(params *ListShipmentInCertificateParams)
|
||||
|
||||
resp := &ListShipmentInCertificateResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -2113,7 +2120,7 @@ func (c FBS) SpecifyNumberOfBoxes(params *SpecifyNumberOfBoxesParams) (*SpecifyN
|
||||
|
||||
resp := &SpecifyNumberOfBoxesResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -2182,7 +2189,7 @@ func (c FBS) StatusOfAct(params *StatusOfActParams) (*StatusOfActResponse, error
|
||||
|
||||
resp := &StatusOfActResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -2234,7 +2241,7 @@ func (c FBS) ETGBCustomsDeclarations(params *ETGBCustomsDeclarationsParams) (*ET
|
||||
|
||||
resp := &ETGBCustomsDeclarationsResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ func (c Finance) ReportOnSoldProducts(params *ReportOnSoldProductsParams) (*Repo
|
||||
|
||||
resp := &ReportOnSoldProductsResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -238,7 +238,7 @@ func (c Finance) GetTotalTransactionsSum(params *GetTotalTransactionsSumParams)
|
||||
|
||||
resp := &GetTotalTransactionsSumResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -377,7 +377,7 @@ func (c Finance) ListTransactions(params *ListTransactionsParams) (*ListTransact
|
||||
|
||||
resp := &ListTransactionsResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ func (c Invoices) CreateUpdate(params *CreateUpdateProformaLinkParams) (*CreateU
|
||||
|
||||
resp := &CreateUpdateProformaLinkResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -61,7 +61,7 @@ func (c Invoices) Get(params *GetProformaLinkParams) (*GetProformaLinkResponse,
|
||||
|
||||
resp := &GetProformaLinkResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -87,7 +87,7 @@ func (c Invoices) Delete(params *DeleteProformaLinkParams) (*DeleteProformaLinkR
|
||||
|
||||
resp := &DeleteProformaLinkResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ func (c Polygons) CreateDelivery(params *CreateDeliveryPolygonParams) (*CreateDe
|
||||
|
||||
resp := &CreateDeliveryPolygonResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -76,7 +76,7 @@ func (c Polygons) Link(params *LinkDeliveryMethodToPolygonParams) (*LinkDelivery
|
||||
|
||||
resp := &LinkDeliveryMethodToPolygonResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -100,7 +100,7 @@ func (c Polygons) Delete(params *DeletePolygonParams) (*DeletePolygonResponse, e
|
||||
|
||||
resp := &DeletePolygonResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
186
ozon/products.go
186
ozon/products.go
@@ -81,7 +81,7 @@ func (c Products) GetStocksInfo(params *GetStocksInfoParams) (*GetStocksInfoResp
|
||||
|
||||
resp := &GetStocksInfoResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -223,7 +223,51 @@ type ProductDetails struct {
|
||||
// Product price including discounts. This value is shown on the product description page
|
||||
Price string `json:"price"`
|
||||
|
||||
// Price index. Learn more in Help Center
|
||||
// Product price indexes
|
||||
PriceIndexes struct {
|
||||
// Competitors' product price on other marketplaces
|
||||
ExternalIndexData struct {
|
||||
// Minimum competitors' product price on other marketplaces
|
||||
MinimalPrice string `json:"minimal_price"`
|
||||
|
||||
// Price currency
|
||||
MinimalPriceCurrency string `json:"minimal_price_currency"`
|
||||
|
||||
// Price index value
|
||||
PriceIndexValue float64 `json:"price_index_value"`
|
||||
} `json:"external_index_data"`
|
||||
|
||||
// Competitors' product price on Ozon
|
||||
OzonIndexData struct {
|
||||
// Minimum competitors' product price on Ozon
|
||||
MinimalPrice string `json:"minimal_price"`
|
||||
|
||||
// Price currency
|
||||
MinimalPriceCurrency string `json:"minimal_price_currency"`
|
||||
|
||||
// Price index value
|
||||
PriceIndexValue float64 `json:"price_index_value"`
|
||||
} `json:"ozon_index_data"`
|
||||
|
||||
// Resulting price index of the product
|
||||
PriceIndex string `json:"price_index"`
|
||||
|
||||
// Price of your product on other marketplaces
|
||||
SelfMarketplaceIndexData struct {
|
||||
// Minimum price of your product on other marketplaces
|
||||
MinimalPrice string `json:"minimal_price"`
|
||||
|
||||
// Price currency
|
||||
MinimalPriceCurrency string `json:"minimal_price_currency"`
|
||||
|
||||
// Price index value
|
||||
PriceIndexValue float64 `json:"price_index_value"`
|
||||
} `json:"self_marketplace_index_data"`
|
||||
} `json:"prices_indexes"`
|
||||
|
||||
// Deprecated: Price index. Learn more in Help Center
|
||||
//
|
||||
// Use PriceIndexes instead
|
||||
PriceIndex string `json:"price_idnex"`
|
||||
|
||||
// Product price suggested by the system based on similar offers
|
||||
@@ -359,7 +403,7 @@ func (c Products) GetProductDetails(params *GetProductDetailsParams) (*GetProduc
|
||||
|
||||
resp := &GetProductDetailsResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -420,7 +464,7 @@ func (c Products) UpdateStocks(params *UpdateStocksParams) (*UpdateStocksRespons
|
||||
|
||||
resp := &UpdateStocksResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -490,7 +534,7 @@ func (c Products) UpdateQuantityStockProducts(params *UpdateQuantityStockProduct
|
||||
|
||||
resp := &UpdateQuantityStockProductsResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -539,7 +583,7 @@ func (c Products) StocksInSellersWarehouse(params *StocksInSellersWarehouseParam
|
||||
|
||||
resp := &StocksInSellersWarehouseResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -612,7 +656,7 @@ func (c Products) UpdatePrices(params *UpdatePricesParams) (*UpdatePricesRespons
|
||||
|
||||
resp := &UpdatePricesResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -785,7 +829,7 @@ func (c Products) CreateOrUpdateProduct(params *CreateOrUpdateProductParams) (*C
|
||||
|
||||
resp := &CreateOrUpdateProductResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -847,7 +891,7 @@ func (c Products) GetListOfProducts(params *GetListOfProductsParams) (*GetListOf
|
||||
|
||||
resp := &GetListOfProductsResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -922,7 +966,7 @@ func (c Products) GetProductsRatingBySKU(params *GetProductsRatingBySKUParams) (
|
||||
|
||||
resp := &GetProductsRatingBySKUResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -977,7 +1021,7 @@ func (c Products) GetProductImportStatus(params *GetProductImportStatusParams) (
|
||||
|
||||
resp := &GetProductImportStatusResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1045,7 +1089,7 @@ func (c Products) CreateProductByOzonID(params *CreateProductByOzonIDParams) (*C
|
||||
|
||||
resp := &CreateProductByOzonIDResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1130,7 +1174,7 @@ func (c Products) UpdateProductImages(params *UpdateProductImagesParams) (*Produ
|
||||
|
||||
resp := &ProductInfoResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1150,7 +1194,7 @@ func (c Products) CheckImageUploadingStatus(params *CheckImageUploadingStatusPar
|
||||
|
||||
resp := &ProductInfoResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1190,7 +1234,7 @@ func (c Products) ListProductsByIDs(params *ListProductsByIDsParams) (*ListProdu
|
||||
|
||||
resp := &ListProductsByIDsResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1360,7 +1404,7 @@ func (c Products) GetDescriptionOfProduct(params *GetDescriptionOfProductParams)
|
||||
|
||||
resp := &GetDescriptionOfProductResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1402,7 +1446,7 @@ func (c Products) GetProductDescription(params *GetProductDescriptionParams) (*G
|
||||
|
||||
resp := &GetProductDescriptionResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1445,13 +1489,14 @@ type GetProductRangeLimitUploadQuota struct {
|
||||
// - Product range limit: how many products you can create in your personal account.
|
||||
// - Products creation limit: how many products you can create per day.
|
||||
// - Products update limit: how many products you can update per day.
|
||||
//
|
||||
// If you have a product range limit and you exceed it, you won't be able to create new products
|
||||
func (c Products) GetProductRangeLimit() (*GetProductRangeLimitResponse, error) {
|
||||
url := "/v4/product/info/limit"
|
||||
|
||||
resp := &GetProductRangeLimitResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, &struct{}{}, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, &struct{}{}, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1496,7 +1541,7 @@ func (c Products) ChangeProductIDs(params *ChangeProductIDsParams) (*ChangeProdu
|
||||
|
||||
resp := &ChangeProductIDsResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1523,7 +1568,7 @@ func (c Products) ArchiveProduct(params *ArchiveProductParams) (*ArchiveProductR
|
||||
|
||||
resp := &ArchiveProductResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1538,7 +1583,7 @@ func (c Products) UnarchiveProduct(params *ArchiveProductParams) (*ArchiveProduc
|
||||
|
||||
resp := &ArchiveProductResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1581,7 +1626,7 @@ func (c Products) RemoveProductWithoutSKU(params *RemoveProductWithoutSKUParams)
|
||||
|
||||
resp := &RemoveProductWithoutSKUResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1640,7 +1685,7 @@ func (c Products) ListGeoRestrictions(params *ListGeoRestrictionsParams) (*ListG
|
||||
|
||||
resp := &ListGeoRestrictionsResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1673,7 +1718,7 @@ func (c Products) UploadActivationCodes(params *UploadActivationCodesParams) (*U
|
||||
|
||||
resp := &UploadActivationCodesResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1706,7 +1751,7 @@ func (c Products) StatusOfUploadingActivationCodes(params *StatusOfUploadingActi
|
||||
|
||||
resp := &StatusOfUploadingActivationCodesResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1866,9 +1911,53 @@ type GetProductPriceInfoResponse struct {
|
||||
VAT string `json:"vat"`
|
||||
} `json:"price"`
|
||||
|
||||
// Price index
|
||||
// Deprected: price index
|
||||
//
|
||||
// Use PriceIndexes instead
|
||||
PriceIndex string `json:"price_index"`
|
||||
|
||||
// Product price indexes
|
||||
PriceIndexes struct {
|
||||
// Competitors' product price on other marketplaces
|
||||
ExternalIndexData struct {
|
||||
// Minimum competitors' product price on other marketplaces
|
||||
MinimalPrice string `json:"minimal_price"`
|
||||
|
||||
// Price currency
|
||||
MinimalPriceCurrency string `json:"minimal_price_currency"`
|
||||
|
||||
// Price index value
|
||||
PriceIndexValue float64 `json:"price_index_value"`
|
||||
} `json:"external_index_data"`
|
||||
|
||||
// Competitors' product price on Ozon
|
||||
OzonIndexData struct {
|
||||
// Minimum competitors' product price on Ozon
|
||||
MinimalPrice string `json:"minimal_price"`
|
||||
|
||||
// Price currency
|
||||
MinimalPriceCurrency string `json:"minimal_price_currency"`
|
||||
|
||||
// Price index value
|
||||
PriceIndexValue float64 `json:"price_index_value"`
|
||||
} `json:"ozon_index_data"`
|
||||
|
||||
// Resulting price index of the product
|
||||
PriceIndex string `json:"price_index"`
|
||||
|
||||
// Price of your product on other marketplaces
|
||||
SelfMarketplaceIndexData struct {
|
||||
// Minimum price of your product on other marketplaces
|
||||
MinimalPrice string `json:"minimal_price"`
|
||||
|
||||
// Price currency
|
||||
MinimalPriceCurrency string `json:"minimal_price_currency"`
|
||||
|
||||
// Price index value
|
||||
PriceIndexValue float64 `json:"price_index_value"`
|
||||
} `json:"self_marketplace_index_data"`
|
||||
} `json:"prices_indexes"`
|
||||
|
||||
// Product identifier
|
||||
ProductId int64 `json:"product_id"`
|
||||
|
||||
@@ -1892,7 +1981,7 @@ func (c Products) GetProductPriceInfo(params *GetProductPriceInfoParams) (*GetPr
|
||||
|
||||
resp := &GetProductPriceInfoResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1910,7 +1999,7 @@ type GetMarkdownInfoResponse struct {
|
||||
core.CommonResponse
|
||||
|
||||
// Information about the markdown and the main product
|
||||
Items []struct{
|
||||
Items []struct {
|
||||
// Comment on the damage reason
|
||||
CommentReasonDamaged string `json:"comment_reason_damaged"`
|
||||
|
||||
@@ -1966,7 +2055,7 @@ func (c Products) GetMarkdownInfo(params *GetMarkdownInfoParams) (*GetMarkdownIn
|
||||
|
||||
resp := &GetMarkdownInfoResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1975,7 +2064,7 @@ func (c Products) GetMarkdownInfo(params *GetMarkdownInfoParams) (*GetMarkdownIn
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
type SetDiscountOnMarkdownProductParams struct{
|
||||
type SetDiscountOnMarkdownProductParams struct {
|
||||
// Discount amount: from 3 to 99 percents
|
||||
Discount int32 `json:"discount"`
|
||||
|
||||
@@ -1983,7 +2072,7 @@ type SetDiscountOnMarkdownProductParams struct{
|
||||
ProductId int64 `json:"product_id"`
|
||||
}
|
||||
|
||||
type SetDiscountOnMarkdownProductResponse struct{
|
||||
type SetDiscountOnMarkdownProductResponse struct {
|
||||
core.CommonResponse
|
||||
|
||||
// Method result. true if the query was executed without errors
|
||||
@@ -1996,7 +2085,40 @@ func (c Products) SetDiscountOnMarkdownProduct(params *SetDiscountOnMarkdownProd
|
||||
|
||||
resp := &SetDiscountOnMarkdownProductResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
response.CopyCommonResponse(&resp.CommonResponse)
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
type NumberOfSubsToProductAvailabilityParams struct {
|
||||
// List of SKUs, product identifiers in the Ozon system
|
||||
SKUS []int64 `json:"skus"`
|
||||
}
|
||||
|
||||
type NumberOfSubsToProductAvailabilityResponse struct {
|
||||
core.CommonResponse
|
||||
|
||||
// Method result
|
||||
Result []struct {
|
||||
// Number of subscribed users
|
||||
Count int64 `json:"count"`
|
||||
|
||||
// Product identifier in the Ozon system, SKU
|
||||
SKU int64 `json:"sku"`
|
||||
} `json:"result"`
|
||||
}
|
||||
|
||||
// You can pass multiple products in a request
|
||||
func (c Products) NumberOfSubsToProductAvailability(params *NumberOfSubsToProductAvailabilityParams) (*NumberOfSubsToProductAvailabilityResponse, error) {
|
||||
url := "/v1/product/info/subscription"
|
||||
|
||||
resp := &NumberOfSubsToProductAvailabilityResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -168,7 +168,24 @@ func TestGetProductDetails(t *testing.T) {
|
||||
"has_stock": false,
|
||||
"active_product": false
|
||||
},
|
||||
"price_index": "0.00",
|
||||
"price_indexes": {
|
||||
"external_index_data": {
|
||||
"minimal_price": "string",
|
||||
"minimal_price_currency": "string",
|
||||
"price_index_value": 0
|
||||
},
|
||||
"ozon_index_data": {
|
||||
"minimal_price": "string",
|
||||
"minimal_price_currency": "string",
|
||||
"price_index_value": 0
|
||||
},
|
||||
"price_index": "WITHOUT_INDEX",
|
||||
"self_marketplaces_index_data": {
|
||||
"minimal_price": "string",
|
||||
"minimal_price_currency": "string",
|
||||
"price_index_value": 0
|
||||
}
|
||||
},
|
||||
"commissions": [],
|
||||
"volume_weight": 0.1,
|
||||
"is_prepayment": false,
|
||||
@@ -233,7 +250,7 @@ func TestGetProductDetails(t *testing.T) {
|
||||
"state_updated_at": "2021-10-21T15:48:03.927309Z"
|
||||
}
|
||||
}
|
||||
}`,
|
||||
}`,
|
||||
},
|
||||
// Test No Client-Id or Api-Key
|
||||
{
|
||||
@@ -2407,3 +2424,66 @@ func TestSetDiscountOnMarkdownProduct(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestNumberOfSubsToProductAvailability(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
statusCode int
|
||||
headers map[string]string
|
||||
params *NumberOfSubsToProductAvailabilityParams
|
||||
response string
|
||||
}{
|
||||
// Test Ok
|
||||
{
|
||||
http.StatusOK,
|
||||
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
|
||||
&NumberOfSubsToProductAvailabilityParams{
|
||||
SKUS: []int64{1234},
|
||||
},
|
||||
`{
|
||||
"result": [
|
||||
{
|
||||
"count": 2,
|
||||
"sku": 1234
|
||||
}
|
||||
]
|
||||
}`,
|
||||
},
|
||||
// Test No Client-Id or Api-Key
|
||||
{
|
||||
http.StatusUnauthorized,
|
||||
map[string]string{},
|
||||
&NumberOfSubsToProductAvailabilityParams{},
|
||||
`{
|
||||
"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))
|
||||
|
||||
resp, err := c.Products().NumberOfSubsToProductAvailability(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.Result) != len(test.params.SKUS) {
|
||||
t.Errorf("Length of SKUS in request and response are not equal")
|
||||
}
|
||||
|
||||
if len(resp.Result) > 0 {
|
||||
if resp.Result[0].SKU != test.params.SKUS[0] {
|
||||
t.Errorf("SKU in request and response are not equal")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ func (c Promotions) GetAvailablePromotions() (*GetAvailablePromotionsResponse, e
|
||||
|
||||
resp := &GetAvailablePromotionsResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodGet, url, nil, resp)
|
||||
response, err := c.client.Request(http.MethodGet, url, nil, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -129,7 +129,7 @@ func (c Promotions) AddToPromotion(params *AddProductToPromotionParams) (*AddPro
|
||||
|
||||
resp := &AddProductToPromotionResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodGet, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodGet, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -192,7 +192,7 @@ func (c Promotions) ProductsAvailableForPromotion(params *ProductsAvailableForPr
|
||||
|
||||
resp := &ProductsAvailableForPromotionResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -231,7 +231,7 @@ func (c Promotions) ProductsInPromotion(params *ProductsInPromotionParams) (*Pro
|
||||
|
||||
resp := &ProductsInPromotionResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -273,7 +273,7 @@ func (c Promotions) RemoveProduct(params *RemoveProductFromPromotionParams) (*Re
|
||||
|
||||
resp := &RemoveProductFromPromotionResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -321,7 +321,7 @@ func (c Promotions) ListHotSalePromotions() (*ListHotSalePromotionsResponse, err
|
||||
|
||||
resp := &ListHotSalePromotionsResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, nil, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, nil, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -381,7 +381,7 @@ func (c Promotions) ProductsAvailableForHotSalePromotion(params *ProductsAvailab
|
||||
|
||||
resp := &ProductsAvailableForHotSalePromotionResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -430,7 +430,7 @@ func (c Promotions) AddProductsToHotSale(params *AddProductsToHotSaleParams) (*P
|
||||
|
||||
resp := &ProductsToHotSaleResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -453,7 +453,7 @@ func (c Promotions) RemoveProductsToHotSale(params *RemoveProductsToHotSaleParam
|
||||
|
||||
resp := &ProductsToHotSaleResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -464,7 +464,7 @@ func (c Promotions) RemoveProductsToHotSale(params *RemoveProductsToHotSaleParam
|
||||
|
||||
type ListDiscountRequestsParams struct {
|
||||
// Discount request status
|
||||
Status string `json:"status" default:"UNKNOWN"`
|
||||
Status ListDiscountRequestsStatus `json:"status" default:"UNKNOWN"`
|
||||
|
||||
// Page number from which you want to download the list of discount requests
|
||||
Page uint64 `json:"page"`
|
||||
@@ -591,7 +591,7 @@ func (c Promotions) ListDiscountRequests(params *ListDiscountRequestsParams) (*L
|
||||
|
||||
resp := &ListDiscountRequestsResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -652,7 +652,7 @@ func (c Promotions) ApproveDiscountRequest(params *DiscountRequestParams) (*Disc
|
||||
|
||||
resp := &DiscountRequestResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -669,7 +669,7 @@ func (c Promotions) DeclineDiscountRequest(params *DiscountRequestParams) (*Disc
|
||||
|
||||
resp := &DiscountRequestResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ func (c Rating) GetCurrentSellerRatingInfo() (*GetCurrentSellerRatingInfoRespons
|
||||
|
||||
resp := &GetCurrentSellerRatingInfoResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, nil, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, nil, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -178,7 +178,7 @@ func (c Rating) GetSellerRatingInfoForPeriod(params *GetSellerRatingInfoForPerio
|
||||
|
||||
resp := &GetSellerRatingInfoPeriodResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ func (c Reports) GetList(params *GetReportsListParams) (*GetReportsListResponse,
|
||||
|
||||
resp := &GetReportsListResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -143,7 +143,7 @@ func (c Reports) GetReportDetails(params *GetReportDetailsParams) (*GetReportDet
|
||||
|
||||
resp := &GetReportDetailsResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -220,7 +220,7 @@ func (c Reports) GetFinancial(params *GetFinancialReportParams) (*GetFinancialRe
|
||||
|
||||
resp := &GetFinancialReportResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -266,7 +266,7 @@ func (c Reports) GetProducts(params *GetProductsReportParams) (*GetProductsRepor
|
||||
|
||||
resp := &GetProductsReportResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -299,7 +299,7 @@ func (c Reports) GetStocks(params *GetStocksReportParams) (*GetStocksReportRespo
|
||||
|
||||
resp := &GetStocksReportResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -342,7 +342,7 @@ func (c Reports) GetProductsMovement(params *GetProductsMovementReportParams) (*
|
||||
|
||||
resp := &GetProductsMovementReportResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -391,7 +391,7 @@ func (c Reports) GetReturns(params *GetReturnsReportParams) (*GetReturnsReportRe
|
||||
|
||||
resp := &GetReturnsReportResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -464,7 +464,7 @@ func (c Reports) GetShipment(params *GetShipmentReportParams) (*GetShipmentRepor
|
||||
|
||||
resp := &GetShipmentReportResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -489,7 +489,7 @@ func (c Reports) IssueOnDiscountedProducts() (*IssueOnDiscountedProductsResponse
|
||||
|
||||
resp := &IssueOnDiscountedProductsResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, nil, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, nil, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -532,7 +532,7 @@ func (c Reports) ReportOnDiscountedProducts(params *ReportOnDiscountedProductsPa
|
||||
|
||||
resp := &ReportOnDiscountedProductsResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, nil, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, nil, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -547,7 +547,7 @@ func (c Reports) ListReportsOnDiscountedProducts() (*ReportOnDiscountedProductsR
|
||||
|
||||
resp := &ReportOnDiscountedProductsResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, nil, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, nil, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ func (c Returns) GetFBOReturns(params *GetFBOReturnsParams) (*GetFBOReturnsRespo
|
||||
|
||||
resp := &GetFBOReturnsResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -240,7 +240,7 @@ func (c Returns) GetFBSReturns(params *GetFBSReturnsParams) (*GetFBSReturnsRespo
|
||||
|
||||
resp := &GetFBSReturnsResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ type GetListOfWarehousesResponse struct {
|
||||
Status string `json:"status"`
|
||||
|
||||
// Warehouse working days
|
||||
WorkingDays []string `json:"working_days"`
|
||||
WorkingDays []WorkingDay `json:"working_days"`
|
||||
} `json:"resulCommonResponse"`
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ func (c Warehouses) GetListOfWarehouses() (*GetListOfWarehousesResponse, error)
|
||||
|
||||
resp := &GetListOfWarehousesResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, nil, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, nil, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -174,7 +174,7 @@ func (c Warehouses) GetListOfDeliveryMethods(params *GetListOfDeliveryMethodsPar
|
||||
|
||||
resp := &GetListOfDeliveryMethodsResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, nil, resp)
|
||||
response, err := c.client.Request(http.MethodPost, url, nil, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user