Update February 17, 2025 (#146)

This commit is contained in:
Kirill
2025-03-02 15:11:00 +03:00
committed by GitHub
parent 1c0c203097
commit bd280b54f4
3 changed files with 326 additions and 148 deletions

View File

@@ -769,7 +769,7 @@ type ValidateLabelingCodesExemplar struct {
GTD string `json:"gtd"` GTD string `json:"gtd"`
// Mandatory “Chestny ZNAK” labeling // Mandatory “Chestny ZNAK” labeling
MandatoryMark string `json:"mandatory_mark"` Marks []SetProductItemsDataProductMark `json:"marks"`
// Product batch registration number // Product batch registration number
RNPT string `json:"rnpt"` RNPT string `json:"rnpt"`
@@ -778,11 +778,6 @@ type ValidateLabelingCodesExemplar struct {
type ValidateLabelingCodesResponse struct { type ValidateLabelingCodesResponse struct {
core.CommonResponse core.CommonResponse
// Method result
Result ValidateLabelingCodesResult `json:"result"`
}
type ValidateLabelingCodesResult struct {
// Products list // Products list
Products []ValidateLabelingCodesResultProduct `json:"products"` Products []ValidateLabelingCodesResultProduct `json:"products"`
} }
@@ -792,7 +787,7 @@ type ValidateLabelingCodesResultProduct struct {
Error string `json:"error"` Error string `json:"error"`
// Product items data // Product items data
Exemplars []FBSProductExemplar `json:"exemplars"` Exemplars []ValidateLabelingCodesResultExemplar `json:"exemplars"`
// Product identifier // Product identifier
ProductId int64 `json:"product_id"` ProductId int64 `json:"product_id"`
@@ -801,11 +796,43 @@ type ValidateLabelingCodesResultProduct struct {
Valid bool `json:"valid"` Valid bool `json:"valid"`
} }
type ValidateLabelingCodesResultExemplar struct {
// Product item validation errors
Errors []string `json:"errors"`
// Сustoms cargo declaration (CCD) number
GTD string `json:"gtd"`
// List of Control Identification Marks in one copy
Marks []ValidateLabelingCodesMark `json:"marks"`
// Product batch registration number
RNPT string `json:"rnpt"`
// Check result. true if the labeling codes of all product items meet the requirements
Valid bool `json:"valid"`
}
type ValidateLabelingCodesMark struct {
// Errors that appeared during verification of Control Identification Marks
Errors []string `json:"errors"`
// Labeling code meaning
Mark string `json:"mark"`
// Labeling code type
MarkType string `json:"mark_type"`
// Check result. true if the labeling
// codes of all product items meet the requirements
Valid bool `json:"valid"`
}
// Method for checking whether labeling codes meet the "Chestny ZNAK" system requirements on length and symbols. // Method for checking whether labeling codes meet the "Chestny ZNAK" system requirements on length and symbols.
// //
// If you don't have the customs cargo declaration (CCD) number, you don't have to specify it // If you don't have the customs cargo declaration (CCD) number, you don't have to specify it
func (c FBS) ValidateLabelingCodes(ctx context.Context, params *ValidateLabelingCodesParams) (*ValidateLabelingCodesResponse, error) { func (c FBS) ValidateLabelingCodes(ctx context.Context, params *ValidateLabelingCodesParams) (*ValidateLabelingCodesResponse, error) {
url := "/v4/fbs/posting/product/exemplar/validate" url := "/v5/fbs/posting/product/exemplar/validate"
resp := &ValidateLabelingCodesResponse{} resp := &ValidateLabelingCodesResponse{}
@@ -1194,39 +1221,23 @@ type ProductDimension struct {
} }
type FBSProductExemplar struct { type FBSProductExemplar struct {
// Product item validation errors // Item identifier
Errors []string `json:"errors"` ExemplarId int64 `json:"exemplar_id"`
// Mandatory “Chestny ZNAK” labeling // Mandatory “Chestny ZNAK” labeling
MandatoryMark string `json:"mandatory_mark"` MandatoryMark string `json:"mandatory_mark"`
// "Chestny ZNAK" labeling check status
MandatoryMarkCheckStatus MandatoryMarkStatus `json:"mandatory_mark_check_status"`
// "Chestny ZNAK" labeling check error codes
MandatoryMarkErrorCodes []string `json:"mandatory_mark_error_codes"`
// Сustoms cargo declaration (CCD) number // Сustoms cargo declaration (CCD) number
GTD string `json:"gtd"` GTD string `json:"gtd"`
// Сustoms cargo declaration (CCD) check status
GTDCheckStatus string `json:"gtd_check_status"`
// Indication that a сustoms cargo declaration (CCD) number hasn't been specified // Indication that a сustoms cargo declaration (CCD) number hasn't been specified
IsGTDAbsest bool `json:"is_gtd_absent"` IsGTDAbsest bool `json:"is_gtd_absent"`
// Сustoms cargo declaration (CCD) check error codes
GTDErrorCodes []string `json:"gtd_error_codes"`
// Product batch registration number // Product batch registration number
RNPT string `json:"rnpt"` RNPT string `json:"rnpt"`
// Indication that a product batch registration number hasn't been specified // Indication that a product batch registration number hasn't been specified
IsRNPTAbsent bool `json:"is_rnpt_absent"` IsRNPTAbsent bool `json:"is_rnpt_absent"`
// Check result.
// `true` if the labeling code of product item meets the requirements
Valid bool `json:"valid"`
} }
// Method for getting shipment details by identifier // Method for getting shipment details by identifier
@@ -1803,7 +1814,7 @@ func (c FBS) GetDropOffPointRestrictions(ctx context.Context, params *GetDropOff
return resp, nil return resp, nil
} }
type CheckProductItemsDataParams struct { type SetProductItemsDataParams struct {
// Quantity of boxes the product is packed in // Quantity of boxes the product is packed in
MultiBoxQuantity int32 `json:"multi_box_qty"` MultiBoxQuantity int32 `json:"multi_box_qty"`
@@ -1811,20 +1822,26 @@ type CheckProductItemsDataParams struct {
PostingNumber string `json:"posting_number"` PostingNumber string `json:"posting_number"`
// Product list // Product list
Products []CheckProductItemsDataProduct `json:"products"` Products []SetProductItemsDataProduct `json:"products"`
} }
type CheckProductItemsDataProduct struct { type SetProductItemsDataProduct struct {
// Product items data // Product items data
Exemplars []CheckProductItemsDataProductExemplar `json:"exemplars"` Exemplars []SetProductItemsDataProductExemplar `json:"exemplars"`
// Indication that you need to pass the сustoms cargo declaration // Indication that you need to pass the сustoms cargo declaration
// (CCD) number for the product and shipment // (CCD) number for the product and shipment
IsGTDNeeded bool `json:"is_gtd_needed"` IsGTDNeeded bool `json:"is_gtd_needed"`
// Indication that you need to pass the unique identifier of charges of the jewelry
IsJwUINNeeded bool `json:"is_jw_uin_needed"`
// Indication that you need to pass the "Chestny ZNAK" labeling // Indication that you need to pass the "Chestny ZNAK" labeling
IsMandatoryMarkNeeded bool `json:"is_mandatory_mark_needed"` IsMandatoryMarkNeeded bool `json:"is_mandatory_mark_needed"`
// Indication that you can pass the "Chestny ZNAK" labeling, but it's not mandatory
IsMandatoryMarkPossible bool `json:"is_mandatory_mark_possible"`
// Indication that you need to pass the product batch registration number // Indication that you need to pass the product batch registration number
IsRNPTNeeded bool `json:"is_rnpt_needed"` IsRNPTNeeded bool `json:"is_rnpt_needed"`
@@ -1835,48 +1852,35 @@ type CheckProductItemsDataProduct struct {
Quantity int32 `json:"quantity"` Quantity int32 `json:"quantity"`
} }
type CheckProductItemsDataProductExemplar struct { type SetProductItemsDataProductExemplar struct {
// Item identifier // Item identifier
ExemplarId int64 `json:"exemplar_id"` ExemplarId int64 `json:"exemplar_id"`
// Customs cargo declaration (CCD) number // Customs cargo declaration (CCD) number
GTD string `json:"gtd"` GTD string `json:"gtd"`
// Сustoms cargo declaration (CCD) check status
GTDCheckStatus string `json:"gtd_check_status"`
// Сustoms cargo declaration (CCD) check error codes
GTDErrorCodes []string `json:"gtd_error_codes"`
// Indication that the customs cargo declaration (CCD) number isn't specified // Indication that the customs cargo declaration (CCD) number isn't specified
IsGTDAbsent bool `json:"is_gtd_absent"` IsGTDAbsent bool `json:"is_gtd_absent"`
// "Chestny ZNAK" labeling check status
MandatoryMarkCheckStatus MandatoryMarkStatus `json:"mandatory_mark_check_status"`
// "Chestny ZNAK" labeling check error codes
MandatoryMarkErrorCodes []string `json:"mandatory_mark_error_codes"`
// Indication that the product batch registration number isn't specified // Indication that the product batch registration number isn't specified
IsRNPTAbsent bool `json:"is_rnpt_absent"` IsRNPTAbsent bool `json:"is_rnpt_absent"`
// Mandatory "Chestny ZNAK" labeling
MandatoryMark string `json:"mandatory_mark"`
// Product batch registration number // Product batch registration number
RNPT string `json:"rnpt"` RNPT string `json:"rnpt"`
// Product batch registration number check status // Errors that appeared during verification of Control Identification Marks
RNPTCheckStatus string `json:"rnpt_check_status"` Marks []SetProductItemsDataProductMark `json:"marks"`
// Product batch registration number check error codes
RNPTErrorCodes []string `json:"rnpt_error_codes"`
// Unique identifier of charges of the jewelry
JWUIN string `json:"jw_uin"`
} }
type CheckProductItemsDataResponse struct { type SetProductItemsDataProductMark struct {
// Labeling code meaning
Mark string `json:"mark"`
// Labeling code type
MarkType string `json:"mark_type"`
}
type SetProductItemsDataResponse struct {
core.CommonResponse core.CommonResponse
// Method result. true if the request was processed successfully // Method result. true if the request was processed successfully
@@ -1885,39 +1889,21 @@ type CheckProductItemsDataResponse struct {
// Asynchronous method: // Asynchronous method:
// //
// for checking the availability of product items in the “Chestny ZNAK” labeling system; // for checking the availability of product items in the “Chestny ZNAK” labeling system;
// for saving product items data. // for saving product items data.
// To get the checks results, use the /v5/fbs/posting/product/exemplar/status method. To get data about created items, use the /v6/fbs/posting/product/exemplar/create-or-get method.
// //
// To get the checks results, // If you have multiple identical products in a shipment, specify one product_id and exemplars array for each product in the shipment.
// use the /v4/fbs/posting/product/exemplar/status method.
// To get data about created items,
// use the /v5/fbs/fbs/posting/product/exemplar/create-or-get 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. // For example, you have 10 product items in your system. You pass them for checking and saving. Then you add another 60 product items to your system. When you pass product items for checking and saving again, pass all of them: both old and newly added.
// You've passed them for checking and saving.
// Then you added another 60 product items to your system.
// When you pass product items for checking and saving again,
// pass all of them: both old and newly added.
// //
// Unlike /v4/fbs/posting/product/exemplar/set, // The 200 response code doesn't guarantee that instance data has been received. It indicates that a task for adding the information has been created. To check the task status, use the /v5/fbs/posting/product/exemplar/status method.
// you can pass more item information in the request. func (c FBS) SetProductItemsData(ctx context.Context, params *SetProductItemsDataParams) (*SetProductItemsDataResponse, error) {
// url := "/v6/fbs/posting/product/exemplar/set"
// The 200 response code doesn't guarantee that instance data has been received.
// It indicates that a task for adding the information has been created.
// To check the task status, use the /v4/fbs/posting/product/exemplar/status method.
func (c FBS) CheckProductItemsData(ctx context.Context, params *CheckProductItemsDataParams) (*CheckProductItemsDataResponse, error) {
url := "/v5/fbs/posting/product/exemplar/set"
resp := &CheckProductItemsDataResponse{} resp := &SetProductItemsDataResponse{}
response, err := c.client.Request(ctx, http.MethodPost, url, params, resp, nil) response, err := c.client.Request(ctx, http.MethodPost, url, params, resp, nil)
if err != nil { if err != nil {
@@ -1940,19 +1926,71 @@ type GetProductItemsCheckStatusesResponse struct {
PostingNumber string `json:"posting_number"` PostingNumber string `json:"posting_number"`
// Products list // Products list
Products []CheckProductItemsDataProduct `json:"products"` Products []GetProductItemsCheckStatusProduct `json:"products"`
// Product items check statuses and order collection availability: // Product items check statuses and order collection availability
// - ship_available — order collection is available,
// - ship_not_available — order collection is unavailable,
// - validation_in_process — product items validation is in progress
Status string `json:"status"` Status string `json:"status"`
} }
// Method for getting check statuses of product items that were passed in the `/fbs/posting/product/exemplar/set` method. type GetProductItemsCheckStatusProduct struct {
// Product identifier
ProductId int64 `json:"product_id"`
// Product items data
Exemplars []GetProductItemsCheckStatusExemplar `json:"exemplars"`
}
type GetProductItemsCheckStatusExemplar struct {
// Item identifier
ExemplarId int64 `json:"exemplar_id"`
// Customs cargo declaration (CCD) number
GTD string `json:"gtd"`
// Сustoms cargo declaration (CCD) check status
GTDCheckStatus string `json:"gtd_check_status"`
// Сustoms cargo declaration (CCD) check error codes
GTDErrorCodes []string `json:"gtd_error_codes"`
// Indication that the customs cargo declaration (CCD) number isn't specified
IsGTDAbsent bool `json:"is_gtd_absent"`
// Indication that the product batch registration number isn't specified
IsRNPTAbsent bool `json:"is_rnpt_absent"`
// List of Control Identification Marks in one copy
Marks []GetProductItemsCheckStatusMark `json:"marks"`
// Product batch registration number
RNPT string `json:"rnpt"`
// Product batch registration number check status
RNPTCheckStatus string `json:"rnpt_check_status"`
// Product batch registration number check error codes
RNPTErrorCodes []string `json:"rnpt_error_codes"`
}
type GetProductItemsCheckStatusMark struct {
// Check status
CheckStatus string `json:"check_status"`
// Errors that appeared during verification of Control Identification Marks
ErrorCodes []string `json:"error_codes"`
// Labeling code meaning
Mark string `json:"mark"`
// Labeling code type
MarkType string `json:"mark_type"`
}
// Method for getting product items addition statuses
// that were passed in the /v6/fbs/posting/product/exemplar/set method.
// Also returns data on these product items. // Also returns data on these product items.
func (c FBS) GetProductItemsCheckStatuses(ctx context.Context, params *GetProductItemsCheckStatusesParams) (*GetProductItemsCheckStatusesResponse, error) { func (c FBS) GetProductItemsCheckStatuses(ctx context.Context, params *GetProductItemsCheckStatusesParams) (*GetProductItemsCheckStatusesResponse, error) {
url := "/v4/fbs/posting/product/exemplar/status" url := "/v5/fbs/posting/product/exemplar/status"
resp := &GetProductItemsCheckStatusesResponse{} resp := &GetProductItemsCheckStatusesResponse{}
@@ -2938,11 +2976,37 @@ type CreateOrGetProductExemplarResponse struct {
Products []CheckProductItemsDataProduct `json:"products"` Products []CheckProductItemsDataProduct `json:"products"`
} }
type CheckProductItemsDataProduct struct {
// Data about items
Exemplars []SetProductItemsDataProductExemplar `json:"exemplars"`
// Indication that you need to pass the сustoms cargo declaration (CCD) number for the product and shipment
IsGTDNeeded bool `json:"is_gtd_needed"`
// Indication that you need to pass the unique identifier of charges of the jewelry
IsJwUINNeeded bool `json:"is_jw_uin_needed"`
// Indication that you need to pass the "Chestny ZNAK" labeling
IsMandatoryMarkNeeded bool `json:"is_mandatory_mark_needed"`
// Indication that you can pass the "Chestny ZNAK" labeling, but it's not mandatory
IsMandatoryMarkPossible bool `json:"is_mandatory_mark_possible"`
// Indication that you need to pass the product batch registration number
IsRNPTNeeded bool `json:"is_rnpt_needed"`
// Product ID
ProductId int64 `json:"product_id"`
// Items quantity
Quantity int32 `json:"quantity"`
}
// Method returns the created items data passed in the `/v5/fbs/posting/product/exemplar/set` method. // Method returns the created items data passed in the `/v5/fbs/posting/product/exemplar/set` method.
// //
// Use this method to get the `exemplar_id` // Use this method to get the `exemplar_id`
func (c FBS) CreateOrGetProductExemplar(ctx context.Context, params *CreateOrGetProductExemplarParams) (*CreateOrGetProductExemplarResponse, error) { func (c FBS) CreateOrGetProductExemplar(ctx context.Context, params *CreateOrGetProductExemplarParams) (*CreateOrGetProductExemplarResponse, error) {
url := "/v5/fbs/posting/product/exemplar/create-or-get" url := "/v6/fbs/posting/product/exemplar/create-or-get"
resp := &CreateOrGetProductExemplarResponse{} resp := &CreateOrGetProductExemplarResponse{}
@@ -3310,3 +3374,29 @@ func (c FBS) VerifyCourierCode(ctx context.Context, params *VerifyCourierCodePar
return resp, nil return resp, nil
} }
type UpdateProductsDataParams struct {
// Shipment number
PostingNumber string `json:"posting_number"`
}
type UpdateProductsDataResponse struct {
core.CommonResponse
}
// Use the method after passing item data using the
// /v6/fbs/posting/product/exemplar/set method to
// save updated item data for shipments in the “Awaiting shipment” status
func (c FBS) UpdateProductsData(ctx context.Context, params *UpdateProductsDataParams) (*UpdateProductsDataResponse, error) {
url := "/v1/fbs/posting/product/exemplar/update"
resp := &UpdateProductsDataResponse{}
response, err := c.client.Request(ctx, http.MethodPost, url, params, resp, nil)
if err != nil {
return nil, err
}
response.CopyCommonResponse(&resp.CommonResponse)
return resp, nil
}

View File

@@ -423,8 +423,7 @@ func TestValidateLabelingCodes(t *testing.T) {
{ {
Exemplars: []ValidateLabelingCodesExemplar{ Exemplars: []ValidateLabelingCodesExemplar{
{ {
GTD: "", GTD: "",
MandatoryMark: "010290000151642731tVMohkbfFgunB",
}, },
}, },
ProductId: 476925391, ProductId: 476925391,
@@ -432,23 +431,33 @@ func TestValidateLabelingCodes(t *testing.T) {
}, },
}, },
`{ `{
"result": { "products": [
"products": [ {
{ "error": "string",
"product_id": 476925391, "exemplars": [
"exemplars": [ {
{ "errors": [
"mandatory_mark": "010290000151642731tVMohkbfFgunB", "string"
"gtd": "", ],
"valid": true, "gtd": "string",
"errors": [] "marks": [
} {
], "errors": [
"valid": true, "string"
"error": "" ],
} "mark": "string",
] "mark_type": "string",
} "valid": true
}
],
"rnpt": "string",
"valid": true
}
],
"product_id": 476925391,
"valid": true
}
]
}`, }`,
}, },
// Test No Client-Id or Api-Key // Test No Client-Id or Api-Key
@@ -480,11 +489,11 @@ func TestValidateLabelingCodes(t *testing.T) {
} }
if resp.StatusCode == http.StatusOK { if resp.StatusCode == http.StatusOK {
if len(resp.Result.Products) != len(test.params.Products) { if len(resp.Products) != len(test.params.Products) {
t.Errorf("Length of products in request and response are not equal") t.Errorf("Length of products in request and response are not equal")
} }
if len(resp.Result.Products) > 0 { if len(resp.Products) > 0 {
if resp.Result.Products[0].ProductId != test.params.Products[0].ProductId { if resp.Products[0].ProductId != test.params.Products[0].ProductId {
t.Errorf("Product ids in request and response are not equal") t.Errorf("Product ids in request and response are not equal")
} }
} }
@@ -1380,52 +1389,52 @@ func TestGetDropOffPointRestrictions(t *testing.T) {
} }
} }
func TestCheckProductItemsData(t *testing.T) { func TestSetProductItemsData(t *testing.T) {
t.Parallel() t.Parallel()
tests := []struct { tests := []struct {
statusCode int statusCode int
headers map[string]string headers map[string]string
params *CheckProductItemsDataParams params *SetProductItemsDataParams
response string response string
}{ }{
// Test Ok // Test Ok
{ {
http.StatusOK, http.StatusOK,
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"}, map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
&CheckProductItemsDataParams{ &SetProductItemsDataParams{
MultiBoxQuantity: 0, MultiBoxQuantity: 0,
PostingNumber: "1234", PostingNumber: "1234",
Products: []CheckProductItemsDataProduct{ Products: []SetProductItemsDataProduct{
{ {
Exemplars: []CheckProductItemsDataProductExemplar{ Exemplars: []SetProductItemsDataProductExemplar{
{ {
ExemplarId: 1, ExemplarId: 1,
GTD: "string", GTD: "string",
IsGTDAbsent: true, IsGTDAbsent: true,
IsRNPTAbsent: true, RNPT: "string",
MandatoryMark: "string",
RNPT: "string",
JWUIN: "string",
}, },
}, },
IsGTDNeeded: true, ProductId: 22,
IsMandatoryMarkNeeded: true,
IsRNPTNeeded: true,
ProductId: 22,
Quantity: 11,
}, },
}, },
}, },
`{ `{
"result": true "code": 0,
"details": [
{
"typeUrl": "string",
"value": "string"
}
],
"message": "string"
}`, }`,
}, },
// Test No Client-Id or Api-Key // Test No Client-Id or Api-Key
{ {
http.StatusUnauthorized, http.StatusUnauthorized,
map[string]string{}, map[string]string{},
&CheckProductItemsDataParams{}, &SetProductItemsDataParams{},
`{ `{
"code": 16, "code": 16,
"message": "Client-Id and Api-Key headers are required" "message": "Client-Id and Api-Key headers are required"
@@ -1437,13 +1446,13 @@ func TestCheckProductItemsData(t *testing.T) {
c := NewMockClient(core.NewMockHttpHandler(test.statusCode, test.response, test.headers)) c := NewMockClient(core.NewMockHttpHandler(test.statusCode, test.response, test.headers))
ctx, _ := context.WithTimeout(context.Background(), testTimeout) ctx, _ := context.WithTimeout(context.Background(), testTimeout)
resp, err := c.FBS().CheckProductItemsData(ctx, test.params) resp, err := c.FBS().SetProductItemsData(ctx, test.params)
if err != nil { if err != nil {
t.Error(err) t.Error(err)
continue continue
} }
compareJsonResponse(t, test.response, &CheckProductItemsDataResponse{}) compareJsonResponse(t, test.response, &SetProductItemsDataResponse{})
if resp.StatusCode != test.statusCode { if resp.StatusCode != test.statusCode {
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode) t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
@@ -1471,21 +1480,37 @@ func TestGetProductItemsCheckStatuses(t *testing.T) {
"posting_number": "23281294-0063-2", "posting_number": "23281294-0063-2",
"products": [ "products": [
{ {
"product_id": 476925391,
"exemplars": [ "exemplars": [
{ {
"mandatory_mark": "010290000151642731tVMohkbfFgunB", "exemplar_id": 0,
"gtd": "", "gtd": "string",
"gtd_check_status": "string",
"gtd_error_codes": [
"string"
],
"is_gtd_absent": true, "is_gtd_absent": true,
"mandatory_mark_check_status": "passed", "is_rnpt_absent": true,
"mandatory_mark_error_codes": [], "marks": [
"gtd_check_status": "passed", {
"gtd_error_codes": [] "check_status": "string",
"error_codes": [
"string"
],
"mark": "string",
"mark_type": "string"
}
],
"rnpt": "string",
"rnpt_check_status": "string",
"rnpt_error_codes": [
"string"
]
} }
] ],
"product_id": 123
} }
], ],
"status": "ship_available" "status": "string"
}`, }`,
}, },
// Test No Client-Id or Api-Key // Test No Client-Id or Api-Key
@@ -1526,8 +1551,8 @@ func TestGetProductItemsCheckStatuses(t *testing.T) {
if resp.Products[0].ProductId == 0 { if resp.Products[0].ProductId == 0 {
t.Errorf("Product id cannot be 0") t.Errorf("Product id cannot be 0")
} }
if len(resp.Products[0].Exemplars) > 0 { if len(resp.Products[0].Exemplars) > 0 && len(resp.Products[0].Exemplars[0].Marks) > 0 {
if resp.Products[0].Exemplars[0].MandatoryMark == "" { if resp.Products[0].Exemplars[0].Marks[0].Mark == "" {
t.Errorf("Mandatory mark cannot be empty") t.Errorf("Mandatory mark cannot be empty")
} }
} }
@@ -2877,13 +2902,19 @@ func TestCreateOrGetProductExemplar(t *testing.T) {
"gtd": "string", "gtd": "string",
"is_gtd_absent": true, "is_gtd_absent": true,
"is_rnpt_absent": true, "is_rnpt_absent": true,
"mandatory_mark": "string", "marks": [
"rnpt": "string", {
"jw_uin": "string" "mark": "string",
"mark_type": "string"
}
],
"rnpt": "string"
} }
], ],
"is_gtd_needed": true, "is_gtd_needed": true,
"is_jw_uin_needed": true,
"is_mandatory_mark_needed": true, "is_mandatory_mark_needed": true,
"is_mandatory_mark_possible": true,
"is_rnpt_needed": true, "is_rnpt_needed": true,
"product_id": 0, "product_id": 0,
"quantity": 0 "quantity": 0
@@ -3426,3 +3457,60 @@ func TestVerifyCourierCode(t *testing.T) {
} }
} }
} }
func TestUpdateProductsData(t *testing.T) {
t.Parallel()
tests := []struct {
statusCode int
headers map[string]string
params *UpdateProductsDataParams
response string
}{
// Test Ok
{
http.StatusOK,
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
&UpdateProductsDataParams{
PostingNumber: "string",
},
`{
"code": 0,
"details": [
{
"typeUrl": "string",
"value": "string"
}
],
"message": "string"
}`,
},
// Test No Client-Id or Api-Key
{
http.StatusUnauthorized,
map[string]string{},
&UpdateProductsDataParams{},
`{
"code": 16,
"message": "Client-Id and Api-Key headers are required"
}`,
},
}
for _, test := range tests {
c := NewMockClient(core.NewMockHttpHandler(test.statusCode, test.response, test.headers))
ctx, _ := context.WithTimeout(context.Background(), testTimeout)
resp, err := c.FBS().UpdateProductsData(ctx, test.params)
if err != nil {
t.Error(err)
continue
}
compareJsonResponse(t, test.response, &UpdateProductsDataResponse{})
if resp.StatusCode != test.statusCode {
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
}
}
}

View File

@@ -1687,7 +1687,7 @@ type GetDescriptionOfProductResultPDF struct {
// Returns a product characteristics description by product identifier. You can search for the product by `offer_id` or `product_id` // Returns a product characteristics description by product identifier. You can search for the product by `offer_id` or `product_id`
func (c Products) GetDescriptionOfProduct(ctx context.Context, params *GetDescriptionOfProductParams) (*GetDescriptionOfProductResponse, error) { func (c Products) GetDescriptionOfProduct(ctx context.Context, params *GetDescriptionOfProductParams) (*GetDescriptionOfProductResponse, error) {
url := "/v3/products/info/attributes" url := "/v4/product/info/attributes"
resp := &GetDescriptionOfProductResponse{} resp := &GetDescriptionOfProductResponse{}