wondeclient 0.0.5 → 0.0.6

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: cce565e4e39b5312ef766bd0a2c13c6cee2f5612
4
- data.tar.gz: ac4b217f44da358d562bfd76deca1e1d24a63e28
3
+ metadata.gz: d91f1aeb7637844d82b9ed695dc211f1546cc6f7
4
+ data.tar.gz: 2af4d79570264a312c4a0a69e62174ce4ce2c295
5
5
  SHA512:
6
- metadata.gz: df843c31804091c8fe5381247c429e409db794be02b6f505baa608c2f313d0c163ec20ce9666edd2a7c0b429b4121050612d5ecb83b3be65f483f87be635742a
7
- data.tar.gz: 80af9f937e0bde09745d5b96c698ab6dd926d15a5da2cff6d8f4face73ace72f071222b380aeb6887868d027b46b82baaf03374cb052c507f4b6946caa58dbf6
6
+ metadata.gz: 8a9fe5e9d77d8c6f46f3ed702a865755e7fa1ddf851b7182d8b4310b8666583c7bd2fc242c85d41c714933564416eadf9e3d2cc004bef10c44be891f59468171
7
+ data.tar.gz: 7c28e142b4b40e1f6d18d41c0aadcb3a34188f22e5d13e87145fc9955d924a3b34bd42c297ece1db07ad4043ede8cb8b5e3ba3d57ab51b02e3873fb369c67732
data/lib/client.rb CHANGED
@@ -17,7 +17,7 @@ module Wonde
17
17
  attr_accessor :schools, :attendanceCodes, :token
18
18
  @@attendanceCodes
19
19
  @@token
20
- @@version = '0.0.5'
20
+ @@version = '0.0.6'
21
21
  # Initialize a Client Object
22
22
  #
23
23
  # @param token [String]
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["data"]
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
@@ -2,6 +2,7 @@
2
2
  module Wonde
3
3
  autoload :Client, 'client'
4
4
  autoload :Endpoints, 'endpoints'
5
+ autoload :ResultIterator, 'resultiterator'
5
6
  #Endpoints
6
7
  autoload :Achievements, 'endpoints/achievements'
7
8
  autoload :Assessment, 'endpoints/assessment'
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.5
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