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

@@ -445,12 +445,22 @@ const (
// carrying the bulky product upstairs
PRROptionStairs PRROptionStatus = "stairs"
// the customer canceled the service,
// the customer canceled the service,
// you don't need to lift the shipment
PRROptionNone PRROptionStatus = "none"
// delivery is included in the price.
// According to the offer you need to
// delivery is included in the price.
// According to the offer you need to
// deliver products to the floor
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
Limit int64 `json:"limit"`
// 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"`
// Return identifier that was loaded the last time.
// Return identifiers with the higher value than `last_id`
// will be returned in the response.
LastId int64 `json:"offset"`
}
type GetFBSReturnsFilter struct {
@@ -110,7 +111,7 @@ type GetFBSReturnsFilter struct {
AcceptedFromCustomerMoment GetFBSReturnsFilterTimeRange `json:"accepted_from_customer_moment"`
// Last day of free storage
LastFreeWaitingDay []GetFBSReturnsFilterTimeRange `json:"last_free_waiting_dat"`
LastFreeWaitingDay GetFBSReturnsFilterTimeRange `json:"last_free_waiting_dat"`
// Order ID
OrderId int64 `json:"order_id"`
@@ -124,13 +125,8 @@ type GetFBSReturnsFilter struct {
// Product ID
ProductOfferId string `json:"product_offer_id"`
// Return status:
// - returned_to_seller — returned to seller,
// - 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"`
// Return status
Status GetFBSReturnsFilterStatus `json:"status"`
}
type GetFBSReturnsFilterTimeRange struct {
@@ -152,12 +148,10 @@ type GetFBSReturnsFilterTimeRange struct {
type GetFBSReturnsResponse struct {
core.CommonResponse
Result GetFBSReturnsResult `json:"result"`
}
type GetFBSReturnsResult struct {
// Elements counter in the response
Count int64 `json:"count"`
// Return identifier that was loaded the last time.
// Return identifiers with the higher value than `last_id`
// will be returned in the response
LastId int64 `json:"last_id"`
// Returns information
Returns []GetFBSReturnResultReturn `json:"returns"`
@@ -176,7 +170,10 @@ type GetFBSReturnResultReturn struct {
// Commission percentage
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"`
// If the product is in transit — true
@@ -200,6 +197,8 @@ type GetFBSReturnResultReturn struct {
// Shipment number
PostingNumber string `json:"posting_number"`
PickingTag string `json:"picking_tag"`
// Current product price without a discount
Price float64 `json:"price"`
@@ -215,6 +214,12 @@ type GetFBSReturnResultReturn struct {
// Product 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
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
func (c Returns) GetFBSReturns(params *GetFBSReturnsParams) (*GetFBSReturnsResponse, error) {
url := "/v2/returns/company/fbs"
url := "/v3/returns/company/fbs"
resp := &GetFBSReturnsResponse{}

View File

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