embulk-input-google_analytics 0.1.18 → 0.1.19

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: 1ab44fb8b7d3108fc5611a58e38640eb2839478b
4
- data.tar.gz: c7dbaea282c1703273cffaf02799c5fc2a4a9013
3
+ metadata.gz: 98cf1ab1dabc69c3b8ee6a48e7054f9ed7a13bfc
4
+ data.tar.gz: b214635c4b353bde69fc9358aa937c82765b6fe7
5
5
  SHA512:
6
- metadata.gz: 42e3f0dedf09f963e1e8d016cc673f4c5737a41f2a708e6b5f2245769862c71ba2bd50ca79b622c66a7b896135c18f7568e1db4c059d0ba42de359c02dcae4e8
7
- data.tar.gz: 4e9e5f619ae9ddf6acfdd413984533f14d28cfbb2a59f34bf351b37a128e665e411a2f3cc49092cbf3b3841de9b099d85b42cd9b112bc7d7cc5413f6f2d32f67
6
+ metadata.gz: e24333e7618c3c729a78ae1a9d0fdb1cac380fef1f9b08bd31fb0a7fdc1b1b0ba25d31a2e399b8c33eed283a3d39007d1da2569dffa6f7c02143dafe55337c6a
7
+ data.tar.gz: bcee119969919b4352761643d18a0c650dd5b5d017abedf1f75a1f980a2e282174d983ea5622dda77b7c7cbc05d0e35db794a0b70f4b5fbed4c2b847c4be0e1c
@@ -1,3 +1,6 @@
1
+ ## 0.1.19 - 2018-10-03
2
+ * Make it easy to understand error message of Google Analytics connector (https://github.com/treasure-data/embulk-input-google_analytics/pull/39)
3
+
1
4
  ## 0.1.18 - 2018-05-23
2
5
  * Suport User Account Authentication [#33](https://github.com/treasure-data/embulk-input-google_analytics/pull/33)
3
6
  * Ignore last_record_time if non-incremental task [#34](https://github.com/treasure-data/embulk-input-google_analytics/pull/34)
@@ -1,7 +1,7 @@
1
1
 
2
2
  Gem::Specification.new do |spec|
3
3
  spec.name = "embulk-input-google_analytics"
4
- spec.version = "0.1.18"
4
+ spec.version = "0.1.19"
5
5
  spec.authors = ["uu59"]
6
6
  spec.summary = "Google Analytics input plugin for Embulk"
7
7
  spec.description = "Loads records from Google Analytics."
@@ -20,6 +20,10 @@ module Embulk
20
20
  unless task['client_id'] && task['client_secret'] && task['refresh_token']
21
21
  raise ConfigError.new("client_id, client_secret and refresh_token are required when using Oauth authentication")
22
22
  end
23
+ elsif task['auth_method'] == Plugin::AUTH_TYPE_JSON_KEY
24
+ if !valid_json?(task["json_key_content"])
25
+ raise ConfigError.new("json_key_content is not a valid JSON object")
26
+ end
23
27
  end
24
28
 
25
29
  columns_list = Client.new(task).get_columns_list
@@ -106,8 +110,21 @@ module Embulk
106
110
  return {}
107
111
  end
108
112
 
113
+ def self.valid_json?(json_object)
114
+ # 'null' string is a valid string for parse function
115
+ # However in our case, json_content_key could not be 'null' therefore this check is added
116
+ if json_object == "null"
117
+ return false
118
+ end
119
+ begin
120
+ JSON.parse(json_object)
121
+ return true
122
+ rescue JSON::ParserError => e
123
+ return false
124
+ end
125
+ end
126
+
109
127
  def init
110
- # PLT-6753
111
128
  if task["start_date"] && !task["end_date"]
112
129
  task["end_date"] = "today"
113
130
  end
@@ -107,6 +107,26 @@ module Embulk
107
107
  end
108
108
  end
109
109
 
110
+ test "invalid json_key_content params for oauth" do
111
+ conf = valid_config["in"]
112
+ # Empty json_key_content
113
+ conf["json_key_content"] = ""
114
+ message = "json_key_content is not a valid JSON object"
115
+ assert_raise(Embulk::ConfigError.new(message)) do
116
+ Plugin.transaction(embulk_config(conf))
117
+ end
118
+ # null json_key_content
119
+ conf["json_key_content"] = "null"
120
+ assert_raise(Embulk::ConfigError.new(message)) do
121
+ Plugin.transaction(embulk_config(conf))
122
+ end
123
+ # Not a string json_key_content
124
+ conf["json_key_content"] = nil
125
+ assert_raise(Embulk::ConfigError.new(message)) do
126
+ Plugin.transaction(embulk_config(conf))
127
+ end
128
+ end
129
+
110
130
  def unknown_auth_method_message
111
131
  "Unknown Authentication method ''."
112
132
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-input-google_analytics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.18
4
+ version: 0.1.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - uu59
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-23 00:00:00.000000000 Z
11
+ date: 2018-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement