embulk-input-zendesk_guide 0.1.0 → 0.1.1

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: 2a556a287bc7d20ad2d86839c23d4a921db47d22
4
- data.tar.gz: 38c8f19a1b2df84fbdd33e72a7e64791531d1728
3
+ metadata.gz: 6412741acd3d0a2ea44116b6e2b61eadd7dafa0f
4
+ data.tar.gz: a9d064039b1ebc16c982b98c4d96f2b7fa55f497
5
5
  SHA512:
6
- metadata.gz: d6449a444dfc0ef9028daf4fd56d7dbf9e7e6f56b9a591cfcb3392d0a147177c7cab45377db966711550ea6cef02a6cae5489327ce6d19e6545da4dcbcb59dc6
7
- data.tar.gz: 245b6695e77b9791aa7dffbbba81be4b4e048890f1824d4ce82d320022a759a6983e2319237bea890d39451e3c6e7a8b6a7fa594e38b4d7f0ef85e4563938c1c
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.0"
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
- uri = URI.parse("#@url/help_center/ja/articles.json")
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.path)
55
+ req = Net::HTTP::Get.new(uri.to_s)
44
56
  req.basic_auth(@username, @token)
45
- response = http.request(req)
46
- JSON.parse(response.body)["articles"].map {|article|
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-input-zendesk_guide
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yasuhisa Yoshida