wondeclient 0.0.5 → 0.0.6
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/lib/client.rb +1 -1
- data/lib/endpoints.rb +2 -2
- data/lib/resultiterator.rb +39 -0
- data/lib/wondeclient.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d91f1aeb7637844d82b9ed695dc211f1546cc6f7
|
4
|
+
data.tar.gz: 2af4d79570264a312c4a0a69e62174ce4ce2c295
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a9fe5e9d77d8c6f46f3ed702a865755e7fa1ddf851b7182d8b4310b8666583c7bd2fc242c85d41c714933564416eadf9e3d2cc004bef10c44be891f59468171
|
7
|
+
data.tar.gz: 7c28e142b4b40e1f6d18d41c0aadcb3a34188f22e5d13e87145fc9955d924a3b34bd42c297ece1db07ad4043ede8cb8b5e3ba3d57ab51b02e3873fb369c67732
|
data/lib/client.rb
CHANGED
data/lib/endpoints.rb
CHANGED
@@ -122,13 +122,13 @@ module Wonde
|
|
122
122
|
else
|
123
123
|
uri = self.uri
|
124
124
|
end
|
125
|
-
response = getRequest(uri).body
|
125
|
+
response = getRequest(uri).body
|
126
126
|
puts response if ENV["debug_wonde"]
|
127
127
|
jsonized = response.to_json
|
128
128
|
puts jsonized if ENV["debug_wonde"]
|
129
129
|
object = JSON.parse(jsonized, object_class: OpenStruct)
|
130
130
|
puts object if ENV["debug_wonde"]
|
131
|
-
return object
|
131
|
+
return ResultIterator.new(object,self.token)
|
132
132
|
end
|
133
133
|
|
134
134
|
private
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Wonde
|
2
|
+
class ResultIterator < Endpoints
|
3
|
+
include Enumerable
|
4
|
+
attr_accessor :myarray, :meta, :token
|
5
|
+
def initialize(myhashostruct, token)
|
6
|
+
super
|
7
|
+
p myhashostruct if ENV["debug_wonde"]
|
8
|
+
self.token = token
|
9
|
+
self.myarray = myhashostruct.data
|
10
|
+
self.meta = myhashostruct.meta unless myhashostruct.meta.nil?
|
11
|
+
end
|
12
|
+
|
13
|
+
def <<(val)
|
14
|
+
@myarray << val
|
15
|
+
end
|
16
|
+
|
17
|
+
def length
|
18
|
+
return self.count()
|
19
|
+
end
|
20
|
+
|
21
|
+
def each
|
22
|
+
original_length = @myarray.length - 1
|
23
|
+
@myarray.each_with_index do |val,index|
|
24
|
+
if index >= original_length and self.meta.pagination.more
|
25
|
+
resp = self.getUrl(self.meta.pagination.next).body
|
26
|
+
jsonized = resp.to_json
|
27
|
+
nextResponse = JSON.parse(jsonized, object_class: OpenStruct)
|
28
|
+
p nextResponse if ENV["debug_wonde"]
|
29
|
+
self.meta = nextResponse.meta unless nextResponse.meta.nil?
|
30
|
+
nextResponse.data.each do |element|
|
31
|
+
@myarray.push(element)
|
32
|
+
end
|
33
|
+
original_length += nextResponse.data.count
|
34
|
+
end
|
35
|
+
yield val
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/wondeclient.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wondeclient
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Donlon
|
@@ -66,6 +66,7 @@ files:
|
|
66
66
|
- lib/exceptions/invalidsessionexception.rb
|
67
67
|
- lib/exceptions/invalidtokenexception.rb
|
68
68
|
- lib/exceptions/validationerror.rb
|
69
|
+
- lib/resultiterator.rb
|
69
70
|
- lib/wondeclient.rb
|
70
71
|
- lib/writeback/lessonattendancerecord.rb
|
71
72
|
- lib/writeback/lessonregister.rb
|