From 2e284d9667d67d507e58b39a60eadbbcf0ca6005 Mon Sep 17 00:00:00 2001 From: Kirill Date: Fri, 24 May 2024 15:42:48 +0300 Subject: [PATCH] Time format fixes and optional fields (#91) --- ozon/analytics.go | 2 +- ozon/cancellations.go | 6 +++--- ozon/chats.go | 2 +- ozon/chats_test.go | 2 +- ozon/fbo.go | 8 ++++---- ozon/fbo_test.go | 4 ++-- ozon/fbs.go | 16 ++++++++-------- ozon/fbs_test.go | 4 ++-- ozon/products.go | 6 +++--- ozon/reports.go | 4 ++-- ozon/reports_test.go | 4 ++-- 11 files changed, 29 insertions(+), 29 deletions(-) diff --git a/ozon/analytics.go b/ozon/analytics.go index 3cda636..f91e9cf 100644 --- a/ozon/analytics.go +++ b/ozon/analytics.go @@ -163,7 +163,7 @@ type GetStocksOnWarehousesParams struct { // 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"` - // Warehouse type filter: + // Warehouse type filter WarehouseType WarehouseType `json:"warehouse_type" default:"ALL"` } diff --git a/ozon/cancellations.go b/ozon/cancellations.go index 3cb573e..b72e8f2 100644 --- a/ozon/cancellations.go +++ b/ozon/cancellations.go @@ -113,15 +113,15 @@ type ListCancellationsParams struct { type ListCancellationsFilter struct { // Filter by cancellation initiator - CancellationInitiator []string `json:"cancellation_initiator"` + CancellationInitiator []string `json:"cancellation_initiator,omitempty"` // Filter by shipment number. // // Optional parameter. You can pass several values here - PostingNumber string `json:"posting_number"` + PostingNumber string `json:"posting_number,omitempty"` // Filter by cancellation request status - State string `json:"state"` + State string `json:"state,omitempty"` } type ListCancellationWith struct { diff --git a/ozon/chats.go b/ozon/chats.go index 00c06a8..3b8f79a 100644 --- a/ozon/chats.go +++ b/ozon/chats.go @@ -386,7 +386,7 @@ func (c Chats) Create(ctx context.Context, params *CreateNewChatParams) (*Create type MarkAsReadParams struct { // Chat identifier - Chatid string `json:"chat_id"` + ChatId string `json:"chat_id"` // Message identifier FromMessageId uint64 `json:"from_message_id"` diff --git a/ozon/chats_test.go b/ozon/chats_test.go index d7317e7..bf148f4 100644 --- a/ozon/chats_test.go +++ b/ozon/chats_test.go @@ -400,7 +400,7 @@ func TestMarkAsRead(t *testing.T) { http.StatusOK, map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"}, &MarkAsReadParams{ - Chatid: "99feb3fc-a474-469f-95d5-268b470cc607", + ChatId: "99feb3fc-a474-469f-95d5-268b470cc607", FromMessageId: 3000000000118032000, }, `{ diff --git a/ozon/fbo.go b/ozon/fbo.go index 6d93de8..25f1eee 100644 --- a/ozon/fbo.go +++ b/ozon/fbo.go @@ -14,7 +14,7 @@ type FBO struct { type GetFBOShipmentsListParams struct { // Sorting direction - Direction string `json:"dir,omitempty"` + Direction Order `json:"dir,omitempty"` // Shipment search filter Filter GetFBOShipmentsListFilter `json:"filter"` @@ -35,13 +35,13 @@ type GetFBOShipmentsListParams struct { // Shipment search filter type GetFBOShipmentsListFilter struct { // Period start in YYYY-MM-DD format - Since time.Time `json:"since"` + Since *core.TimeFormat `json:"since,omitempty"` // Shipment status - Status string `json:"status"` + Status string `json:"status,omitempty"` // Period end in YYYY-MM-DD format - To time.Time `json:"to"` + To *core.TimeFormat `json:"to,omitempty"` } // Additional fields to add to the response diff --git a/ozon/fbo_test.go b/ozon/fbo_test.go index c4d7cdd..5eec229 100644 --- a/ozon/fbo_test.go +++ b/ozon/fbo_test.go @@ -24,9 +24,9 @@ func TestGetFBOShipmentsList(t *testing.T) { &GetFBOShipmentsListParams{ Direction: "ASC", Filter: GetFBOShipmentsListFilter{ - Since: core.TimeFromString(t, "2006-01-02T15:04:05Z", "2021-09-01T00:00:00.000Z"), + Since: core.NewTimeFormat(core.TimeFromString(t, "2006-01-02T15:04:05Z", "2021-09-01T00:00:00.000Z"), "2006-01-02T15:04:05Z"), Status: "awaiting_packaging", - To: core.TimeFromString(t, "2006-01-02T15:04:05Z", "2021-11-17T10:44:12.828Z"), + To: core.NewTimeFormat(core.TimeFromString(t, "2006-01-02T15:04:05Z", "2021-11-17T10:44:12.828Z"), "2006-01-02T15:04:05Z"), }, Limit: 5, Offset: 0, diff --git a/ozon/fbs.go b/ozon/fbs.go index 8168cb1..cccd1c4 100644 --- a/ozon/fbs.go +++ b/ozon/fbs.go @@ -37,18 +37,18 @@ type ListUnprocessedShipmentsFilter struct { // Filter by the time by which the seller should pack the order. Period start. // // Format: YYYY-MM-DDThh: mm:ss. mcsZ. Example: 2020-03-18T07:34:50.359 Z - CutoffFrom time.Time `json:"cutoff_from"` + CutoffFrom *core.TimeFormat `json:"cutoff_from,omitempty"` // Filter by the time by which the seller should pack the order. Period end. // // Format: YYYY-MM-DDThh: mm:ss. mcsZ. Example: 2020-03-18T07:34:50.359 Z - CutoffTo time.Time `json:"cutoff_to"` + CutoffTo *core.TimeFormat `json:"cutoff_to,omitempty"` // Minimum date when shipment should be handed over for delivery - DeliveringDateFrom time.Time `json:"delivering_date_from"` + DeliveringDateFrom *core.TimeFormat `json:"delivering_date_from,omitempty"` // Maximum date when shipment should be handed over for delivery - DeliveringDateTo time.Time `json:"delivering_date_to"` + DeliveringDateTo *core.TimeFormat `json:"delivering_date_to,omitempty"` // Delivery method identifier DeliveryMethodId []int64 `json:"delivery_method_id"` @@ -58,7 +58,7 @@ type ListUnprocessedShipmentsFilter struct { // Default value is all. // // The FBP scheme is available only for sellers from China - FBPFilter FBPFilter `json:"fbpFilter"` + FBPFilter FBPFilter `json:"fbpFilter" default:"all"` // Delivery service identifier ProviderId []int64 `json:"provider_id"` @@ -511,7 +511,7 @@ func (c FBS) ListUnprocessedShipments(ctx context.Context, params *ListUnprocess type GetFBSShipmentsListParams struct { // Sorting direction - Direction string `json:"dir,omitempty"` + Direction Order `json:"dir,omitempty"` // Filter Filter GetFBSShipmentsListFilter `json:"filter"` @@ -532,12 +532,12 @@ type GetFBSShipmentsListFilter struct { // Delivery method identifier DeliveryMethodId []int64 `json:"delivery_method_id"` - // Filter for shipments delivered from partner warehouse (FBP). You can pass one of the following values: + // Filter for shipments delivered from partner warehouse (FBP) // // Default value is all. // // The FBP scheme is available only for sellers from China - FBPFilter FBPFilter `json:"fbpFilter"` + FBPFilter FBPFilter `json:"fbpFilter" default:"all"` // Order identifier OrderId int64 `json:"order_id"` diff --git a/ozon/fbs_test.go b/ozon/fbs_test.go index e663a4c..5228823 100644 --- a/ozon/fbs_test.go +++ b/ozon/fbs_test.go @@ -24,8 +24,8 @@ func TestListUnprocessedShipments(t *testing.T) { &ListUnprocessedShipmentsParams{ Direction: "ASC", Filter: ListUnprocessedShipmentsFilter{ - CutoffFrom: core.TimeFromString(t, "2006-01-02T15:04:05Z", "2021-08-24T14:15:22Z"), - CutoffTo: core.TimeFromString(t, "2006-01-02T15:04:05Z", "2021-08-31T14:15:22Z"), + CutoffFrom: core.NewTimeFormat(core.TimeFromString(t, "2006-01-02T15:04:05Z", "2021-08-24T14:15:22Z"), "2006-01-02T15:04:05Z"), + CutoffTo: core.NewTimeFormat(core.TimeFromString(t, "2006-01-02T15:04:05Z", "2021-08-31T14:15:22Z"), "2006-01-02T15:04:05Z"), Status: "awaiting_packaging", }, Limit: 100, diff --git a/ozon/products.go b/ozon/products.go index 8823151..57e1d5c 100644 --- a/ozon/products.go +++ b/ozon/products.go @@ -99,13 +99,13 @@ func (c Products) GetStocksInfo(ctx context.Context, params *GetStocksInfoParams type GetProductDetailsParams struct { // Product identifier in the seller's system - OfferId string `json:"offer_id"` + OfferId string `json:"offer_id,omitempty"` // Product identifier - ProductId int64 `json:"product_id"` + ProductId int64 `json:"product_id,omitempty"` // Product identifier in the Ozon system, SKU - SKU int64 `json:"sku"` + SKU int64 `json:"sku,omitempty"` } type GetProductDetailsResponse struct { diff --git a/ozon/reports.go b/ozon/reports.go index 23d341b..f3da60f 100644 --- a/ozon/reports.go +++ b/ozon/reports.go @@ -526,10 +526,10 @@ type GetShipmentReportFilter struct { OfferId string `json:"offer_id"` // Order processing start date and time - ProcessedAtFrom time.Time `json:"processed_at_from"` + ProcessedAtFrom *core.TimeFormat `json:"processed_at_from,omitempty"` // Time when the order appeared in your personal account - ProcessedAtTo time.Time `json:"processed_at_to"` + ProcessedAtTo *core.TimeFormat `json:"processed_at_to,omitempty"` // Product identifier in the Ozon system, SKU SKU []int64 `json:"sku"` diff --git a/ozon/reports_test.go b/ozon/reports_test.go index 9b30509..61e028d 100644 --- a/ozon/reports_test.go +++ b/ozon/reports_test.go @@ -437,8 +437,8 @@ func TestGetShipmentReport(t *testing.T) { &GetShipmentReportParams{ Filter: &GetShipmentReportFilter{ DeliverySchema: []string{"fbs", "fbo", "crossborder"}, - ProcessedAtFrom: core.TimeFromString(t, "2006-01-02T15:04:05Z", "2021-09-02T17:10:54.861Z"), - ProcessedAtTo: core.TimeFromString(t, "2006-01-02T15:04:05Z", "2021-11-02T17:10:54.861Z"), + ProcessedAtFrom: core.NewTimeFormat(core.TimeFromString(t, "2006-01-02T15:04:05Z", "2021-09-02T17:10:54.861Z"), "2006-01-02T15:04:05Z"), + ProcessedAtTo: core.NewTimeFormat(core.TimeFromString(t, "2006-01-02T15:04:05Z", "2021-11-02T17:10:54.861Z"), "2006-01-02T15:04:05Z"), }, }, `{