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

@@ -40,11 +40,11 @@ type ListUnprocessedShipmentsResponse struct {
}
type ListUnprocessedShipmentsResult struct {
Count int64 `json:"count"`
Postings []ListUnprocessedShipmentsPosting `json:"postings"`
Count int64 `json:"count"`
Postings []FBSPosting `json:"postings"`
}
type ListUnprocessedShipmentsPosting struct {
type FBSPosting struct {
Addressee struct {
Name string `json:"name"`
Phone string `json:"phone"`
@@ -79,26 +79,7 @@ type ListUnprocessedShipmentsPosting struct {
CancelledAfterShip bool `json:"cancellation_after_ship"`
} `json:"cancellation"`
Customer struct {
Address struct {
AddressTail string `json:"address_tail"`
City string `json:"city"`
Comment string `json:"comment"`
Country string `json:"country"`
District string `json:"district"`
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
ProviderPVZCode string `json:"provider_pvz_code"`
PVZCode int64 `json:"pvz_code"`
Region string `json:"region"`
ZIPCode string `json:"zip_code"`
} `json:"customer"`
CustomerEmail string `json:"customer_email"`
CustomerId int64 `json:"customer_id"`
Name string `json:"name"`
Phone string `json:"phone"`
} `json:"customer"`
Customer FBSCustomer `json:"customer"`
DeliveringDate time.Time `json:"delivering_date"`
@@ -116,27 +97,7 @@ type ListUnprocessedShipmentsPosting struct {
ClusterTo string `json:"cluster_to"`
PostingServices MarketplaceServices `json:"posting_services"`
Products []struct {
Actions []string `json:"actions"`
ClientPrice string `json:"client_price"`
CommissionAmount float64 `json:"commission_amount"`
CommissionPercent int64 `json:"commission_percent"`
CommissionsCurrencyCode string `json:"commissions_currency_code"`
ItemServices MarketplaceServices `json:"item_services"`
CurrencyCode string `json:"currency_code"`
OldPrice float64 `json:"old_price"`
Payout float64 `json:"payout"`
Picking struct {
Amount float64 `json:"amount"`
Moment time.Time `json:"moment"`
Tag string `json:"tag"`
} `json:"picking"`
Price float64 `json:"price"`
ProductId int64 `json:"product_id"`
Quantity int64 `json:"quantity"`
TotalDiscountPercent float64 `json:"total_discount_percent"`
TotalDiscountValue float64 `json:"total_discount_value"`
} `json:"products"`
Products []FinancialDataProduct `json:"products"`
}
InProccessAt time.Time `json:"in_process_at"`
@@ -171,6 +132,27 @@ type ListUnprocessedShipmentsPosting struct {
TrackingNumber string `json:"tracking_number"`
}
type FBSCustomer struct {
Address struct {
AddressTail string `json:"address_tail"`
City string `json:"city"`
Comment string `json:"comment"`
Country string `json:"country"`
District string `json:"district"`
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
ProviderPVZCode string `json:"provider_pvz_code"`
PVZCode int64 `json:"pvz_code"`
Region string `json:"region"`
ZIPCode string `json:"zip_code"`
} `json:"customer"`
CustomerEmail string `json:"customer_email"`
CustomerId int64 `json:"customer_id"`
Name string `json:"name"`
Phone string `json:"phone"`
}
type MarketplaceServices struct {
DeliveryToCustomer float64 `json:"marketplace_service_item_deliv_to_customer"`
DirectFlowTrans float64 `json:"marketplace_service_item_direct_flow_trans"`
@@ -185,6 +167,28 @@ type MarketplaceServices struct {
ReturnPartGoodsCustomer float64 `json:"marketplace_service_item_return_part_goods_customer"`
}
type FinancialDataProduct struct {
Actions []string `json:"actions"`
ClientPrice string `json:"client_price"`
CommissionAmount float64 `json:"commission_amount"`
CommissionPercent int64 `json:"commission_percent"`
CommissionsCurrencyCode string `json:"commissions_currency_code"`
ItemServices MarketplaceServices `json:"item_services"`
CurrencyCode string `json:"currency_code"`
OldPrice float64 `json:"old_price"`
Payout float64 `json:"payout"`
Picking struct {
Amount float64 `json:"amount"`
Moment time.Time `json:"moment"`
Tag string `json:"tag"`
} `json:"picking"`
Price float64 `json:"price"`
ProductId int64 `json:"product_id"`
Quantity int64 `json:"quantity"`
TotalDiscountPercent float64 `json:"total_discount_percent"`
TotalDiscountValue float64 `json:"total_discount_value"`
}
func (c Client) ListUnprocessedShipments(params *ListUnprocessedShipmentsParams) (*ListUnprocessedShipmentsResponse, error) {
url := "/v3/posting/fbs/unfulfilled/list"
@@ -198,3 +202,102 @@ func (c Client) ListUnprocessedShipments(params *ListUnprocessedShipmentsParams)
return resp, nil
}
type GetFBSShipmentsListParams struct {
// Sorting direction
Direction string `json:"direction"`
//Filter
Filter GetFBSShipmentsListFilter `json:"filter"`
// Number of shipments in the response:
// - maximum is 50,
// - minimum is 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"`
// Additional fields that should be added to the response
With GetFBSShipmentsListWith `json:"with"`
}
type GetFBSShipmentsListFilter struct {
// Delivery method identifier
DeliveryMethodId []int64 `json:"delivery_method_id"`
// Order identifier
OrderId int64 `json:"order_id"`
// Delivery service identifier
ProviderId []int64 `json:"provider_id"`
// Start date of the period for which a list of shipments should be generated.
//
// Format: YYYYY-MM-DDTHH:MM:SSZ.
//
// Example: 2019-08-24T14:15:22Z
Since time.Time `json:"since"`
// End date of the period for which a list of shipments should be generated.
//
// Format: YYYYY-MM-DDTHH:MM:SSZ.
//
// Example: 2019-08-24T14:15:22Z.
To time.Time `json:"to"`
// Shipment status
Status string `json:"status"`
// Warehouse identifier
WarehouseId []int64 `json:"warehouse_id"`
}
type GetFBSShipmentsListWith struct {
// Add analytics data to the response
AnalyticsData bool `json:"analytics_data"`
// Add the shipment barcodes to the response
Barcodes bool `json:"barcodes"`
// Add financial data to the response
FinancialData bool `json:"financial_data"`
// Transliterate the return values
Translit bool `json:"translit"`
}
type GetFBSShipmentsListResponse struct {
core.CommonResponse
// Array of shipments
Result struct {
// Indicates that the response returned not the entire array of shipments:
//
// - true — it is necessary to make a new request with a different offset value to get information on the remaining shipments;
// - false — the entire array of shipments for the filter specified in the request was returned in the response
HasNext bool `json:"has_next"`
// Shipment details
Postings FBSPosting `json:"postings"`
} `json:"result"`
}
// Returns a list of shipments for the specified time period: it shouldn't be longer than one year.
//
// You can filter shipments by their status. The list of available statuses is specified in the description of the filter.status parameter.
//
// The true value of the has_next parameter in the response means there is not the entire array of shipments in the response. To get information on the remaining shipments, make a new request with a different offset value.
func (c Client) GetFBSShipmentsList(params *GetFBSShipmentsListParams) (*GetFBSShipmentsListResponse, error) {
url := "/v3/posting/fbs/list"
resp := &GetFBSShipmentsListResponse{}
response, err := c.client.Request(http.MethodPost, url, params, resp)
if err != nil {
return nil, err
}
response.CopyCommonResponse(&resp.CommonResponse)
return resp, nil
}