Merge pull request #5 from diPhantxm/refactor-enum-types
add enum types where possible
This commit is contained in:
@@ -19,7 +19,7 @@ type GetAnalyticsDataParams struct {
|
|||||||
DateTo time.Time `json:"date_to"`
|
DateTo time.Time `json:"date_to"`
|
||||||
|
|
||||||
// Items Enum: "unknownDimension" "sku" "spu" "day" "week" "month" "year" "category1" "category2" "category3" "category4" "brand" "modelID"
|
// Items Enum: "unknownDimension" "sku" "spu" "day" "week" "month" "year" "category1" "category2" "category3" "category4" "brand" "modelID"
|
||||||
Dimension []string `json:"dimension"`
|
Dimension []GetAnalyticsDataDimension `json:"dimension"`
|
||||||
|
|
||||||
// Filters
|
// Filters
|
||||||
Filters []struct {
|
Filters []struct {
|
||||||
@@ -27,9 +27,7 @@ type GetAnalyticsDataParams struct {
|
|||||||
Key string `json:"key"`
|
Key string `json:"key"`
|
||||||
|
|
||||||
// Comparison operation
|
// Comparison operation
|
||||||
//
|
Operation GetAnalyticsDataFilterOperation `json:"operation"`
|
||||||
// Enum: "EQ" "GT" "GTE" "LT" "LTE"
|
|
||||||
Operation string `json:"operation"`
|
|
||||||
|
|
||||||
// Value for comparison
|
// Value for comparison
|
||||||
Value string `json:"value"`
|
Value string `json:"value"`
|
||||||
@@ -41,11 +39,7 @@ type GetAnalyticsDataParams struct {
|
|||||||
Limit int64 `json:"limit"`
|
Limit int64 `json:"limit"`
|
||||||
|
|
||||||
// Specify up to 14 metrics. If there are more, you will get an error with the InvalidArgument code
|
// Specify up to 14 metrics. If there are more, you will get an error with the InvalidArgument code
|
||||||
//
|
Metrics []GetAnalyticsDataFilterMetric `json:"metrics"`
|
||||||
// Items Enum: "unknown_metric" "hits_view_search" "hits_view_pdp" "hits_view" "hits_tocart_search" "hits_tocart_pdp" "hits_tocart" "session_view_search"
|
|
||||||
// "session_view_pdp" "session_view" "conv_tocart_search" "conv_tocart_pdp" "conv_tocart" "revenue" "returns" "cancellations" "ordered_units" "delivered_units"
|
|
||||||
// "adv_view_pdp" "adv_view_search_category" "adv_view_all" "adv_sum_all" "position_category" "postings" "postings_premium"
|
|
||||||
Metrics []string `json:"metrics"`
|
|
||||||
|
|
||||||
// Number of elements that will be skipped in the response. For example, if `offset=10`, the response will start with the 11th element found
|
// 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"`
|
Offset int64 `json:"offset"`
|
||||||
@@ -57,12 +51,10 @@ type GetAnalyticsDataParams struct {
|
|||||||
// Report sorting settings
|
// Report sorting settings
|
||||||
type GetAnalyticsDataSort struct {
|
type GetAnalyticsDataSort struct {
|
||||||
// Metric by which the method result will be sorted
|
// Metric by which the method result will be sorted
|
||||||
Key string `json:"key"`
|
Key GetAnalyticsDataFilterMetric `json:"key"`
|
||||||
|
|
||||||
// Sorting type
|
// Sorting type
|
||||||
// - ASC — in ascending order,
|
Order Order `json:"order"`
|
||||||
// - DESC — in descending order.
|
|
||||||
Order string `json:"order"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetAnalyticsDataResponse struct {
|
type GetAnalyticsDataResponse struct {
|
||||||
@@ -118,10 +110,7 @@ type GetStocksOnWarehousesParams struct {
|
|||||||
Offset int64 `json:"offset"`
|
Offset int64 `json:"offset"`
|
||||||
|
|
||||||
// Warehouse type filter:
|
// Warehouse type filter:
|
||||||
// - EXPRESS_DARK_STORE — Ozon warehouses with Fresh delivery.
|
WarehouseType WarehouseType `json:"warehouse_type"`
|
||||||
// - NOT_EXPRESS_DARK_STORE — Ozon warehouses without Fresh delivery.
|
|
||||||
// - ALL — all Ozon warehouses.
|
|
||||||
WarehouseType string `json:"warehouse_type"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetStocksOnWarehousesResponse struct {
|
type GetStocksOnWarehousesResponse struct {
|
||||||
|
|||||||
@@ -23,12 +23,12 @@ func TestGetAnalyticsData(t *testing.T) {
|
|||||||
&GetAnalyticsDataParams{
|
&GetAnalyticsDataParams{
|
||||||
DateFrom: core.TimeFromString(t, "2006-01-02", "2020-09-01"),
|
DateFrom: core.TimeFromString(t, "2006-01-02", "2020-09-01"),
|
||||||
DateTo: core.TimeFromString(t, "2006-01-02", "2021-10-15"),
|
DateTo: core.TimeFromString(t, "2006-01-02", "2021-10-15"),
|
||||||
Dimension: []string{"sku", "day"},
|
Dimension: []GetAnalyticsDataDimension{SKUDimension, DayDimension},
|
||||||
Metrics: []string{"hits_view_search"},
|
Metrics: []GetAnalyticsDataFilterMetric{AdvViewAll},
|
||||||
Sort: []GetAnalyticsDataSort{
|
Sort: []GetAnalyticsDataSort{
|
||||||
{
|
{
|
||||||
Key: "hits_view_search",
|
Key: HistViewPDP,
|
||||||
Order: "DESC",
|
Order: Descending,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Limit: 1000,
|
Limit: 1000,
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ type GetProductTreeParams struct {
|
|||||||
CategoryId int64 `json:"category_id"`
|
CategoryId int64 `json:"category_id"`
|
||||||
|
|
||||||
// Response language
|
// Response language
|
||||||
Language string `json:"language" default:"DEFAULT"`
|
Language Language `json:"language" default:"DEFAULT"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetProductTreeResponse struct {
|
type GetProductTreeResponse struct {
|
||||||
@@ -54,13 +54,13 @@ func (c Categories) Tree(params *GetProductTreeParams) (*GetProductTreeResponse,
|
|||||||
|
|
||||||
type GetCategoryAttributesParams struct {
|
type GetCategoryAttributesParams struct {
|
||||||
// Filter by characteristics
|
// Filter by characteristics
|
||||||
AttributeType string `json:"attribute_type" default:"ALL"`
|
AttributeType AttributeType `json:"attribute_type" default:"ALL"`
|
||||||
|
|
||||||
// Category identifier
|
// Category identifier
|
||||||
CategoryId []int64 `json:"category_id"`
|
CategoryId []int64 `json:"category_id"`
|
||||||
|
|
||||||
// Response language
|
// Response language
|
||||||
Language string `json:"language" default:"DEFAULT"`
|
Language Language `json:"language" default:"DEFAULT"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetCategoryAttributesResponse struct {
|
type GetCategoryAttributesResponse struct {
|
||||||
@@ -151,7 +151,7 @@ type GetAttributeDictionaryParams struct {
|
|||||||
|
|
||||||
// Response language
|
// Response language
|
||||||
// The default language is Russian
|
// The default language is Russian
|
||||||
Language string `json:"language" default:"DEFAULT"`
|
Language Language `json:"language" default:"DEFAULT"`
|
||||||
|
|
||||||
LastValueId int64 `json:"last_value_id"`
|
LastValueId int64 `json:"last_value_id"`
|
||||||
|
|
||||||
|
|||||||
122
ozon/common.go
Normal file
122
ozon/common.go
Normal file
@@ -0,0 +1,122 @@
|
|||||||
|
package ozon
|
||||||
|
|
||||||
|
type Order string
|
||||||
|
|
||||||
|
const (
|
||||||
|
Ascending Order = "ASC"
|
||||||
|
Descending Order = "DESC"
|
||||||
|
)
|
||||||
|
|
||||||
|
type GetAnalyticsDataFilterOperation string
|
||||||
|
|
||||||
|
const (
|
||||||
|
Equal GetAnalyticsDataFilterOperation = "EQ"
|
||||||
|
Greater GetAnalyticsDataFilterOperation = "GT"
|
||||||
|
GreaterEqual GetAnalyticsDataFilterOperation = "GTE"
|
||||||
|
Lesser GetAnalyticsDataFilterOperation = "LT"
|
||||||
|
LesserEqual GetAnalyticsDataFilterOperation = "LTE"
|
||||||
|
)
|
||||||
|
|
||||||
|
type GetAnalyticsDataFilterMetric string
|
||||||
|
|
||||||
|
const (
|
||||||
|
UnknownMetric GetAnalyticsDataFilterMetric = "unknown_metric"
|
||||||
|
HitsViewSearch GetAnalyticsDataFilterMetric = "hits_view_search"
|
||||||
|
HistViewPDP GetAnalyticsDataFilterMetric = "hits_view_pdp"
|
||||||
|
HitsView GetAnalyticsDataFilterMetric = "hist_view"
|
||||||
|
HitsToCartSearch GetAnalyticsDataFilterMetric = "hits_tocart_search"
|
||||||
|
HitsToCartPDP GetAnalyticsDataFilterMetric = "hits_tocart_pdp"
|
||||||
|
SessionViewSearch GetAnalyticsDataFilterMetric = "session_view_search"
|
||||||
|
SessionViewPDP GetAnalyticsDataFilterMetric = "session_view_pdp"
|
||||||
|
SessionView GetAnalyticsDataFilterMetric = "session_view"
|
||||||
|
ConvToCartSearch GetAnalyticsDataFilterMetric = "conv_tocart_search"
|
||||||
|
ConvToCartPDP GetAnalyticsDataFilterMetric = "conv_tocart_pdp"
|
||||||
|
ConvToCart GetAnalyticsDataFilterMetric = "conv_tocart"
|
||||||
|
Revenue GetAnalyticsDataFilterMetric = "revenue"
|
||||||
|
ReturnsMetric GetAnalyticsDataFilterMetric = "returns"
|
||||||
|
CancellationsMetric GetAnalyticsDataFilterMetric = "cancellations"
|
||||||
|
OrderedUnits GetAnalyticsDataFilterMetric = "ordered_units"
|
||||||
|
DeliveredUnits GetAnalyticsDataFilterMetric = "delivered_units"
|
||||||
|
AdvViewPDP GetAnalyticsDataFilterMetric = "adv_view_pdp"
|
||||||
|
AdvViewSearchCategory GetAnalyticsDataFilterMetric = "adv_view_search_category"
|
||||||
|
AdvViewAll GetAnalyticsDataFilterMetric = "adv_view_all"
|
||||||
|
AdvSumAll GetAnalyticsDataFilterMetric = "adv_sum_all"
|
||||||
|
PositionCategory GetAnalyticsDataFilterMetric = "position_category"
|
||||||
|
PostingsMetric GetAnalyticsDataFilterMetric = "postings"
|
||||||
|
PostingsPremium GetAnalyticsDataFilterMetric = "postings_premium"
|
||||||
|
)
|
||||||
|
|
||||||
|
type WarehouseType string
|
||||||
|
|
||||||
|
const (
|
||||||
|
// Ozon warehouses with Fresh delivery
|
||||||
|
ExpressDarkStore WarehouseType = "EXPRESS_DARK_STORE"
|
||||||
|
|
||||||
|
// Ozon warehouses without Fresh delivery
|
||||||
|
NotExressDarkStore WarehouseType = "NOT_EXPRESS_DARK_STORE"
|
||||||
|
|
||||||
|
// All Ozon warehouses
|
||||||
|
ALLWarehouseType WarehouseType = "ALL"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Language string
|
||||||
|
|
||||||
|
const (
|
||||||
|
Default Language = "DEFAULT"
|
||||||
|
Russian Language = "RU"
|
||||||
|
English Language = "EN"
|
||||||
|
Turkish Language = "TR"
|
||||||
|
Chinese Language = "ZH_HANS"
|
||||||
|
)
|
||||||
|
|
||||||
|
type AttributeType string
|
||||||
|
|
||||||
|
const (
|
||||||
|
All AttributeType = "ALL"
|
||||||
|
Required AttributeType = "REQUIRED"
|
||||||
|
Optional AttributeType = "OPTIONAL"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ListDiscountRequestsStatus string
|
||||||
|
|
||||||
|
const (
|
||||||
|
New ListDiscountRequestsStatus = "NEW"
|
||||||
|
Seen ListDiscountRequestsStatus = "SEEN"
|
||||||
|
Approved ListDiscountRequestsStatus = "APPROVED"
|
||||||
|
PartlyApproved ListDiscountRequestsStatus = "PARTLY_APPROVED"
|
||||||
|
Declined ListDiscountRequestsStatus = "DECLINED"
|
||||||
|
AutoDeclined ListDiscountRequestsStatus = "AUTO_DECLINED"
|
||||||
|
DeclinedByUser ListDiscountRequestsStatus = "DECLINED_BY_USER"
|
||||||
|
Coupon ListDiscountRequestsStatus = "COUPON"
|
||||||
|
Purchased ListDiscountRequestsStatus = "PURCHASED"
|
||||||
|
)
|
||||||
|
|
||||||
|
type WorkingDay string
|
||||||
|
|
||||||
|
const (
|
||||||
|
Mon WorkingDay = "1"
|
||||||
|
Tue WorkingDay = "2"
|
||||||
|
Wed WorkingDay = "3"
|
||||||
|
Thu WorkingDay = "4"
|
||||||
|
Fri WorkingDay = "5"
|
||||||
|
Sat WorkingDay = "6"
|
||||||
|
Sun WorkingDay = "7"
|
||||||
|
)
|
||||||
|
|
||||||
|
type GetAnalyticsDataDimension string
|
||||||
|
|
||||||
|
const (
|
||||||
|
UnknownDimension GetAnalyticsDataDimension = "unknownDimension"
|
||||||
|
SKUDimension GetAnalyticsDataDimension = "sku"
|
||||||
|
SPUDimension GetAnalyticsDataDimension = "spu"
|
||||||
|
DayDimension GetAnalyticsDataDimension = "day"
|
||||||
|
WeekDimension GetAnalyticsDataDimension = "week"
|
||||||
|
MonthDimension GetAnalyticsDataDimension = "month"
|
||||||
|
YearDimension GetAnalyticsDataDimension = "year"
|
||||||
|
Category1Dimension GetAnalyticsDataDimension = "category1"
|
||||||
|
Category2Dimension GetAnalyticsDataDimension = "category2"
|
||||||
|
Category3Dimension GetAnalyticsDataDimension = "category3"
|
||||||
|
Category4Dimension GetAnalyticsDataDimension = "category4"
|
||||||
|
BrandDimension GetAnalyticsDataDimension = "brand"
|
||||||
|
ModelIDDimension GetAnalyticsDataDimension = "modelID"
|
||||||
|
)
|
||||||
@@ -464,7 +464,7 @@ func (c Promotions) RemoveProductsToHotSale(params *RemoveProductsToHotSaleParam
|
|||||||
|
|
||||||
type ListDiscountRequestsParams struct {
|
type ListDiscountRequestsParams struct {
|
||||||
// Discount request status
|
// Discount request status
|
||||||
Status string `json:"status" default:"UNKNOWN"`
|
Status ListDiscountRequestsStatus `json:"status" default:"UNKNOWN"`
|
||||||
|
|
||||||
// Page number from which you want to download the list of discount requests
|
// Page number from which you want to download the list of discount requests
|
||||||
Page uint64 `json:"page"`
|
Page uint64 `json:"page"`
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ type GetListOfWarehousesResponse struct {
|
|||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
|
|
||||||
// Warehouse working days
|
// Warehouse working days
|
||||||
WorkingDays []string `json:"working_days"`
|
WorkingDays []WorkingDay `json:"working_days"`
|
||||||
} `json:"resulCommonResponse"`
|
} `json:"resulCommonResponse"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user