bridge_api 0.0.10 → 0.0.11

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: fff6d7e4f40afd6489e00f363522839bc555c81e
4
- data.tar.gz: 72b1516f3a3b45ac7b25aad4d700fbb8b9dfd6cb
3
+ metadata.gz: e97b036ecdf252f7e84b6031f3aa8dfd0cd7610b
4
+ data.tar.gz: 6a090874c4fac1e9b5136498ef7f5ead6966418c
5
5
  SHA512:
6
- metadata.gz: c3a18e535a948c4f25a9fb4969673b2ea4bdf9d25d9129f7f3a3889b21b3950faf5db1d731458b00cf18403d95fd9ee8c0870138af7c4579c074457fdf062bed
7
- data.tar.gz: 644f45595347fa9e6372e1c085b0d99c0655f6da5a31de9d0fdf6ec79cb538975712756f5b90c029466157e6d92e90c1a36db6469b0927f158edb79d2a52d0c6
6
+ metadata.gz: db5215aa793422983809d8fb88f50165be6d72229d89e033ffe290be1c5af35ae8b136f63b9cf3918947ed51e2443e39e1390da5437c81bbc5fe6fdfc993f016
7
+ data.tar.gz: 87dac09e9d041a5cadc937a2c2b0bf1524e51c83e00a2b093cb2c3d4f223c033f509e365db0830ec608a30e032702dbab320f9b2728744acaf2e21c7a55eb351
data/Gemfile.lock CHANGED
@@ -14,13 +14,14 @@ GEM
14
14
  i18n (~> 0.7)
15
15
  minitest (~> 5.1)
16
16
  tzinfo (~> 1.1)
17
- addressable (2.4.0)
18
- byebug (8.2.2)
17
+ addressable (2.5.0)
18
+ public_suffix (~> 2.0, >= 2.0.2)
19
+ byebug (8.2.5)
19
20
  coderay (1.1.1)
20
21
  concurrent-ruby (1.0.5)
21
22
  crack (0.4.3)
22
23
  safe_yaml (~> 1.0.0)
23
- diff-lcs (1.2.5)
24
+ diff-lcs (1.3)
24
25
  faraday (0.9.2)
25
26
  multipart-post (>= 1.2, < 3)
26
27
  faraday_middleware (0.9.2)
@@ -29,17 +30,20 @@ GEM
29
30
  activesupport (>= 3.0.0)
30
31
  faraday (~> 0.9.0)
31
32
  link_header (>= 0.0.7)
32
- hashdiff (0.2.3)
33
+ hashdiff (0.3.2)
33
34
  i18n (0.8.1)
34
35
  link_header (0.0.8)
35
36
  method_source (0.8.2)
36
37
  minitest (5.10.1)
37
38
  multipart-post (2.0.0)
38
- pry (0.10.3)
39
+ pry (0.10.4)
39
40
  coderay (~> 1.1.0)
40
41
  method_source (~> 0.8.1)
41
42
  slop (~> 3.4)
42
- rack (1.6.4)
43
+ public_suffix (2.0.5)
44
+ rack (1.6.5)
45
+ rack-protection (1.5.3)
46
+ rack
43
47
  rake (0.9.6)
44
48
  rspec (2.99.0)
45
49
  rspec-core (~> 2.99.0)
@@ -50,8 +54,10 @@ GEM
50
54
  diff-lcs (>= 1.1.3, < 2.0)
51
55
  rspec-mocks (2.99.4)
52
56
  safe_yaml (1.0.4)
53
- sinatra (1.0)
54
- rack (>= 1.0)
57
+ sinatra (1.4.8)
58
+ rack (~> 1.5)
59
+ rack-protection (~> 1.4)
60
+ tilt (>= 1.3, < 3)
55
61
  slop (3.6.0)
56
62
  thread_safe (0.3.6)
57
63
  tilt (1.4.1)
@@ -77,4 +83,4 @@ DEPENDENCIES
77
83
  webmock (~> 1.22.6)
78
84
 
79
85
  BUNDLED WITH
80
- 1.13.7
86
+ 1.13.6
@@ -11,7 +11,7 @@ module BridgeAPI
11
11
  attr_reader :status, :headers, :members
12
12
 
13
13
  def self.process_response(response, api_client)
14
- ApiArray.new(response, api_client)
14
+ ApiArray.new(response, api_client)
15
15
  end
16
16
 
17
17
  def initialize(response, api_client)
@@ -19,7 +19,7 @@ module BridgeAPI
19
19
  @linked = {}
20
20
  @meta = {}
21
21
  case response.status
22
- when 200..206
22
+ when *((200..206).to_a + [302])
23
23
  apply_response_metadata(response)
24
24
  @members = get_response_content(response)
25
25
  end
@@ -11,6 +11,8 @@ require 'base64'
11
11
  module BridgeAPI
12
12
  class Client < Footrest::Client
13
13
 
14
+ DATA_DUMP_DOWNLOAD_PATH = '/data_dumps/download'
15
+ DATA_DUMP_PATH = '/data_dumps'
14
16
  COURSE_TEMPLATE_PATH = '/course_templates'
15
17
  ENROLLMENT_PATH = '/enrollments'
16
18
  USER_PATH = '/users'
@@ -32,6 +34,7 @@ module BridgeAPI
32
34
  include Manager
33
35
  include CustomField
34
36
  include Footrest
37
+ include DataDump
35
38
 
36
39
  # Override Footrest request for ApiArray support
37
40
  def request(method, &block)
@@ -48,8 +51,8 @@ module BridgeAPI
48
51
  elsif config[:logger]
49
52
  faraday.use Faraday::Response::Logger, config[:logger]
50
53
  end
54
+ faraday.use Footrest::FollowRedirects, limit: 5 unless config[:follow_redirects] == false
51
55
  faraday.adapter Faraday.default_adapter
52
- faraday.use Footrest::FollowRedirects
53
56
  faraday.use Footrest::ParseJson, :content_type => /\bjson$/
54
57
  faraday.use Footrest::RaiseFootrestErrors
55
58
  faraday.use Footrest::Pagination
@@ -0,0 +1,17 @@
1
+ module BridgeAPI
2
+ class Client
3
+ module DataDump
4
+ def get_data_dumps(params = {})
5
+ get("#{API_PATH}#{ADMIN_PATH}#{DATA_DUMP_PATH}", params)
6
+ end
7
+
8
+ def create_data_dump(params = {})
9
+ post("#{API_PATH}#{ADMIN_PATH}#{DATA_DUMP_PATH}", params)
10
+ end
11
+
12
+ def download_data_dump(params = {})
13
+ get("#{API_PATH}#{ADMIN_PATH}#{DATA_DUMP_DOWNLOAD_PATH}", params)
14
+ end
15
+ end
16
+ end
17
+ end
@@ -1,3 +1,3 @@
1
1
  module BridgeAPI
2
- VERSION = '0.0.10' unless defined?(BridgeAPI::VERSION)
2
+ VERSION = '0.0.11' unless defined?(BridgeAPI::VERSION)
3
3
  end
@@ -0,0 +1,26 @@
1
+ require 'test_helper'
2
+
3
+ describe BridgeAPI::Client::DataDump do
4
+ before do
5
+ @client = BridgeAPI::Client.new(prefix: "http://test.bridge.com", token: "test_token")
6
+ end
7
+
8
+ it 'should get all data dumps' do
9
+ response = @client.get_data_dumps
10
+ expect(response.status).to eq(200)
11
+ expect(response.members.count).to eq(1)
12
+ expect(response.members.first['status']).to eq('complete')
13
+ end
14
+
15
+ it 'should create a data dump' do
16
+ response = @client.create_data_dump
17
+ expect(response.status).to eq(200)
18
+ expect(response.members.count).to eq(1)
19
+ expect(response.members.first['status']).to eq('pending')
20
+ end
21
+
22
+ it 'should download a data dump' do
23
+ response = @client.download_data_dump
24
+ expect(response.status).to eq(200)
25
+ end
26
+ end
@@ -0,0 +1,9 @@
1
+ {
2
+ "meta": {},
3
+ "data_dumps": [
4
+ {
5
+ "status": "pending",
6
+ "date": "2015-11-12T19:03:37Z"
7
+ }
8
+ ]
9
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "meta": {},
3
+ "data_dumps": [
4
+ {
5
+ "status": "complete",
6
+ "date": "2015-11-12T19:03:37Z"
7
+ }
8
+ ]
9
+ }
@@ -106,6 +106,20 @@ class FakeBridge < Sinatra::Base
106
106
  get_json_data 204, nil
107
107
  end
108
108
 
109
+ # Data Dumps
110
+
111
+ get %r{/api/admin/data_dumps} do
112
+ get_json_data 200, 'data_dumps.json'
113
+ end
114
+
115
+ post %r{/api/admin/data_dumps} do
116
+ get_json_data 200, 'data_dump.json'
117
+ end
118
+
119
+ get %r{/api/admin/data_dumps/download} do
120
+ get_json_data 200, nil
121
+ end
122
+
109
123
  private
110
124
 
111
125
  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.10
4
+ version: 0.0.11
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-09 00:00:00.000000000 Z
11
+ date: 2017-03-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -192,12 +192,14 @@ files:
192
192
  - lib/bridge_api/client.rb
193
193
  - lib/bridge_api/client/course_template.rb
194
194
  - lib/bridge_api/client/custom_field.rb
195
+ - lib/bridge_api/client/data_dump.rb
195
196
  - lib/bridge_api/client/enrollment.rb
196
197
  - lib/bridge_api/client/manager.rb
197
198
  - lib/bridge_api/client/user.rb
198
199
  - lib/bridge_api/version.rb
199
200
  - spec/bridge_api/client/course_template_spec.rb
200
201
  - spec/bridge_api/client/custom_field_spec.rb
202
+ - spec/bridge_api/client/data_dump_spec.rb
201
203
  - spec/bridge_api/client/enrollment_spec.rb
202
204
  - spec/bridge_api/client/manager_spec.rb
203
205
  - spec/bridge_api/client/user_spec.rb
@@ -205,6 +207,8 @@ files:
205
207
  - spec/fixtures/course.json
206
208
  - spec/fixtures/courses.json
207
209
  - spec/fixtures/custom_fields.json
210
+ - spec/fixtures/data_dump.json
211
+ - spec/fixtures/data_dumps.json
208
212
  - spec/fixtures/direct_reports.json
209
213
  - spec/fixtures/enrollment.json
210
214
  - spec/fixtures/enrollments.json
@@ -234,13 +238,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
234
238
  version: '0'
235
239
  requirements: []
236
240
  rubyforge_project:
237
- rubygems_version: 2.5.1
241
+ rubygems_version: 2.4.5
238
242
  signing_key:
239
243
  specification_version: 4
240
244
  summary: Bridge API
241
245
  test_files:
242
246
  - spec/bridge_api/client/course_template_spec.rb
243
247
  - spec/bridge_api/client/custom_field_spec.rb
248
+ - spec/bridge_api/client/data_dump_spec.rb
244
249
  - spec/bridge_api/client/enrollment_spec.rb
245
250
  - spec/bridge_api/client/manager_spec.rb
246
251
  - spec/bridge_api/client/user_spec.rb
@@ -248,6 +253,8 @@ test_files:
248
253
  - spec/fixtures/course.json
249
254
  - spec/fixtures/courses.json
250
255
  - spec/fixtures/custom_fields.json
256
+ - spec/fixtures/data_dump.json
257
+ - spec/fixtures/data_dumps.json
251
258
  - spec/fixtures/direct_reports.json
252
259
  - spec/fixtures/enrollment.json
253
260
  - spec/fixtures/enrollments.json
@@ -257,3 +264,4 @@ test_files:
257
264
  - spec/fixtures/users.json
258
265
  - spec/support/fake_bridge.rb
259
266
  - spec/test_helper.rb
267
+ has_rdoc: