-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.go
220 lines (198 loc) · 7.56 KB
/
models.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
package gpp
import (
"github.com/bots-house/google-play-parser/internal/shared"
"github.com/bots-house/google-play-parser/models"
)
type App struct {
AppID string `json:"app_id"`
URL string `json:"url"`
Title string `json:"title"`
Description string `json:"description,omitempty"`
DescriptionText string `json:"description_text,omitempty"`
Summary string `json:"summary"`
Installs string `json:"installs,omitempty"`
MinInstalls float64 `json:"min_installs,omitempty"`
MaxInstalls float64 `json:"max_installs,omitempty"`
Currency string `json:"currency"`
Price float64 `json:"price,omitempty"`
PriceText string `json:"price_text,omitempty"`
Free bool `json:"free"`
Score float64 `json:"score"`
ScoreText string `json:"score_text"`
Ratings float64 `json:"ratings,omitempty"`
Reviews float64 `json:"reviews,omitempty"`
Histogram map[int]float64 `json:"histogram,omitempty"`
Available bool `json:"available,omitempty"`
OffersIAP bool `json:"offers_iap,omitempty"`
IAPRange string `json:"iap_range,omitempty"`
AndroidVersion string `json:"android_version,omitempty"`
AndroidVersionText string `json:"android_version_text,omitempty"`
Developer string `json:"developer"`
DeveloperID string `json:"developer_id,omitempty"`
DeveloperEmail string `json:"developer_email,omitempty"`
DeveloperWebsite string `json:"developer_website,omitempty"`
DeveloperAddress string `json:"developer_address,omitempty"`
PrivacyPolicy string `json:"privacy_policy,omitempty"`
DeveloperInternalID string `json:"developer_internal_id,omitempty"`
Genre string `json:"genre,omitempty"`
GenreID string `json:"genre_id,omitempty"`
FamilyGenre string `json:"family_genre,omitempty"`
FamilyGenreID string `json:"family_genre_id,omitempty"`
Icon string `json:"icon"`
HeaderImage string `json:"header_image,omitempty"`
Screenshots []string `json:"screenshots,omitempty"`
Video string `json:"video,omitempty"`
VideoImage string `json:"video_image,omitempty"`
PreviewVideo string `json:"preview_video,omitempty"`
ContentRating string `json:"content_rating,omitempty"`
ContentRatingDescription string `json:"content_rating_description,omitempty"`
AdSupported bool `json:"ad_supported,omitempty"`
Released string `json:"released,omitempty"`
Updated float64 `json:"updated,omitempty"`
Version string `json:"version,omitempty"`
RecentChanges string `json:"recent_changes,omitempty"`
Comments []any `json:"comments,omitempty"`
InAppPurchase bool `json:"in_app_purchase"`
}
func newFromInternal(app *models.App) App {
return App{
AppID: app.AppID,
URL: app.URL,
Title: app.Title,
Description: app.Description,
DescriptionText: app.DescriptionText,
Summary: app.Summary,
Installs: app.Installs,
MinInstalls: app.MinInstalls,
MaxInstalls: app.MaxInstalls,
Currency: app.Currency,
Price: app.Price,
PriceText: app.PriceText,
Free: app.Free,
Score: app.Score,
ScoreText: app.ScoreText,
Ratings: app.Ratings,
Reviews: app.Reviews,
Histogram: app.Histogram,
Available: app.Available,
OffersIAP: app.OffersIAP,
IAPRange: app.IAPRange,
AndroidVersion: app.AndroidVersion,
AndroidVersionText: app.AndroidVersionText,
Developer: app.Developer,
DeveloperID: app.DeveloperID,
DeveloperEmail: app.DeveloperEmail,
DeveloperWebsite: app.DeveloperWebsite,
DeveloperAddress: app.DeveloperAddress,
Genre: app.Genre,
GenreID: app.GenreID,
FamilyGenre: app.FamilyGenre,
FamilyGenreID: app.FamilyGenreID,
Icon: app.Icon,
HeaderImage: app.HeaderImage,
Screenshots: app.Screenshots,
Video: app.Video,
VideoImage: app.VideoImage,
PreviewVideo: app.PreviewVideo,
ContentRating: app.ContentRating,
PrivacyPolicy: app.PrivacyPolicy,
ContentRatingDescription: app.ContentRatingDescription,
AdSupported: app.AdSupported,
Released: app.Released,
Updated: app.Updated,
Version: app.Version,
RecentChanges: app.RecentChanges,
Comments: app.Comments,
InAppPurchase: app.InAppPurchase,
}
}
func newApps(apps ...models.App) []App {
result := make([]App, 0, len(apps))
for idx := range apps {
app := apps[idx]
result = append(result, newFromInternal(&app))
}
return result
}
func (app *App) Assign(rhs *App) App {
return shared.Assign(app, rhs)
}
type ApplicationSpec struct {
AppID string
Lang string
Country string
Count int
Full bool
}
func (spec ApplicationSpec) toInternal() models.ApplicationSpec {
return models.ApplicationSpec{
AppID: spec.AppID,
Country: spec.Country,
Lang: spec.Lang,
Count: spec.Count,
Full: spec.Full,
}
}
type ListSpec struct {
Count int
Age string
Lang string
Country string
Category string
Collection string
Full bool
}
func (spec ListSpec) toInternal() models.ListSpec {
return models.ListSpec{
Count: spec.Count,
Age: spec.Age,
Lang: spec.Lang,
Country: spec.Country,
Category: spec.Category,
Collection: spec.Collection,
Full: spec.Full,
}
}
type DeveloperSpec struct {
DevID string
Lang string
Country string
Count int
Full bool
}
func (spec DeveloperSpec) toInternal() models.DeveloperSpec {
return models.DeveloperSpec{
DevID: spec.DevID,
Lang: spec.Lang,
Country: spec.Country,
Count: spec.Count,
Full: spec.Full,
}
}
type SearchSpec models.SearchSpec
type DataSafety models.DataSafety
type Permission models.Permission
type ReviewsSpec struct {
AppID string
Lang string
Country string
Count int
Sort ReviewsSort
}
func (spec ReviewsSpec) toInternal() models.ReviewsSpec {
return models.ReviewsSpec{
AppID: spec.AppID,
Country: spec.Country,
Lang: spec.Lang,
Count: spec.Count,
Sort: spec.Sort.int(),
}
}
type ReviewsSort int
func (sort ReviewsSort) int() int { return int(sort) }
const (
ReviewsSortHelpfulness ReviewsSort = iota + 1
ReviewsSortNewest
ReviewsSortRating
)
type Review models.Review