bridge_api 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5aab44d2529605313129140d8ef6144830e69b20
4
- data.tar.gz: 009f3875596e5ddaa7216462f8b605289ce40614
3
+ metadata.gz: 0a1de39e97d1d9cadedf267acdd46a191d2f5cc3
4
+ data.tar.gz: 60e39f89efaa95fdd6d8c7ff181f9bf9b5199384
5
5
  SHA512:
6
- metadata.gz: 4f0d07ab9e68c9eaa81a07517daf8dc285de353197f47d738b2f413e614956feac06b2a8609ed59b7c569a09819b39c9a07447578502f0e66430a29ae404c510
7
- data.tar.gz: bf5cf61588796feb7c1ffd883c2dcce69399d100faf5add8b06be4fc544b9915c926aad07cb346c071eb4aaa41d64284e90bb2466663fa3e322d7ec94c9dd172
6
+ metadata.gz: 08a85d3aa87e53f9eb87289e4e913b403a3fe712f424ba399713fe56f1923c171f388f6a97c86363e0f5e31978cf04ed1a6f9897171f7d5759080f3fefdf0625
7
+ data.tar.gz: acdb384cddc1b0f71a94454c0e79e7eabe05eef1974b50805e632d8a3139d336faafa07dd2689926573452b256b411f1ecb6b780c23a33eb233184a9a6932374
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bridge_api (0.0.3)
4
+ bridge_api (0.0.6)
5
5
  faraday (~> 0.9.0)
6
6
  faraday_middleware (~> 0.9.0)
7
7
  footrest (>= 0.5.1)
@@ -17,6 +17,7 @@ module BridgeAPI
17
17
  ADMIN_PATH = "/admin"
18
18
  AUTHOR_PATH = "/author"
19
19
  LEARNER_PATH = "/learner"
20
+ CUSTOM_FIELD_PATH = "/custom_fields"
20
21
  API_VERSION = 1
21
22
  API_PATH = '/api'
22
23
 
@@ -27,6 +28,7 @@ module BridgeAPI
27
28
  include CourseTemplate
28
29
  include Enrollment
29
30
  include User
31
+ include CustomField
30
32
  include Footrest
31
33
 
32
34
  # Override Footrest request for ApiArray support
@@ -0,0 +1,27 @@
1
+ module BridgeAPI
2
+ class Client
3
+ module CustomField
4
+
5
+ def add_custom_field(params = {})
6
+ post("#{API_PATH}#{AUTHOR_PATH}#{CUSTOM_FIELD_PATH}", params)
7
+ end
8
+
9
+ def get_custom_field(custom_field_id, params = {})
10
+ get("#{API_PATH}#{AUTHOR_PATH}#{CUSTOM_FIELD_PATH}/#{custom_field_id}", params)
11
+ end
12
+
13
+ def delete_custom_field(custom_field_id, params = {})
14
+ delete("#{API_PATH}#{AUTHOR_PATH}#{CUSTOM_FIELD_PATH}/#{custom_field_id}", params)
15
+ end
16
+
17
+ def update_custom_field(custom_field_id, params = {})
18
+ put("#{API_PATH}#{AUTHOR_PATH}#{CUSTOM_FIELD_PATH}/#{custom_field_id}", params)
19
+ end
20
+
21
+ def get_all_custom_fields(params = {})
22
+ get("#{API_PATH}#{AUTHOR_PATH}#{CUSTOM_FIELD_PATH}", params)
23
+ end
24
+
25
+ end
26
+ end
27
+ end
@@ -1,3 +1,3 @@
1
1
  module BridgeAPI
2
- VERSION = '0.0.5' unless defined?(BridgeAPI::VERSION)
2
+ VERSION = '0.0.6' unless defined?(BridgeAPI::VERSION)
3
3
  end
@@ -0,0 +1,35 @@
1
+ require 'test_helper'
2
+ require 'byebug'
3
+ describe BridgeAPI::Client::CustomField do
4
+
5
+ before do
6
+ @client = BridgeAPI::Client.new(prefix: "http://test.bridge.com", token: "test_token")
7
+ end
8
+
9
+ it 'should add an custom field' do
10
+ response = @client.add_custom_field
11
+ expect(response.first['id']).to(eq("30"))
12
+ end
13
+
14
+ it 'should get a custom field' do
15
+ response = @client.get_custom_field(1)
16
+ expect(response.first['id']).to(eq("30"))
17
+ end
18
+
19
+ it 'should delete an custom field' do
20
+ response = @client.delete_custom_field(1)
21
+ expect(response.status).to(eq(204))
22
+ end
23
+
24
+ it 'should update a custom field' do
25
+ response = @client.update_custom_field(1)
26
+ expect(response.first['id']).to(eq("30"))
27
+ end
28
+
29
+ it 'should get all custom field' do
30
+ response = @client.get_all_custom_fields
31
+ expect(response.length).to(eq(1))
32
+ end
33
+
34
+ end
35
+
@@ -0,0 +1,9 @@
1
+ {
2
+ "meta": {},
3
+ "custom_fields": [
4
+ {
5
+ "id": "30",
6
+ "name": "test1"
7
+ }
8
+ ]
9
+ }
@@ -75,6 +75,28 @@ class FakeBridge < Sinatra::Base
75
75
  get_json_data 200, 'enrollment.json'
76
76
  end
77
77
 
78
+ #Custom Fields
79
+
80
+ get %r{/api/author/custom_fields} do
81
+ get_json_data 200, 'custom_fields.json'
82
+ end
83
+
84
+ get %r{/api/author/custom_fields/\d+$} do
85
+ get_json_data 200, 'custom_fields.json'
86
+ end
87
+
88
+ put %r{/api/author/custom_fields/\d+$} do
89
+ get_json_data 200, 'custom_fields.json'
90
+ end
91
+
92
+ post %r{/api/author/custom_fields} do
93
+ get_json_data 200, 'custom_fields.json'
94
+ end
95
+
96
+ delete %r{/api/author/custom_fields/\d+$} do
97
+ get_json_data 204, nil
98
+ end
99
+
78
100
  private
79
101
 
80
102
  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.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jay Shaffer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-29 00:00:00.000000000 Z
11
+ date: 2016-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -191,15 +191,18 @@ files:
191
191
  - lib/bridge_api/api_array.rb
192
192
  - lib/bridge_api/client.rb
193
193
  - lib/bridge_api/client/course_template.rb
194
+ - lib/bridge_api/client/custom_field.rb
194
195
  - lib/bridge_api/client/enrollment.rb
195
196
  - lib/bridge_api/client/user.rb
196
197
  - lib/bridge_api/version.rb
197
198
  - spec/bridge_api/client/course_template_spec.rb
199
+ - spec/bridge_api/client/custom_field_spec.rb
198
200
  - spec/bridge_api/client/enrollment_spec.rb
199
201
  - spec/bridge_api/client/user_spec.rb
200
202
  - spec/bridge_api/client_spec.rb
201
203
  - spec/fixtures/course.json
202
204
  - spec/fixtures/courses.json
205
+ - spec/fixtures/custom_fields.json
203
206
  - spec/fixtures/enrollment.json
204
207
  - spec/fixtures/enrollments.json
205
208
  - spec/fixtures/programs.json
@@ -227,17 +230,19 @@ required_rubygems_version: !ruby/object:Gem::Requirement
227
230
  version: '0'
228
231
  requirements: []
229
232
  rubyforge_project:
230
- rubygems_version: 2.2.2
233
+ rubygems_version: 2.5.1
231
234
  signing_key:
232
235
  specification_version: 4
233
236
  summary: Bridge API
234
237
  test_files:
235
238
  - spec/bridge_api/client/course_template_spec.rb
239
+ - spec/bridge_api/client/custom_field_spec.rb
236
240
  - spec/bridge_api/client/enrollment_spec.rb
237
241
  - spec/bridge_api/client/user_spec.rb
238
242
  - spec/bridge_api/client_spec.rb
239
243
  - spec/fixtures/course.json
240
244
  - spec/fixtures/courses.json
245
+ - spec/fixtures/custom_fields.json
241
246
  - spec/fixtures/enrollment.json
242
247
  - spec/fixtures/enrollments.json
243
248
  - spec/fixtures/programs.json
@@ -245,4 +250,3 @@ test_files:
245
250
  - spec/fixtures/users.json
246
251
  - spec/support/fake_bridge.rb
247
252
  - spec/test_helper.rb
248
- has_rdoc: