ruboty-app_annie 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 69b2cf002a37be4266e14ad65b7e5e07bd9932ca
4
- data.tar.gz: abb250f856ae690fb7abe5c26ffea79a41d61082
3
+ metadata.gz: 258235bca361a0e59801fe949194c6241ca55211
4
+ data.tar.gz: 52c69bd1be6c2b004d1109da72af6596e533c2b2
5
5
  SHA512:
6
- metadata.gz: c68ef82ba6804bd23e072cb481e37a930cb197f8504af7130703ab06641d716ba4a21999fdfba28dc8ef54cf88badd1512e0152782ae2e1a6f5c0d9466726b5c
7
- data.tar.gz: a5430b8971db22da26797833fcc93e530d24320ecc99e3b224907160cc2447a1e3f2e2da25d19e9ff392fb9304bd8914987e81fa2f2613fbb1334098c96b8ab6
6
+ metadata.gz: 70c11d7a8732b300112b13e41dabe87fef14a22e44bf019aec36758bfe23122cf866b9a82d2e391819ae81a955a7a5b5348e994b4ec5354cdb21555568a53e65
7
+ data.tar.gz: dcdfc2705d4216c41cc4b2635b1d2259b74421724d990b83969d4b1811efb57ccf3f8fcfb96f07206e1b21e524253042ae70a1741c9d9144609fafe5fce6cf17
data/README.md CHANGED
@@ -17,6 +17,7 @@ gem "ruboty-app_annie"
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
19
  @ruboty annie list {ios|android} reviews of <product_id> from <start_date> to <end_date> in <country> - Retrieve one product’s reviews
20
+ @ruboty annie list {ios|android} reviews of <product_id> days ago <days_ago> in <country> - Retrieve one product’s reviews of days ago
20
21
  ```
21
22
 
22
23
  ## ENV
@@ -3,17 +3,27 @@ module Ruboty
3
3
  module Actions
4
4
  class ListReviews < Base
5
5
  def call
6
- list_reviews if exists_reviews?
6
+ initialize_date_conditions
7
+ return if !exists_reviews?
8
+
9
+ list_reviews
7
10
  end
8
11
 
9
12
  private
10
13
 
14
+ def exists_reviews?
15
+ !reviews.empty?
16
+ end
17
+
11
18
  def list_reviews
12
19
  message.reply(reviews.join("\n\n"))
13
20
  end
14
21
 
15
- def exists_reviews?
16
- !reviews.empty?
22
+ def initialize_date_conditions
23
+ days_ago = Date.today.ago(given_days_ago.to_i.days).to_date.to_s
24
+ @start_date = days_ago
25
+ @end_date = days_ago
26
+ rescue IndexError
17
27
  end
18
28
 
19
29
  def reviews
@@ -77,11 +87,15 @@ module Ruboty
77
87
  end
78
88
 
79
89
  def given_start_date
80
- message[:start_date]
90
+ @start_date ||= message[:start_date]
81
91
  end
82
92
 
83
93
  def given_end_date
84
- message[:end_date]
94
+ @end_date ||= message[:end_date]
95
+ end
96
+
97
+ def given_days_ago
98
+ message[:days_ago]
85
99
  end
86
100
 
87
101
  def given_country
@@ -1,5 +1,5 @@
1
1
  module Ruboty
2
2
  module AppAnnie
3
- VERSION = "0.0.4"
3
+ VERSION = "0.0.5"
4
4
  end
5
5
  end
@@ -1,3 +1,6 @@
1
+ require "active_support/core_ext/date"
2
+ require "active_support/core_ext/time"
3
+ require "active_support/core_ext/numeric/time"
1
4
  require "anego"
2
5
 
3
6
  require "ruboty"
@@ -21,6 +21,12 @@ module Ruboty
21
21
  description: "Retrieve one product’s reviews",
22
22
  )
23
23
 
24
+ on(
25
+ /annie list (?<market>ios|android) reviews of (?<product_id>.+) days ago (?<days_ago>.+) in (?<country>.+)\z/,
26
+ name: "list_reviews_of_days_ago",
27
+ description: "Retrieve one product’s reviews of days ago",
28
+ )
29
+
24
30
  def list_accounts(message)
25
31
  Ruboty::AppAnnie::Actions::ListAccounts.new(message).call
26
32
  end
@@ -32,6 +38,10 @@ module Ruboty
32
38
  def list_reviews(message)
33
39
  Ruboty::AppAnnie::Actions::ListReviews.new(message).call
34
40
  end
41
+
42
+ def list_reviews_of_days_ago(message)
43
+ Ruboty::AppAnnie::Actions::ListReviews.new(message).call
44
+ end
35
45
  end
36
46
  end
37
47
  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
4
+ version: 0.0.5
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-20 00:00:00.000000000 Z
11
+ date: 2016-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruboty