embulk-input-zendesk_guide 0.1.0 → 0.1.1
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/embulk-input-zendesk_guide.gemspec +1 -1
- data/lib/embulk/input/zendesk_guide/articles.rb +18 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6412741acd3d0a2ea44116b6e2b61eadd7dafa0f
|
4
|
+
data.tar.gz: a9d064039b1ebc16c982b98c4d96f2b7fa55f497
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d0ca6bf2c9fbebb5afd039fa09fa1e65c8a0cf623b3a23638ddd0acac524b40cff2433d2e12c8ee690f8d73884b441d3eacdb47d62d01a3244c4e110167fa1c
|
7
|
+
data.tar.gz: 65b6df99a4581ff4859798cc7106414852834dccd0f4bf52dc7691af0d2472e36a7556cbfa1259768f88f0bb77eae448cd2c246ca366708ca8592b4b488d3d06
|
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
2
|
Gem::Specification.new do |spec|
|
3
3
|
spec.name = "embulk-input-zendesk_guide"
|
4
|
-
spec.version = "0.1.
|
4
|
+
spec.version = "0.1.1"
|
5
5
|
spec.authors = ["Yasuhisa Yoshida"]
|
6
6
|
spec.summary = "Zendesk Guide input plugin for Embulk"
|
7
7
|
spec.description = "Loads records from Zendesk Guide."
|
@@ -36,14 +36,27 @@ class Articles
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def get
|
39
|
-
|
39
|
+
result = []
|
40
|
+
next_url = "#@url/help_center/ja/articles.json"
|
41
|
+
while !next_url.nil? do
|
42
|
+
tmp, next_url = get_from_url(next_url)
|
43
|
+
result.concat(tmp)
|
44
|
+
return result if next_url.nil?
|
45
|
+
sleep 1
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
def get_from_url(url)
|
51
|
+
uri = URI.parse(url)
|
40
52
|
http = Net::HTTP.new(uri.host, uri.port)
|
41
53
|
http.use_ssl = uri.scheme === "https"
|
42
54
|
|
43
|
-
req = Net::HTTP::Get.new(uri.
|
55
|
+
req = Net::HTTP::Get.new(uri.to_s)
|
44
56
|
req.basic_auth(@username, @token)
|
45
|
-
response = http.request(req)
|
46
|
-
|
57
|
+
response = JSON.parse(http.request(req).body)
|
58
|
+
|
59
|
+
return response["articles"].map {|article|
|
47
60
|
[
|
48
61
|
article["id"],
|
49
62
|
article["url"],
|
@@ -69,7 +82,6 @@ class Articles
|
|
69
82
|
Date.parse(article["edited_at"]).to_time,
|
70
83
|
Date.parse(article["updated_at"]).to_time,
|
71
84
|
]
|
72
|
-
}
|
85
|
+
}, response["next_page"]
|
73
86
|
end
|
74
|
-
|
75
87
|
end
|