Refactor ProductDetails struct for improved clarity and organization
Some checks failed
tests / unit (push) Has been cancelled
tests / coverage (push) Has been cancelled

This commit is contained in:
2025-05-26 03:37:54 +03:00
parent c9ca89e364
commit c6c3030925

View File

@@ -106,157 +106,41 @@ func (c Products) GetStocksInfo(ctx context.Context, params *GetStocksInfoParams
} }
type ProductDetails struct { type ProductDetails struct {
// All product barcodes
Barcodes []string `json:"barcodes"` Barcodes []string `json:"barcodes"`
// Main offer price on Ozon.
//
// The field is deprecated. Returns an empty string ""
BuyboxPrice string `json:"buybox_price"`
// Category identifier
DescriptionCategoryId int64 `json:"description_category_id"`
// Markdown product stocks at the Ozon warehouse
DiscountedFBOStocks int32 `json:"discounted_fbo_stocks"`
// Details on errors when creating or validating a product
Errors []ProductDetailsError `json:"errors"`
// Indication that the product has similar markdown products at the Ozon warehouse
HasDiscountedFBOItem bool `json:"has_discounted_fbo_item"`
// Product type identifier
TypeId int64 `json:"type_id"`
// Marketing color
ColorImage []string `json:"color_image"` ColorImage []string `json:"color_image"`
// Commission fees details
Commissions []ProductDetailCommission `json:"commissions"` Commissions []ProductDetailCommission `json:"commissions"`
// Date and time when the product was created
CreatedAt time.Time `json:"created_at"` CreatedAt time.Time `json:"created_at"`
// Product SKU
SKU int64 `json:"sku"`
// SKU of the product that is sold from the Ozon warehouse (FBO)
FBOSKU int64 `json:"fbo_sku,omitempty"`
// SKU of the product that is sold from the seller's warehouse (FBS and rFBS)
FBSSKU int64 `json:"fbs_sku,omitempty"`
// Product identifier
Id int64 `json:"id"`
// An array of links to images. The images in the array are arranged in the order of their arrangement on the site. If the `primary_image` parameter is not specified, the first image in the list is the main one for the product
Images []string `json:"images"`
// Main product image
PrimaryImage []string `json:"primary_image"`
// Array of 360 images
Images360 []string `json:"images360"`
// true if the product has markdown equivalents at the Ozon warehouse
HasDiscountedItem bool `json:"has_discounted_item"`
// Indication of a markdown product:
//
// * true if the product was created by the seller as a markdown
//
// * false if the product is not markdown or was marked down by Ozon
IsDiscounted bool `json:"is_discounted"`
// Markdown products stocks
DiscountedStocks ProductDiscountedStocks `json:"discounted_stocks"`
// Indication of a bulky product
IsKGT bool `json:"is_kgt"`
// Indication of mandatory prepayment for the product:
//
// * true — to buy a product, you need to make a prepayment.
//
// * false—prepayment is not required
IsPrepayment bool `json:"is_prepayment"`
// If prepayment is possible, the value is true
IsPrepaymentAllowed bool `json:"is_prepayment_allowed"`
// Currency of your prices. It matches the currency set in the personal account settings
CurrencyCode string `json:"currency_code"` CurrencyCode string `json:"currency_code"`
DescriptionCategoryId int64 `json:"description_category_id"`
// The price of the product including all promotion discounts. This value will be shown on the Ozon storefront DiscountedFBOStocks int32 `json:"discounted_fbo_stocks"`
MarketingPrice string `json:"marketing_price"` Errors []ProductDetailsError `json:"errors"`
HasDiscountedFBOItem bool `json:"has_discounted_fbo_item"`
// Minimum price for similar products on Ozon. Id int64 `json:"id"`
// Images []string `json:"images"`
// The field is deprecated. Returns an empty string "" Images360 []string `json:"images360"`
MinOzonPrice string `json:"min_ozon_price"`
// Minimum product price with all promotions applied
MinPrice string `json:"min_price"`
// Name
Name string `json:"name"`
// Product identifier in the seller's system
OfferId string `json:"offer_id"`
// Price before discounts. Displayed strikethrough on the product description page
OldPrice string `json:"old_price"`
// Product price including discounts. This value is shown on the product description page
Price string `json:"price"`
// Product price indexes
PriceIndexes ProductDetailPriceIndex `json:"price_indexes"`
// Deprecated: Price index. Learn more in Help Center
//
// Use PriceIndexes instead
PriceIndex string `json:"price_index"`
// Product state description
Status ProductDetailStatus `json:"status"`
// Details about the sources of similar offers. Learn more in Help Сenter
Sources []ProductDetailSource `json:"sources"`
// Details about product stocks
Stocks ProductDetailStock `json:"stocks"`
// Date of the last product update
UpdatedAt time.Time `json:"updated_at"`
// Product VAT rate
VAT string `json:"vat"`
// Product visibility settings
VisibilityDetails ProductDetailVisibilityDetails `json:"visibility_details"`
// If the product is on sale, the value is true
Visible bool `json:"visible"`
// Product volume weight
VolumeWeight float64 `json:"volume_weight"`
// 'true' if the item is archived manually.
IsArchived bool `json:"is_archived"` IsArchived bool `json:"is_archived"`
IsAutoarchived bool `json:"is_autoarchived"`
// 'true' if the item is archived automatically. IsDiscounted bool `json:"is_discounted"`
IsArchivedAuto bool `json:"is_autoarchived"` IsKGT bool `json:"is_kgt"`
IsPrepaymentAllowed bool `json:"is_prepayment_allowed"`
// Product status details
Statuses ProductDetailsStatus `json:"statuses"`
// Product model details
ModelInfo ProductDetailsModelInfo `json:"model_info"`
// Indication of a super product
IsSuper bool `json:"is_super"` IsSuper bool `json:"is_super"`
MarketingPrice string `json:"marketing_price"`
MinPrice string `json:"min_price"`
ModelInfo *ProductDetailsModelInfo `json:"model_info"`
Name string `json:"name"`
OfferId string `json:"offer_id"`
OldPrice string `json:"old_price"`
Price string `json:"price"`
PriceIndexes ProductDetailPriceIndex `json:"price_indexes"`
PrimaryImage []string `json:"primary_image"`
Sources []ProductDetailSource `json:"sources"`
Statuses ProductDetailsStatus `json:"statuses"`
Stocks ProductDetailStock `json:"stocks"`
TypeId int64 `json:"type_id"`
UpdatedAt time.Time `json:"updated_at"`
VAT string `json:"vat"`
VisibilityDetails ProductDetailVisibilityDetails `json:"visibility_details"`
VolumeWeight float64 `json:"volume_weight"`
} }
type ProductDetailsError struct { type ProductDetailsError struct {
@@ -306,31 +190,14 @@ type NameValue struct {
} }
type ProductDetailsStatus struct { type ProductDetailsStatus struct {
// true, if the product is created correctly
IsCreated bool `json:"is_created"` IsCreated bool `json:"is_created"`
// Moderation status
ModerateStatus string `json:"moderate_status"` ModerateStatus string `json:"moderate_status"`
// Product status
Status string `json:"status"` Status string `json:"status"`
StatusDescription string `json:"status_description"`
// Product status description StatusFailed string `json:"status_failed"`
Description string `json:"status_description"` StatusName string `json:"status_name"`
StatusTooltip string `json:"status_tooltip"`
// Status of the product where the error occurred StatusUpdatedAt time.Time `json:"status_updated_at"`
Failed string `json:"status_failed"`
// Product status name
Name string `json:"status_name"`
// Status description
Tooltip string `json:"status_tooltip"`
// Time of the last status change
UpdatedAt time.Time `json:"status_updated_at"`
// Validation status
ValidationStatus string `json:"validation_status"` ValidationStatus string `json:"validation_status"`
} }
@@ -445,58 +312,28 @@ type ProductDetailStatus struct {
} }
type ProductDetailSource struct { type ProductDetailSource struct {
// Product creation date
CreatedAt time.Time `json:"created_at"` CreatedAt time.Time `json:"created_at"`
// Product identifier in the Ozon system, SKU
SKU int64 `json:"sku"`
// Link to the source
Source string `json:"source"`
// Package type
ShipmentType string `json:"shipment_type"`
// List of MOQs with products
QuantCode string `json:"quant_code"` QuantCode string `json:"quant_code"`
ShipmentType string `json:"shipment_type"`
SKU int64 `json:"sku"`
Source string `json:"source"`
} }
type ProductDetailStock struct { type ProductDetailStock struct {
// true, if there are stocks at the warehouses
HasStock bool `json:"has_stock"` HasStock bool `json:"has_stock"`
// Status of product stocks
Stocks []ProductDetailStockStock `json:"stocks"` Stocks []ProductDetailStockStock `json:"stocks"`
} }
type ProductDetailStockStock struct { type ProductDetailStockStock struct {
// Product identifier in the Ozon system, SKU
SKU int64 `json:"sku"`
// Currently at the warehouse
Present int32 `json:"present"` Present int32 `json:"present"`
// Reserved
Reserved int32 `json:"reserved"` Reserved int32 `json:"reserved"`
SKU int64 `json:"sku"`
// Sales scheme
Source string `json:"source"` Source string `json:"source"`
} }
type ProductDetailVisibilityDetails struct { type ProductDetailVisibilityDetails struct {
// If the product is active, the value is true
//
// Deprecated: Use `visible` parameter of `ProductDetails`
ActiveProduct bool `json:"active_product"`
// If the price is set, the value is true
HasPrice bool `json:"has_price"` HasPrice bool `json:"has_price"`
// If there is stock at the warehouses, the value is true
HasStock bool `json:"has_stock"` HasStock bool `json:"has_stock"`
// Reason why the product is hidden
Reasons map[string]interface{} `json:"reasons"`
} }
type ProductDiscountedStocks struct { type ProductDiscountedStocks struct {