ruboty-app_annie 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0c12e6413c774ab68051b55a5bd4ec0f47397e0a
4
- data.tar.gz: beda80f4a60a7efaa6eaee41502b58442fe40ec3
3
+ metadata.gz: 69b2cf002a37be4266e14ad65b7e5e07bd9932ca
4
+ data.tar.gz: abb250f856ae690fb7abe5c26ffea79a41d61082
5
5
  SHA512:
6
- metadata.gz: 12ceddf1a130947bede8266798301c68b0862a75d5ec4e7b7e9bbec7812266222f72f35b8307e3e51736cfdd8743a97dd4d348bdfa859c2053967b9b64440462
7
- data.tar.gz: c585e6bea9dd5f6ad91144127148abf5f13362d23dd279a022797ab2b5e9496ed040349649eae4394858a9b60c709534ef46cf5df0fb1f0ccfd182e223bc0307
6
+ metadata.gz: c68ef82ba6804bd23e072cb481e37a930cb197f8504af7130703ab06641d716ba4a21999fdfba28dc8ef54cf88badd1512e0152782ae2e1a6f5c0d9466726b5c
7
+ data.tar.gz: a5430b8971db22da26797833fcc93e530d24320ecc99e3b224907160cc2447a1e3f2e2da25d19e9ff392fb9304bd8914987e81fa2f2613fbb1334098c96b8ab6
data/README.md CHANGED
@@ -16,6 +16,7 @@ gem "ruboty-app_annie"
16
16
  ```
17
17
  @ruboty annie list accounts - Retrieve all account connections available in an App Annie user account
18
18
  @ruboty annie list products of <account_id> - Retrieve the product list of an Analytics Account Connection
19
+ @ruboty annie list {ios|android} reviews of <product_id> from <start_date> to <end_date> in <country> - Retrieve one product’s reviews
19
20
  ```
20
21
 
21
22
  ## ENV
@@ -0,0 +1,93 @@
1
+ module Ruboty
2
+ module AppAnnie
3
+ module Actions
4
+ class ListReviews < Base
5
+ def call
6
+ list_reviews if exists_reviews?
7
+ end
8
+
9
+ private
10
+
11
+ def list_reviews
12
+ message.reply(reviews.join("\n\n"))
13
+ end
14
+
15
+ def exists_reviews?
16
+ !reviews.empty?
17
+ end
18
+
19
+ def reviews
20
+ @reviews ||= client.product_reviews(market, given_product_id, given_start_date, given_end_date, given_country).body.reviews.map do |review|
21
+ "#{market_string(market)} #{product.product_name} #{version_string(review)}\n" + "> #{rating_string(review)}#{title_string(review)}\n" + "> ```#{review.text}```"
22
+ end
23
+ end
24
+
25
+ def product
26
+ @product ||= client.product_details(market, given_product_id).body.product
27
+ end
28
+
29
+ def market_string(market)
30
+ case market
31
+ when "ios" then ios_string
32
+ when "google-play" then android_string
33
+ end
34
+ end
35
+
36
+ def ios_string
37
+ ENV["APP_ANNIE_IOS_STRING"] || "iOS:"
38
+ end
39
+
40
+ def android_string
41
+ ENV["APP_ANNIE_ANDROID_STRING"] || "Android:"
42
+ end
43
+
44
+ def version_string(review)
45
+ review.version.nil? ? "" : "- v#{review.version}"
46
+ end
47
+
48
+ def rating_string(review)
49
+ (positive_star_string * review.rating) + (negative_star_string * (5 - review.rating))
50
+ end
51
+
52
+ def positive_star_string
53
+ ENV["APP_ANNIE_POSITIVE_STAR_STRING"] || "★"
54
+ end
55
+
56
+ def negative_star_string
57
+ ENV["APP_ANNIE_NEGATIVE_STAR_STRING"] || "☆"
58
+ end
59
+
60
+ def title_string(review)
61
+ review.title.nil? ? "" : " / *#{review.title}*"
62
+ end
63
+
64
+ def market
65
+ case given_market
66
+ when "ios" then "ios"
67
+ when "android" then "google-play"
68
+ end
69
+ end
70
+
71
+ def given_market
72
+ message[:market]
73
+ end
74
+
75
+ def given_product_id
76
+ message[:product_id]
77
+ end
78
+
79
+ def given_start_date
80
+ message[:start_date]
81
+ end
82
+
83
+ def given_end_date
84
+ message[:end_date]
85
+ end
86
+
87
+ def given_country
88
+ message[:country]
89
+ end
90
+ end
91
+ end
92
+ end
93
+ end
@@ -1,5 +1,5 @@
1
1
  module Ruboty
2
2
  module AppAnnie
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
@@ -4,5 +4,6 @@ require "ruboty"
4
4
  require "ruboty/app_annie/actions/base"
5
5
  require "ruboty/app_annie/actions/list_accounts"
6
6
  require "ruboty/app_annie/actions/list_products"
7
+ require "ruboty/app_annie/actions/list_reviews"
7
8
  require "ruboty/app_annie/version"
8
9
  require "ruboty/handlers/app_annie"
@@ -15,6 +15,12 @@ module Ruboty
15
15
  description: "Retrieve the product list of an Analytics Account Connection",
16
16
  )
17
17
 
18
+ on(
19
+ /annie list (?<market>ios|android) reviews of (?<product_id>.+) from (?<start_date>.+) to (?<end_date>.+) in (?<country>.+)\z/,
20
+ name: "list_reviews",
21
+ description: "Retrieve one product’s reviews",
22
+ )
23
+
18
24
  def list_accounts(message)
19
25
  Ruboty::AppAnnie::Actions::ListAccounts.new(message).call
20
26
  end
@@ -22,6 +28,10 @@ module Ruboty
22
28
  def list_products(message)
23
29
  Ruboty::AppAnnie::Actions::ListProducts.new(message).call
24
30
  end
31
+
32
+ def list_reviews(message)
33
+ Ruboty::AppAnnie::Actions::ListReviews.new(message).call
34
+ end
25
35
  end
26
36
  end
27
37
  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.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - fakestarbaby
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-19 00:00:00.000000000 Z
11
+ date: 2016-04-20 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_reviews.rb
89
90
  - lib/ruboty/app_annie/version.rb
90
91
  - lib/ruboty/handlers/app_annie.rb
91
92
  - ruboty-app_annie.gemspec
@@ -109,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
110
  version: '0'
110
111
  requirements: []
111
112
  rubyforge_project:
112
- rubygems_version: 2.4.5.1
113
+ rubygems_version: 2.5.1
113
114
  signing_key:
114
115
  specification_version: 4
115
116
  summary: Manage App Annie via Ruboty.