wondeclient 0.0.5
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 +7 -0
- data/bin/wondeclient +4 -0
- data/lib/client.rb +72 -0
- data/lib/endpoints/achievements.rb +11 -0
- data/lib/endpoints/assessment/aspects.rb +11 -0
- data/lib/endpoints/assessment/marksheets.rb +11 -0
- data/lib/endpoints/assessment/results.rb +11 -0
- data/lib/endpoints/assessment/resultsets.rb +11 -0
- data/lib/endpoints/assessment/templates.rb +11 -0
- data/lib/endpoints/assessment.rb +14 -0
- data/lib/endpoints/attendance.rb +16 -0
- data/lib/endpoints/attendancecodes.rb +11 -0
- data/lib/endpoints/behaviours.rb +11 -0
- data/lib/endpoints/classes.rb +11 -0
- data/lib/endpoints/contacts.rb +11 -0
- data/lib/endpoints/counts.rb +11 -0
- data/lib/endpoints/deletions.rb +11 -0
- data/lib/endpoints/employees.rb +11 -0
- data/lib/endpoints/events.rb +11 -0
- data/lib/endpoints/groups.rb +11 -0
- data/lib/endpoints/lessonattendance.rb +15 -0
- data/lib/endpoints/lessons.rb +11 -0
- data/lib/endpoints/medicalconditions.rb +11 -0
- data/lib/endpoints/medicalevents.rb +11 -0
- data/lib/endpoints/periods.rb +11 -0
- data/lib/endpoints/photos.rb +11 -0
- data/lib/endpoints/rooms.rb +11 -0
- data/lib/endpoints/schools.rb +54 -0
- data/lib/endpoints/students.rb +11 -0
- data/lib/endpoints/subjects.rb +11 -0
- data/lib/endpoints.rb +141 -0
- data/lib/exceptions/invalidattendanceexception.rb +7 -0
- data/lib/exceptions/invalidlessonattendanceexception.rb +7 -0
- data/lib/exceptions/invalidsessionexception.rb +7 -0
- data/lib/exceptions/invalidtokenexception.rb +7 -0
- data/lib/exceptions/validationerror.rb +7 -0
- data/lib/wondeclient.rb +45 -0
- data/lib/writeback/lessonattendancerecord.rb +53 -0
- data/lib/writeback/lessonregister.rb +30 -0
- data/lib/writeback/sessionattendancerecord.rb +89 -0
- data/lib/writeback/sessionregister.rb +30 -0
- metadata +98 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: cce565e4e39b5312ef766bd0a2c13c6cee2f5612
|
4
|
+
data.tar.gz: ac4b217f44da358d562bfd76deca1e1d24a63e28
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: df843c31804091c8fe5381247c429e409db794be02b6f505baa608c2f313d0c163ec20ce9666edd2a7c0b429b4121050612d5ecb83b3be65f483f87be635742a
|
7
|
+
data.tar.gz: 80af9f937e0bde09745d5b96c698ab6dd926d15a5da2cff6d8f4face73ace72f071222b380aeb6887868d027b46b82baaf03374cb052c507f4b6946caa58dbf6
|
data/bin/wondeclient
ADDED
data/lib/client.rb
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'pp'
|
2
|
+
# Main Module/Namespace to hold all the Wonde classes
|
3
|
+
#
|
4
|
+
module Wonde
|
5
|
+
# Main client class that the user will interface with
|
6
|
+
#
|
7
|
+
# @param token [String]
|
8
|
+
# @return [Object]
|
9
|
+
#
|
10
|
+
# @example
|
11
|
+
# require 'wondeclient'
|
12
|
+
# client = Wonde::Client.new('TOKEN_GOES_HERE')
|
13
|
+
# client.schools.all().each do |school|
|
14
|
+
# p school.name
|
15
|
+
# end
|
16
|
+
class Client
|
17
|
+
attr_accessor :schools, :attendanceCodes, :token
|
18
|
+
@@attendanceCodes
|
19
|
+
@@token
|
20
|
+
@@version = '0.0.5'
|
21
|
+
# Initialize a Client Object
|
22
|
+
#
|
23
|
+
# @param token [String]
|
24
|
+
# @return [Object]
|
25
|
+
#
|
26
|
+
# @example
|
27
|
+
# Wonde::Client.new("SOMETOKEN") #=> #<Wonde::Client:0x007fb223953da0 @token="SOMETOKEN">
|
28
|
+
def initialize(token)
|
29
|
+
@@token = token
|
30
|
+
@token = token
|
31
|
+
@schools = Wonde::Schools.new(token)
|
32
|
+
@attendanceCodes = Wonde::AttendanceCodes.new(token)
|
33
|
+
end
|
34
|
+
|
35
|
+
# Get School/Schools Object
|
36
|
+
#
|
37
|
+
# @param id [String]
|
38
|
+
# @return [Object]
|
39
|
+
#
|
40
|
+
# @example
|
41
|
+
# client = Wonde::Client.new("SOMETOKEN")
|
42
|
+
# school = client.school('SCHOOLID')
|
43
|
+
def school(id)
|
44
|
+
return Wonde::Schools.new(@token, id)
|
45
|
+
end
|
46
|
+
|
47
|
+
# requestAccess endpoint POST
|
48
|
+
#
|
49
|
+
# @param schoolId [String]
|
50
|
+
# @return [Object]
|
51
|
+
#
|
52
|
+
# @example
|
53
|
+
# client = Wonde::Client.new("SOMETOKEN")
|
54
|
+
# client.requestAccess("A0000000000")
|
55
|
+
def requestAccess(schoolId)
|
56
|
+
return Wonde::Endpoints.new(@token, ('schools/' + schoolId + '/request-access')).post()
|
57
|
+
end
|
58
|
+
|
59
|
+
# revokeAccess endpoint DELETE
|
60
|
+
#
|
61
|
+
# @param schoolId [String]
|
62
|
+
# @return [Object]
|
63
|
+
#
|
64
|
+
# @example
|
65
|
+
# client = Wonde::Client.new("SOMETOKEN")
|
66
|
+
# client.revokeAccess('A0000000000')
|
67
|
+
def revokeAccess(schoolId)
|
68
|
+
return Wonde::Endpoints.new(@token, ('schools/' + schoolId + '/revoke-access')).delete()
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Wonde
|
2
|
+
class Assessment < Endpoints
|
3
|
+
attr_accessor :uri, :templates, :aspects, :marksheets, :results, :resultsets
|
4
|
+
def initialize(token, id=false)
|
5
|
+
super
|
6
|
+
self.templates = Templates.new(token, self.uri)
|
7
|
+
self.aspects = Aspects.new(token, self.uri)
|
8
|
+
self.marksheets = MarkSheets.new(token, self.uri)
|
9
|
+
self.results = Results.new(token, self.uri)
|
10
|
+
self.resultsets = ResultSets.new(token, self.uri)
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Wonde
|
2
|
+
class Attendance < Endpoints
|
3
|
+
@@uri = 'attendance/session'
|
4
|
+
def initialize(token, id=false)
|
5
|
+
super(token, id)
|
6
|
+
self.uri = @@uri
|
7
|
+
self.uri = id + '/' + @@uri if id
|
8
|
+
self.uri = self.uri.gsub("//", "/").chomp("/")
|
9
|
+
end
|
10
|
+
|
11
|
+
def sessionRegister(register)
|
12
|
+
throw InvalidSessionException unless register.class == SessionRegister
|
13
|
+
return self.post(register)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Wonde
|
2
|
+
class LessonAttendance < Endpoints
|
3
|
+
@@uri = 'attendance/lesson/'
|
4
|
+
def initialize(token, id=false)
|
5
|
+
super(token, id)
|
6
|
+
self.uri = @@uri
|
7
|
+
self.uri = id + '/' + @@uri if id
|
8
|
+
self.uri = self.uri.gsub("//", "/").chomp("/")
|
9
|
+
end
|
10
|
+
def lessonRegister(register)
|
11
|
+
throw InvalidSessionException unless register.class == LessonRegister
|
12
|
+
return self.post(register)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Wonde
|
2
|
+
class MedicalConditions < Endpoints
|
3
|
+
@@uri = 'medical-conditions/'
|
4
|
+
def initialize(token, id=false)
|
5
|
+
super(token, id)
|
6
|
+
self.uri = @@uri
|
7
|
+
self.uri = id + '/' + @@uri if id
|
8
|
+
self.uri = self.uri.gsub("//", "/").chomp("/")
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module Wonde
|
2
|
+
class Schools < Endpoints
|
3
|
+
attr_accessor :uri, :achievements, :attendance, :behaviours, :classes,
|
4
|
+
:contacts, :counts, :employees, :groups, :lessons,
|
5
|
+
:lessonAttendance, :medicalConditions, :medicalEvents, :periods,
|
6
|
+
:photos, :rooms, :subjects, :students, :assessment, :deletions,
|
7
|
+
:events
|
8
|
+
@@uri = 'schools/'
|
9
|
+
def initialize(token, id=false)
|
10
|
+
super(token, id)
|
11
|
+
self.token = token
|
12
|
+
self.uri = @@uri
|
13
|
+
self.uri = @@uri + id + '/' if id
|
14
|
+
self.uri = self.uri.gsub("//", "/").chomp("/")
|
15
|
+
self.achievements = Wonde::Achievements.new(token, self.uri)
|
16
|
+
self.assessment = Wonde::Assessment.new(token, self.uri)
|
17
|
+
self.attendance = Wonde::Attendance.new(token, self.uri)
|
18
|
+
self.behaviours = Wonde::Behaviours.new(token, self.uri)
|
19
|
+
self.classes = Wonde::Classes.new(token, self.uri)
|
20
|
+
self.contacts = Wonde::Contacts.new(token, self.uri)
|
21
|
+
self.counts = Wonde::Counts.new(token, self.uri)
|
22
|
+
self.deletions = Wonde::Deletions.new(token, self.uri)
|
23
|
+
self.employees = Wonde::Employees.new(token, self.uri)
|
24
|
+
self.events = Wonde::Events.new(token, self.uri)
|
25
|
+
self.groups = Wonde::Groups.new(token, self.uri)
|
26
|
+
self.lessons = Wonde::Lessons.new(token, self.uri)
|
27
|
+
self.lessonAttendance = Wonde::LessonAttendance.new(token, self.uri)
|
28
|
+
self.medicalConditions = Wonde::MedicalConditions.new(token, self.uri)
|
29
|
+
self.medicalEvents = Wonde::MedicalEvents.new(token, self.uri)
|
30
|
+
self.periods = Wonde::Periods.new(token, self.uri)
|
31
|
+
self.photos = Wonde::Photos.new(token, self.uri)
|
32
|
+
self.rooms = Wonde::Rooms.new(token, self.uri)
|
33
|
+
self.students = Wonde::Students.new(token, self.uri)
|
34
|
+
self.subjects = Wonde::Subjects.new(token, self.uri)
|
35
|
+
end
|
36
|
+
|
37
|
+
def pending(includes = Array.new(), parameters = Array.new())
|
38
|
+
self.uri = @@uri + 'pending/'
|
39
|
+
return self.all(includes, parameters)
|
40
|
+
end
|
41
|
+
|
42
|
+
def search(includes = Hash.new(), parameters = Hash.new())
|
43
|
+
self.uri = @@uri + 'all/'
|
44
|
+
return self.all(includes, parameters)
|
45
|
+
end
|
46
|
+
|
47
|
+
def get(id, includes = Array.new(), parameters = Array.new())
|
48
|
+
self.uri = @@uri
|
49
|
+
school = super(id, includes, parameters)
|
50
|
+
return school
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
data/lib/endpoints.rb
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
module Wonde
|
2
|
+
# Top level Endpoints class, most of our classes inherit from this
|
3
|
+
# Some methods use this directly
|
4
|
+
class Endpoints
|
5
|
+
require 'unirest'
|
6
|
+
require 'ostruct'
|
7
|
+
require "addressable/uri"
|
8
|
+
require 'json'
|
9
|
+
attr_accessor :endpoint, :uri, :token, :version
|
10
|
+
# Main endpoint, base URI
|
11
|
+
@@endpoint = 'https://api.wonde.com/v1.0/'
|
12
|
+
|
13
|
+
|
14
|
+
def initialize(token, uri=false)
|
15
|
+
self.endpoint = @@endpoint
|
16
|
+
self.uri = String.new()
|
17
|
+
self.version = '0.0.1'
|
18
|
+
self.token = token
|
19
|
+
self.uri = uri if uri
|
20
|
+
end
|
21
|
+
|
22
|
+
# Forwards request info, eventually to unirest
|
23
|
+
#
|
24
|
+
# @param endpoint [String]
|
25
|
+
# @return [Object]
|
26
|
+
def getRequest(endpoint)
|
27
|
+
puts "self.endpoint: " + self.endpoint if ENV["debug_wonde"]
|
28
|
+
puts "endpoint:" + endpoint if ENV["debug_wonde"]
|
29
|
+
return getUrl(self.endpoint + endpoint)
|
30
|
+
end
|
31
|
+
|
32
|
+
# Forwards request info to unirest
|
33
|
+
#
|
34
|
+
# @param url [String]
|
35
|
+
# @return [Object]
|
36
|
+
def getUrl(url)
|
37
|
+
return _client().get(url)
|
38
|
+
end
|
39
|
+
|
40
|
+
# Builds get request and passes it along
|
41
|
+
#
|
42
|
+
# @param id [String]
|
43
|
+
# @param includes [Hash]
|
44
|
+
# @param parameters [Hash]
|
45
|
+
# @return [Object]
|
46
|
+
def get(id, includes = Hash.new(), parameters = Hash.new())
|
47
|
+
unless includes.nil? or includes.empty?
|
48
|
+
parameters['include'] = includes.join(",")
|
49
|
+
end
|
50
|
+
unless parameters.empty?
|
51
|
+
uriparams = Addressable::URI.new
|
52
|
+
uriparams.query_values = parameters
|
53
|
+
uri = self.uri + id + "?" + uriparams.query
|
54
|
+
else
|
55
|
+
uri = self.uri + id
|
56
|
+
end
|
57
|
+
response = getRequest(uri).body["data"]
|
58
|
+
puts response if ENV["debug_wonde"]
|
59
|
+
jsonized = response.to_json
|
60
|
+
puts jsonized if ENV["debug_wonde"]
|
61
|
+
object = JSON.parse(jsonized, object_class: OpenStruct)
|
62
|
+
puts object if ENV["debug_wonde"]
|
63
|
+
return object
|
64
|
+
end
|
65
|
+
|
66
|
+
def postRequest(endpoint, body=Hash.new())
|
67
|
+
puts "self.endpoint:\n " + self.endpoint if ENV["debug_wonde"]
|
68
|
+
puts "endpoint:\n" + endpoint if ENV["debug_wonde"]
|
69
|
+
puts "body:\n" + body.to_json if ENV["debug_wonde"]
|
70
|
+
return postUrl(self.endpoint + endpoint, body)
|
71
|
+
end
|
72
|
+
|
73
|
+
def postUrl(url, body=Hash.new())
|
74
|
+
puts body.to_json if ENV["debug_wonde"]
|
75
|
+
return _client().post(url, headers:{ "Accept" => "application/json",
|
76
|
+
"Content-Type" => "application/json"},
|
77
|
+
parameters:body.to_json)
|
78
|
+
end
|
79
|
+
|
80
|
+
def post(body=Hash.new())
|
81
|
+
hash_response = self.postRequest(self.uri, body).body
|
82
|
+
if hash_response.nil?
|
83
|
+
return Hash.new()
|
84
|
+
end
|
85
|
+
return OpenStruct.new hash_response
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
def deleteRequest(endpoint, body=Hash.new())
|
90
|
+
puts "self.endpoint: " + self.endpoint if ENV["debug_wonde"]
|
91
|
+
puts "endpoint:" + endpoint if ENV["debug_wonde"]
|
92
|
+
puts "body:" + body.to_json if ENV["debug_wonde"]
|
93
|
+
return deleteUrl(self.endpoint + endpoint, body)
|
94
|
+
end
|
95
|
+
|
96
|
+
def deleteUrl(url, body=Hash.new())
|
97
|
+
puts body.to_json if ENV["debug_wonde"]
|
98
|
+
return _client().delete(url, headers:{ "Accept" => "application/json",
|
99
|
+
"Content-Type" => "application/json"},
|
100
|
+
parameters:body.to_json)
|
101
|
+
end
|
102
|
+
|
103
|
+
def delete(body=Hash.new())
|
104
|
+
hash_response = self.deleteRequest(self.uri, body).body
|
105
|
+
if hash_response.nil?
|
106
|
+
return Hash.new()
|
107
|
+
end
|
108
|
+
return OpenStruct.new hash_response
|
109
|
+
|
110
|
+
end
|
111
|
+
|
112
|
+
def all(includes = Array.new(), parameters = Hash.new())
|
113
|
+
unless includes.nil? or includes.empty?
|
114
|
+
parameters['include'] = includes.join(",")
|
115
|
+
end
|
116
|
+
|
117
|
+
unless parameters.nil? or parameters.empty?
|
118
|
+
uriparams = Addressable::URI.new
|
119
|
+
uriparams.query_values = parameters
|
120
|
+
uriparams.query
|
121
|
+
uri = self.uri + '?' + uriparams.query
|
122
|
+
else
|
123
|
+
uri = self.uri
|
124
|
+
end
|
125
|
+
response = getRequest(uri).body["data"]
|
126
|
+
puts response if ENV["debug_wonde"]
|
127
|
+
jsonized = response.to_json
|
128
|
+
puts jsonized if ENV["debug_wonde"]
|
129
|
+
object = JSON.parse(jsonized, object_class: OpenStruct)
|
130
|
+
puts object if ENV["debug_wonde"]
|
131
|
+
return object
|
132
|
+
end
|
133
|
+
|
134
|
+
private
|
135
|
+
def _client()
|
136
|
+
Unirest.default_header('Authorization', ('Basic ' + self.token))
|
137
|
+
Unirest.default_header("User-Agent", ("wonde-rb-client-" + self.version))
|
138
|
+
return Unirest
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
data/lib/wondeclient.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
|
2
|
+
module Wonde
|
3
|
+
autoload :Client, 'client'
|
4
|
+
autoload :Endpoints, 'endpoints'
|
5
|
+
#Endpoints
|
6
|
+
autoload :Achievements, 'endpoints/achievements'
|
7
|
+
autoload :Assessment, 'endpoints/assessment'
|
8
|
+
autoload :Attendance, 'endpoints/attendance'
|
9
|
+
autoload :AttendanceCodes, 'endpoints/attendancecodes'
|
10
|
+
autoload :Behaviours, 'endpoints/behaviours'
|
11
|
+
autoload :Classes, 'endpoints/classes'
|
12
|
+
autoload :Contacts, 'endpoints/contacts'
|
13
|
+
autoload :Counts, 'endpoints/counts'
|
14
|
+
autoload :Deletions, 'endpoints/deletions'
|
15
|
+
autoload :Employees, 'endpoints/employees'
|
16
|
+
autoload :Events, 'endpoints/events'
|
17
|
+
autoload :Groups, 'endpoints/groups'
|
18
|
+
autoload :LessonAttendance, 'endpoints/lessonattendance'
|
19
|
+
autoload :Lessons, 'endpoints/lessons'
|
20
|
+
autoload :MedicalConditions, 'endpoints/medicalconditions'
|
21
|
+
autoload :MedicalEvents, 'endpoints/medicalevents'
|
22
|
+
autoload :Periods, 'endpoints/periods'
|
23
|
+
autoload :Photos, 'endpoints/photos'
|
24
|
+
autoload :Rooms, 'endpoints/rooms'
|
25
|
+
autoload :Schools, 'endpoints/schools'
|
26
|
+
autoload :Students, 'endpoints/students'
|
27
|
+
autoload :Subjects, 'endpoints/subjects'
|
28
|
+
#Assesments
|
29
|
+
autoload :Aspects, 'endpoints/assessment/aspects'
|
30
|
+
autoload :MarkSheets, 'endpoints/assessment/marksheets'
|
31
|
+
autoload :Results, 'endpoints/assessment/results'
|
32
|
+
autoload :ResultSets, 'endpoints/assessment/resultsets'
|
33
|
+
autoload :Templates, 'endpoints/assessment/templates'
|
34
|
+
#Writebacks
|
35
|
+
autoload :LessonAttendanceRecord, 'writeback/lessonattendancerecord'
|
36
|
+
autoload :LessonRegister, 'writeback/lessonregister'
|
37
|
+
autoload :SessionAttendanceRecord, 'writeback/sessionattendancerecord'
|
38
|
+
autoload :SessionRegister, 'writeback/sessionregister'
|
39
|
+
#Exceptions
|
40
|
+
autoload :InvalidAttendanceException, 'exceptions/invalidattendanceexception'
|
41
|
+
autoload :InvalidLessonAttendanceException, 'exceptions/invalidlessonattendanceexception'
|
42
|
+
autoload :InvalidSessionException, 'exceptions/invalidsessionexception'
|
43
|
+
autoload :InvalidTokenException, 'exceptions/invalidtokenexception'
|
44
|
+
autoload :ValidationError, 'exceptions/validationerror'
|
45
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Wonde
|
2
|
+
class LessonAttendanceRecord
|
3
|
+
attr_accessor :student_id, :lesson_id, :attendance_code_id
|
4
|
+
|
5
|
+
#most of these methods are here to be compatible 1:1 with the php module, standard ruby getters and setters should still work too
|
6
|
+
|
7
|
+
def setStudentId(studentId)
|
8
|
+
if studentId.empty? or studentId.nil?
|
9
|
+
throw InvalidLessonAttendanceException, 'Student id can not be set to null.'
|
10
|
+
end
|
11
|
+
@student_id = studentId
|
12
|
+
end
|
13
|
+
|
14
|
+
def setLessonId(lessonId)
|
15
|
+
if lessonId.empty? or lessonId.nil?
|
16
|
+
throw InvalidLessonAttendanceException, 'Lesson id can not be set to null.'
|
17
|
+
end
|
18
|
+
@lesson_id = lessonId
|
19
|
+
end
|
20
|
+
|
21
|
+
def setAttendanceCodeId(attendanceCodeId)
|
22
|
+
if attendanceCodeId.empty? or attendanceCodeId.nil?
|
23
|
+
throw InvalidLessonAttendanceException, 'Attendance code id can not be set to null.'
|
24
|
+
end
|
25
|
+
@attendance_code_id = attendanceCodeId
|
26
|
+
end
|
27
|
+
|
28
|
+
def isValid()
|
29
|
+
return ! (self.getStudentId().empty? || self.getLessonId().empty? || self.getAttendanceCodeId().empty?)
|
30
|
+
end
|
31
|
+
|
32
|
+
def getStudentId()
|
33
|
+
return self.student_id
|
34
|
+
end
|
35
|
+
|
36
|
+
def getLessonId()
|
37
|
+
return self.lesson_id
|
38
|
+
end
|
39
|
+
|
40
|
+
def getAttendanceCodeId()
|
41
|
+
return self.attendance_code_id
|
42
|
+
end
|
43
|
+
|
44
|
+
def toArray()
|
45
|
+
required = {
|
46
|
+
'lesson_id': self.getLessonId(),
|
47
|
+
'student_id': self.getStudentId(),
|
48
|
+
'attendance_code_id': self.getAttendanceCodeId()
|
49
|
+
}
|
50
|
+
return required
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Wonde
|
2
|
+
class LessonRegister
|
3
|
+
attr_accessor :attendance
|
4
|
+
def initialize()
|
5
|
+
self.attendance = Array.new()
|
6
|
+
end
|
7
|
+
|
8
|
+
def to_json()
|
9
|
+
{'attendance' => [self.attendance]}.to_json
|
10
|
+
end
|
11
|
+
|
12
|
+
def add(lessonAttendance)
|
13
|
+
newlessonattendance = Array.new()
|
14
|
+
newlessonattendance.push(lessonAttendance)
|
15
|
+
newlessonattendance.each do |lessonAttendanceSingular|
|
16
|
+
if lessonAttendanceSingular.class == LessonAttendanceRecord && lessonAttendanceSingular.isValid()
|
17
|
+
self.attendance = lessonAttendanceSingular.toArray()
|
18
|
+
else
|
19
|
+
unless lessonAttendanceSingular.class == LessonAttendanceRecord
|
20
|
+
throw InvalidLessonAttendanceException, 'Attendance is not an instance of the LessonAttendance Class.'
|
21
|
+
end
|
22
|
+
unless lessonAttendanceSingular.isValid()
|
23
|
+
throw InvalidLessonAttendanceException, 'Attendance has empty fields.'
|
24
|
+
end
|
25
|
+
throw InvalidLessonAttendanceException
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
module Wonde
|
2
|
+
class SessionAttendanceRecord
|
3
|
+
require 'time'
|
4
|
+
attr_accessor :student_id, :date, :session, :attendance_code_id, :comment
|
5
|
+
|
6
|
+
#most of these methods are here to be compatible 1:1 with the php module, standard ruby getters and setters should still work too
|
7
|
+
|
8
|
+
def setStudentId(studentId)
|
9
|
+
if studentId.empty? or studentId.nil?
|
10
|
+
throw InvalidAttendanceException, 'Student id can not be set to null.'
|
11
|
+
end
|
12
|
+
@student_id = studentId
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
def setAttendanceCodeId(attendanceCodeId)
|
17
|
+
if attendanceCodeId.empty? or attendanceCodeId.nil?
|
18
|
+
throw InvalidAttendanceException, 'Attendance code id can not be set to null.'
|
19
|
+
end
|
20
|
+
@attendance_code_id = attendanceCodeId
|
21
|
+
end
|
22
|
+
|
23
|
+
def setDate(date)
|
24
|
+
if date.empty? or date.nil?
|
25
|
+
throw InvalidAttendanceException, 'Date can not be set to null.'
|
26
|
+
end
|
27
|
+
begin
|
28
|
+
mytime = Time.parse(date).to_i
|
29
|
+
rescue
|
30
|
+
throw InvalidAttendanceException, 'Date provided is invalid'
|
31
|
+
end
|
32
|
+
newdate = Time.at(mytime)
|
33
|
+
self.date = newdate
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
def setSession(session)
|
38
|
+
session = session.upcase
|
39
|
+
|
40
|
+
if (session == 'AM' || session == 'PM')
|
41
|
+
self.session = session
|
42
|
+
else
|
43
|
+
throw InvalidSessionException, 'The session is invalid'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def isValid()
|
48
|
+
return ! (self.getDate().empty? || self.getStudentId().empty? || self.getSession().empty? || self.getAttendanceCodeId().empty?)
|
49
|
+
end
|
50
|
+
|
51
|
+
def getStudentId()
|
52
|
+
return self.student_id
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
def getAttendanceCodeId()
|
57
|
+
return self.attendance_code_id
|
58
|
+
end
|
59
|
+
|
60
|
+
def getDate()
|
61
|
+
return self.date.to_s
|
62
|
+
end
|
63
|
+
|
64
|
+
def getSession()
|
65
|
+
return self.session
|
66
|
+
end
|
67
|
+
|
68
|
+
def toArray()
|
69
|
+
required = {
|
70
|
+
'date': self.getDate(),
|
71
|
+
'session': self.getSession(),
|
72
|
+
'student_id': self.getStudentId(),
|
73
|
+
'attendance_code_id': self.getAttendanceCodeId()
|
74
|
+
}
|
75
|
+
unless self.getComment.nil? or self.getComment.empty?
|
76
|
+
required['comment'] = self.getComment()
|
77
|
+
end
|
78
|
+
return required
|
79
|
+
end
|
80
|
+
|
81
|
+
def getComment()
|
82
|
+
return self.comment;
|
83
|
+
end
|
84
|
+
|
85
|
+
def setComment(comment)
|
86
|
+
self.comment = comment;
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Wonde
|
2
|
+
class SessionRegister
|
3
|
+
attr_accessor :attendance
|
4
|
+
def initialize()
|
5
|
+
self.attendance = Array.new()
|
6
|
+
end
|
7
|
+
|
8
|
+
def to_json()
|
9
|
+
{'attendance' => [self.attendance]}.to_json
|
10
|
+
end
|
11
|
+
|
12
|
+
def add(attendance)
|
13
|
+
newattendance = Array.new()
|
14
|
+
newattendance.push(attendance)
|
15
|
+
newattendance.each do |attendanceSingular|
|
16
|
+
if attendanceSingular.class == SessionAttendanceRecord && attendanceSingular.isValid()
|
17
|
+
self.attendance = attendanceSingular.toArray()
|
18
|
+
else
|
19
|
+
unless attendanceSingular.class == SessionAttendanceRecord
|
20
|
+
throw InvalidAttendanceException, 'Attendance is not an instance of the Attendance Class.'
|
21
|
+
end
|
22
|
+
unless attendanceSingular.isValid()
|
23
|
+
throw InvalidAttendanceException, 'Attendance has empty fields.'
|
24
|
+
end
|
25
|
+
throw InvalidAttendanceException
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: wondeclient
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.5
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mike Donlon
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-03-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: unirest
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: Wonde Client
|
28
|
+
email: 'miked63017@gmail.com '
|
29
|
+
executables:
|
30
|
+
- wondeclient
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- bin/wondeclient
|
35
|
+
- lib/client.rb
|
36
|
+
- lib/endpoints.rb
|
37
|
+
- lib/endpoints/achievements.rb
|
38
|
+
- lib/endpoints/assessment.rb
|
39
|
+
- lib/endpoints/assessment/aspects.rb
|
40
|
+
- lib/endpoints/assessment/marksheets.rb
|
41
|
+
- lib/endpoints/assessment/results.rb
|
42
|
+
- lib/endpoints/assessment/resultsets.rb
|
43
|
+
- lib/endpoints/assessment/templates.rb
|
44
|
+
- lib/endpoints/attendance.rb
|
45
|
+
- lib/endpoints/attendancecodes.rb
|
46
|
+
- lib/endpoints/behaviours.rb
|
47
|
+
- lib/endpoints/classes.rb
|
48
|
+
- lib/endpoints/contacts.rb
|
49
|
+
- lib/endpoints/counts.rb
|
50
|
+
- lib/endpoints/deletions.rb
|
51
|
+
- lib/endpoints/employees.rb
|
52
|
+
- lib/endpoints/events.rb
|
53
|
+
- lib/endpoints/groups.rb
|
54
|
+
- lib/endpoints/lessonattendance.rb
|
55
|
+
- lib/endpoints/lessons.rb
|
56
|
+
- lib/endpoints/medicalconditions.rb
|
57
|
+
- lib/endpoints/medicalevents.rb
|
58
|
+
- lib/endpoints/periods.rb
|
59
|
+
- lib/endpoints/photos.rb
|
60
|
+
- lib/endpoints/rooms.rb
|
61
|
+
- lib/endpoints/schools.rb
|
62
|
+
- lib/endpoints/students.rb
|
63
|
+
- lib/endpoints/subjects.rb
|
64
|
+
- lib/exceptions/invalidattendanceexception.rb
|
65
|
+
- lib/exceptions/invalidlessonattendanceexception.rb
|
66
|
+
- lib/exceptions/invalidsessionexception.rb
|
67
|
+
- lib/exceptions/invalidtokenexception.rb
|
68
|
+
- lib/exceptions/validationerror.rb
|
69
|
+
- lib/wondeclient.rb
|
70
|
+
- lib/writeback/lessonattendancerecord.rb
|
71
|
+
- lib/writeback/lessonregister.rb
|
72
|
+
- lib/writeback/sessionattendancerecord.rb
|
73
|
+
- lib/writeback/sessionregister.rb
|
74
|
+
homepage: https://github.com/wondeltd
|
75
|
+
licenses:
|
76
|
+
- MIT
|
77
|
+
metadata: {}
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options: []
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
requirements: []
|
93
|
+
rubyforge_project:
|
94
|
+
rubygems_version: 2.5.1
|
95
|
+
signing_key:
|
96
|
+
specification_version: 4
|
97
|
+
summary: Wonde Client
|
98
|
+
test_files: []
|