274 lines
8.6 KiB
Go
274 lines
8.6 KiB
Go
package sravni
|
|
|
|
import (
|
|
"time"
|
|
|
|
"git.loyso.art/frx/kurious/internal/common/errors"
|
|
)
|
|
|
|
const (
|
|
ErrClientNotInited errors.SimpleError = "client was not inited"
|
|
)
|
|
|
|
type PageStateRuntimeConfig struct {
|
|
BrandingURL string `json:"brandingUrl"`
|
|
Release string `json:"release"`
|
|
Environment string `json:"environment"`
|
|
Gateway string `json:"gatewayUrl"`
|
|
APIGatewayURL string `json:"apiGatewayUrl"`
|
|
EducationURL string `json:"educationUrl"`
|
|
PhoneVerifierURL string `json:"phoneVerifierUrl"`
|
|
WebPath string `json:"webPath"`
|
|
ServiceName string `json:"serviceName"`
|
|
OrgnazationURL string `json:"organizationsUrl"`
|
|
}
|
|
|
|
type Link struct {
|
|
URL string `json:"url"`
|
|
Title string `json:"title"`
|
|
}
|
|
|
|
type ReduxStatePrefooterItem struct {
|
|
Title string `json:"title"`
|
|
Links []Link `json:"links"`
|
|
}
|
|
|
|
type ReduxMetadata struct {
|
|
Data struct {
|
|
Prefooter []ReduxStatePrefooterItem `json:"prefooter"`
|
|
} `json:"data"`
|
|
}
|
|
|
|
type field struct {
|
|
Name string `json:"name"`
|
|
Value string `json:"value"`
|
|
}
|
|
|
|
type ReduxDictionaryContainer struct {
|
|
ID string `json:"_id"`
|
|
Alias string `json:"alias"`
|
|
Name string `json:"name"`
|
|
UserID string `json:"userId"`
|
|
Created time.Time `json:"created"`
|
|
Updated time.Time `json:"updated"`
|
|
Fields []field `json:"fields"`
|
|
}
|
|
|
|
type ReduxDictionaries struct {
|
|
Data struct {
|
|
CourseThematics ReduxDictionaryContainer `json:"coursesThematics"`
|
|
LearningType ReduxDictionaryContainer `json:"learningType"`
|
|
LearningTypeSelection ReduxDictionaryContainer `json:"learningTypeSelection"`
|
|
} `json:"data"`
|
|
}
|
|
|
|
type DataContainer[T any] struct {
|
|
Data T `json:"data"`
|
|
}
|
|
|
|
type DataContainerDictionaries DataContainer[Dictionaries]
|
|
type DataContainerCategories DataContainer[map[string]int]
|
|
type DataContainerFiltersCount DataContainer[Filters]
|
|
|
|
type Dictionaries struct {
|
|
CourseThematics ReduxDictionaryContainer `json:"coursesThematics"`
|
|
LearningType ReduxDictionaryContainer `json:"learningType"`
|
|
LearningTypeSelection ReduxDictionaryContainer `json:"learningTypeSelection"`
|
|
}
|
|
|
|
type Flagged struct {
|
|
False int `json:"0"`
|
|
True int `json:"1"`
|
|
}
|
|
|
|
type Filters struct {
|
|
IsCourseProfeccion Flagged `json:"isCourseProfession"`
|
|
}
|
|
|
|
type DataSourceType string
|
|
|
|
const (
|
|
DataSourceTypeDictionaryConfig DataSourceType = "dictionaryConfig"
|
|
DataSourceTypeDictionary DataSourceType = "dictionary"
|
|
DataSourceTypeOrganization DataSourceType = "organization"
|
|
)
|
|
|
|
type ReduxDataSource struct {
|
|
Type DataSourceType `json:"type"`
|
|
Source string `json:"source"`
|
|
}
|
|
|
|
type ReduxConfigDictionaryBaseUnit struct {
|
|
Label string `json:"label"`
|
|
Value string `json:"value"`
|
|
}
|
|
|
|
type ReduxConfigDictionaryRangeUnit struct {
|
|
ReduxConfigDictionaryBaseUnit
|
|
|
|
Range struct {
|
|
From int `json:"from"`
|
|
To int `json:"to"`
|
|
} `json:"range"`
|
|
}
|
|
|
|
type ReduxConfigFilterUnit struct {
|
|
Label string `json:"label"`
|
|
Func string `json:"func"` // multiSelect, calculate, checkBox, multiSelectRange,
|
|
Properties []string `json:"properties"`
|
|
Name string `json:"name"`
|
|
DataSource string `json:"dataSource"`
|
|
IsInversion bool `json:"isInversion"`
|
|
Property string `json:"property"`
|
|
Value string `json:"value"`
|
|
}
|
|
|
|
type ReduxConfigSorting struct {
|
|
Property string `json:"property"`
|
|
// 3 more fields
|
|
}
|
|
|
|
type ReduxConfig struct {
|
|
Default struct {
|
|
SortingParameters []string `json:"sortingParameters"`
|
|
} `json:"default"`
|
|
DataSources map[string]ReduxDataSource `json:"dataSources"`
|
|
Dictionaries struct {
|
|
PriceFilter []ReduxConfigDictionaryRangeUnit `json:"dictionaryPriceFilter"`
|
|
GraphicFilter []ReduxConfigDictionaryBaseUnit `json:"dictionaryGraphicFilterNew"`
|
|
FormatFilter []ReduxConfigDictionaryBaseUnit `json:"dictionaryFormatFilterNew"`
|
|
LevelFilter []ReduxConfigDictionaryBaseUnit `json:"dictionaryLevelFilterNew"`
|
|
TimeFilter []ReduxConfigDictionaryRangeUnit `json:"dictionaryTimeFilter"`
|
|
InstallmentFilter []ReduxConfigDictionaryRangeUnit `json:"dictionaryInstallmentFilter"`
|
|
}
|
|
Filters []ReduxConfigFilterUnit `json:"filters"`
|
|
Sorting []ReduxConfigSorting `json:"sorting"`
|
|
}
|
|
|
|
type InitialReduxState struct {
|
|
Metadata ReduxMetadata `json:"metadata"`
|
|
Config ReduxConfig `json:"config"`
|
|
Dictionaries DataContainerDictionaries `json:"dictionaries"`
|
|
Categories DataContainerCategories `json:"categories"`
|
|
FiltersCount DataContainerFiltersCount `json:"filtersCount"`
|
|
}
|
|
|
|
type PageStateProperties struct {
|
|
InitialReduxState InitialReduxState `json:"initialReduxState"`
|
|
}
|
|
|
|
type PageState struct {
|
|
Page string `json:"page"`
|
|
Query map[string]string `json:"query"`
|
|
BuildID string `json:"buildId"`
|
|
RuntimeConfig PageStateRuntimeConfig `json:"runtimeConfig"`
|
|
Props PageStateProperties `json:"props"`
|
|
}
|
|
|
|
func (p *PageState) Clone() *PageState {
|
|
copiedState := *p
|
|
copiedState.Query = make(map[string]string, len(p.Query))
|
|
for k, v := range p.Query {
|
|
copiedState.Query[k] = v
|
|
}
|
|
|
|
data := p.Props.InitialReduxState.Categories.Data
|
|
copiedData := make(map[string]int, len(data))
|
|
for k, v := range data {
|
|
copiedData[k] = v
|
|
}
|
|
copiedState.Props.InitialReduxState.Categories.Data = copiedData
|
|
|
|
return &copiedState
|
|
}
|
|
|
|
type CourseDiscount struct {
|
|
PromoCode string `json:"promoCode"`
|
|
PromoCodeType string `json:"promoCodeType"`
|
|
Percent any `json:"percent"`
|
|
EndDate time.Time `json:"endDate"`
|
|
EndTime time.Time `json:"endTime"`
|
|
}
|
|
|
|
type CourseAdvertising struct {
|
|
Cost float64 `json:"cost"`
|
|
ButtonText string `json:"buttonText"`
|
|
ButtonMobileText string `json:"buttonMobileText"`
|
|
IsPartner bool `json:"isPartner"`
|
|
LabelText string `json:"labelText"`
|
|
Monetization struct {
|
|
Pixels struct {
|
|
Click string `json:"click"`
|
|
Display string `json:"display"`
|
|
} `json:"pixels"`
|
|
Kind string `json:"kind"`
|
|
} `json:"monetization"`
|
|
Dialog string `json:"dialog"`
|
|
SideBarBannerText string `json:"sideBarBannerText"`
|
|
OfferHighlightColor string `json:"offerHighlightColor"`
|
|
HasOffersID string `json:"hasOffersId"`
|
|
TrackingType string `json:"trackingType"`
|
|
Token []struct {
|
|
ID string `json:"_id"`
|
|
Token []string `json:"token"`
|
|
Updated time.Time `json:"updated"`
|
|
V int `json:"__v"`
|
|
} `json:"token"`
|
|
}
|
|
|
|
type Course struct {
|
|
ID string `json:"id"`
|
|
Name string `json:"name"`
|
|
Organization string `json:"organization"`
|
|
Discount CourseDiscount `json:"discount"`
|
|
Link string `json:"link"`
|
|
Learningtype []string `json:"learningtype"`
|
|
DateStart *time.Time `json:"dateStart"`
|
|
TimeStart *time.Time `json:"timeStart"`
|
|
TimeAllHour *float64 `json:"timeAllHour"`
|
|
TimeAllDay *float64 `json:"timeAllDay"`
|
|
TimeAllMonth *float64 `json:"timeAllMonth"`
|
|
IsTermApproximately bool `json:"isTermApproximately"`
|
|
DictionaryFormatFilterNew []string `json:"dictionaryFormatFilterNew"`
|
|
DictionaryLevelFilterNew []string `json:"dictionaryLevelFilterNew"`
|
|
Price float64 `json:"price"`
|
|
PriceAll float64 `json:"priceAll"`
|
|
PriceInstallment float64 `json:"priceInstallment"`
|
|
CourseImage string `json:"courseImage"`
|
|
WithoutDiscountPrice int `json:"withoutDiscountPrice"`
|
|
Advertising CourseAdvertising `json:"advertising"`
|
|
}
|
|
|
|
type OrganizationName struct {
|
|
Short string `json:"short"`
|
|
Full string `json:"full"`
|
|
Prepositional string `json:"prepositional"`
|
|
Genitive string `json:"genitive"`
|
|
}
|
|
|
|
type RatingsInfo struct {
|
|
ComplexCalculatedRatingValue float64 `json:"complexCalculatedRatingValue"`
|
|
ParticipantsCount int `json:"participantsCount"`
|
|
Approved int `json:"approved"`
|
|
}
|
|
|
|
type Contacts struct {
|
|
Address string `json:"address"`
|
|
Phone []string `json:"phone"`
|
|
}
|
|
|
|
type Organization struct {
|
|
ID string `json:"id"`
|
|
Alias string `json:"alias"`
|
|
License string `json:"license"`
|
|
Name OrganizationName `json:"name"`
|
|
RatingsInfo RatingsInfo `json:"ratingsInfo"`
|
|
Contacts Contacts `json:"contacts"`
|
|
Logotypes struct {
|
|
Square string `json:"square"`
|
|
Web string `json:"web"`
|
|
Android string `json:"android"`
|
|
} `json:"logotypes"`
|
|
IsLabsPartner bool `json:"isLabsPartner"`
|
|
}
|