bridge_api 0.0.11 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -3
- data/lib/bridge_api/client.rb +5 -10
- data/lib/bridge_api/client/group.rb +13 -0
- data/lib/bridge_api/version.rb +1 -1
- data/spec/bridge_api/client/group_spec.rb +25 -0
- data/spec/fixtures/group.json +14 -0
- data/spec/support/fake_bridge.rb +10 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ffdeb2475681552091445eba9aa00bdcf33df8d7
|
4
|
+
data.tar.gz: c6503c5b12114a7f8cd639b810ac5dd656b23671
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51cfb544f896ba30f56edb9d80eedb216ed9b7419709a2d7b9bc32f4f9f9930944d37e36363a8c1cea286743382c83a7a27009fabca673f5fdeeb2b055a8d953
|
7
|
+
data.tar.gz: 1b58a15df476ded08dd5f1d827938b7085ce3ebff3c8c2cd17ed54463baec4eceb350ba43c4c714b13268049958849925652b686695f5a5ce9e4cad1aecc6076
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
bridge_api (0.0.
|
4
|
+
bridge_api (0.0.12)
|
5
5
|
faraday (~> 0.9.0)
|
6
6
|
faraday_middleware (~> 0.9.0)
|
7
7
|
footrest (>= 0.5.1)
|
@@ -14,7 +14,7 @@ GEM
|
|
14
14
|
i18n (~> 0.7)
|
15
15
|
minitest (~> 5.1)
|
16
16
|
tzinfo (~> 1.1)
|
17
|
-
addressable (2.5.
|
17
|
+
addressable (2.5.1)
|
18
18
|
public_suffix (~> 2.0, >= 2.0.2)
|
19
19
|
byebug (8.2.5)
|
20
20
|
coderay (1.1.1)
|
@@ -61,7 +61,7 @@ GEM
|
|
61
61
|
slop (3.6.0)
|
62
62
|
thread_safe (0.3.6)
|
63
63
|
tilt (1.4.1)
|
64
|
-
tzinfo (1.2.
|
64
|
+
tzinfo (1.2.3)
|
65
65
|
thread_safe (~> 0.1)
|
66
66
|
webmock (1.22.6)
|
67
67
|
addressable (>= 2.3.6)
|
data/lib/bridge_api/client.rb
CHANGED
@@ -16,6 +16,7 @@ module BridgeAPI
|
|
16
16
|
COURSE_TEMPLATE_PATH = '/course_templates'
|
17
17
|
ENROLLMENT_PATH = '/enrollments'
|
18
18
|
USER_PATH = '/users'
|
19
|
+
GROUPS_PATH = '/groups'
|
19
20
|
MANAGER_PATH = '/managers'
|
20
21
|
ADMIN_PATH = "/admin"
|
21
22
|
AUTHOR_PATH = "/author"
|
@@ -26,15 +27,10 @@ module BridgeAPI
|
|
26
27
|
|
27
28
|
require 'bridge_api/api_array'
|
28
29
|
|
29
|
-
Dir[File.dirname(__FILE__) + '/client/*.rb'].each
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
include User
|
34
|
-
include Manager
|
35
|
-
include CustomField
|
36
|
-
include Footrest
|
37
|
-
include DataDump
|
30
|
+
Dir[File.dirname(__FILE__) + '/client/*.rb'].each do |file|
|
31
|
+
require file
|
32
|
+
include self.const_get("#{File.basename(file).gsub('.rb','').split("_").map{|ea| ea.capitalize}.join('')}")
|
33
|
+
end
|
38
34
|
|
39
35
|
# Override Footrest request for ApiArray support
|
40
36
|
def request(method, &block)
|
@@ -68,7 +64,6 @@ module BridgeAPI
|
|
68
64
|
end
|
69
65
|
end
|
70
66
|
end
|
71
|
-
|
72
67
|
end
|
73
68
|
end
|
74
69
|
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module BridgeAPI
|
2
|
+
class Client
|
3
|
+
module Group
|
4
|
+
def add_group(params = {})
|
5
|
+
post("#{API_PATH}#{AUTHOR_PATH}#{GROUPS_PATH}", params)
|
6
|
+
end
|
7
|
+
|
8
|
+
def update_group(group_id, params = {})
|
9
|
+
put("#{API_PATH}#{AUTHOR_PATH}#{GROUPS_PATH}/#{group_id}", params)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/bridge_api/version.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
describe BridgeAPI::Client::Group do
|
4
|
+
before do
|
5
|
+
@client = BridgeAPI::Client.new(prefix: "http://test.bridge.com", token: "test_token")
|
6
|
+
end
|
7
|
+
|
8
|
+
let(:params) {{ name: 'Test Group', smart: true }}
|
9
|
+
|
10
|
+
it 'should create a group' do
|
11
|
+
response = @client.add_group(groups: params)
|
12
|
+
expect(response.status).to eq(201)
|
13
|
+
expect(response.members.count).to eq(1)
|
14
|
+
expect(response.members.first['id']).to eq('6')
|
15
|
+
expect(response.members.first['type']).to eq('smart')
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should update a group' do
|
19
|
+
response = @client.update_group(1, group: params)
|
20
|
+
expect(response.status).to eq(200)
|
21
|
+
expect(response.members.count).to eq(1)
|
22
|
+
expect(response.members.first['id']).to eq('6')
|
23
|
+
expect(response.members.first['type']).to eq('smart')
|
24
|
+
end
|
25
|
+
end
|
data/spec/support/fake_bridge.rb
CHANGED
@@ -120,6 +120,16 @@ class FakeBridge < Sinatra::Base
|
|
120
120
|
get_json_data 200, nil
|
121
121
|
end
|
122
122
|
|
123
|
+
# Groups
|
124
|
+
|
125
|
+
post %r{/api/author/groups} do
|
126
|
+
get_json_data 201, 'group.json'
|
127
|
+
end
|
128
|
+
|
129
|
+
put %r{/api/author/groups/\d+$} do
|
130
|
+
get_json_data 200, 'group.json'
|
131
|
+
end
|
132
|
+
|
123
133
|
private
|
124
134
|
|
125
135
|
def get_json_data(response_code, file_name)
|
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.
|
4
|
+
version: 0.0.12
|
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-
|
11
|
+
date: 2017-04-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -194,6 +194,7 @@ files:
|
|
194
194
|
- lib/bridge_api/client/custom_field.rb
|
195
195
|
- lib/bridge_api/client/data_dump.rb
|
196
196
|
- lib/bridge_api/client/enrollment.rb
|
197
|
+
- lib/bridge_api/client/group.rb
|
197
198
|
- lib/bridge_api/client/manager.rb
|
198
199
|
- lib/bridge_api/client/user.rb
|
199
200
|
- lib/bridge_api/version.rb
|
@@ -201,6 +202,7 @@ files:
|
|
201
202
|
- spec/bridge_api/client/custom_field_spec.rb
|
202
203
|
- spec/bridge_api/client/data_dump_spec.rb
|
203
204
|
- spec/bridge_api/client/enrollment_spec.rb
|
205
|
+
- spec/bridge_api/client/group_spec.rb
|
204
206
|
- spec/bridge_api/client/manager_spec.rb
|
205
207
|
- spec/bridge_api/client/user_spec.rb
|
206
208
|
- spec/bridge_api/client_spec.rb
|
@@ -212,6 +214,7 @@ files:
|
|
212
214
|
- spec/fixtures/direct_reports.json
|
213
215
|
- spec/fixtures/enrollment.json
|
214
216
|
- spec/fixtures/enrollments.json
|
217
|
+
- spec/fixtures/group.json
|
215
218
|
- spec/fixtures/managers.json
|
216
219
|
- spec/fixtures/programs.json
|
217
220
|
- spec/fixtures/user.json
|
@@ -247,6 +250,7 @@ test_files:
|
|
247
250
|
- spec/bridge_api/client/custom_field_spec.rb
|
248
251
|
- spec/bridge_api/client/data_dump_spec.rb
|
249
252
|
- spec/bridge_api/client/enrollment_spec.rb
|
253
|
+
- spec/bridge_api/client/group_spec.rb
|
250
254
|
- spec/bridge_api/client/manager_spec.rb
|
251
255
|
- spec/bridge_api/client/user_spec.rb
|
252
256
|
- spec/bridge_api/client_spec.rb
|
@@ -258,6 +262,7 @@ test_files:
|
|
258
262
|
- spec/fixtures/direct_reports.json
|
259
263
|
- spec/fixtures/enrollment.json
|
260
264
|
- spec/fixtures/enrollments.json
|
265
|
+
- spec/fixtures/group.json
|
261
266
|
- spec/fixtures/managers.json
|
262
267
|
- spec/fixtures/programs.json
|
263
268
|
- spec/fixtures/user.json
|