bridge_api 0.0.12 → 0.0.13

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: ffdeb2475681552091445eba9aa00bdcf33df8d7
4
- data.tar.gz: c6503c5b12114a7f8cd639b810ac5dd656b23671
3
+ metadata.gz: aa247d0c90a1e78f78434ff7a13b768627956db8
4
+ data.tar.gz: 7112201e71a64448ba46a366c77bd353a306df9a
5
5
  SHA512:
6
- metadata.gz: 51cfb544f896ba30f56edb9d80eedb216ed9b7419709a2d7b9bc32f4f9f9930944d37e36363a8c1cea286743382c83a7a27009fabca673f5fdeeb2b055a8d953
7
- data.tar.gz: 1b58a15df476ded08dd5f1d827938b7085ce3ebff3c8c2cd17ed54463baec4eceb350ba43c4c714b13268049958849925652b686695f5a5ce9e4cad1aecc6076
6
+ metadata.gz: b35e1515f91a563140e1c889e5346e9ef8886ba153d608f1f250c709ccba5a53600e50168c787ade26c93145aabd05c9adc6e6e86c189205400df19bbeb0b74f
7
+ data.tar.gz: 0a5b2d4b7884c7d87ab342728b78d447b90fcd4c3e7e6db3ba88883f841eb4a935256d895740b1cac53dd380dcdd3d620e1d862ff9074a93447e6cb3e874da8e
@@ -15,6 +15,8 @@ module BridgeAPI
15
15
  DATA_DUMP_PATH = '/data_dumps'
16
16
  COURSE_TEMPLATE_PATH = '/course_templates'
17
17
  ENROLLMENT_PATH = '/enrollments'
18
+ PROGRAM_PATH = '/programs'
19
+ PROGRAM_ENROLLMENT_PATH = '/learners'
18
20
  USER_PATH = '/users'
19
21
  GROUPS_PATH = '/groups'
20
22
  MANAGER_PATH = '/managers'
@@ -0,0 +1,21 @@
1
+ module BridgeAPI
2
+ class Client
3
+ # WARNING: the API endpoint for program enrollments is currently undocumented
4
+ # in the Bridge API. It's possible that it might change or be removed in the
5
+ # future, causing this to break.
6
+
7
+ module ProgramEnrollment
8
+ def add_program_enrollment(program_id, params = {})
9
+ post("#{API_PATH}#{AUTHOR_PATH}#{PROGRAM_PATH}/#{program_id}#{PROGRAM_ENROLLMENT_PATH}", params)
10
+ end
11
+
12
+ def delete_program_enrollment(program_id, enrollment_id, params = {})
13
+ delete("#{API_PATH}#{AUTHOR_PATH}#{PROGRAM_PATH}/#{program_id}#{PROGRAM_ENROLLMENT_PATH}/#{enrollment_id}", params)
14
+ end
15
+
16
+ def get_all_program_enrollments(program_id, params = {})
17
+ get("#{API_PATH}#{AUTHOR_PATH}#{PROGRAM_PATH}/#{program_id}#{PROGRAM_ENROLLMENT_PATH}", params)
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,3 +1,3 @@
1
1
  module BridgeAPI
2
- VERSION = '0.0.12' unless defined?(BridgeAPI::VERSION)
2
+ VERSION = '0.0.13' unless defined?(BridgeAPI::VERSION)
3
3
  end
@@ -0,0 +1,22 @@
1
+ require 'test_helper'
2
+
3
+ describe BridgeAPI::Client::ProgramEnrollment do
4
+ before do
5
+ @client = BridgeAPI::Client.new(prefix: "http://test.bridge.com", token: "test_token")
6
+ end
7
+
8
+ it 'should add a program enrollment' do
9
+ response = @client.add_program_enrollment(1)
10
+ expect(response.status).to(eq(204))
11
+ end
12
+
13
+ it 'should delete a program enrollment' do
14
+ response = @client.delete_program_enrollment(1, 2)
15
+ expect(response.status).to(eq(204))
16
+ end
17
+
18
+ it 'should get all program enrollments' do
19
+ enrollments = @client.get_all_enrollments(1)
20
+ expect(enrollments.length).to(eq(2))
21
+ end
22
+ end
@@ -0,0 +1,39 @@
1
+ {
2
+ "meta": {},
3
+ "learners": [
4
+ {
5
+ "id": "2",
6
+ "name": "fakeperon",
7
+ "email": "fakeemail@fakedomain.com",
8
+ "avatar_url": null,
9
+ "state": "active",
10
+ "current_program_item_index": 0,
11
+ "program_items_complete": 0,
12
+ "total_program_items": 1,
13
+ "current_program_item_due": 7,
14
+ "program_due": null,
15
+ "group_ids": [],
16
+ "current_course_index": 0,
17
+ "courses_complete": 0,
18
+ "total_courses": 1,
19
+ "current_course_due": 7
20
+ },
21
+ {
22
+ "id": "3",
23
+ "name": "fakeperson2",
24
+ "email": null,
25
+ "avatar_url": null,
26
+ "state": "active",
27
+ "current_program_item_index": 0,
28
+ "program_items_complete": 0,
29
+ "total_program_items": 1,
30
+ "current_program_item_due": 7,
31
+ "program_due": null,
32
+ "group_ids": [],
33
+ "current_course_index": 0,
34
+ "courses_complete": 0,
35
+ "total_courses": 1,
36
+ "current_course_due": 7
37
+ }
38
+ ]
39
+ }
@@ -35,6 +35,20 @@ class FakeBridge < Sinatra::Base
35
35
  get_json_data 200, 'programs.json'
36
36
  end
37
37
 
38
+ ## Program enrollments
39
+
40
+ get %r{/api/author/programs/\d+/learners} do
41
+ get_json_data 200, 'program_enrollments.json'
42
+ end
43
+
44
+ post %r{/api/author/programs/\d+/learners} do
45
+ get_json_data 204, nil
46
+ end
47
+
48
+ delete %r{/api/author/programs/\d+/learners} do
49
+ get_json_data 204, nil
50
+ end
51
+
38
52
  ## Users
39
53
 
40
54
  get %r{/api/author/users$} do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bridge_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jay Shaffer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-17 00:00:00.000000000 Z
11
+ date: 2017-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -196,6 +196,7 @@ files:
196
196
  - lib/bridge_api/client/enrollment.rb
197
197
  - lib/bridge_api/client/group.rb
198
198
  - lib/bridge_api/client/manager.rb
199
+ - lib/bridge_api/client/program_enrollment.rb
199
200
  - lib/bridge_api/client/user.rb
200
201
  - lib/bridge_api/version.rb
201
202
  - spec/bridge_api/client/course_template_spec.rb
@@ -204,6 +205,7 @@ files:
204
205
  - spec/bridge_api/client/enrollment_spec.rb
205
206
  - spec/bridge_api/client/group_spec.rb
206
207
  - spec/bridge_api/client/manager_spec.rb
208
+ - spec/bridge_api/client/program_enrollment_spec.rb
207
209
  - spec/bridge_api/client/user_spec.rb
208
210
  - spec/bridge_api/client_spec.rb
209
211
  - spec/fixtures/course.json
@@ -216,6 +218,7 @@ files:
216
218
  - spec/fixtures/enrollments.json
217
219
  - spec/fixtures/group.json
218
220
  - spec/fixtures/managers.json
221
+ - spec/fixtures/program_enrollments.json
219
222
  - spec/fixtures/programs.json
220
223
  - spec/fixtures/user.json
221
224
  - spec/fixtures/users.json
@@ -241,7 +244,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
241
244
  version: '0'
242
245
  requirements: []
243
246
  rubyforge_project:
244
- rubygems_version: 2.4.5
247
+ rubygems_version: 2.5.2
245
248
  signing_key:
246
249
  specification_version: 4
247
250
  summary: Bridge API
@@ -252,6 +255,7 @@ test_files:
252
255
  - spec/bridge_api/client/enrollment_spec.rb
253
256
  - spec/bridge_api/client/group_spec.rb
254
257
  - spec/bridge_api/client/manager_spec.rb
258
+ - spec/bridge_api/client/program_enrollment_spec.rb
255
259
  - spec/bridge_api/client/user_spec.rb
256
260
  - spec/bridge_api/client_spec.rb
257
261
  - spec/fixtures/course.json
@@ -264,9 +268,9 @@ test_files:
264
268
  - spec/fixtures/enrollments.json
265
269
  - spec/fixtures/group.json
266
270
  - spec/fixtures/managers.json
271
+ - spec/fixtures/program_enrollments.json
267
272
  - spec/fixtures/programs.json
268
273
  - spec/fixtures/user.json
269
274
  - spec/fixtures/users.json
270
275
  - spec/support/fake_bridge.rb
271
276
  - spec/test_helper.rb
272
- has_rdoc: