absorb_api 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +84 -1
- data/lib/absorb_api.rb +6 -0
- data/lib/absorb_api/course.rb +4 -1
- data/lib/absorb_api/lesson.rb +5 -0
- data/lib/absorb_api/orm.rb +9 -1
- data/lib/absorb_api/prerequisite.rb +5 -0
- data/lib/absorb_api/resource.rb +5 -0
- data/lib/absorb_api/role.rb +5 -0
- data/lib/absorb_api/session_schedule.rb +5 -0
- data/lib/absorb_api/tag.rb +7 -0
- data/lib/absorb_api/user.rb +2 -1
- data/lib/absorb_api/version.rb +1 -1
- metadata +7 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29ac6927feaf3f06a8b8cc7d1c67f83696e34300
|
4
|
+
data.tar.gz: f1dff5922ac85bdf95aa3f0f742c9401e0e1da00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3af4ec6f0fecc9c48b305155cc2fce09ce1292feb4510347cfc4baa7eadcbf633176c671d8c3c4680c743e44ade1406d3ed9d7da13806de36d15f358aff29f5
|
7
|
+
data.tar.gz: 514173a715b6d9c2db6637e263d9b2e55dcc81641c86b14427161adaece3189ba05a2169e32f8509178f4542731b0f7142d89a532c94347c2daf86273acd08c3
|
data/README.md
CHANGED
@@ -17,6 +17,12 @@ Full documentation can be found at [http://npezza93.github.io/absorb_api/](http:
|
|
17
17
|
* [Chapter](#chapter)
|
18
18
|
* [Curriculum](#curriculum)
|
19
19
|
* [Department](#department)
|
20
|
+
* [Role](#role)
|
21
|
+
* [Tag](#tag)
|
22
|
+
* [SessionSchedule](#sessionschedule)
|
23
|
+
* [Resource](#resource)
|
24
|
+
* [Prerequisite](#prerequisite)
|
25
|
+
* [Lesson](#lesson)
|
20
26
|
* [CourseEnrollment](#courseenrollment)
|
21
27
|
* [LessonEnrollment](#lessonenrollment)
|
22
28
|
4. [Development](#development)
|
@@ -73,6 +79,9 @@ user.certificates
|
|
73
79
|
# To return a single certificate for a specific user
|
74
80
|
user.find_certificate(id)
|
75
81
|
|
82
|
+
# To return a collection of all resources available to an user
|
83
|
+
user.resources
|
84
|
+
|
76
85
|
# To return a collection of all courses available for enrollment for a user
|
77
86
|
user.courses
|
78
87
|
|
@@ -110,7 +119,7 @@ course.enrollments
|
|
110
119
|
# Available filters for enrollments include status and modifiedSince
|
111
120
|
course.enrollments(status: 0, modifiedSince: DateTime.new(2016, 1, 1).to_s)
|
112
121
|
|
113
|
-
# To return a collection of all certificates awarded
|
122
|
+
# To return a collection of all certificates awarded in a course
|
114
123
|
course.certificates
|
115
124
|
# Available filters for certificates include includeExpired, acquiredDate, and expiryDate
|
116
125
|
course.certificates(includeExpired: true)
|
@@ -122,6 +131,19 @@ course.chapters
|
|
122
131
|
# To return a single chapters for a specific course
|
123
132
|
course.find_chapter(id)
|
124
133
|
|
134
|
+
# To return a collection of all resources available to a course
|
135
|
+
course.resources
|
136
|
+
# To return a single resource for a specific course
|
137
|
+
course.find_resource(id)
|
138
|
+
|
139
|
+
# To return a collection of all prerequisites to a course
|
140
|
+
course.prerequisites
|
141
|
+
|
142
|
+
# To return a collection of all lessons available to a course
|
143
|
+
course.lessons
|
144
|
+
# To return a single lesson for a specific course
|
145
|
+
course.find_lesson(id)
|
146
|
+
|
125
147
|
# To return a collection of associated enrollments given a collection of courses
|
126
148
|
# Available conditions include modifiedSince and status
|
127
149
|
AbsorbApi::Course.enrollments_from_collection(courses, modifiedSince: DateTime.new(2016, 1, 1))
|
@@ -185,6 +207,67 @@ AbsorbApi::Department.create do |department|
|
|
185
207
|
end
|
186
208
|
```
|
187
209
|
|
210
|
+
### Role
|
211
|
+
```ruby
|
212
|
+
# To return a collection of all available roles
|
213
|
+
AbsorbApi::Role.all
|
214
|
+
|
215
|
+
# To find a single role by id
|
216
|
+
AbsorbApi::Role.find(id)
|
217
|
+
```
|
218
|
+
|
219
|
+
### Tag
|
220
|
+
```ruby
|
221
|
+
# To return a collection of all available tags
|
222
|
+
AbsorbApi::Tag.all
|
223
|
+
|
224
|
+
# To find a single tag by id
|
225
|
+
AbsorbApi::Tag.find(id)
|
226
|
+
|
227
|
+
# To create a new tag
|
228
|
+
AbsorbApi::Tag.create(name: "example")
|
229
|
+
# or
|
230
|
+
AbsorbApi::Tag.create do |tag|
|
231
|
+
user.name = "example"
|
232
|
+
end
|
233
|
+
```
|
234
|
+
|
235
|
+
### SessionSchedule
|
236
|
+
```ruby
|
237
|
+
# To return a collection of all available session schedules
|
238
|
+
AbsorbApi::SessionSchedule.all
|
239
|
+
|
240
|
+
# To find a single session schedule by id
|
241
|
+
AbsorbApi::SessionSchedule.find(id)
|
242
|
+
```
|
243
|
+
|
244
|
+
### Resource
|
245
|
+
```ruby
|
246
|
+
# To return a collection of all available resources
|
247
|
+
AbsorbApi::Resource.all
|
248
|
+
|
249
|
+
# To find a single resource by id
|
250
|
+
AbsorbApi::Resource.find(id)
|
251
|
+
```
|
252
|
+
|
253
|
+
### Prerequisite
|
254
|
+
```ruby
|
255
|
+
# To return a collection of all available prerequisites
|
256
|
+
AbsorbApi::Prerequisite.all
|
257
|
+
|
258
|
+
# To find a single prerequisite by id
|
259
|
+
AbsorbApi::Prerequisite.find(id)
|
260
|
+
```
|
261
|
+
|
262
|
+
### Lesson
|
263
|
+
```ruby
|
264
|
+
# To return a collection of all available lessons
|
265
|
+
AbsorbApi::Lesson.all
|
266
|
+
|
267
|
+
# To find a single lesson by id
|
268
|
+
AbsorbApi::Lesson.find(id)
|
269
|
+
```
|
270
|
+
|
188
271
|
### CourseEnrollment
|
189
272
|
```ruby
|
190
273
|
# To return a collection of associated lessons matching conditions
|
data/lib/absorb_api.rb
CHANGED
@@ -21,6 +21,12 @@ require "absorb_api/certificate"
|
|
21
21
|
require "absorb_api/chapter"
|
22
22
|
require "absorb_api/curriculum"
|
23
23
|
require "absorb_api/department"
|
24
|
+
require "absorb_api/tag"
|
25
|
+
require "absorb_api/session_schedule"
|
26
|
+
require "absorb_api/role"
|
27
|
+
require "absorb_api/resource"
|
28
|
+
require "absorb_api/prerequisite"
|
29
|
+
require "absorb_api/lesson"
|
24
30
|
|
25
31
|
module AbsorbApi
|
26
32
|
end
|
data/lib/absorb_api/course.rb
CHANGED
@@ -7,7 +7,10 @@ module AbsorbApi
|
|
7
7
|
has_many :certificates
|
8
8
|
has_many :chapters
|
9
9
|
has_many :enrollments, :course_enrollment
|
10
|
-
|
10
|
+
has_many :resources
|
11
|
+
has_many :prerequisites
|
12
|
+
has_many :lessons
|
13
|
+
|
11
14
|
# gets all associated enrollments given a collection of courses
|
12
15
|
# all calls are called in parallel
|
13
16
|
def self.enrollments_from_collection(courses, **conditions)
|
data/lib/absorb_api/orm.rb
CHANGED
@@ -10,13 +10,21 @@ module AbsorbApi
|
|
10
10
|
def find(id)
|
11
11
|
raise ResourceNotFound if id.blank?
|
12
12
|
response = Base.api.get("#{to_s.demodulize.pluralize}/#{id}")
|
13
|
-
response.status == 404
|
13
|
+
if response.status == 404
|
14
|
+
raise(RouteNotFound)
|
15
|
+
elsif response.status == 400
|
16
|
+
raise ResourceNotFound
|
17
|
+
else
|
18
|
+
new(response.body)
|
19
|
+
end
|
14
20
|
end
|
15
21
|
|
16
22
|
def all
|
17
23
|
response = Base.api.get("#{to_s.demodulize.pluralize}")
|
18
24
|
if response.status == 404
|
19
25
|
raise RouteNotFound
|
26
|
+
elsif response.status == 400
|
27
|
+
raise ResourceNotFound
|
20
28
|
else
|
21
29
|
Collection.new( response.body.map! do |attributes|
|
22
30
|
new(attributes)
|
data/lib/absorb_api/user.rb
CHANGED
@@ -7,7 +7,8 @@ module AbsorbApi
|
|
7
7
|
has_many :courses
|
8
8
|
has_many :enrollments, klass: :course_enrollment
|
9
9
|
has_many :certificates
|
10
|
-
|
10
|
+
has_many :resources
|
11
|
+
|
11
12
|
# gets all associated courses given a collection of users
|
12
13
|
# all calls are called in parallel
|
13
14
|
# users are chunked in groups of 105 to keep typhoeus from getting bogged down
|
data/lib/absorb_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: absorb_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- npezza
|
@@ -135,9 +135,15 @@ files:
|
|
135
135
|
- lib/absorb_api/course_enrollment.rb
|
136
136
|
- lib/absorb_api/curriculum.rb
|
137
137
|
- lib/absorb_api/department.rb
|
138
|
+
- lib/absorb_api/lesson.rb
|
138
139
|
- lib/absorb_api/lesson_enrollment.rb
|
139
140
|
- lib/absorb_api/orm.rb
|
141
|
+
- lib/absorb_api/prerequisite.rb
|
140
142
|
- lib/absorb_api/relations.rb
|
143
|
+
- lib/absorb_api/resource.rb
|
144
|
+
- lib/absorb_api/role.rb
|
145
|
+
- lib/absorb_api/session_schedule.rb
|
146
|
+
- lib/absorb_api/tag.rb
|
141
147
|
- lib/absorb_api/user.rb
|
142
148
|
- lib/absorb_api/version.rb
|
143
149
|
homepage: https://github.com/npezza93/absorb_api
|