bridge_api 0.0.1 → 0.0.2

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: 15c3b894f06ca9f65f91b19eb4cde98f2ef5c570
4
- data.tar.gz: a369351fe7d85428b9a6fe90f71fc72b076bc962
3
+ metadata.gz: 264eec7506c4257374c9c315ee8e9f85812fc845
4
+ data.tar.gz: 9687012147f9c6a73cc0590f91672625e2ae54ab
5
5
  SHA512:
6
- metadata.gz: 37eccbf695ba29433e660db1c93a516d1eb57ffecf41a9f0d05f89489597d04456bb2757e2709725ebbeca086f5263f6f9f328dce1c8ee44e773867b5b3e875a
7
- data.tar.gz: b9c5fe4cf15c271badb1a3ca210fff894cb0648f7a8300835675870bd5e19c663a43abb1f3a18885648e39bf32f604af8e8b0e5385006a9e047719d79cb9ed68
6
+ metadata.gz: 6483a097e8dfef5684c9cc68cd90f4e1cb7a57fa9aac9a56b74a3b7c0c5fb95f398199d0158a4deeb936b76166690cb5a11aa319e9c9b27ba30ff6d9e175581f
7
+ data.tar.gz: 3929e52aade312c104db482ffb6cd3242107608b7eefbb21807c15b9808d3d9f8d6d47a0b11e694f996f9995985edc504b4da93abec501aa707bef8477f56568
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,81 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ bridge_api (0.0.1)
5
+ faraday (~> 0.9.0)
6
+ faraday_middleware (~> 0.9.0)
7
+ footrest (>= 0.5.1)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ activesupport (4.2.6)
13
+ i18n (~> 0.7)
14
+ json (~> 1.7, >= 1.7.7)
15
+ minitest (~> 5.1)
16
+ thread_safe (~> 0.3, >= 0.3.4)
17
+ tzinfo (~> 1.1)
18
+ addressable (2.4.0)
19
+ byebug (8.2.2)
20
+ coderay (1.1.1)
21
+ crack (0.4.3)
22
+ safe_yaml (~> 1.0.0)
23
+ diff-lcs (1.2.5)
24
+ faraday (0.9.2)
25
+ multipart-post (>= 1.2, < 3)
26
+ faraday_middleware (0.9.2)
27
+ faraday (>= 0.7.4, < 0.10)
28
+ footrest (0.5.1)
29
+ activesupport (>= 3.0.0)
30
+ faraday (~> 0.9.0)
31
+ link_header (>= 0.0.7)
32
+ hashdiff (0.2.3)
33
+ i18n (0.7.0)
34
+ json (1.8.3)
35
+ link_header (0.0.8)
36
+ method_source (0.8.2)
37
+ minitest (5.8.4)
38
+ multipart-post (2.0.0)
39
+ pry (0.10.3)
40
+ coderay (~> 1.1.0)
41
+ method_source (~> 0.8.1)
42
+ slop (~> 3.4)
43
+ rack (1.6.4)
44
+ rake (0.9.6)
45
+ rspec (2.99.0)
46
+ rspec-core (~> 2.99.0)
47
+ rspec-expectations (~> 2.99.0)
48
+ rspec-mocks (~> 2.99.0)
49
+ rspec-core (2.99.2)
50
+ rspec-expectations (2.99.2)
51
+ diff-lcs (>= 1.1.3, < 2.0)
52
+ rspec-mocks (2.99.4)
53
+ safe_yaml (1.0.4)
54
+ sinatra (1.0)
55
+ rack (>= 1.0)
56
+ slop (3.6.0)
57
+ thread_safe (0.3.5)
58
+ tilt (1.4.1)
59
+ tzinfo (1.2.2)
60
+ thread_safe (~> 0.1)
61
+ webmock (1.22.6)
62
+ addressable (>= 2.3.6)
63
+ crack (>= 0.3.2)
64
+ hashdiff
65
+
66
+ PLATFORMS
67
+ ruby
68
+
69
+ DEPENDENCIES
70
+ bridge_api!
71
+ bundler (~> 1.0, >= 1.0.0)
72
+ byebug (~> 8.2.2)
73
+ pry (~> 0)
74
+ rake (~> 0)
75
+ rspec (~> 2.6)
76
+ sinatra (~> 1.0)
77
+ tilt (~> 1.3, >= 1.3.4)
78
+ webmock (~> 1.22.6)
79
+
80
+ BUNDLED WITH
81
+ 1.11.2
data/bridge_api.gemspec CHANGED
@@ -21,10 +21,14 @@ Gem::Specification.new do |gem|
21
21
  gem.add_development_dependency 'rake', '~> 0'
22
22
  gem.add_development_dependency 'bundler', '~> 1.0', '>= 1.0.0'
23
23
  gem.add_development_dependency 'rspec', '~> 2.6'
24
- gem.add_development_dependency 'webmock', '~> 0'
24
+ gem.add_development_dependency 'webmock', '~>1.22.6'
25
25
  gem.add_development_dependency 'pry', '~> 0'
26
26
  gem.add_development_dependency 'tilt', '>= 1.3.4', '~> 1.3'
27
+ gem.add_development_dependency 'sinatra', '~> 1.0'
28
+ gem.add_development_dependency 'byebug', '~> 8.2.2'
27
29
 
28
- gem.add_dependency 'footrest', '~> 0.2', '>= 0.2.2'
30
+ gem.add_dependency 'footrest', '>= 0.5.1'
31
+ gem.add_dependency 'faraday', '~> 0.9.0'
32
+ gem.add_dependency 'faraday_middleware', '~> 0.9.0'
29
33
 
30
34
  end
@@ -1,4 +1,12 @@
1
1
  require 'footrest/client'
2
+ require 'faraday'
3
+ require 'footrest'
4
+ require 'byebug'
5
+ require 'footrest/http_error'
6
+ require 'footrest/pagination'
7
+ require 'footrest/follow_redirects'
8
+ require 'footrest/parse_json'
9
+
2
10
 
3
11
  module BridgeAPI
4
12
  class Client < Footrest::Client
@@ -19,12 +27,41 @@ module BridgeAPI
19
27
  include CourseTemplate
20
28
  include Enrollment
21
29
  include User
30
+ include Footrest
22
31
 
23
32
  # Override Footrest request for ApiArray support
24
33
  def request(method, &block)
25
34
  ApiArray::process_response(connection.send(method, &block), self)
26
35
  end
27
36
 
37
+ def set_connection(config)
38
+ config[:logger] = config[:logging] if config[:logging]
39
+ @connection = Faraday.new(url: config[:prefix]) do |faraday|
40
+ faraday.request :multipart
41
+ faraday.request :url_encoded
42
+ if config[:logger] == true
43
+ faraday.response :logger
44
+ elsif config[:logger]
45
+ faraday.use Faraday::Response::Logger, config[:logger]
46
+ end
47
+ faraday.adapter Faraday.default_adapter
48
+ faraday.use Footrest::FollowRedirects
49
+ faraday.use Footrest::ParseJson, :content_type => /\bjson$/
50
+ faraday.use Footrest::RaiseFootrestErrors
51
+ faraday.use Footrest::Pagination
52
+ faraday.headers[:accept] = "application/json"
53
+ faraday.headers[:authorization] = "Bearer #{config[:token]}" if config[:token]
54
+ faraday.headers[:user_agent] = "Footrest"
55
+ if config[:basic_api_token]
56
+ faraday.headers[:authorization] = "Basic #{config[:basic_api_token]}"
57
+ elsif config[:token]
58
+ faraday.headers[:authorization] = "Bearer #{config[:token]}"
59
+ else
60
+ raise 'No authorization token provided'
61
+ end
62
+ end
63
+ end
64
+
28
65
  end
29
66
  end
30
67
 
@@ -1,3 +1,3 @@
1
1
  module BridgeAPI
2
- VERSION = '0.0.1' unless defined?(BridgeAPI::VERSION)
2
+ VERSION = '0.0.2' unless defined?(BridgeAPI::VERSION)
3
3
  end
@@ -0,0 +1,10 @@
1
+
2
+ describe BridgeAPI::Client do
3
+
4
+ it 'should set the auth header to basic auth' do
5
+ client = BridgeAPI::Client.new(prefix: "https://www.fake.com", basic_api_token: "test_token")
6
+ expect(client.connection.headers['Authorization']).to(eq("Basic test_token"))
7
+ end
8
+
9
+
10
+ end
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.1
4
+ version: 0.0.2
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-03 00:00:00.000000000 Z
11
+ date: 2016-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -64,14 +64,14 @@ dependencies:
64
64
  requirements:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: '0'
67
+ version: 1.22.6
68
68
  type: :development
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
- version: '0'
74
+ version: 1.22.6
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: pry
77
77
  requirement: !ruby/object:Gem::Requirement
@@ -107,25 +107,75 @@ dependencies:
107
107
  - !ruby/object:Gem::Version
108
108
  version: '1.3'
109
109
  - !ruby/object:Gem::Dependency
110
- name: footrest
110
+ name: sinatra
111
+ requirement: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - "~>"
114
+ - !ruby/object:Gem::Version
115
+ version: '1.0'
116
+ type: :development
117
+ prerelease: false
118
+ version_requirements: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - "~>"
121
+ - !ruby/object:Gem::Version
122
+ version: '1.0'
123
+ - !ruby/object:Gem::Dependency
124
+ name: byebug
111
125
  requirement: !ruby/object:Gem::Requirement
112
126
  requirements:
113
127
  - - "~>"
114
128
  - !ruby/object:Gem::Version
115
- version: '0.2'
129
+ version: 8.2.2
130
+ type: :development
131
+ prerelease: false
132
+ version_requirements: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - "~>"
135
+ - !ruby/object:Gem::Version
136
+ version: 8.2.2
137
+ - !ruby/object:Gem::Dependency
138
+ name: footrest
139
+ requirement: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - ">="
142
+ - !ruby/object:Gem::Version
143
+ version: 0.5.1
144
+ type: :runtime
145
+ prerelease: false
146
+ version_requirements: !ruby/object:Gem::Requirement
147
+ requirements:
116
148
  - - ">="
117
149
  - !ruby/object:Gem::Version
118
- version: 0.2.2
150
+ version: 0.5.1
151
+ - !ruby/object:Gem::Dependency
152
+ name: faraday
153
+ requirement: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - "~>"
156
+ - !ruby/object:Gem::Version
157
+ version: 0.9.0
119
158
  type: :runtime
120
159
  prerelease: false
121
160
  version_requirements: !ruby/object:Gem::Requirement
122
161
  requirements:
123
162
  - - "~>"
124
163
  - !ruby/object:Gem::Version
125
- version: '0.2'
126
- - - ">="
164
+ version: 0.9.0
165
+ - !ruby/object:Gem::Dependency
166
+ name: faraday_middleware
167
+ requirement: !ruby/object:Gem::Requirement
168
+ requirements:
169
+ - - "~>"
170
+ - !ruby/object:Gem::Version
171
+ version: 0.9.0
172
+ type: :runtime
173
+ prerelease: false
174
+ version_requirements: !ruby/object:Gem::Requirement
175
+ requirements:
176
+ - - "~>"
127
177
  - !ruby/object:Gem::Version
128
- version: 0.2.2
178
+ version: 0.9.0
129
179
  description: Ruby gem for interacting with the bridge API
130
180
  email:
131
181
  - jshaffer@instructure.com
@@ -134,6 +184,8 @@ extensions: []
134
184
  extra_rdoc_files: []
135
185
  files:
136
186
  - ".gitignore"
187
+ - Gemfile
188
+ - Gemfile.lock
137
189
  - bridge_api.gemspec
138
190
  - lib/bridge_api.rb
139
191
  - lib/bridge_api/api_array.rb
@@ -145,6 +197,7 @@ files:
145
197
  - spec/bridge_api/client/course_template_spec.rb
146
198
  - spec/bridge_api/client/enrollment_spec.rb
147
199
  - spec/bridge_api/client/user_spec.rb
200
+ - spec/bridge_api/client_spec.rb
148
201
  - spec/fixtures/course.json
149
202
  - spec/fixtures/courses.json
150
203
  - spec/fixtures/enrollment.json
@@ -174,7 +227,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
174
227
  version: '0'
175
228
  requirements: []
176
229
  rubyforge_project:
177
- rubygems_version: 2.4.3
230
+ rubygems_version: 2.2.2
178
231
  signing_key:
179
232
  specification_version: 4
180
233
  summary: Bridge API
@@ -182,6 +235,7 @@ test_files:
182
235
  - spec/bridge_api/client/course_template_spec.rb
183
236
  - spec/bridge_api/client/enrollment_spec.rb
184
237
  - spec/bridge_api/client/user_spec.rb
238
+ - spec/bridge_api/client_spec.rb
185
239
  - spec/fixtures/course.json
186
240
  - spec/fixtures/courses.json
187
241
  - spec/fixtures/enrollment.json