-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstore_stats.go
140 lines (122 loc) · 4.02 KB
/
store_stats.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
package appannie
import (
"fmt"
"net/url"
)
//NOTE:
//You can only call this API for products which you have connected to Analytics or products that have been shared with you through App Annie
//Apps that are no longer published will return limited information.
func (cli *Client) ProductDetail(vertical, market, asset string, productId int) (info ProductInfo, err error) {
var resp struct {
APIResponse
Product ProductInfo
}
path := fmt.Sprintf("/%s/%s/%s/%d/details", vertical, market, asset, productId)
err = cli.request(path, nil, &resp)
if err != nil {
return
}
return resp.Product, err
}
type RatingInfo struct {
Average float32 `json:"average"`
Star5Count int `json:"star_5_count"`
Star4Count int `json:"star_4_count"`
Star3Count int `json:"star_3_count"`
Star2Count int `json:"star_2_count"`
Star1Count int `json:"star_1_count"`
RatingCount int `json:"rating_count"`
}
type ProductRatingResponse struct {
APIResponse
PagedAPIResponse
AppName string `json:"app_name"`
Ratings []struct {
Country string `json:"country"`
AllRating RatingInfo `json:"all_ratings"`
CurrentRating RatingInfo `json:"current_ratings"` //iOS and mac Only, current version ratings
} `json:"ratings"`
}
func (cli *Client) ProductRatings(vertical, market, asset string, productId, page int) (info ProductRatingResponse, err error) {
q := url.Values{"page_index": []string{fmt.Sprintf("%d", page)}}
path := fmt.Sprintf("/%s/%s/%s/%d/ratings", vertical, market, asset, productId)
err = cli.request(path, q, &info)
return
}
type ProductRankResponse struct {
APIResponse
PagedAPIResponse
ProductName string `json:"product_name"`
Device string `json:"device"`
UpdateTime map[string]string
ProductRanks []struct {
Country string
Category string
Feed string
Interval string
Ranks map[string]int
} `json:"product_ranks"`
}
//Parameter q should include params below:
// start_date: yyyy-mm-dd
// end_date: yyyy-mm-dd
// interval: default daily, or hourly
// countries: default all, refer CountryMeta()
// category: default all, refer CategoryMeta()
// feed: free | paid | grossing | new | top_new_free | top_new_paid | new_rising
// device: iphone | ipad | mac | android | x86 | x64 | arm
func (cli *Client) ProductRank(vertical, market, asset string, productId int, q url.Values) (info ProductRankResponse, err error) {
path := fmt.Sprintf("/%s/%s/%s/%d/ranks", vertical, market, asset, productId)
err = cli.request(path, q, &info)
return
}
type ProductFeatureResponse struct {
APIResponse
PagedAPIResponse
ProductName string `json:"product_name"`
Features []struct {
Level int
Position int
Date string
Country string
Device string
Section string
}
}
//Parameter q should include params below:
// start_date: yyyy-mm-dd
// end_date: yyyy-mm-dd
// countries: default all, refer CountryMeta()
// page_index: 0
func (cli *Client) ProductFeature(vertical, market, asset string, productId int, q url.Values) (info ProductFeatureResponse, err error) {
path := fmt.Sprintf("/%s/%s/%s/%d/features", vertical, market, asset, productId)
err = cli.request(path, q, &info)
return
}
type ProductReviewResponse struct {
APIResponse
PagedAPIResponse
ProductName string `json:"product_name"`
Reviews []struct {
Date string
Country string
Rating int
Title string
Text string
Reviewer string
Version string
Device string
}
}
//Parameter q should include params below:
// start_date: yyyy-mm-dd
// end_date: yyyy-mm-dd
// countries: default all, refer CountryMeta()
// verison: specific verison, such as 2.0.1, Google Play not support
// rating: default all, Options 1|2|3|4|5, support multiple ratings. Example: 1+2 or 4+5
// page_index: 0
func (cli *Client) ProductReview(vertical, market, asset string, productId int, q url.Values) (info ProductReviewResponse, err error) {
path := fmt.Sprintf("/%s/%s/%s/%d/reviews", vertical, market, asset, productId)
err = cli.request(path, q, &info)
return
}