embulk-input-zendesk 0.2.9 → 0.2.10
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 +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +4 -1
- data/embulk-input-zendesk.gemspec +1 -1
- data/lib/embulk/input/zendesk/client.rb +30 -2
- data/lib/embulk/input/zendesk/plugin.rb +3 -0
- data/test/embulk/input/zendesk/test_plugin.rb +20 -0
- data/test/fixtures/invalid_app_marketplace_lack_one_property.yml +13 -0
- data/test/fixtures/invalid_app_marketplace_lack_two_property.yml +12 -0
- data/test/fixtures/valid_app_marketplace.yml +14 -0
- metadata +7 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0187b06702508e3aa734155601f2ac61bfa9456
|
4
|
+
data.tar.gz: 0978a2745e336986fc17c57796a77f271439ba4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b19b4372816708a26d2110a823a3fba165fd066ab650f85002d3751ae9efb3f3b3e6eb9163f2a1eca976f9c31ccae00edf760da7216a6c017d8f78a775abb79
|
7
|
+
data.tar.gz: 374a88e38e1ab5469f66500aab6fd2be1f9fead2ea21358698ad8458d5ea26df88eea4ae4f7fdfffe9cedb4b7e8f0b7cedc91bbe930691ebc666414c559c902e
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -32,7 +32,10 @@ Required Embulk version >= 0.8.1.
|
|
32
32
|
- **retry_limit**: Try to retry this times (integer, default: 5)
|
33
33
|
- **retry_initial_wait_sec**: Wait seconds for exponential backoff initial value (integer, default: 4)
|
34
34
|
- **incremental**: If false, `start_time` in next.yml would not be updated that means you always fetch all of data from Zendesk with statically conditions. If true, `start_time` would be updated in next.yml. (bool, default: true)
|
35
|
-
|
35
|
+
- **app_marketplace_integration_name**: Invisible to user, only requires to be a part of the Zendesk Apps Marketplace. This should be used to name of the integration.
|
36
|
+
- **app_marketplace_org_id**: Invisible to user, only requires to be a part of the Zendesk Apps Marketplace. This should be the Organization ID for your organization from the new developer portal.
|
37
|
+
- **app_marketplace_app_id**: Invisible to user, only requires to be a part of the Zendesk Apps Marketplace. This is the “App ID” that will be assigned to you when you submit your app.
|
38
|
+
|
36
39
|
## Example
|
37
40
|
|
38
41
|
```yaml
|
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
2
|
Gem::Specification.new do |spec|
|
3
3
|
spec.name = "embulk-input-zendesk"
|
4
|
-
spec.version = "0.2.
|
4
|
+
spec.version = "0.2.10"
|
5
5
|
spec.authors = ["uu59", "muga", "sakama"]
|
6
6
|
spec.summary = "Zendesk input plugin for Embulk"
|
7
7
|
spec.description = "Loads records from Zendesk."
|
@@ -43,6 +43,7 @@ module Embulk
|
|
43
43
|
def validate_config
|
44
44
|
validate_credentials
|
45
45
|
validate_target
|
46
|
+
validate_app_marketplace
|
46
47
|
end
|
47
48
|
|
48
49
|
def validate_credentials
|
@@ -68,6 +69,15 @@ module Embulk
|
|
68
69
|
end
|
69
70
|
end
|
70
71
|
|
72
|
+
def validate_app_marketplace
|
73
|
+
valid = config[:app_marketplace_integration_name] && config[:app_marketplace_org_id] && config[:app_marketplace_app_id]
|
74
|
+
valid = valid || (!config[:app_marketplace_integration_name] && !config[:app_marketplace_org_id] && !config[:app_marketplace_app_id])
|
75
|
+
|
76
|
+
unless valid
|
77
|
+
raise Embulk::ConfigError.new("All of app_marketplace_integration_name, app_marketplace_org_id, app_marketplace_app_id are required to fill out for Apps Marketplace API header")
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
71
81
|
# they have both Incremental API and non-incremental API
|
72
82
|
# 170717: `ticket_events` can use standard endpoint format now, ie. `<target>.json`
|
73
83
|
%w(tickets ticket_events users organizations).each do |target|
|
@@ -255,9 +265,18 @@ module Embulk
|
|
255
265
|
u = URI.parse(config[:login_url])
|
256
266
|
u.path = path
|
257
267
|
|
268
|
+
# https://help.zendesk.com/hc/en-us/articles/115010249348-Announcing-Updated-Apps-Marketplace-API-Header-Requirementsmerg
|
269
|
+
extheader = {}
|
270
|
+
|
271
|
+
if config[:app_marketplace_integration_name] && config[:app_marketplace_org_id] && config[:app_marketplace_app_id]
|
272
|
+
extheader = {"X-Zendesk-Marketplace-Name" => config[:app_marketplace_integration_name],
|
273
|
+
"X-Zendesk-Marketplace-Organization-Id" => config[:app_marketplace_org_id],
|
274
|
+
"X-Zendesk-Marketplace-App-Id" => config[:app_marketplace_app_id]}
|
275
|
+
end
|
276
|
+
|
258
277
|
retryer.with_retry do
|
259
278
|
Embulk.logger.debug "Fetching #{u.to_s}"
|
260
|
-
response = httpclient.get(u.to_s, query,
|
279
|
+
response = httpclient.get(u.to_s, query, extheader)
|
261
280
|
|
262
281
|
handle_response(response.status, response.headers, response.body)
|
263
282
|
response
|
@@ -271,11 +290,20 @@ module Embulk
|
|
271
290
|
u = URI.parse(config[:login_url])
|
272
291
|
u.path = path
|
273
292
|
|
293
|
+
# https://help.zendesk.com/hc/en-us/articles/115010249348-Announcing-Updated-Apps-Marketplace-API-Header-Requirementsmerg
|
294
|
+
extheader = {}
|
295
|
+
|
296
|
+
if config[:app_marketplace_integration_name] && config[:app_marketplace_org_id] && config[:app_marketplace_app_id]
|
297
|
+
extheader = {"X-Zendesk-Marketplace-Name" => config[:app_marketplace_integration_name],
|
298
|
+
"X-Zendesk-Marketplace-Organization-Id" => config[:app_marketplace_org_id],
|
299
|
+
"X-Zendesk-Marketplace-App-Id" => config[:app_marketplace_app_id]}
|
300
|
+
end
|
301
|
+
|
274
302
|
retryer.with_retry do
|
275
303
|
Embulk.logger.debug "Fetching #{u.to_s}"
|
276
304
|
buf = ""
|
277
305
|
auth_retry = 0
|
278
|
-
httpclient.get(u.to_s, query,
|
306
|
+
httpclient.get(u.to_s, query, extheader) do |message, chunk|
|
279
307
|
if message.status == 401
|
280
308
|
# First request will fail by 401 because not included credentials.
|
281
309
|
# HTTPClient will retry request with credentials.
|
@@ -96,6 +96,9 @@ module Embulk
|
|
96
96
|
incremental: config.param("incremental", :bool, default: true),
|
97
97
|
schema: config.param(:columns, :array, default: []),
|
98
98
|
includes: config.param(:includes, :array, default: []),
|
99
|
+
app_marketplace_integration_name: config.param("app_marketplace_integration_name", :string, default: nil),
|
100
|
+
app_marketplace_org_id: config.param("app_marketplace_org_id", :string, default: nil),
|
101
|
+
app_marketplace_app_id: config.param("app_marketplace_app_id", :string, default: nil)
|
99
102
|
}
|
100
103
|
end
|
101
104
|
|
@@ -50,6 +50,26 @@ module Embulk
|
|
50
50
|
run_with("invalid_lack_username.yml")
|
51
51
|
end
|
52
52
|
end
|
53
|
+
|
54
|
+
test "run with valid.yml (app_marketplace) contains three properties" do
|
55
|
+
assert_nothing_raised do
|
56
|
+
run_with("valid_app_marketplace.yml")
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
test "run with invalid lack one of app marketplace properties" do
|
61
|
+
# NOTE: will be raised Java::OrgEmbulkExec::PartialExecutionException, not ConfigError. It is Embulk internally exception handling matter.
|
62
|
+
assert_raise do
|
63
|
+
run_with("invalid_app_marketplace_lack_one_property.yml")
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
test "run with invalid lack two of app marketplace properties" do
|
68
|
+
# NOTE: will be raised Java::OrgEmbulkExec::PartialExecutionException, not ConfigError. It is Embulk internally exception handling matter.
|
69
|
+
assert_raise do
|
70
|
+
run_with("invalid_app_marketplace_lack_two_property.yml")
|
71
|
+
end
|
72
|
+
end
|
53
73
|
end
|
54
74
|
|
55
75
|
sub_test_case ".transaction" do
|
@@ -0,0 +1,13 @@
|
|
1
|
+
in:
|
2
|
+
type: zendesk
|
3
|
+
login_url: "https://example.zendesk.com/"
|
4
|
+
auth_method: basic
|
5
|
+
target: tickets
|
6
|
+
username: foo@example.com
|
7
|
+
password: password
|
8
|
+
app_marketplace_integration_name: App Name for Zendesk
|
9
|
+
app_marketplace_org_id: 12345
|
10
|
+
columns:
|
11
|
+
- {name: id, type: string}
|
12
|
+
out:
|
13
|
+
type: "null"
|
@@ -0,0 +1,12 @@
|
|
1
|
+
in:
|
2
|
+
type: zendesk
|
3
|
+
login_url: "https://example.zendesk.com/"
|
4
|
+
auth_method: basic
|
5
|
+
target: tickets
|
6
|
+
username: foo@example.com
|
7
|
+
password: password
|
8
|
+
app_marketplace_integration_name: App Name for Zendesk
|
9
|
+
columns:
|
10
|
+
- {name: id, type: string}
|
11
|
+
out:
|
12
|
+
type: "null"
|
@@ -0,0 +1,14 @@
|
|
1
|
+
in:
|
2
|
+
type: zendesk
|
3
|
+
login_url: "https://example.zendesk.com/"
|
4
|
+
auth_method: basic
|
5
|
+
target: tickets
|
6
|
+
username: foo@example.com
|
7
|
+
password: password
|
8
|
+
app_marketplace_integration_name: App Name for Zendesk
|
9
|
+
app_marketplace_org_id: 12345
|
10
|
+
app_marketplace_app_id: 99999
|
11
|
+
columns:
|
12
|
+
- {name: id, type: string}
|
13
|
+
out:
|
14
|
+
type: "null"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: embulk-input-zendesk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- uu59
|
@@ -224,9 +224,12 @@ files:
|
|
224
224
|
- test/embulk/input/zendesk/test_client.rb
|
225
225
|
- test/embulk/input/zendesk/test_plugin.rb
|
226
226
|
- test/fixture_helper.rb
|
227
|
+
- test/fixtures/invalid_app_marketplace_lack_one_property.yml
|
228
|
+
- test/fixtures/invalid_app_marketplace_lack_two_property.yml
|
227
229
|
- test/fixtures/invalid_lack_username.yml
|
228
230
|
- test/fixtures/invalid_unknown_auth.yml
|
229
231
|
- test/fixtures/tickets.json
|
232
|
+
- test/fixtures/valid_app_marketplace.yml
|
230
233
|
- test/fixtures/valid_auth_basic.yml
|
231
234
|
- test/fixtures/valid_auth_oauth.yml
|
232
235
|
- test/fixtures/valid_auth_token.yml
|
@@ -261,9 +264,12 @@ test_files:
|
|
261
264
|
- test/embulk/input/zendesk/test_client.rb
|
262
265
|
- test/embulk/input/zendesk/test_plugin.rb
|
263
266
|
- test/fixture_helper.rb
|
267
|
+
- test/fixtures/invalid_app_marketplace_lack_one_property.yml
|
268
|
+
- test/fixtures/invalid_app_marketplace_lack_two_property.yml
|
264
269
|
- test/fixtures/invalid_lack_username.yml
|
265
270
|
- test/fixtures/invalid_unknown_auth.yml
|
266
271
|
- test/fixtures/tickets.json
|
272
|
+
- test/fixtures/valid_app_marketplace.yml
|
267
273
|
- test/fixtures/valid_auth_basic.yml
|
268
274
|
- test/fixtures/valid_auth_oauth.yml
|
269
275
|
- test/fixtures/valid_auth_token.yml
|