hisui 0.1.4 → 0.1.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
  SHA256:
3
- metadata.gz: b39bcdc510844184ee5b7115e3c5993498d596b022902ca9af4b7ad045847082
4
- data.tar.gz: '094b0cfe1131f880dc85f65e555aa47f1b343e90927ee3b1e71ebbbce500b717'
3
+ metadata.gz: ed5550e23b11889424c0bf4ec332d655989f080ab442e78954e62342b9450a65
4
+ data.tar.gz: c4d88b0d28878e96196ba088db6b6610617cbeba5e3c7dd4f2c8c013bef708df
5
5
  SHA512:
6
- metadata.gz: 8ccfbdb73e5904d98d776737c274a4195b83bbc118fe35fca914e09b47506d0aceeafedc99e08ecc468256310cf515c5fc0ec969c3e1052ffdad8ec5e413e634
7
- data.tar.gz: 88c3098046b9dec4896f84702dc79ec9746a58188dab2a97be1ac2183c8b54fd4a4af438de18a3d0c4c13faf0db21cef56ef04620d0a35f50ac34e1e80968dea
6
+ metadata.gz: 1ab1c8635dd6023ca3778c47df5940d846e89ee02e701b66cbd2252bc15bb7a0e72cf3d0a2fc5be38985680e36b0798cb81cb2a653b21ae8d12da2ef7444e7bf
7
+ data.tar.gz: 8ec50ed5bdc40a0d28f86e90052323532c61ace7c8b71eba99232978066238dad326b1747e032ec78e5451252b16f6b39cd3b13d868f40a22f5a59f29c8972b1
data/README.md CHANGED
@@ -88,6 +88,23 @@ response.data?
88
88
  #=> true
89
89
  ```
90
90
 
91
+ #### Filtering
92
+ When you set `filters_expression` method with `field_name`, `operator` and `value` params, you can filter Google Analytics Data.
93
+
94
+ For example, this is filtered by organic.
95
+ ```ruby
96
+ class OrganicMedium
97
+ extend Hisui::Model
98
+
99
+ metrics :pageviews, :sessions, :users, :new_users, :bounce_rate, :pageviews_per_session, :avg_session_duration
100
+ dimensions :medium
101
+ filters_expression({ field_name: 'medium', operator: '==', value: 'organic' })
102
+ end
103
+ ```
104
+
105
+ other `operator` s are [here](https://developers.google.com/analytics/devguides/reporting/core/v3/reference?hl=ja#filterOperators)
106
+
107
+
91
108
  ## Contributing
92
109
  Fork it, fix me, and send me your pull requests.
93
110
 
@@ -4,6 +4,7 @@ require 'hisui/user'
4
4
  require 'hisui/model'
5
5
  require 'hisui/request'
6
6
  require 'hisui/response'
7
+ require 'hisui/filters_expression'
7
8
 
8
9
  require 'hisui/management/base'
9
10
  require 'hisui/management/account'
@@ -0,0 +1,13 @@
1
+ module Hisui
2
+ class FiltersExpression
3
+ def initialize(field_name:, value:, operator:)
4
+ @field_name = field_name
5
+ @value = value
6
+ @operator = operator
7
+ end
8
+
9
+ def to_param
10
+ "#{Hisui.to_ga_string(@field_name)}#{@operator}#{@value}"
11
+ end
12
+ end
13
+ end
@@ -34,6 +34,22 @@ module Hisui
34
34
  @order_bys
35
35
  end
36
36
 
37
+ # Adds filters_expression to the class for retrieval from GA
38
+ #
39
+ # @param field [Hash] options:
40
+ # * field_name
41
+ # * operator
42
+ # * value
43
+ #
44
+ # operators are '==', '~=' and so on. cf: https://developers.google.com/analytics/devguides/reporting/core/v3/reference?hl=ja#filters
45
+ #
46
+ # @return concatenated string
47
+ def filters_expression(field = nil)
48
+ @filters_expression ||= ''
49
+ @filters_expression = Hisui::FiltersExpression.new(field).to_param if field
50
+ @filters_expression
51
+ end
52
+
37
53
  def results(profile:, **options)
38
54
  Hisui::Request.new(profile: profile, model: self, **options).fetch_data
39
55
  end
@@ -34,6 +34,7 @@ module Hisui
34
34
  metrics: model.metrics,
35
35
  dimensions: model.dimensions,
36
36
  date_ranges: date_ranges,
37
+ filters_expression: model.filters_expression,
37
38
  order_bys: model.order_bys,
38
39
  page_size: limit
39
40
  )]
@@ -1,3 +1,3 @@
1
1
  module Hisui
2
- VERSION = '0.1.4'
2
+ VERSION = '0.1.5'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hisui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - ikepon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-01 00:00:00.000000000 Z
11
+ date: 2018-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -161,6 +161,7 @@ files:
161
161
  - README.md
162
162
  - Rakefile
163
163
  - lib/hisui.rb
164
+ - lib/hisui/filters_expression.rb
164
165
  - lib/hisui/management/account.rb
165
166
  - lib/hisui/management/account_summary.rb
166
167
  - lib/hisui/management/base.rb