Update GetFBSReturns to v3. Add exemplar_id and return_barcode fields to method reponse

This commit is contained in:
diPhantxm
2023-07-06 19:39:54 +03:00
parent e7c5dc320e
commit f54aa64b63
3 changed files with 77 additions and 64 deletions

View File

@@ -454,3 +454,13 @@ const (
// deliver products to the floor // deliver products to the floor
PRROptionDeliveryDefault PRROptionStatus = "delivery_default" PRROptionDeliveryDefault PRROptionStatus = "delivery_default"
) )
type GetFBSReturnsFilterStatus string
const (
ReturnedToSeller GetFBSReturnsFilterStatus = "returned_to_seller"
WaitingForSeller GetFBSReturnsFilterStatus = "waiting_for_seller"
AcceptedFromCustomer GetFBSReturnsFilterStatus = "accepted_from_customer"
CancelledWithCompensation GetFBSReturnsFilterStatus = "cancelled_with_compensation"
ReadyForShipment GetFBSReturnsFilterStatus = "ready_for_shipment"
)

View File

@@ -100,9 +100,10 @@ type GetFBSReturnsParams struct {
// - minimum — 1 // - minimum — 1
Limit int64 `json:"limit"` Limit int64 `json:"limit"`
// Number of elements that will be skipped in the response. // Return identifier that was loaded the last time.
// For example, if offset=10, the response will start with the 11th element found // Return identifiers with the higher value than `last_id`
Offset int64 `json:"offset"` // will be returned in the response.
LastId int64 `json:"offset"`
} }
type GetFBSReturnsFilter struct { type GetFBSReturnsFilter struct {
@@ -110,7 +111,7 @@ type GetFBSReturnsFilter struct {
AcceptedFromCustomerMoment GetFBSReturnsFilterTimeRange `json:"accepted_from_customer_moment"` AcceptedFromCustomerMoment GetFBSReturnsFilterTimeRange `json:"accepted_from_customer_moment"`
// Last day of free storage // Last day of free storage
LastFreeWaitingDay []GetFBSReturnsFilterTimeRange `json:"last_free_waiting_dat"` LastFreeWaitingDay GetFBSReturnsFilterTimeRange `json:"last_free_waiting_dat"`
// Order ID // Order ID
OrderId int64 `json:"order_id"` OrderId int64 `json:"order_id"`
@@ -124,13 +125,8 @@ type GetFBSReturnsFilter struct {
// Product ID // Product ID
ProductOfferId string `json:"product_offer_id"` ProductOfferId string `json:"product_offer_id"`
// Return status: // Return status
// - returned_to_seller — returned to seller, Status GetFBSReturnsFilterStatus `json:"status"`
// - waiting_for_seller — waiting for seller,
// - accepted_from_customer — accepted from customer,
// - cancelled_with_compensation — cancelled with compensation,
// - ready_for_shipment — ready for shipment
Status string `json:"status"`
} }
type GetFBSReturnsFilterTimeRange struct { type GetFBSReturnsFilterTimeRange struct {
@@ -152,12 +148,10 @@ type GetFBSReturnsFilterTimeRange struct {
type GetFBSReturnsResponse struct { type GetFBSReturnsResponse struct {
core.CommonResponse core.CommonResponse
Result GetFBSReturnsResult `json:"result"` // Return identifier that was loaded the last time.
} // Return identifiers with the higher value than `last_id`
// will be returned in the response
type GetFBSReturnsResult struct { LastId int64 `json:"last_id"`
// Elements counter in the response
Count int64 `json:"count"`
// Returns information // Returns information
Returns []GetFBSReturnResultReturn `json:"returns"` Returns []GetFBSReturnResultReturn `json:"returns"`
@@ -176,7 +170,10 @@ type GetFBSReturnResultReturn struct {
// Commission percentage // Commission percentage
CommissionPercent float64 `json:"commission_percent"` CommissionPercent float64 `json:"commission_percent"`
// Return identifier // Product item identifier in the Ozon logistics system
ExemplarId int64 `json:"exemplar_id"`
// Return identifier in the Ozon accounting system
Id int64 `json:"id"` Id int64 `json:"id"`
// If the product is in transit — true // If the product is in transit — true
@@ -200,6 +197,8 @@ type GetFBSReturnResultReturn struct {
// Shipment number // Shipment number
PostingNumber string `json:"posting_number"` PostingNumber string `json:"posting_number"`
PickingTag string `json:"picking_tag"`
// Current product price without a discount // Current product price without a discount
Price float64 `json:"price"` Price float64 `json:"price"`
@@ -215,6 +214,12 @@ type GetFBSReturnResultReturn struct {
// Product quantity // Product quantity
Quantity int64 `json:"quantity"` Quantity int64 `json:"quantity"`
// Barcode on the return label. Use this parameter value to work with the return label
ReturnBarcode string `json:"return_barcode"`
// Package unit identifier in the Ozon logistics system
ReturnClearingId int64 `json:"return_clearing_id"`
// Product return date // Product return date
ReturnDate string `json:"return_date"` ReturnDate string `json:"return_date"`
@@ -242,7 +247,7 @@ type GetFBSReturnResultReturn struct {
// Method for getting information on returned products that are sold from the seller's warehouse // Method for getting information on returned products that are sold from the seller's warehouse
func (c Returns) GetFBSReturns(params *GetFBSReturnsParams) (*GetFBSReturnsResponse, error) { func (c Returns) GetFBSReturns(params *GetFBSReturnsParams) (*GetFBSReturnsResponse, error) {
url := "/v2/returns/company/fbs" url := "/v3/returns/company/fbs"
resp := &GetFBSReturnsResponse{} resp := &GetFBSReturnsResponse{}

View File

@@ -105,42 +105,43 @@ func TestGetFBSReturns(t *testing.T) {
Status: "returned_to_seller", Status: "returned_to_seller",
}, },
Limit: 1000, Limit: 1000,
Offset: 0, LastId: 0,
}, },
`{ `{
"result": { "last_id": 0,
"returns": [ "returns": [
{ {
"id": 19166541735000, "accepted_from_customer_moment": "string",
"clearing_id": 19166541725000, "clearing_id": 23,
"posting_number": "07402477-0022-2", "commission": 21,
"product_id": 172423678, "commission_percent": 0,
"sku": 172423678, "exemplar_id": 42,
"status": "returned_to_seller", "id": 123,
"returns_keeping_cost": 0, "is_moving": true,
"return_reason_name": "5.12 Заказ более не актуален: долгие сроки доставки", "is_opened": true,
"return_date": "2020-08-12T17:27:50+00:00", "last_free_waiting_day": "string",
"quantity": 1, "place_id": 122,
"product_name": "Кофе ароматизированный \"Лесной орех\" 250 гр", "moving_to_place_name": "string",
"price": 294, "picking_amount": 0,
"waiting_for_seller_date_time": "2020-08-16T02:50:35+00:00", "posting_number": "string",
"returned_to_seller_date_time": "2020-08-21T10:07:13+00:00", "picking_tag": "string",
"last_free_waiting_day": "2020-08-19T23:59:59+00:00", "price": 0,
"is_opened": false, "price_without_commission": 0,
"place_id": 0, "product_id": 2222,
"commission_percent": 0, "product_name": "string",
"commission": 0, "quantity": 0,
"price_without_commission": 0, "return_barcode": "string",
"is_moving": false, "return_clearing_id": 0,
"moving_to_place_name": "МОСКВА_ХАБ", "return_date": "string",
"waiting_for_seller_days": 2, "return_reason_name": "string",
"picking_amount": null, "waiting_for_seller_date_time": "string",
"accepted_from_customer_moment": null, "returned_to_seller_date_time": "string",
"picking_tag": null "waiting_for_seller_days": 0,
} "returns_keeping_cost": 0,
], "sku": 33332,
"count": 1 "status": "string"
} }
]
}`, }`,
}, },
// Test No Client-Id or Api-Key // Test No Client-Id or Api-Key
@@ -168,20 +169,17 @@ func TestGetFBSReturns(t *testing.T) {
} }
if resp.StatusCode == http.StatusOK { if resp.StatusCode == http.StatusOK {
if int(resp.Result.Count) != len(resp.Result.Returns) { if len(resp.Returns) > 0 {
t.Errorf("Count must equal to length of returns") if resp.Returns[0].Id == 0 {
}
if len(resp.Result.Returns) > 0 {
if resp.Result.Returns[0].Id == 0 {
t.Errorf("Id cannot be 0") t.Errorf("Id cannot be 0")
} }
if resp.Result.Returns[0].ProductId == 0 { if resp.Returns[0].ProductId == 0 {
t.Errorf("Product id cannot be 0") t.Errorf("Product id cannot be 0")
} }
if resp.Result.Returns[0].SKU == 0 { if resp.Returns[0].SKU == 0 {
t.Errorf("SKU cannot be 0") t.Errorf("SKU cannot be 0")
} }
if resp.Result.Returns[0].Status == "" { if resp.Returns[0].Status == "" {
t.Errorf("Status cannot be empty") t.Errorf("Status cannot be empty")
} }
} }