Skip to content

Commit

Permalink
Time format fixes and optional fields (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
diPhantxm authored May 24, 2024
1 parent 7ffcf3f commit 2e284d9
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion ozon/analytics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}

Expand Down
6 changes: 3 additions & 3 deletions ozon/cancellations.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion ozon/chats.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
2 changes: 1 addition & 1 deletion ozon/chats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
`{
Expand Down
8 changes: 4 additions & 4 deletions ozon/fbo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions ozon/fbo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
16 changes: 8 additions & 8 deletions ozon/fbs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand All @@ -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"`
Expand Down Expand Up @@ -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"`
Expand All @@ -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"`
Expand Down
4 changes: 2 additions & 2 deletions ozon/fbs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions ozon/products.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions ozon/reports.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
4 changes: 2 additions & 2 deletions ozon/reports_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
},
},
`{
Expand Down

0 comments on commit 2e284d9

Please sign in to comment.