Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e60a3f1ca2 | ||
|
|
2f1dbd5c00 | ||
|
|
387af0e30e | ||
|
|
c1e7f2b370 | ||
|
|
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
|
||||
}
|
||||
|
||||
379
ozon/common.go
Normal file
379
ozon/common.go
Normal file
@@ -0,0 +1,379 @@
|
||||
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"
|
||||
)
|
||||
|
||||
type DetailsDeliveryItemName string
|
||||
|
||||
const (
|
||||
DirectFlowLogisticSumDetailsDeliveryItemName DetailsDeliveryItemName = "MarketplaceServiceItemDirectFlowLogisticSum"
|
||||
DropoffDetailsDeliveryItemName DetailsDeliveryItemName = "MarketplaceServiceItemDropoff"
|
||||
DelivToCustomerDetailsDeliveryItemName DetailsDeliveryItemName = "MarketplaceServiceItemDelivToCustomer"
|
||||
)
|
||||
|
||||
type DetailsReturnServiceName string
|
||||
|
||||
const (
|
||||
ReturnAfterDelivToCustomerDetailsReturnServiceName DetailsReturnServiceName = "MarketplaceServiceItemReturnAfterDelivToCustomer"
|
||||
ReturnPartGoodsCustomerDetailsReturnServiceName DetailsReturnServiceName = "MarketplaceServiceItemReturnPartGoodsCustomer"
|
||||
ReturnNotDelivToCustomerDetailsReturnServiceName DetailsReturnServiceName = "MarketplaceServiceItemReturnNotDelivToCustomer"
|
||||
ReturnFlowLogisticDetailsReturnServiceName DetailsReturnServiceName = "MarketplaceServiceItemReturnFlowLogistic"
|
||||
)
|
||||
|
||||
type DetailsServiceItemName string
|
||||
|
||||
const (
|
||||
OtherMarketAndTech DetailsServiceItemName = "MarketplaceServiceItemOtherMarketAndTechService"
|
||||
ReturnStorageServiceAtThePickupPointFbsItem DetailsServiceItemName = "MarketplaceReturnStorageServiceAtThePickupPointFbsItem"
|
||||
SaleReviewsItem DetailsServiceItemName = "MarketplaceSaleReviewsItem"
|
||||
ServicePremiumCashbackIndividualPoints DetailsServiceItemName = "MarketplaceServicePremiumCashbackIndividualPoints"
|
||||
ServiceStorageItem DetailsServiceItemName = "MarketplaceServiceStorageItem"
|
||||
ServiceStockDisposal DetailsServiceItemName = "MarketplaceServiceStockDisposal"
|
||||
ReturnDisposalServiceFbsItem DetailsServiceItemName = "MarketplaceReturnDisposalServiceFbsItem"
|
||||
ServiceItemFlexiblePaymentSchedule DetailsServiceItemName = "MarketplaceServiceItemFlexiblePaymentSchedule"
|
||||
ServiceProcessingSpoilage DetailsServiceItemName = "MarketplaceServiceProcessingSpoilage"
|
||||
ServiceProcessingIdentifiedSurplus DetailsServiceItemName = "MarketplaceServiceProcessingIdentifiedSurplus"
|
||||
ServiceProcessingIdentifiedDiscrepancies DetailsServiceItemName = "MarketplaceServiceProcessingIdentifiedDiscrepancies"
|
||||
ServiceItemInternetSiteAdvertising DetailsServiceItemName = "MarketplaceServiceItemInternetSiteAdvertising"
|
||||
ServiceItemPremiumSubscribtion DetailsServiceItemName = "MarketplaceServiceItemPremiumSubscribtion"
|
||||
AgencyFeeAggregator3PLGlobalItem DetailsServiceItemName = "MarketplaceAgencyFeeAggregator3PLGlobalItem"
|
||||
)
|
||||
|
||||
type DetailsOtherItemName string
|
||||
|
||||
const (
|
||||
RedistributionOfAcquiringOperation DetailsOtherItemName = "MarketplaceRedistributionOfAcquiringOperation"
|
||||
CompensationLossOfGoodsOperation DetailsOtherItemName = "MarketplaceSellerCompensationLossOfGoodsOperation"
|
||||
CorrectionOperation DetailsOtherItemName = "MarketplaceSellerCorrectionOperation"
|
||||
OperationCorrectionSeller DetailsOtherItemName = "OperationCorrectionSeller"
|
||||
OperationMarketplaceWithHoldingForUndeliverableGoods DetailsOtherItemName = "OperationMarketplaceWithHoldingForUndeliverableGoods"
|
||||
OperationClaim DetailsOtherItemName = "OperationClaim"
|
||||
)
|
||||
|
||||
type StrategyType string
|
||||
|
||||
const (
|
||||
MinExtPrice StrategyType = "MIN_EXT_PRICE"
|
||||
CompPrice StrategyType = "COMP_PRICE"
|
||||
)
|
||||
|
||||
type StrategyUpdateType string
|
||||
|
||||
const (
|
||||
StrategyEnabled StrategyUpdateType = "strategyEnabled"
|
||||
StrategyDisabled StrategyUpdateType = "strategyDisabled"
|
||||
StrategyChanged StrategyUpdateType = "strategyChanged"
|
||||
StrategyCreated StrategyUpdateType = "strategyCreated"
|
||||
StrategyItemsListChanged StrategyUpdateType = "strategyItemsListChanged"
|
||||
)
|
||||
264
ozon/fbo.go
264
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,251 @@ 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
|
||||
}
|
||||
response.CopyCommonResponse(&resp.CommonResponse)
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
type GetWarehouseWorkloadResponse struct {
|
||||
core.CommonResponse
|
||||
|
||||
// Method result
|
||||
Result []struct {
|
||||
// Workload
|
||||
Schedule struct {
|
||||
// Data on the products quantity supplied to the warehouse
|
||||
Capacity []struct {
|
||||
// Period start, local time
|
||||
Start time.Time `json:"start"`
|
||||
|
||||
// Period end, local time
|
||||
End time.Time `json:"end"`
|
||||
|
||||
// Average number of products that the warehouse can accept per day for the period
|
||||
Value int32 `json:"value"`
|
||||
} `json:"capacity"`
|
||||
|
||||
// The closest available date for supply, local time
|
||||
Date time.Time `json:"date"`
|
||||
} `json:"schedule"`
|
||||
|
||||
// Warehouse
|
||||
Warehouse struct {
|
||||
// Warehouse identifier
|
||||
Id string `json:"id"`
|
||||
|
||||
// Warehouse name
|
||||
Name string `json:"name"`
|
||||
} `json:"warehouse"`
|
||||
} `json:"result"`
|
||||
}
|
||||
|
||||
// Method returns a list of active Ozon warehouses with information about their average workload in the nearest future
|
||||
func (c FBO) GetWarehouseWorkload() (*GetWarehouseWorkloadResponse, error) {
|
||||
url := "/v1/supplier/available_warehouses"
|
||||
|
||||
resp := &GetWarehouseWorkloadResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodGet, url, nil, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
263
ozon/fbo_test.go
263
ozon/fbo_test.go
@@ -277,3 +277,266 @@ 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetWarehouseWorkload(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
statusCode int
|
||||
headers map[string]string
|
||||
response string
|
||||
}{
|
||||
// Test Ok
|
||||
{
|
||||
http.StatusOK,
|
||||
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
|
||||
`{
|
||||
"result": [
|
||||
{
|
||||
"schedule": {
|
||||
"capacity": [
|
||||
{
|
||||
"start": "2019-08-24T14:15:22Z",
|
||||
"end": "2019-08-24T14:15:22Z",
|
||||
"value": 0
|
||||
}
|
||||
],
|
||||
"date": "2019-08-24T14:15:22Z"
|
||||
},
|
||||
"warehouse": {
|
||||
"id": "string",
|
||||
"name": "string"
|
||||
}
|
||||
}
|
||||
]
|
||||
}`,
|
||||
},
|
||||
// Test No Client-Id or Api-Key
|
||||
{
|
||||
http.StatusUnauthorized,
|
||||
map[string]string{},
|
||||
`{
|
||||
"code": 16,
|
||||
"message": "Client-Id and Api-Key headers are required"
|
||||
}`,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
c := NewMockClient(core.NewMockHttpHandler(test.statusCode, test.response, test.headers))
|
||||
|
||||
resp, err := c.FBO().GetWarehouseWorkload()
|
||||
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,6 +30,7 @@ type Client struct {
|
||||
brands *Brands
|
||||
chats *Chats
|
||||
certificates *Certificates
|
||||
strategies *Strategies
|
||||
}
|
||||
|
||||
func (c Client) Analytics() *Analytics {
|
||||
@@ -100,6 +101,10 @@ func (c Client) Certificates() *Certificates {
|
||||
return c.certificates
|
||||
}
|
||||
|
||||
func (c Client) Strategies() *Strategies {
|
||||
return c.strategies
|
||||
}
|
||||
|
||||
func NewClient(clientId, apiKey string) *Client {
|
||||
coreClient := core.NewClient(DefaultAPIBaseUrl, map[string]string{
|
||||
"Client-Id": clientId,
|
||||
@@ -125,6 +130,7 @@ func NewClient(clientId, apiKey string) *Client {
|
||||
brands: &Brands{client: coreClient},
|
||||
chats: &Chats{client: coreClient},
|
||||
certificates: &Certificates{client: coreClient},
|
||||
strategies: &Strategies{client: coreClient},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,5 +156,6 @@ func NewMockClient(handler http.HandlerFunc) *Client {
|
||||
brands: &Brands{client: coreClient},
|
||||
chats: &Chats{client: coreClient},
|
||||
certificates: &Certificates{client: coreClient},
|
||||
strategies: &Strategies{client: coreClient},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
242
ozon/products.go
242
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,96 @@ 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
|
||||
}
|
||||
response.CopyCommonResponse(&resp.CommonResponse)
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
type UpdateCharacteristicsParams struct {
|
||||
// Products and characteristics to be updated
|
||||
Items []UpdateCharacteristicsItem `json:"items"`
|
||||
}
|
||||
|
||||
type UpdateCharacteristicsItem struct {
|
||||
// Product characteristics
|
||||
Attributes []UpdateCharacteristicsItemAttribute `json:"attributes"`
|
||||
|
||||
// Product ID
|
||||
OfferId string `json:"offer_id"`
|
||||
}
|
||||
|
||||
type UpdateCharacteristicsItemAttribute struct {
|
||||
// Identifier of the characteristic that supports nested properties.
|
||||
// Each of the nested characteristics can have multiple value variants
|
||||
ComplexId int64 `json:"complex_id"`
|
||||
|
||||
// Characteristic identifier
|
||||
Id int64 `json:"id"`
|
||||
|
||||
// Array of nested characteristic values
|
||||
Values []UpdateCharacteristicsItemValue `json:"values"`
|
||||
}
|
||||
|
||||
type UpdateCharacteristicsItemValue struct {
|
||||
// Characteristic identifier in the dictionary
|
||||
DictionaryValueId int64 `json:"dictionary_value_id"`
|
||||
|
||||
// Product characteristic value
|
||||
Value string `json:"value"`
|
||||
}
|
||||
|
||||
type UpdateCharacteristicsResponse struct {
|
||||
core.CommonResponse
|
||||
|
||||
// Products update task code.
|
||||
//
|
||||
// To check the update status, pass the received value to the `/v1/product/import/info` method
|
||||
TaskId int64 `json:"task_id"`
|
||||
}
|
||||
|
||||
func (c Products) UpdateCharacteristics(params *UpdateCharacteristicsParams) (*UpdateCharacteristicsResponse, error) {
|
||||
url := "/v1/product/attributes/update"
|
||||
|
||||
resp := &UpdateCharacteristicsResponse{}
|
||||
|
||||
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,128 @@ 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")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestUpdateCharacteristics(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
statusCode int
|
||||
headers map[string]string
|
||||
params *UpdateCharacteristicsParams
|
||||
response string
|
||||
}{
|
||||
// Test Ok
|
||||
{
|
||||
http.StatusOK,
|
||||
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
|
||||
&UpdateCharacteristicsParams{
|
||||
Items: []UpdateCharacteristicsItem{
|
||||
{
|
||||
Attributes: []UpdateCharacteristicsItemAttribute{
|
||||
{
|
||||
ComplexId: 0,
|
||||
Id: 0,
|
||||
Values: []UpdateCharacteristicsItemValue{
|
||||
{
|
||||
DictionaryValueId: 0,
|
||||
Value: "string",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
OfferId: "string",
|
||||
},
|
||||
},
|
||||
},
|
||||
`{
|
||||
"task_id": 0
|
||||
}`,
|
||||
},
|
||||
// Test No Client-Id or Api-Key
|
||||
{
|
||||
http.StatusUnauthorized,
|
||||
map[string]string{},
|
||||
&UpdateCharacteristicsParams{},
|
||||
`{
|
||||
"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().UpdateCharacteristics(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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
118
ozon/reports.go
118
ozon/reports.go
@@ -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
|
||||
}
|
||||
@@ -159,6 +159,9 @@ type GetFinancialReportParams struct {
|
||||
// Number of the page returned in the request
|
||||
Page int64 `json:"page"`
|
||||
|
||||
// true, если нужно добавить дополнительные параметры в ответ
|
||||
WithDetails bool `json:"with_details"`
|
||||
|
||||
// Number of items on the page
|
||||
PageSize int64 `json:"page_size"`
|
||||
}
|
||||
@@ -209,6 +212,99 @@ type GetFinancialReportResponse struct {
|
||||
CurrencyCode string `json:"currency_code"`
|
||||
} `json:"cash_flows"`
|
||||
|
||||
// Detailed info
|
||||
Details struct {
|
||||
// Balance on the beginning of period
|
||||
BeginBalanceAmount float64 `json:"begin_balance_amount"`
|
||||
|
||||
// Orders
|
||||
Delivery struct {
|
||||
Total float64 `json:"total"`
|
||||
|
||||
Amount float64 `json:"amount"`
|
||||
|
||||
DeliveryServices struct {
|
||||
Total float64 `json:"total"`
|
||||
|
||||
Items []struct {
|
||||
Name DetailsDeliveryItemName `json:"name"`
|
||||
|
||||
Price float64 `json:"price"`
|
||||
} `json:"items"`
|
||||
} `json:"delivery_services"`
|
||||
} `json:"delivery"`
|
||||
|
||||
InvoiceTransfer float64 `json:"invoice_transfer"`
|
||||
|
||||
Loan float64 `json:"loan"`
|
||||
|
||||
Payments []struct {
|
||||
CurrencyCode string `json:"currency_code"`
|
||||
|
||||
Payment float64 `json:"payment"`
|
||||
} `json:"payments"`
|
||||
|
||||
Period struct {
|
||||
Begin time.Time `json:"begin"`
|
||||
|
||||
End time.Time `json:"end"`
|
||||
|
||||
Id int64 `json:"id"`
|
||||
} `json:"period"`
|
||||
|
||||
Return struct {
|
||||
Total float64 `json:"total"`
|
||||
|
||||
Amount float64 `json:"amount"`
|
||||
|
||||
ReturnServices struct {
|
||||
Total float64 `json:"total"`
|
||||
|
||||
Items []struct {
|
||||
Name DetailsReturnServiceName `json:"name"`
|
||||
|
||||
Price float64 `json:"price"`
|
||||
} `json:"items"`
|
||||
} `json:"return_services"`
|
||||
} `json:"return"`
|
||||
|
||||
RFBS struct {
|
||||
Total float64 `json:"total"`
|
||||
|
||||
TransferDelivery float64 `json:"transfer_delivery"`
|
||||
|
||||
TransferDeliveryReturn float64 `json:"transfer_delivery_return"`
|
||||
|
||||
CompensationDeliveryReturn float64 `json:"compensation_delivery_return"`
|
||||
|
||||
PartialCompensation float64 `json:"partial_compensation"`
|
||||
|
||||
PartialCompensationReturn float64 `json:"partial_compensation_return"`
|
||||
} `json:"rfbs"`
|
||||
|
||||
Services struct {
|
||||
Total float64 `json:"total"`
|
||||
|
||||
Items []struct {
|
||||
Name DetailsServiceItemName `json:"name"`
|
||||
|
||||
Price float64 `json:"price"`
|
||||
} `json:"items"`
|
||||
} `json:"services"`
|
||||
|
||||
Others struct {
|
||||
Total float64 `json:"total"`
|
||||
|
||||
Items []struct {
|
||||
Name DetailsOtherItemName `json:"name"`
|
||||
|
||||
Price float64 `json:"price"`
|
||||
} `json:"items"`
|
||||
} `json:"others"`
|
||||
|
||||
EndBalanceAmount float64 `json:"end_balance_amount"`
|
||||
} `json:"details"`
|
||||
|
||||
// Number of pages with reports
|
||||
PageCount int64 `json:"page_count"`
|
||||
} `json:"result"`
|
||||
@@ -220,7 +316,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 +362,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 +395,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 +438,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 +487,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 +560,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 +585,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 +628,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 +643,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
|
||||
}
|
||||
|
||||
@@ -165,28 +165,98 @@ func TestGetFinancialReport(t *testing.T) {
|
||||
From: core.TimeFromString(t, "2006-01-02T15:04:05Z", "2022-01-01T00:00:00.000Z"),
|
||||
To: core.TimeFromString(t, "2006-01-02T15:04:05Z", "2022-12-31T00:00:00.000Z"),
|
||||
},
|
||||
Page: 1,
|
||||
PageSize: 1,
|
||||
WithDetails: true,
|
||||
Page: 1,
|
||||
PageSize: 1,
|
||||
},
|
||||
`{
|
||||
"result": {
|
||||
"cash_flows": [
|
||||
{
|
||||
"period": {
|
||||
"id": 11567022278500,
|
||||
"begin": "2022-08-01T00:00:00Z",
|
||||
"end": "2022-08-15T00:00:00Z"
|
||||
},
|
||||
"orders_amount": 1000,
|
||||
"returns_amount": -3000,
|
||||
"commission_amount": 1437,
|
||||
"services_amount": 8471.28,
|
||||
"currency_code": "string",
|
||||
"item_delivery_and_return_amount": 1991,
|
||||
"currency_code": "RUB"
|
||||
"orders_amount": 1000,
|
||||
"period": {
|
||||
"begin": "2023-04-03T09:12:10.239Z",
|
||||
"end": "2023-04-03T09:12:10.239Z",
|
||||
"id": 11567022278500
|
||||
},
|
||||
"returns_amount": -3000,
|
||||
"services_amount": 8471.28
|
||||
}
|
||||
],
|
||||
"page_count": 15
|
||||
}
|
||||
"details": {
|
||||
"period": {
|
||||
"begin": "2023-04-03T09:12:10.239Z",
|
||||
"end": "2023-04-03T09:12:10.239Z",
|
||||
"id": 11567022278500
|
||||
},
|
||||
"payments": [
|
||||
{
|
||||
"payment": 0,
|
||||
"currency_code": "string"
|
||||
}
|
||||
],
|
||||
"begin_balance_amount": 0,
|
||||
"delivery": {
|
||||
"total": 0,
|
||||
"amount": 0,
|
||||
"delivery_services": {
|
||||
"total": 0,
|
||||
"items": [
|
||||
{
|
||||
"name": "string",
|
||||
"price": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"return": {
|
||||
"total": 0,
|
||||
"amount": 0,
|
||||
"return_services": {
|
||||
"total": 0,
|
||||
"items": [
|
||||
{
|
||||
"name": "string",
|
||||
"price": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"loan": 0,
|
||||
"invoice_transfer": 0,
|
||||
"rfbs": {
|
||||
"total": 0,
|
||||
"transfer_delivery": 0,
|
||||
"transfer_delivery_return": 0,
|
||||
"compensation_delivery_return": 0,
|
||||
"partial_compensation": 0,
|
||||
"partial_compensation_return": 0
|
||||
},
|
||||
"services": {
|
||||
"total": 0,
|
||||
"items": [
|
||||
{
|
||||
"name": "string",
|
||||
"price": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
"others": {
|
||||
"total": 0,
|
||||
"items": [
|
||||
{
|
||||
"name": "string",
|
||||
"price": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
"end_balance_amount": 0
|
||||
}
|
||||
},
|
||||
"page_count": 15
|
||||
}`,
|
||||
},
|
||||
// Test No Client-Id or Api-Key
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
381
ozon/strategies.go
Normal file
381
ozon/strategies.go
Normal file
@@ -0,0 +1,381 @@
|
||||
package ozon
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
core "github.com/diphantxm/ozon-api-client"
|
||||
)
|
||||
|
||||
type Strategies struct {
|
||||
client *core.Client
|
||||
}
|
||||
|
||||
type ListCompetitorsParams struct {
|
||||
Page int64 `json:"page"`
|
||||
|
||||
Limit int64 `json:"limit"`
|
||||
}
|
||||
|
||||
type ListCompetitorsResponse struct {
|
||||
core.CommonResponse
|
||||
|
||||
Competitors []struct {
|
||||
Name string `json:"name"`
|
||||
|
||||
Id int64 `json:"id"`
|
||||
} `json:"competitors"`
|
||||
|
||||
Total int32 `json:"total"`
|
||||
}
|
||||
|
||||
func (c Strategies) ListCompetitors(params *ListCompetitorsParams) (*ListCompetitorsResponse, error) {
|
||||
url := "/v1/pricing-strategy/competitors/list"
|
||||
|
||||
resp := &ListCompetitorsResponse{}
|
||||
|
||||
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 ListStrategiesParams struct {
|
||||
Page int64 `json:"page"`
|
||||
|
||||
Limit int64 `json:"limit"`
|
||||
}
|
||||
|
||||
type ListStrategiesResponse struct {
|
||||
core.CommonResponse
|
||||
|
||||
Strategies []struct {
|
||||
Id string `json:"id"`
|
||||
|
||||
Name string `json:"name"`
|
||||
|
||||
Type StrategyType `json:"type"`
|
||||
|
||||
UpdateType StrategyUpdateType `json:"update_type"`
|
||||
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
|
||||
ProductsCount int64 `json:"products_count"`
|
||||
|
||||
CompetitorsCount int64 `json:"competitors_count"`
|
||||
|
||||
Enabled bool `json:"enabled"`
|
||||
} `json:"strategies"`
|
||||
|
||||
Total int32 `json:"total"`
|
||||
}
|
||||
|
||||
func (c Strategies) List(params *ListStrategiesParams) (*ListStrategiesResponse, error) {
|
||||
url := "/v1/pricing-strategy/list"
|
||||
|
||||
resp := &ListStrategiesResponse{}
|
||||
|
||||
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 CreateStrategyParams struct {
|
||||
Competitors []CreateStrategyCompetitor `json:"competitors"`
|
||||
|
||||
StrategyName string `json:"strategy_name"`
|
||||
}
|
||||
|
||||
type CreateStrategyCompetitor struct {
|
||||
Coefficient float32 `json:"coefficient"`
|
||||
|
||||
CompetitorId int64 `json:"competitor_id"`
|
||||
}
|
||||
|
||||
type CreateStrategyResponse struct {
|
||||
core.CommonResponse
|
||||
|
||||
Result struct {
|
||||
StrategyId string `json:"strategy_id"`
|
||||
} `json:"result"`
|
||||
}
|
||||
|
||||
func (c Strategies) Create(params *CreateStrategyParams) (*CreateStrategyResponse, error) {
|
||||
url := "/v1/pricing-strategy/create"
|
||||
|
||||
resp := &CreateStrategyResponse{}
|
||||
|
||||
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 InfoStrategyParams struct {
|
||||
StrategyId string `json:"strategy_id"`
|
||||
}
|
||||
|
||||
type InfoStrategyResponse struct {
|
||||
core.CommonResponse
|
||||
|
||||
Result struct {
|
||||
Competitors []CreateStrategyCompetitor `json:"competitors"`
|
||||
|
||||
Enabled bool `json:"enabled"`
|
||||
|
||||
Name string `json:"name"`
|
||||
|
||||
Type StrategyType `json:"type"`
|
||||
|
||||
UpdateType StrategyUpdateType `json:"update_type"`
|
||||
} `json:"result"`
|
||||
}
|
||||
|
||||
func (c Strategies) Info(params *InfoStrategyParams) (*InfoStrategyResponse, error) {
|
||||
url := "/v1/pricing-strategy/info"
|
||||
|
||||
resp := &InfoStrategyResponse{}
|
||||
|
||||
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 UpdateStrategyParams struct {
|
||||
Competitors []CreateStrategyCompetitor `json:"competitors"`
|
||||
|
||||
StrategyId string `json:"strategy_id"`
|
||||
|
||||
StrategyName string `json:"strategy_name"`
|
||||
}
|
||||
|
||||
type UpdateStrategyResponse struct {
|
||||
core.CommonResponse
|
||||
}
|
||||
|
||||
func (c Strategies) Update(params *UpdateStrategyParams) (*UpdateStrategyResponse, error) {
|
||||
url := "/v1/pricing-strategy/update"
|
||||
|
||||
resp := &UpdateStrategyResponse{}
|
||||
|
||||
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 AddProductsToStrategyParams struct {
|
||||
ProductId []int64 `json:"product_id"`
|
||||
|
||||
StrategyId string `json:"strategy_id"`
|
||||
}
|
||||
|
||||
type AddProductsToStrategyResponse struct {
|
||||
core.CommonResponse
|
||||
|
||||
Result struct {
|
||||
Errors []struct {
|
||||
Code string `json:"code"`
|
||||
|
||||
Error string `json:"error"`
|
||||
|
||||
ProductId int64 `json:"product_id"`
|
||||
} `json:"errors"`
|
||||
|
||||
FailedProductCount int32 `json:"failed_product_count"`
|
||||
} `json:"result"`
|
||||
}
|
||||
|
||||
func (c Strategies) AddProducts(params *AddProductsToStrategyParams) (*AddProductsToStrategyResponse, error) {
|
||||
url := "/v1/pricing-strategy/products/add"
|
||||
|
||||
resp := &AddProductsToStrategyResponse{}
|
||||
|
||||
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 GetStrategiesByProductIdsParams struct {
|
||||
ProductId []int64 `json:"product_id"`
|
||||
}
|
||||
|
||||
type GetStrategiesByProductIdsResponse struct {
|
||||
core.CommonResponse
|
||||
|
||||
Result struct {
|
||||
ProductsInfo []struct {
|
||||
ProductId int64 `json:"product_id"`
|
||||
|
||||
StrategyId string `json:"strategy_id"`
|
||||
} `json:"products_info"`
|
||||
} `json:"result"`
|
||||
}
|
||||
|
||||
func (c Strategies) GetByProductIds(params *GetStrategiesByProductIdsParams) (*GetStrategiesByProductIdsResponse, error) {
|
||||
url := "/v1/pricing-strategy/strategy-ids-by-product-ids"
|
||||
|
||||
resp := &GetStrategiesByProductIdsResponse{}
|
||||
|
||||
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 ListProductsInStrategyParams struct {
|
||||
StrategyId string `json:"strategy_id"`
|
||||
}
|
||||
|
||||
type ListProductsInStrategyResponse struct {
|
||||
core.CommonResponse
|
||||
|
||||
Result struct {
|
||||
ProductId []string `json:"product_id"`
|
||||
} `json:"result"`
|
||||
}
|
||||
|
||||
func (c Strategies) ListProducts(params *ListProductsInStrategyParams) (*ListProductsInStrategyResponse, error) {
|
||||
url := "/v1/pricing-strategy/products/list"
|
||||
|
||||
resp := &ListProductsInStrategyResponse{}
|
||||
|
||||
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 GetCompetitorPriceParams struct {
|
||||
ProductId int64 `json:"product_id"`
|
||||
}
|
||||
|
||||
type GetCompetitorPriceResponse struct {
|
||||
core.CommonResponse
|
||||
|
||||
Result struct {
|
||||
StrategyId string `json:"strategy_id"`
|
||||
|
||||
IsEnabled bool `json:"is_enabled"`
|
||||
|
||||
StrategyProductPrice int32 `json:"strategy_product_price"`
|
||||
|
||||
PriceDownloadedAt string `json:"price_downloaded_at"`
|
||||
|
||||
StrategyCompetitorId int64 `json:"strategy_competitor_id"`
|
||||
|
||||
StrategyCompetitorProductURL string `json:"strategy_competitor_product_url"`
|
||||
} `json:"result"`
|
||||
}
|
||||
|
||||
func (c Strategies) GetCompetitorPrice(params *GetCompetitorPriceParams) (*GetCompetitorPriceResponse, error) {
|
||||
url := "/v1/pricing-strategy/product/info"
|
||||
|
||||
resp := &GetCompetitorPriceResponse{}
|
||||
|
||||
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 RemoveProductsFromStrategyParams struct {
|
||||
ProductId []int64 `json:"product_id"`
|
||||
}
|
||||
|
||||
type RemoveProductsFromStrategyResponse struct {
|
||||
core.CommonResponse
|
||||
|
||||
Result struct {
|
||||
FailedProductCount int32 `json:"failed_product_count"`
|
||||
} `json:"result"`
|
||||
}
|
||||
|
||||
func (c Strategies) RemoveProducts(params *RemoveProductsFromStrategyParams) (*RemoveProductsFromStrategyResponse, error) {
|
||||
url := "/v1/pricing-strategy/products/delete"
|
||||
|
||||
resp := &RemoveProductsFromStrategyResponse{}
|
||||
|
||||
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 ChangeStrategyStatusParams struct {
|
||||
Enabled bool `json:"enabled"`
|
||||
|
||||
StrategyId string `json:"strategy_id"`
|
||||
}
|
||||
|
||||
type ChangeStrategyStatusResponse struct {
|
||||
core.CommonResponse
|
||||
}
|
||||
|
||||
func (c Strategies) ChangeStatus(params *ChangeStrategyStatusParams) (*ChangeStrategyStatusResponse, error) {
|
||||
url := "/v1/pricing-strategy/status"
|
||||
|
||||
resp := &ChangeStrategyStatusResponse{}
|
||||
|
||||
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 RemoveStrategyParams struct {
|
||||
StrategyId string `json:"strategy_id"`
|
||||
}
|
||||
|
||||
type RemoveStrategyResponse struct {
|
||||
core.CommonResponse
|
||||
}
|
||||
|
||||
func (c Strategies) Remove(params *RemoveStrategyParams) (*RemoveStrategyResponse, error) {
|
||||
url := "/v1/pricing-strategy/delete"
|
||||
|
||||
resp := &RemoveStrategyResponse{}
|
||||
|
||||
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
response.CopyCommonResponse(&resp.CommonResponse)
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
668
ozon/strategies_test.go
Normal file
668
ozon/strategies_test.go
Normal file
@@ -0,0 +1,668 @@
|
||||
package ozon
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
core "github.com/diphantxm/ozon-api-client"
|
||||
)
|
||||
|
||||
func TestListCompetitors(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
statusCode int
|
||||
headers map[string]string
|
||||
params *ListCompetitorsParams
|
||||
response string
|
||||
}{
|
||||
// Test Ok
|
||||
{
|
||||
http.StatusOK,
|
||||
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
|
||||
&ListCompetitorsParams{
|
||||
Page: 1,
|
||||
Limit: 20,
|
||||
},
|
||||
`{
|
||||
"competitor": [
|
||||
{
|
||||
"competitor_name": "string",
|
||||
"competitor_id": 0
|
||||
}
|
||||
],
|
||||
"total": 0
|
||||
}`,
|
||||
},
|
||||
// Test No Client-Id or Api-Key
|
||||
{
|
||||
http.StatusUnauthorized,
|
||||
map[string]string{},
|
||||
&ListCompetitorsParams{},
|
||||
`{
|
||||
"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.Strategies().ListCompetitors(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 TestListStrategies(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
statusCode int
|
||||
headers map[string]string
|
||||
params *ListStrategiesParams
|
||||
response string
|
||||
}{
|
||||
// Test Ok
|
||||
{
|
||||
http.StatusOK,
|
||||
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
|
||||
&ListStrategiesParams{
|
||||
Page: 1,
|
||||
Limit: 20,
|
||||
},
|
||||
`{
|
||||
"strategies": [
|
||||
{
|
||||
"strategy_id": "string",
|
||||
"strategy_name": "string",
|
||||
"type": "string",
|
||||
"update_type": "string",
|
||||
"updated_at": "string",
|
||||
"products_count": 0,
|
||||
"competitors_count": 0,
|
||||
"enabled": true
|
||||
}
|
||||
],
|
||||
"total": 0
|
||||
}`,
|
||||
},
|
||||
// Test No Client-Id or Api-Key
|
||||
{
|
||||
http.StatusUnauthorized,
|
||||
map[string]string{},
|
||||
&ListStrategiesParams{},
|
||||
`{
|
||||
"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.Strategies().List(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 TestCreateStrategy(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
statusCode int
|
||||
headers map[string]string
|
||||
params *CreateStrategyParams
|
||||
response string
|
||||
}{
|
||||
// Test Ok
|
||||
{
|
||||
http.StatusOK,
|
||||
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
|
||||
&CreateStrategyParams{
|
||||
StrategyName: "New strategy",
|
||||
Competitors: []CreateStrategyCompetitor{
|
||||
{
|
||||
CompetitorId: 1008426,
|
||||
Coefficient: 1,
|
||||
},
|
||||
{
|
||||
CompetitorId: 204,
|
||||
Coefficient: 1,
|
||||
},
|
||||
{
|
||||
CompetitorId: 91,
|
||||
Coefficient: 1,
|
||||
},
|
||||
{
|
||||
CompetitorId: 48,
|
||||
Coefficient: 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
`{
|
||||
"result": {
|
||||
"id": "4f3a1d4c-5833-4f04-b69b-495cbc1f6f1c"
|
||||
}
|
||||
}`,
|
||||
},
|
||||
// Test No Client-Id or Api-Key
|
||||
{
|
||||
http.StatusUnauthorized,
|
||||
map[string]string{},
|
||||
&CreateStrategyParams{},
|
||||
`{
|
||||
"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.Strategies().Create(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 TestInfoStrategy(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
statusCode int
|
||||
headers map[string]string
|
||||
params *InfoStrategyParams
|
||||
response string
|
||||
}{
|
||||
// Test Ok
|
||||
{
|
||||
http.StatusOK,
|
||||
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
|
||||
&InfoStrategyParams{
|
||||
StrategyId: "1",
|
||||
},
|
||||
`{
|
||||
"result": {
|
||||
"strategy_name": "test1",
|
||||
"enabled": true,
|
||||
"update_type": "strategyItemsListChanged",
|
||||
"type": "COMP_PRICE",
|
||||
"competitors": [
|
||||
{
|
||||
"competitor_id": 204,
|
||||
"coefficient": 1
|
||||
},
|
||||
{
|
||||
"competitor_id": 1008426,
|
||||
"coefficient": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
}`,
|
||||
},
|
||||
// Test No Client-Id or Api-Key
|
||||
{
|
||||
http.StatusUnauthorized,
|
||||
map[string]string{},
|
||||
&InfoStrategyParams{},
|
||||
`{
|
||||
"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.Strategies().Info(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 TestUpdateStrategy(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
statusCode int
|
||||
headers map[string]string
|
||||
params *UpdateStrategyParams
|
||||
response string
|
||||
}{
|
||||
// Test Ok
|
||||
{
|
||||
http.StatusOK,
|
||||
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
|
||||
&UpdateStrategyParams{
|
||||
StrategyId: "a3de1826-9c54-40f1-bb6d-1a9e2638b058",
|
||||
StrategyName: "New Strategy",
|
||||
Competitors: []CreateStrategyCompetitor{
|
||||
{
|
||||
CompetitorId: 1008426,
|
||||
Coefficient: 1,
|
||||
},
|
||||
{
|
||||
CompetitorId: 204,
|
||||
Coefficient: 1,
|
||||
},
|
||||
{
|
||||
CompetitorId: 91,
|
||||
Coefficient: 1,
|
||||
},
|
||||
{
|
||||
CompetitorId: 48,
|
||||
Coefficient: 1,
|
||||
},
|
||||
{
|
||||
CompetitorId: 45,
|
||||
Coefficient: 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
`{}`,
|
||||
},
|
||||
// Test No Client-Id or Api-Key
|
||||
{
|
||||
http.StatusUnauthorized,
|
||||
map[string]string{},
|
||||
&UpdateStrategyParams{},
|
||||
`{
|
||||
"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.Strategies().Update(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 TestAddProductsToStrategy(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
statusCode int
|
||||
headers map[string]string
|
||||
params *AddProductsToStrategyParams
|
||||
response string
|
||||
}{
|
||||
// Test Ok
|
||||
{
|
||||
http.StatusOK,
|
||||
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
|
||||
&AddProductsToStrategyParams{
|
||||
ProductId: []int64{29209},
|
||||
StrategyId: "e29114f0-177d-4160-8d06-2bc528470dda",
|
||||
},
|
||||
`{
|
||||
"result": {
|
||||
"failed_product_count": 0
|
||||
}
|
||||
}`,
|
||||
},
|
||||
// Test No Client-Id or Api-Key
|
||||
{
|
||||
http.StatusUnauthorized,
|
||||
map[string]string{},
|
||||
&AddProductsToStrategyParams{},
|
||||
`{
|
||||
"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.Strategies().AddProducts(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 TestGetStrategiesByProductIds(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
statusCode int
|
||||
headers map[string]string
|
||||
params *GetStrategiesByProductIdsParams
|
||||
response string
|
||||
}{
|
||||
// Test Ok
|
||||
{
|
||||
http.StatusOK,
|
||||
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
|
||||
&GetStrategiesByProductIdsParams{
|
||||
ProductId: []int64{29209},
|
||||
},
|
||||
`{
|
||||
"result": {
|
||||
"products_info": [
|
||||
{
|
||||
"product_id": 29209,
|
||||
"strategy_id": "b7cd30e6-5667-424d-b105-fbec30a52477"
|
||||
}
|
||||
]
|
||||
}
|
||||
}`,
|
||||
},
|
||||
// Test No Client-Id or Api-Key
|
||||
{
|
||||
http.StatusUnauthorized,
|
||||
map[string]string{},
|
||||
&GetStrategiesByProductIdsParams{},
|
||||
`{
|
||||
"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.Strategies().GetByProductIds(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.ProductsInfo) != len(test.params.ProductId) {
|
||||
t.Errorf("Length of product ids in request and response are not equal")
|
||||
}
|
||||
|
||||
if len(resp.Result.ProductsInfo) > 0 {
|
||||
if resp.Result.ProductsInfo[0].ProductId != test.params.ProductId[0] {
|
||||
t.Errorf("Product ids in request and response are not equal")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestListProductsInStrategy(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
statusCode int
|
||||
headers map[string]string
|
||||
params *ListProductsInStrategyParams
|
||||
response string
|
||||
}{
|
||||
// Test Ok
|
||||
{
|
||||
http.StatusOK,
|
||||
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
|
||||
&ListProductsInStrategyParams{
|
||||
StrategyId: "string",
|
||||
},
|
||||
`{
|
||||
"result": {
|
||||
"product_id": [
|
||||
"string"
|
||||
]
|
||||
}
|
||||
}`,
|
||||
},
|
||||
// Test No Client-Id or Api-Key
|
||||
{
|
||||
http.StatusUnauthorized,
|
||||
map[string]string{},
|
||||
&ListProductsInStrategyParams{},
|
||||
`{
|
||||
"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.Strategies().ListProducts(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 TestGetCompetitorPrice(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
statusCode int
|
||||
headers map[string]string
|
||||
params *GetCompetitorPriceParams
|
||||
response string
|
||||
}{
|
||||
// Test Ok
|
||||
{
|
||||
http.StatusOK,
|
||||
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
|
||||
&GetCompetitorPriceParams{
|
||||
ProductId: 0,
|
||||
},
|
||||
`{
|
||||
"result": {
|
||||
"strategy_id": "string",
|
||||
"is_enabled": true,
|
||||
"strategy_product_price": 0,
|
||||
"price_downloaded_at": "2022-11-17T15:33:53.936Z",
|
||||
"strategy_competitor_id": 0,
|
||||
"strategy_competitor_product_url": "string"
|
||||
}
|
||||
}`,
|
||||
},
|
||||
// Test No Client-Id or Api-Key
|
||||
{
|
||||
http.StatusUnauthorized,
|
||||
map[string]string{},
|
||||
&GetCompetitorPriceParams{},
|
||||
`{
|
||||
"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.Strategies().GetCompetitorPrice(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 TestRemoveProductsFromStrategy(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
statusCode int
|
||||
headers map[string]string
|
||||
params *RemoveProductsFromStrategyParams
|
||||
response string
|
||||
}{
|
||||
// Test Ok
|
||||
{
|
||||
http.StatusOK,
|
||||
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
|
||||
&RemoveProductsFromStrategyParams{
|
||||
ProductId: []int64{0},
|
||||
},
|
||||
`{
|
||||
"result": {
|
||||
"failed_product_count": 0
|
||||
}
|
||||
}`,
|
||||
},
|
||||
// Test No Client-Id or Api-Key
|
||||
{
|
||||
http.StatusUnauthorized,
|
||||
map[string]string{},
|
||||
&RemoveProductsFromStrategyParams{},
|
||||
`{
|
||||
"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.Strategies().RemoveProducts(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 TestChangeStrategyStatus(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
statusCode int
|
||||
headers map[string]string
|
||||
params *ChangeStrategyStatusParams
|
||||
response string
|
||||
}{
|
||||
// Test Ok
|
||||
{
|
||||
http.StatusOK,
|
||||
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
|
||||
&ChangeStrategyStatusParams{
|
||||
Enabled: true,
|
||||
StrategyId: "c7516438-7124-4e2c-85d3-ccd92b6b9b65",
|
||||
},
|
||||
`{}`,
|
||||
},
|
||||
// Test No Client-Id or Api-Key
|
||||
{
|
||||
http.StatusUnauthorized,
|
||||
map[string]string{},
|
||||
&ChangeStrategyStatusParams{},
|
||||
`{
|
||||
"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.Strategies().ChangeStatus(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 TestRemoveStrategy(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
statusCode int
|
||||
headers map[string]string
|
||||
params *RemoveStrategyParams
|
||||
response string
|
||||
}{
|
||||
// Test Ok
|
||||
{
|
||||
http.StatusOK,
|
||||
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
|
||||
&RemoveStrategyParams{
|
||||
StrategyId: "strategy",
|
||||
},
|
||||
`{}`,
|
||||
},
|
||||
// Test No Client-Id or Api-Key
|
||||
{
|
||||
http.StatusUnauthorized,
|
||||
map[string]string{},
|
||||
&RemoveStrategyParams{},
|
||||
`{
|
||||
"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.Strategies().Remove(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)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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