add get shipments lists methods for fbs and fbo

This commit is contained in:
diPhantxm
2023-03-13 21:00:28 +03:00
parent 75c28bf1dc
commit 4c4427f26c
4 changed files with 545 additions and 45 deletions

View File

@@ -1,6 +1,7 @@
package ozon
import (
"net/http"
"testing"
core "github.com/diphantxm/ozon-api-client"
@@ -14,7 +15,7 @@ func TestListUnprocessedShipments(t *testing.T) {
response string
}{
{
200,
http.StatusOK,
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
&ListUnprocessedShipmentsParams{
Direction: "ASC",
@@ -163,3 +164,101 @@ func TestListUnprocessedShipments(t *testing.T) {
}
}
}
func TestGetFBSShipmentsList(t *testing.T) {
tests := []struct {
statusCode int
headers map[string]string
params *GetFBSShipmentsListParams
response string
}{
{
http.StatusOK,
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
&GetFBSShipmentsListParams{
Direction: "ASC",
Filter: GetFBSShipmentsListFilter{
Since: core.TimeFromString(t, "2021-11-01T00:00:00.000Z"),
To: core.TimeFromString(t, "2021-12-01T23:59:59.000Z"),
Status: "awaiting_packaging",
},
Limit: 100,
Offset: 0,
With: GetFBSShipmentsListWith{
AnalyticsData: true,
FinancialData: true,
Translit: true,
},
},
`{
"result": {
"postings": [
{
"posting_number": "05708065-0029-1",
"order_id": 680420041,
"order_number": "05708065-0029",
"status": "awaiting_deliver",
"delivery_method": {
"id": 21321684811000,
"name": "Ozon Логистика самостоятельно, Красногорск",
"warehouse_id": 21321684811000,
"warehouse": "Стим Тойс Нахабино",
"tpl_provider_id": 24,
"tpl_provider": "Ozon Логистика"
},
"tracking_number": "",
"tpl_integration_type": "ozon",
"in_process_at": "2022-05-13T07:07:32Z",
"shipment_date": "2022-05-13T10:00:00Z",
"delivering_date": null,
"cancellation": {
"cancel_reason_id": 0,
"cancel_reason": "",
"cancellation_type": "",
"cancelled_after_ship": false,
"affect_cancellation_rating": false,
"cancellation_initiator": ""
},
"customer": null,
"products": [
{
"currency_code": "RUB",
"price": "1390.000000",
"offer_id": "205953",
"name": " Электронный конструктор PinLab Позитроник",
"sku": 358924380,
"quantity": 1,
"mandatory_mark": []
}
],
"addressee": null,
"barcodes": null,
"analytics_data": null,
"financial_data": null,
"is_express": false,
"requirements": {
"products_requiring_gtd": [],
"products_requiring_country": [],
"products_requiring_mandatory_mark": []
}
}
],
"has_next": true
}
}`,
},
}
for _, test := range tests {
c := NewMockClient(core.NewMockHttpHandler(test.statusCode, test.response, test.headers))
resp, err := c.GetFBSShipmentsList(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)
}
}
}