ruboty-app_annie 0.0.9 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/ruboty/app_annie.rb +1 -0
- data/lib/ruboty/app_annie/actions/list_ranks.rb +111 -0
- data/lib/ruboty/app_annie/version.rb +1 -1
- data/lib/ruboty/handlers/app_annie.rb +10 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14cd665a6737de86b045a84effc4fe1199a961a3
|
4
|
+
data.tar.gz: fb18ee0780792c53601e79d2c4bc0e4833332a2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00be45b9084fd0d9681cb882b24c352cf21476e37705be23deae651d9167695f253d93cb5263c51ebe9a7b04f2d503aac228e05c3471d36630f2c182ca93ee32
|
7
|
+
data.tar.gz: ccee4390045e9f38267dd7b23eeca3de0ea2f8949312e94f3305339303e734b5583778f5b4574bb562a09baeda0fae92ebfaddc614478dd53c56d9b8a4945022
|
data/README.md
CHANGED
@@ -18,6 +18,8 @@ gem "ruboty-app_annie"
|
|
18
18
|
@ruboty annie list products of <account_id> - Retrieve the product list of an Analytics Account Connection
|
19
19
|
@ruboty annie list {ios|android} reviews of <product_id> from <start_date> to <end_date> in <country> - Retrieve one product’s reviews
|
20
20
|
@ruboty annie list {ios|android} reviews of <product_id> days ago <days_ago> in <country> - Retrieve one product’s reviews of days ago
|
21
|
+
@ruboty annie list {ios|android} all reviews days ago <days_ago> in <country> - Retrieve all product's reviews of days ago
|
22
|
+
@ruboty annie list {ios|android} all ranks of <feed> days ago <days_ago> in <country> and <category> - Retrieve all product's ranks of days ago
|
21
23
|
```
|
22
24
|
|
23
25
|
## ENV
|
data/lib/ruboty/app_annie.rb
CHANGED
@@ -7,6 +7,7 @@ require "ruboty"
|
|
7
7
|
require "ruboty/app_annie/actions/base"
|
8
8
|
require "ruboty/app_annie/actions/list_accounts"
|
9
9
|
require "ruboty/app_annie/actions/list_products"
|
10
|
+
require "ruboty/app_annie/actions/list_ranks"
|
10
11
|
require "ruboty/app_annie/actions/list_reviews"
|
11
12
|
require "ruboty/app_annie/version"
|
12
13
|
require "ruboty/handlers/app_annie"
|
@@ -0,0 +1,111 @@
|
|
1
|
+
module Ruboty
|
2
|
+
module AppAnnie
|
3
|
+
module Actions
|
4
|
+
class ListRanks < Base
|
5
|
+
def call
|
6
|
+
initialize_date_conditions
|
7
|
+
|
8
|
+
case
|
9
|
+
when !exists_ranks?
|
10
|
+
return true
|
11
|
+
else
|
12
|
+
list_ranks
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def exists_ranks?
|
19
|
+
!ranks.empty?
|
20
|
+
end
|
21
|
+
|
22
|
+
def list_ranks
|
23
|
+
message.reply(ranks.join("\n"))
|
24
|
+
end
|
25
|
+
|
26
|
+
def initialize_date_conditions
|
27
|
+
days_ago = Date.today.ago(given_days_ago.to_i.days).to_date.to_s
|
28
|
+
@start_date = days_ago
|
29
|
+
@end_date = days_ago
|
30
|
+
rescue IndexError
|
31
|
+
end
|
32
|
+
|
33
|
+
def ranks
|
34
|
+
reply_ranks = []
|
35
|
+
client.products(account.account_id).body.products.select{ |p| p.status }.map do |p|
|
36
|
+
reply_rank = product_ranks(p.product_id, p.product_name)
|
37
|
+
reply_ranks << reply_rank unless reply_rank.nil?
|
38
|
+
end
|
39
|
+
reply_ranks
|
40
|
+
end
|
41
|
+
|
42
|
+
def product_ranks(product_id, product_name)
|
43
|
+
response = client.product_ranks(market, product_id, given_start_date, given_end_date, given_country, given_category, given_feed).body.product_ranks
|
44
|
+
return if response.empty?
|
45
|
+
|
46
|
+
response.first.ranks.map do |key, value|
|
47
|
+
"#{market_string(market)} #{key} #{value} #{product_name}"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def account
|
52
|
+
client.accounts.body.accounts.select { |a| a.market == market }.first
|
53
|
+
end
|
54
|
+
|
55
|
+
def product(product_id)
|
56
|
+
client.product_details(market, product_id).body.product
|
57
|
+
end
|
58
|
+
|
59
|
+
def market_string(market)
|
60
|
+
case market
|
61
|
+
when "ios" then ios_string
|
62
|
+
when "google-play" then android_string
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def ios_string
|
67
|
+
ENV["APP_ANNIE_IOS_STRING"] || "iOS:"
|
68
|
+
end
|
69
|
+
|
70
|
+
def android_string
|
71
|
+
ENV["APP_ANNIE_ANDROID_STRING"] || "Android:"
|
72
|
+
end
|
73
|
+
|
74
|
+
def market
|
75
|
+
case given_market
|
76
|
+
when "ios" then "ios"
|
77
|
+
when "android" then "google-play"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def given_market
|
82
|
+
message[:market]
|
83
|
+
end
|
84
|
+
|
85
|
+
def given_feed
|
86
|
+
message[:feed]
|
87
|
+
end
|
88
|
+
|
89
|
+
def given_start_date
|
90
|
+
@start_date ||= message[:start_date]
|
91
|
+
end
|
92
|
+
|
93
|
+
def given_end_date
|
94
|
+
@end_date ||= message[:end_date]
|
95
|
+
end
|
96
|
+
|
97
|
+
def given_days_ago
|
98
|
+
message[:days_ago]
|
99
|
+
end
|
100
|
+
|
101
|
+
def given_country
|
102
|
+
message[:country]
|
103
|
+
end
|
104
|
+
|
105
|
+
def given_category
|
106
|
+
message[:category]
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
@@ -33,6 +33,12 @@ module Ruboty
|
|
33
33
|
description: "Retrieve all product's reviews of days ago",
|
34
34
|
)
|
35
35
|
|
36
|
+
on(
|
37
|
+
/annie list (?<market>(?:ios|android)) all ranks of (?<feed>.+) days ago (?<days_ago>.+) in (?<country>.+) and (?<category>.+)\z/,
|
38
|
+
name: "list_all_ranks_of_days_ago",
|
39
|
+
description: "Retrieve all product's ranks of days ago",
|
40
|
+
)
|
41
|
+
|
36
42
|
def list_accounts(message)
|
37
43
|
Ruboty::AppAnnie::Actions::ListAccounts.new(message).call
|
38
44
|
end
|
@@ -52,6 +58,10 @@ module Ruboty
|
|
52
58
|
def list_all_reviews_of_days_ago(message)
|
53
59
|
Ruboty::AppAnnie::Actions::ListReviews.new(message).call
|
54
60
|
end
|
61
|
+
|
62
|
+
def list_all_ranks_of_days_ago(message)
|
63
|
+
Ruboty::AppAnnie::Actions::ListRanks.new(message).call
|
64
|
+
end
|
55
65
|
end
|
56
66
|
end
|
57
67
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruboty-app_annie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- fakestarbaby
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruboty
|
@@ -86,6 +86,7 @@ files:
|
|
86
86
|
- lib/ruboty/app_annie/actions/base.rb
|
87
87
|
- lib/ruboty/app_annie/actions/list_accounts.rb
|
88
88
|
- lib/ruboty/app_annie/actions/list_products.rb
|
89
|
+
- lib/ruboty/app_annie/actions/list_ranks.rb
|
89
90
|
- lib/ruboty/app_annie/actions/list_reviews.rb
|
90
91
|
- lib/ruboty/app_annie/version.rb
|
91
92
|
- lib/ruboty/handlers/app_annie.rb
|