Skip to content

Commit f54aa64

Browse files
committed
Update GetFBSReturns to v3. Add exemplar_id and return_barcode fields to method reponse
1 parent e7c5dc3 commit f54aa64

File tree

3 files changed

+77
-64
lines changed

3 files changed

+77
-64
lines changed

ozon/common.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -445,12 +445,22 @@ const (
445445
// carrying the bulky product upstairs
446446
PRROptionStairs PRROptionStatus = "stairs"
447447

448-
// the customer canceled the service,
448+
// the customer canceled the service,
449449
// you don't need to lift the shipment
450450
PRROptionNone PRROptionStatus = "none"
451451

452-
// delivery is included in the price.
453-
// According to the offer you need to
452+
// delivery is included in the price.
453+
// According to the offer you need to
454454
// deliver products to the floor
455455
PRROptionDeliveryDefault PRROptionStatus = "delivery_default"
456456
)
457+
458+
type GetFBSReturnsFilterStatus string
459+
460+
const (
461+
ReturnedToSeller GetFBSReturnsFilterStatus = "returned_to_seller"
462+
WaitingForSeller GetFBSReturnsFilterStatus = "waiting_for_seller"
463+
AcceptedFromCustomer GetFBSReturnsFilterStatus = "accepted_from_customer"
464+
CancelledWithCompensation GetFBSReturnsFilterStatus = "cancelled_with_compensation"
465+
ReadyForShipment GetFBSReturnsFilterStatus = "ready_for_shipment"
466+
)

ozon/returns.go

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -100,17 +100,18 @@ type GetFBSReturnsParams struct {
100100
// - minimum — 1
101101
Limit int64 `json:"limit"`
102102

103-
// Number of elements that will be skipped in the response.
104-
// For example, if offset=10, the response will start with the 11th element found
105-
Offset int64 `json:"offset"`
103+
// Return identifier that was loaded the last time.
104+
// Return identifiers with the higher value than `last_id`
105+
// will be returned in the response.
106+
LastId int64 `json:"offset"`
106107
}
107108

108109
type GetFBSReturnsFilter struct {
109110
// Time of receiving the return from the customer
110111
AcceptedFromCustomerMoment GetFBSReturnsFilterTimeRange `json:"accepted_from_customer_moment"`
111112

112113
// Last day of free storage
113-
LastFreeWaitingDay []GetFBSReturnsFilterTimeRange `json:"last_free_waiting_dat"`
114+
LastFreeWaitingDay GetFBSReturnsFilterTimeRange `json:"last_free_waiting_dat"`
114115

115116
// Order ID
116117
OrderId int64 `json:"order_id"`
@@ -124,13 +125,8 @@ type GetFBSReturnsFilter struct {
124125
// Product ID
125126
ProductOfferId string `json:"product_offer_id"`
126127

127-
// Return status:
128-
// - returned_to_seller — returned to seller,
129-
// - waiting_for_seller — waiting for seller,
130-
// - accepted_from_customer — accepted from customer,
131-
// - cancelled_with_compensation — cancelled with compensation,
132-
// - ready_for_shipment — ready for shipment
133-
Status string `json:"status"`
128+
// Return status
129+
Status GetFBSReturnsFilterStatus `json:"status"`
134130
}
135131

136132
type GetFBSReturnsFilterTimeRange struct {
@@ -152,12 +148,10 @@ type GetFBSReturnsFilterTimeRange struct {
152148
type GetFBSReturnsResponse struct {
153149
core.CommonResponse
154150

155-
Result GetFBSReturnsResult `json:"result"`
156-
}
157-
158-
type GetFBSReturnsResult struct {
159-
// Elements counter in the response
160-
Count int64 `json:"count"`
151+
// Return identifier that was loaded the last time.
152+
// Return identifiers with the higher value than `last_id`
153+
// will be returned in the response
154+
LastId int64 `json:"last_id"`
161155

162156
// Returns information
163157
Returns []GetFBSReturnResultReturn `json:"returns"`
@@ -176,7 +170,10 @@ type GetFBSReturnResultReturn struct {
176170
// Commission percentage
177171
CommissionPercent float64 `json:"commission_percent"`
178172

179-
// Return identifier
173+
// Product item identifier in the Ozon logistics system
174+
ExemplarId int64 `json:"exemplar_id"`
175+
176+
// Return identifier in the Ozon accounting system
180177
Id int64 `json:"id"`
181178

182179
// If the product is in transit — true
@@ -200,6 +197,8 @@ type GetFBSReturnResultReturn struct {
200197
// Shipment number
201198
PostingNumber string `json:"posting_number"`
202199

200+
PickingTag string `json:"picking_tag"`
201+
203202
// Current product price without a discount
204203
Price float64 `json:"price"`
205204

@@ -215,6 +214,12 @@ type GetFBSReturnResultReturn struct {
215214
// Product quantity
216215
Quantity int64 `json:"quantity"`
217216

217+
// Barcode on the return label. Use this parameter value to work with the return label
218+
ReturnBarcode string `json:"return_barcode"`
219+
220+
// Package unit identifier in the Ozon logistics system
221+
ReturnClearingId int64 `json:"return_clearing_id"`
222+
218223
// Product return date
219224
ReturnDate string `json:"return_date"`
220225

@@ -242,7 +247,7 @@ type GetFBSReturnResultReturn struct {
242247

243248
// Method for getting information on returned products that are sold from the seller's warehouse
244249
func (c Returns) GetFBSReturns(params *GetFBSReturnsParams) (*GetFBSReturnsResponse, error) {
245-
url := "/v2/returns/company/fbs"
250+
url := "/v3/returns/company/fbs"
246251

247252
resp := &GetFBSReturnsResponse{}
248253

ozon/returns_test.go

Lines changed: 40 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -105,42 +105,43 @@ func TestGetFBSReturns(t *testing.T) {
105105
Status: "returned_to_seller",
106106
},
107107
Limit: 1000,
108-
Offset: 0,
108+
LastId: 0,
109109
},
110110
`{
111-
"result": {
112-
"returns": [
113-
{
114-
"id": 19166541735000,
115-
"clearing_id": 19166541725000,
116-
"posting_number": "07402477-0022-2",
117-
"product_id": 172423678,
118-
"sku": 172423678,
119-
"status": "returned_to_seller",
120-
"returns_keeping_cost": 0,
121-
"return_reason_name": "5.12 Заказ более не актуален: долгие сроки доставки",
122-
"return_date": "2020-08-12T17:27:50+00:00",
123-
"quantity": 1,
124-
"product_name": "Кофе ароматизированный \"Лесной орех\" 250 гр",
125-
"price": 294,
126-
"waiting_for_seller_date_time": "2020-08-16T02:50:35+00:00",
127-
"returned_to_seller_date_time": "2020-08-21T10:07:13+00:00",
128-
"last_free_waiting_day": "2020-08-19T23:59:59+00:00",
129-
"is_opened": false,
130-
"place_id": 0,
131-
"commission_percent": 0,
132-
"commission": 0,
133-
"price_without_commission": 0,
134-
"is_moving": false,
135-
"moving_to_place_name": "МОСКВА_ХАБ",
136-
"waiting_for_seller_days": 2,
137-
"picking_amount": null,
138-
"accepted_from_customer_moment": null,
139-
"picking_tag": null
140-
}
141-
],
142-
"count": 1
143-
}
111+
"last_id": 0,
112+
"returns": [
113+
{
114+
"accepted_from_customer_moment": "string",
115+
"clearing_id": 23,
116+
"commission": 21,
117+
"commission_percent": 0,
118+
"exemplar_id": 42,
119+
"id": 123,
120+
"is_moving": true,
121+
"is_opened": true,
122+
"last_free_waiting_day": "string",
123+
"place_id": 122,
124+
"moving_to_place_name": "string",
125+
"picking_amount": 0,
126+
"posting_number": "string",
127+
"picking_tag": "string",
128+
"price": 0,
129+
"price_without_commission": 0,
130+
"product_id": 2222,
131+
"product_name": "string",
132+
"quantity": 0,
133+
"return_barcode": "string",
134+
"return_clearing_id": 0,
135+
"return_date": "string",
136+
"return_reason_name": "string",
137+
"waiting_for_seller_date_time": "string",
138+
"returned_to_seller_date_time": "string",
139+
"waiting_for_seller_days": 0,
140+
"returns_keeping_cost": 0,
141+
"sku": 33332,
142+
"status": "string"
143+
}
144+
]
144145
}`,
145146
},
146147
// Test No Client-Id or Api-Key
@@ -168,20 +169,17 @@ func TestGetFBSReturns(t *testing.T) {
168169
}
169170

170171
if resp.StatusCode == http.StatusOK {
171-
if int(resp.Result.Count) != len(resp.Result.Returns) {
172-
t.Errorf("Count must equal to length of returns")
173-
}
174-
if len(resp.Result.Returns) > 0 {
175-
if resp.Result.Returns[0].Id == 0 {
172+
if len(resp.Returns) > 0 {
173+
if resp.Returns[0].Id == 0 {
176174
t.Errorf("Id cannot be 0")
177175
}
178-
if resp.Result.Returns[0].ProductId == 0 {
176+
if resp.Returns[0].ProductId == 0 {
179177
t.Errorf("Product id cannot be 0")
180178
}
181-
if resp.Result.Returns[0].SKU == 0 {
179+
if resp.Returns[0].SKU == 0 {
182180
t.Errorf("SKU cannot be 0")
183181
}
184-
if resp.Result.Returns[0].Status == "" {
182+
if resp.Returns[0].Status == "" {
185183
t.Errorf("Status cannot be empty")
186184
}
187185
}

0 commit comments

Comments
 (0)