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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e97b036ecdf252f7e84b6031f3aa8dfd0cd7610b
4
- data.tar.gz: 6a090874c4fac1e9b5136498ef7f5ead6966418c
3
+ metadata.gz: ffdeb2475681552091445eba9aa00bdcf33df8d7
4
+ data.tar.gz: c6503c5b12114a7f8cd639b810ac5dd656b23671
5
5
  SHA512:
6
- metadata.gz: db5215aa793422983809d8fb88f50165be6d72229d89e033ffe290be1c5af35ae8b136f63b9cf3918947ed51e2443e39e1390da5437c81bbc5fe6fdfc993f016
7
- data.tar.gz: 87dac09e9d041a5cadc937a2c2b0bf1524e51c83e00a2b093cb2c3d4f223c033f509e365db0830ec608a30e032702dbab320f9b2728744acaf2e21c7a55eb351
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.10)
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.0)
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.2)
64
+ tzinfo (1.2.3)
65
65
  thread_safe (~> 0.1)
66
66
  webmock (1.22.6)
67
67
  addressable (>= 2.3.6)
@@ -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 {|file| require file }
30
-
31
- include CourseTemplate
32
- include Enrollment
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
@@ -1,3 +1,3 @@
1
1
  module BridgeAPI
2
- VERSION = '0.0.11' unless defined?(BridgeAPI::VERSION)
2
+ VERSION = '0.0.12' unless defined?(BridgeAPI::VERSION)
3
3
  end
@@ -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
@@ -0,0 +1,14 @@
1
+ {
2
+ "meta": { },
3
+ "groups": [
4
+ {
5
+ "id": "6",
6
+ "parent_id": "",
7
+ "external_id": "",
8
+ "name": null,
9
+ "type": "smart",
10
+ "users_count": 0,
11
+ "links": { }
12
+ }
13
+ ]
14
+ }
@@ -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.11
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-03-30 00:00:00.000000000 Z
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