-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmodel.go
57 lines (47 loc) · 1.6 KB
/
model.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
package main
import (
"github.com/OlegSchmidt/soup"
)
// AppReview stores all information related to a review found on the Google Play Page
type AppReview struct {
ReviewID string `json:"review_id"`
PackageName string `json:"package_name"`
Author string `json:"author"`
Date int64 `json:"date_posted"`
Rating int `json:"rating"`
Title string `json:"title"`
Body string `json:"body"`
PermaLink string `json:"perma_link"`
Errors []string `json:"errors"`
}
// struct for the response
type AppReviewResponse struct {
Status int `json:"status"`
Error string `json:"error"`
Reviews []AppReview `json:"reviews"`
}
func (review AppReview) fillBySoup(packageName string, documentFull soup.Root, documentReview soup.Root) AppReview {
var lastError error = nil
review.PackageName = packageName
review.Author, lastError = getHtmlReviewAuthor(documentReview)
if lastError != nil {
review.Errors = append(review.Errors, lastError.Error())
}
review.Date, lastError = getHtmlReviewDate(documentReview)
if lastError != nil {
review.Errors = append(review.Errors, lastError.Error())
}
review.Rating, lastError = getHtmlReviewRating(documentReview)
if lastError != nil {
review.Errors = append(review.Errors, lastError.Error())
}
review.Title, lastError = getHtmlReviewTitle(documentReview)
if lastError != nil {
review.Errors = append(review.Errors, lastError.Error())
}
review.Body, lastError = getHtmlReviewBody(documentReview)
if lastError != nil {
review.Errors = append(review.Errors, lastError.Error())
}
return review
}