package ozon import ( "context" "net/http" "time" core "github.com/diphantxm/ozon-api-client" ) type FBO struct { client *core.Client } type GetFBOShipmentsListParams struct { // Sorting direction Direction Order `json:"dir,omitempty"` // Shipment search filter Filter GetFBOShipmentsListFilter `json:"filter"` // Number of values in the response. Maximum is 1000, 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,omitempty"` // true if the address transliteration from Cyrillic to Latin is enabled Translit bool `json:"translit,omitempty"` // Additional fields to add to the response With *GetFBOShipmentsListWith `json:"with,omitempty"` } // Shipment search filter type GetFBOShipmentsListFilter struct { // Period start in YYYY-MM-DD format Since *core.TimeFormat `json:"since,omitempty"` // Shipment status Status string `json:"status,omitempty"` // Period end in YYYY-MM-DD format To *core.TimeFormat `json:"to,omitempty"` } // Additional fields to add to the response type GetFBOShipmentsListWith struct { // Specify true to add analytics data to the response AnalyticsData bool `json:"analytics_data"` // Specify true to add financial data to the response FinancialData bool `json:"financial_data"` } type GetFBOShipmentsListResponse struct { core.CommonResponse // Shipments list Result []GetFBOShipmentsListResult `json:"result"` } type GetFBOShipmentsListResult struct { // Additional data for shipment list AdditionalData []GetFBOShipmentsListResultAdditionalData `json:"additional_data"` // Analytical data AnalyticsData GetFBOShipmentsListResultAnalyticsData `json:"analytics_data"` // Shipment cancellation reason identifier CancelReasonId int64 `json:"cancel_reason_id"` // Date and time of shipment creation CreatedAt time.Time `json:"created_at"` // Financial data FinancialData FBOFinancialData `json:"financial_data"` // Date and time of shipment processing start InProccessAt time.Time `json:"in_process_at"` // Identifier of the order to which the shipment belongs OrderId int64 `json:"order_id"` // Number of the order to which the shipment belongs OrderNumber string `json:"order_number"` // Shipment number PostingNumber string `json:"posting_number"` // Number of products in the shipment Products []FBOPostingProduct `json:"products"` // Shipment status Status string `json:"status"` } type GetFBOShipmentsListResultAdditionalData struct { Key string `json:"key"` Value string `json:"value"` } type GetFBOShipmentsListResultAnalyticsData struct { // Delivery city City string `json:"city"` // Delivery method DeliveryType string `json:"delivery_type"` // Indication that the recipient is a legal person // * true — a legal person, // * false — a natural person. IsLegal bool `json:"is_legal"` // Premium subscription IsPremium bool `json:"is_premium"` // Payment method PaymentTypeGroupName PaymentTypeGroupName `json:"payment_type_group_name"` // Delivery region Region string `json:"region"` // Warehouse identifier WarehouseId int64 `json:"warehouse_id"` // Name of the warehouse from which the order is shipped WarehouseName string `json:"warehouse_name"` } type FBOPostingProduct struct { // Activation codes for services and digital products DigitalCodes []string `json:"digital_codes"` // Currency of your prices. It matches the currency set in the personal account settings CurrencyCode string `json:"currency_code"` // Product name Name string `json:"name"` // Product identifier in the seller's system OfferId string `json:"offer_id"` // Product price Price string `json:"price"` // Quantity of products in the shipment Quantity int64 `json:"quantity"` // Product identifier in the Ozon system, SKU SKU int64 `json:"sku"` } type FBOFinancialData struct { // Identifier of the cluster, where the shipment is sent from ClusterFrom string `json:"cluster_from"` // Identifier of the cluster, where the shipment is delivered to ClusterTo string `json:"cluster_to"` // Services PostingServices MarketplaceServices `json:"posting_services"` // Products list Products []FinancialDataProduct `json:"products"` } // Returns a list of shipments for a specified period of time. You can additionally filter the shipments by their status func (c FBO) GetShipmentsList(ctx context.Context, params *GetFBOShipmentsListParams) (*GetFBOShipmentsListResponse, error) { url := "/v2/posting/fbo/list" resp := &GetFBOShipmentsListResponse{} response, err := c.client.Request(ctx, http.MethodPost, url, params, resp, nil) if err != nil { return nil, err } response.CopyCommonResponse(&resp.CommonResponse) return resp, nil } type GetShipmentDetailsParams struct { // Shipment number PostingNumber string `json:"posting_number"` // true if the address transliteration from Cyrillic to Latin is enabled Translit bool `json:"translit,omitempty"` // Additional fields to add to the response With *GetShipmentDetailsWith `json:"with,omitempty"` } type GetShipmentDetailsWith struct { // Specify true to add analytics data to the response AnalyticsData bool `json:"analytics_data"` // Specify true to add financial data to the response FinancialData bool `json:"financial_data"` } type GetShipmentDetailsResponse struct { core.CommonResponse // Method result Result GetShipmentDetailsResult `json:"result"` } type GetShipmentDetailsResult struct { // Additional data AdditionalData []GetShipmentDetailsResultAdditionalData `json:"additional_data"` // Analytical data AnalyticsData GetShipmentDetailsResultAnalyticsData `json:"analytics_data"` // Shipment cancellation reason identifier CancelReasonId int64 `json:"cancel_reason_id"` // Date and time of shipment creation CreatedAt time.Time `json:"created_at"` // Financial data FinancialData FBOFinancialData `json:"financial_data"` // Date and time of shipment processing start InProcessAt time.Time `json:"in_process_at"` // Identifier of the order to which the shipment belongs OrderId int64 `json:"order_id"` // Number of the order to which the shipment belongs OrderNumber string `json:"order_number"` // Shipment number PostingNumber string `json:"posting_number"` // Number of products in the shipment Products []FBOPostingProduct `json:"products"` // Shipment status Status string `json:"status"` } type GetShipmentDetailsResultAdditionalData struct { Key string `json:"key"` Value string `json:"value"` } type GetShipmentDetailsResultAnalyticsData struct { // Delivery city City string `json:"city"` // Delivery method DeliveryType string `json:"delivery_type"` // Indication that the recipient is a legal person: // - true — a legal person // - false — a natural person IsLegal bool `json:"is_legal"` // Premium subscription IsPremium bool `json:"is_premium"` // Payment method PaymentTypeGroupName string `json:"payment_type_group_name"` // Delivery region Region string `json:"region"` // Warehouse identifier WarehouseId int64 `json:"warehouse_id"` // Name of the warehouse from which the order is shipped WarehouseName string `json:"warehouse_name"` } // Returns information about the shipment by its identifier func (c FBO) GetShipmentDetails(ctx context.Context, params *GetShipmentDetailsParams) (*GetShipmentDetailsResponse, error) { url := "/v2/posting/fbo/get" resp := &GetShipmentDetailsResponse{} response, err := c.client.Request(ctx, http.MethodPost, url, params, resp, nil) if err != nil { return nil, err } response.CopyCommonResponse(&resp.CommonResponse) return resp, nil } type ListSupplyRequestsParams struct { // Filter Filter *ListSupplyRequestsFilter `json:"filter"` // Customizing the display of the requests list Paging *ListSupplyRequestsPaging `json:"paging"` } type ListSupplyRequestsFilter struct { States []string `json:"states"` } type ListSupplyRequestsPaging struct { // Supply number from which the list of requests will start FromOrderId int64 `json:"from_supply_order_id"` // Number of requests in the response Limit int32 `json:"limit"` } type ListSupplyRequestsResponse struct { core.CommonResponse // Supply request identifier you last requested LastSupplyOrderId int64 `json:"last_supply_order_id"` // Supply request identifier SupplyOrderId []string `json:"supply_order_id"` } // Requests with supply to a specific warehouse and through a virtual distribution center (vDC) are taken into account func (c FBO) ListSupplyRequests(ctx context.Context, params *ListSupplyRequestsParams) (*ListSupplyRequestsResponse, error) { url := "/v2/supply-order/list" resp := &ListSupplyRequestsResponse{} response, err := c.client.Request(ctx, http.MethodPost, url, params, resp, nil) if err != nil { return nil, err } response.CopyCommonResponse(&resp.CommonResponse) return resp, nil } type GetSupplyRequestInfoParams struct { // Supply request identifier in the Ozon system OrderIds []string `json:"order_ids"` } type GetSupplyRequestInfoResponse struct { core.CommonResponse // Supply request details Orders []SupplyOrder `json:"orders"` // Warehouse details Warehouses []SupplyWarehouse `json:"warehouses"` } type SupplyOrder struct { // Date of supply request creation CreationDate string `json:"creation_date"` // Request source CreationFlow string `json:"creation_flow"` // Time remaining in seconds to fill in the supply details. Only for requests from the vDC DataFillingDeadline time.Time `json:"data_filling_deadline_utc"` // Supply warehouse identifier DropoffWarehouseId int64 `json:"dropoff_warehouse_id"` // Filter by supply status State string `json:"state"` // Supply request contents Supplies []Supply `json:"supplies"` // Supply request identifier Id int64 `json:"supply_order_id"` // Request number OrderNumber string `json:"supply_order_number"` // Supply time slot Timeslot []SupplyTimeslot `json:"timeslot"` // Driver and vehicle details Vehicle []SupplyVehicle `json:"vehicle"` } type Supply struct { // Supply contents identifier. Used in the /v1/supply-order/bundle method BundleId string `json:"bundle_id"` // Storage warehouse identifier StorageWarehouseId int64 `json:"storage_warehouse_id"` // Supply identifier Id int64 `json:"supply_id"` } type SupplyTimeslot struct { // Reason why you can't select the supply time slot Reasons []string `json:"can_not_set_reasons"` // true, if you can select or edit the supply time slot CanSet bool `json:"can_set"` // true, if the characteristic is required IsRequired bool `json:"is_required"` Value SupplyTimeslotValue `json:"value"` } type SupplyVehicle struct { // Reason why you can't select the supply time slot Reasons []string `json:"can_not_set_reasons"` // true, if you can select or edit the supply time slot CanSet bool `json:"can_set"` // true, if the characteristic is required IsRequired bool `json:"is_required"` Value []GetSupplyRequestInfoVehicle `json:"value"` } type SupplyTimeslotValue struct { // Supply time slot in local time Timeslot []SupplyTimeslotValueTimeslot `json:"timeslot"` // Time zone Timezone []SupplyTimeslotValueTimezone `json:"timezone_info"` } type SupplyTimeslotValueTimeslot struct { // Supply time slot start From time.Time `json:"from"` // Supply time slot end To time.Time `json:"to"` } type SupplyTimeslotValueTimezone struct { // Time zone name Name string `json:"iana_name"` // Time zone offset from UTC-0 in seconds Offset string `json:"offset"` } type GetSupplyRequestInfoVehicle struct { // Driver name DriverName string `json:"driver_name"` // Driver phone number DriverPhone string `json:"driver_phone"` // Car model VehicleModel string `json:"vehicle_model"` // Car number VehicleNumber string `json:"vehicle_number"` } type SupplyWarehouse struct { // Warehouse address Address string `json:"address"` // Warehouse name Name string `json:"name"` // Warehouse identifier Id int64 `json:"warehouse_id"` } // Method for getting detailed information on a supply request. // Requests with supply both to a specific warehouse and via a // virtual distribution center (vDC) are taken into account func (c FBO) GetSupplyRequestInfo(ctx context.Context, params *GetSupplyRequestInfoParams) (*GetSupplyRequestInfoResponse, error) { url := "/v2/supply-order/get" resp := &GetSupplyRequestInfoResponse{} response, err := c.client.Request(ctx, http.MethodPost, url, params, resp, nil) if err != nil { return nil, err } response.CopyCommonResponse(&resp.CommonResponse) return resp, nil } type ListProductsInSupplyRequestParams struct { // Number of the page returned in the query Page int32 `json:"page"` // Number of elements on the page PageSize int32 `json:"page_size"` // Supply request identifier SupplyOrderId int64 `json:"supply_order_id"` } type ListProductsInSupplyRequestResponse struct { core.CommonResponse // Indicates that the response contains not the entire array of supply requests: // - true — make a new request with a different page and page_size values to get the remaining products; // - false — the entire array of product was returned in the response HasNext bool `json:"has_next"` // Products list Items []ListProductsInSupplyRequestItem `json:"items"` // Total number of products in the request TotalItemsCount int32 `json:"total_items_count"` } type ListProductsInSupplyRequestItem struct { // Link to product image IconPath string `json:"icon_path"` // Product name Name string `json:"name"` // Product ID OfferId string `json:"offer_id"` // Product quantity Quantity int64 `json:"quantity"` // Product identifier in the Ozon system, SKU SKU int64 `json:"sku"` } // List of products in the sullpy request func (c FBO) ListProductsInSupplyRequest(ctx context.Context, params *ListProductsInSupplyRequestParams) (*ListProductsInSupplyRequestResponse, error) { url := "/v1/supply-order/items" resp := &ListProductsInSupplyRequestResponse{} response, err := c.client.Request(ctx, http.MethodPost, url, params, resp, nil) if err != nil { return nil, err } response.CopyCommonResponse(&resp.CommonResponse) return resp, nil } type GetWarehouseWorkloadResponse struct { core.CommonResponse // Method result Result []GetWarehouseWorkloadResult `json:"result"` } type GetWarehouseWorkloadResult struct { // Workload Schedule GetWarehouseWorkloadResultSchedule `json:"schedule"` // Warehouse Warehouse GetWarehouseWorkloadResultWarehouse `json:"warehouse"` } type GetWarehouseWorkloadResultSchedule struct { // Data on the products quantity supplied to the warehouse Capacity []GetWarehouseWorkloadResultScheduleCapacity `json:"capacity"` // The closest available date for supply, local time Date time.Time `json:"date"` } type GetWarehouseWorkloadResultScheduleCapacity struct { // Period start, local time Start time.Time `json:"start"` // Period end, local time End time.Time `json:"end"` // Average number of products that the warehouse can accept per day for the period Value int32 `json:"value"` } type GetWarehouseWorkloadResultWarehouse struct { // Warehouse identifier Id string `json:"id"` // Warehouse name Name string `json:"name"` } // Method returns a list of active Ozon warehouses with information about their average workload in the nearest future func (c FBO) GetWarehouseWorkload(ctx context.Context) (*GetWarehouseWorkloadResponse, error) { url := "/v1/supplier/available_warehouses" resp := &GetWarehouseWorkloadResponse{} response, err := c.client.Request(ctx, http.MethodGet, url, nil, resp, nil) if err != nil { return nil, err } response.CopyCommonResponse(&resp.CommonResponse) return resp, nil } type GetSupplyOrdersByStatusParams struct { } type GetSupplyOrdersByStatusResponse struct { core.CommonResponse Items []SupplyOrdersByStatus `json:"items"` } type SupplyOrdersByStatus struct { // Number of supply requests in this status Count int32 `json:"count"` // Supply status OrderState string `json:"order_state"` } // Returns the number of supply requests in a specific status. func (c FBO) GetSupplyOrdersByStatus(ctx context.Context) (*GetSupplyOrdersByStatusResponse, error) { url := "/v1/supply-order/status/counter" resp := &GetSupplyOrdersByStatusResponse{} response, err := c.client.Request(ctx, http.MethodGet, url, &GetSupplyOrdersByStatusParams{}, resp, nil) if err != nil { return nil, err } response.CopyCommonResponse(&resp.CommonResponse) return resp, nil } type GetSupplyTimeslotsParams struct { // Supply request identifier SupplyOrderId int64 `json:"supply_order_id"` } type GetSupplyTimeslotsResponse struct { core.CommonResponse // Supply time slot Timeslots []SupplyTimeslotValueTimeslot `json:"timeslots"` // Time zone Timezones []SupplyTimeslotValueTimezone `json:"timezone"` } func (c FBO) GetSupplyTimeslots(ctx context.Context, params *GetSupplyTimeslotsParams) (*GetSupplyTimeslotsResponse, error) { url := "/v1/supply-order/timeslot/get" resp := &GetSupplyTimeslotsResponse{} response, err := c.client.Request(ctx, http.MethodGet, url, params, resp, nil) if err != nil { return nil, err } response.CopyCommonResponse(&resp.CommonResponse) return resp, nil } type UpdateSupplyTimeslotParams struct { // Supply request identifier SupplyOrderId int64 `json:"supply_order_id"` // Supply time slot details Timeslot SupplyTimeslotValueTimeslot `json:"timeslot"` } type UpdateSupplyTimeslotResponse struct { core.CommonResponse // Possible errors Errors []string `json:"errors"` // Operation identifier OperationId string `json:"operation_id"` } func (c FBO) UpdateSupplyTimeslot(ctx context.Context, params *UpdateSupplyTimeslotParams) (*UpdateSupplyTimeslotResponse, error) { url := "/v1/supply-order/timeslot/update" resp := &UpdateSupplyTimeslotResponse{} response, err := c.client.Request(ctx, http.MethodGet, url, params, resp, nil) if err != nil { return nil, err } response.CopyCommonResponse(&resp.CommonResponse) return resp, nil } type GetSupplyTimeslotStatusParams struct { // Operation identifier OperationId string `json:"operation_id"` } type GetSupplyTimeslotStatusResponse struct { core.CommonResponse // Possible errors Errors []string `json:"errors"` // Data status Status string `json:"status"` } func (c FBO) GetSupplyTimeslotStatus(ctx context.Context, params *GetSupplyTimeslotStatusParams) (*GetSupplyTimeslotStatusResponse, error) { url := "/v1/supply-order/timeslot/status" resp := &GetSupplyTimeslotStatusResponse{} response, err := c.client.Request(ctx, http.MethodGet, url, params, resp, nil) if err != nil { return nil, err } response.CopyCommonResponse(&resp.CommonResponse) return resp, nil } type CreatePassParams struct { // Supply request identifier SupplyOrderId int64 `json:"supply_order_id"` // Driver and car information Vehicle GetSupplyRequestInfoVehicle `json:"vehicle"` } type CreatePassResponse struct { core.CommonResponse // Possible errors Errors []string `json:"error_reasons"` // Operation identifier OperationId string `json:"operation_id"` } func (c FBO) CreatePass(ctx context.Context, params *CreatePassParams) (*CreatePassResponse, error) { url := "/v1/supply-order/pass/create" resp := &CreatePassResponse{} response, err := c.client.Request(ctx, http.MethodGet, url, params, resp, nil) if err != nil { return nil, err } response.CopyCommonResponse(&resp.CommonResponse) return resp, nil } type GetPassParams struct { // Operation identifier OperationId string `json:"operation_id"` } type GetPassResponse struct { core.CommonResponse // Possible errors Errors []string `json:"errors"` // Status of driver and vehicle data entry Result string `json:"result"` } func (c FBO) GetPass(ctx context.Context, params *GetPassParams) (*GetPassResponse, error) { url := "/v1/supply-order/pass/status" resp := &GetPassResponse{} response, err := c.client.Request(ctx, http.MethodGet, url, params, resp, nil) if err != nil { return nil, err } response.CopyCommonResponse(&resp.CommonResponse) return resp, nil } type GetSupplyContentParams struct { // Identifiers of supply contents. Minimum is 1, maximum is 1000. You can get them using the /v2/supply-order/get method BundleIds []string `json:"bundle_ids"` // true, to sort in ascending order IsAsc bool `json:"is_asc"` // Identifier of the last value on the page LastId string `json:"last_id"` // Number of values on the page. Minimum is 1, maximum is 1000 Limit int32 `json:"limit"` // Search query, for example: by name, article code, or SKU Query string `json:"query"` // Sorting by parameters SortField string `json:"sort_field"` } type GetSupplyContentResponse struct { core.CommonResponse // List of products in the supply request Items []SupplyContentItem `json:"items"` // Quantity of products in the request TotalCount int32 `json:"total_count"` // Indication that the response hasn't returned all products HasNext bool `json:"has_next"` // Identifier of the last value on the page LastId string `json:"last_id"` } type SupplyContentItem struct { // Link to product image IconPath string `json:"icon_path"` // Product identifier in the Ozon system, SKU SKU int64 `json:"sku"` // Product name Name string `json:"name"` // Product items quantity Quantity int32 `json:"quantity"` // Barcode Barcode string `json:"barcode"` // Product identifier ProductId int64 `json:"product_id"` // Quantity of products in one package Quant int32 `json:"quant"` // true if the quantity of products in one package can be edited IsQuantEditable bool `json:"is_quant_editable"` // Volume of products in liters VolumeInLiters float64 `json:"volume_in_litres"` // Volume of all products in liters TotalVolumeInLiters float64 `json:"total_volume_in_litres"` // Product article code ContractorItemCode string `json:"contractor_item_code"` // Super product label SFBOAttribute string `json:"sfbo_attribute"` // Type of wrapper ShipmentType string `json:"shipment_type"` } func (c FBO) GetSupplyContent(ctx context.Context, params *GetSupplyContentParams) (*GetSupplyContentResponse, error) { url := "/v1/supply-order/bundle" resp := &GetSupplyContentResponse{} response, err := c.client.Request(ctx, http.MethodGet, url, params, resp, nil) if err != nil { return nil, err } response.CopyCommonResponse(&resp.CommonResponse) return resp, nil }