From c6c303092505102eb108e1ebea91a7adff98edd3 Mon Sep 17 00:00:00 2001 From: admin Date: Mon, 26 May 2025 03:37:54 +0300 Subject: [PATCH] Refactor ProductDetails struct for improved clarity and organization --- ozon/products.go | 273 ++++++++++------------------------------------- 1 file changed, 55 insertions(+), 218 deletions(-) diff --git a/ozon/products.go b/ozon/products.go index 86a2795..4329a1b 100644 --- a/ozon/products.go +++ b/ozon/products.go @@ -106,157 +106,41 @@ func (c Products) GetStocksInfo(ctx context.Context, params *GetStocksInfoParams } type ProductDetails struct { - // All product 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"` - - // Commission fees details - Commissions []ProductDetailCommission `json:"commissions"` - - // Date and time when the product was created - 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"` - - // The price of the product including all promotion discounts. This value will be shown on the Ozon storefront - MarketingPrice string `json:"marketing_price"` - - // Minimum price for similar products on Ozon. - // - // The field is deprecated. Returns an empty string "" - 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"` - - // 'true' if the item is archived automatically. - IsArchivedAuto bool `json:"is_autoarchived"` - - // 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"` + Barcodes []string `json:"barcodes"` + ColorImage []string `json:"color_image"` + Commissions []ProductDetailCommission `json:"commissions"` + CreatedAt time.Time `json:"created_at"` + CurrencyCode string `json:"currency_code"` + DescriptionCategoryId int64 `json:"description_category_id"` + DiscountedFBOStocks int32 `json:"discounted_fbo_stocks"` + Errors []ProductDetailsError `json:"errors"` + HasDiscountedFBOItem bool `json:"has_discounted_fbo_item"` + Id int64 `json:"id"` + Images []string `json:"images"` + Images360 []string `json:"images360"` + IsArchived bool `json:"is_archived"` + IsAutoarchived bool `json:"is_autoarchived"` + IsDiscounted bool `json:"is_discounted"` + IsKGT bool `json:"is_kgt"` + IsPrepaymentAllowed bool `json:"is_prepayment_allowed"` + 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 { @@ -306,32 +190,15 @@ type NameValue struct { } type ProductDetailsStatus struct { - // true, if the product is created correctly - IsCreated bool `json:"is_created"` - - // Moderation status - ModerateStatus string `json:"moderate_status"` - - // Product status - Status string `json:"status"` - - // Product status description - Description string `json:"status_description"` - - // Status of the product where the error occurred - 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"` + IsCreated bool `json:"is_created"` + ModerateStatus string `json:"moderate_status"` + Status string `json:"status"` + StatusDescription string `json:"status_description"` + StatusFailed string `json:"status_failed"` + StatusName string `json:"status_name"` + StatusTooltip string `json:"status_tooltip"` + StatusUpdatedAt time.Time `json:"status_updated_at"` + ValidationStatus string `json:"validation_status"` } type ProductDetailsModelInfo struct { @@ -445,58 +312,28 @@ type ProductDetailStatus struct { } type ProductDetailSource struct { - // Product creation date - 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"` + CreatedAt time.Time `json:"created_at"` + QuantCode string `json:"quant_code"` + ShipmentType string `json:"shipment_type"` + SKU int64 `json:"sku"` + Source string `json:"source"` } type ProductDetailStock struct { - // true, if there are stocks at the warehouses - HasStock bool `json:"has_stock"` - - // Status of product stocks - Stocks []ProductDetailStockStock `json:"stocks"` + HasStock bool `json:"has_stock"` + Stocks []ProductDetailStockStock `json:"stocks"` } type ProductDetailStockStock struct { - // Product identifier in the Ozon system, SKU - SKU int64 `json:"sku"` - - // Currently at the warehouse - Present int32 `json:"present"` - - // Reserved - Reserved int32 `json:"reserved"` - - // Sales scheme - Source string `json:"source"` + Present int32 `json:"present"` + Reserved int32 `json:"reserved"` + SKU int64 `json:"sku"` + Source string `json:"source"` } 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"` - - // If there is stock at the warehouses, the value is true HasStock bool `json:"has_stock"` - - // Reason why the product is hidden - Reasons map[string]interface{} `json:"reasons"` } type ProductDiscountedStocks struct {