bcx 1.0.0 → 1.1.0
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 +4 -4
- data/README.md +3 -2
- data/bcx.gemspec +1 -1
- data/lib/bcx.rb +7 -2
- data/lib/bcx/client/http.rb +6 -0
- data/lib/bcx/client/oauth.rb +7 -0
- data/lib/bcx/configuration.rb +1 -1
- data/lib/bcx/response_error.rb +5 -1
- data/lib/bcx/version.rb +1 -1
- data/spec/bcx/access_spec.rb +2 -2
- data/spec/bcx/client_spec.rb +9 -2
- data/spec/cassettes/Bcx_Client/error_handling/should_raise_exception_with_array_error.yml +56 -0
- data/spec/cassettes/Bcx_Client/error_handling/{should_raise_exception.yml → should_raise_exception_with_string_error.yml} +1 -1
- data/spec/spec_helper.rb +0 -1
- metadata +24 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85e40c84d39ed27c5608eb29bbc277dc05c46f70
|
4
|
+
data.tar.gz: 1a1afb7ebbe093ee8286422ae2f6267d99562580
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21b3887a2b1d025448eefa216b8a368af69a96ba0631a8f170dc3b1368c3eaea6675318bba23d86d571959f5f2d4060eb4035aaa1906f19761df0fd50db820a2
|
7
|
+
data.tar.gz: 23b400ac212a1a29e4434b4d3c7683eb5e8dc221801fe972b901d0d4ce0a575548326376562e5220e577be074d809ba03a473dde9f4cea7c8f103b32157a13d0
|
data/README.md
CHANGED
@@ -35,11 +35,12 @@ $ bundle install
|
|
35
35
|
|
36
36
|
### Usage
|
37
37
|
|
38
|
-
Configure Bcx for your Basecamp account
|
38
|
+
Configure Bcx for your Basecamp account. Basecamp requests that you provide contact information for your app through the user_agent string, for eventual technical issues.
|
39
39
|
|
40
40
|
```ruby
|
41
41
|
Bcx.configure do |config|
|
42
42
|
config.account = '1234567890'
|
43
|
+
config.user_agent = 'My great app name. https://app.com/contact_us.rb, contact: me@me.com'
|
43
44
|
end
|
44
45
|
```
|
45
46
|
|
@@ -82,7 +83,7 @@ client = Bcx::Client::OAuth.new(client_id: '1234567890', client_secret: '831994c
|
|
82
83
|
|
83
84
|
You can get a `client_id` and `client_secret` from https://integrate.37signals.com/
|
84
85
|
|
85
|
-
You can also pass an `:account` option to the OAuth client (allowing multiple clients in your app).
|
86
|
+
You can also pass an `:account` option to the OAuth client (allowing multiple clients in your app), in which case do you not need to specify an account in the config block.
|
86
87
|
|
87
88
|
```ruby
|
88
89
|
client = Bcx::Client::OAuth.new(account: 99999999, ...)
|
data/bcx.gemspec
CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |gem|
|
|
16
16
|
gem.version = Bcx::VERSION
|
17
17
|
gem.license = 'MIT'
|
18
18
|
|
19
|
-
gem.add_runtime_dependency 'rapidash', '~> 0.
|
19
|
+
gem.add_runtime_dependency 'rapidash', '~> 0.4.0'
|
20
20
|
|
21
21
|
gem.add_development_dependency 'rake'
|
22
22
|
gem.add_development_dependency 'rspec'
|
data/lib/bcx.rb
CHANGED
@@ -29,12 +29,17 @@ module Bcx
|
|
29
29
|
end
|
30
30
|
|
31
31
|
class << self
|
32
|
-
|
32
|
+
attr_writer :configuration
|
33
|
+
end
|
34
|
+
|
35
|
+
# Create configuration block in case the user does not call configure
|
36
|
+
def self.configuration
|
37
|
+
self.class.instance_variable_set('@configuration',Configuration.new) if self.class.instance_variable_get('@configuration').nil?
|
38
|
+
self.class.instance_variable_get('@configuration')
|
33
39
|
end
|
34
40
|
|
35
41
|
# Expose configuration block
|
36
42
|
def self.configure
|
37
|
-
self.configuration ||= Configuration.new
|
38
43
|
yield(configuration)
|
39
44
|
end
|
40
45
|
end
|
data/lib/bcx/client/http.rb
CHANGED
@@ -24,6 +24,12 @@ module Bcx
|
|
24
24
|
def initialize(options = {})
|
25
25
|
@account = Bcx.configuration.account
|
26
26
|
@api_version = Bcx.configuration.api_version
|
27
|
+
@user_agent = options[:user_agent] || Bcx.configuration.user_agent
|
28
|
+
if @user_agent
|
29
|
+
options[:request_default_options] ||= {}
|
30
|
+
options[:request_default_options][:header] ||= {}
|
31
|
+
options[:request_default_options][:header][:user_agent] ||= @user_agent
|
32
|
+
end
|
27
33
|
|
28
34
|
self.class.site("https://basecamp.com/#{@account}/api/#{@api_version}/")
|
29
35
|
|
data/lib/bcx/client/oauth.rb
CHANGED
@@ -23,11 +23,18 @@ module Bcx
|
|
23
23
|
def initialize(options = {})
|
24
24
|
@account = options[:account] || Bcx.configuration.account
|
25
25
|
@api_version = Bcx.configuration.api_version
|
26
|
+
@user_agent = options[:user_agent] || Bcx.configuration.user_agent
|
26
27
|
|
27
28
|
options[:site] = "https://basecamp.com/#{@account}/api/#{@api_version}"
|
28
29
|
options[:uid] ||= options[:client_id]
|
29
30
|
options[:secret] ||= options[:client_secret]
|
30
31
|
|
32
|
+
if @user_agent
|
33
|
+
options[:request_default_options] ||= {}
|
34
|
+
options[:request_default_options][:header] ||= {}
|
35
|
+
options[:request_default_options][:header][:user_agent] ||= @user_agent
|
36
|
+
end
|
37
|
+
|
31
38
|
super(options)
|
32
39
|
end
|
33
40
|
end
|
data/lib/bcx/configuration.rb
CHANGED
data/lib/bcx/response_error.rb
CHANGED
@@ -27,7 +27,11 @@ module Bcx
|
|
27
27
|
messages = []
|
28
28
|
|
29
29
|
body.each_pair do |attribute, msgs|
|
30
|
-
msgs.each
|
30
|
+
if msgs.respond_to? :each
|
31
|
+
msgs.each { |msg| messages.push "#{attribute} #{msg}" }
|
32
|
+
else
|
33
|
+
messages.push "#{attribute} #{msgs.to_s}"
|
34
|
+
end
|
31
35
|
end
|
32
36
|
|
33
37
|
messages.join(', ')
|
data/lib/bcx/version.rb
CHANGED
data/spec/bcx/access_spec.rb
CHANGED
@@ -19,7 +19,7 @@ describe Bcx::Resources::Access, :vcr do
|
|
19
19
|
it "should grant access" do
|
20
20
|
client.projects(2951531).accesses.create!(email_addresses: ["hopper.derek@gmail.com"])
|
21
21
|
accesses = client.projects(2951531).accesses!
|
22
|
-
accesses.detect { |access| access.id == 4996562 }.
|
22
|
+
expect(accesses.detect { |access| access.id == 4996562 }).to be_present
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
@@ -27,7 +27,7 @@ describe Bcx::Resources::Access, :vcr do
|
|
27
27
|
it "should revoke access" do
|
28
28
|
client.projects(2951531).accesses(4996562).delete!
|
29
29
|
accesses = client.projects(2951531).accesses!
|
30
|
-
accesses.detect { |access| access.id == 4996562 }.
|
30
|
+
expect(accesses.detect { |access| access.id == 4996562 }).not_to be_present
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
data/spec/bcx/client_spec.rb
CHANGED
@@ -33,13 +33,20 @@ describe Bcx::Client do
|
|
33
33
|
|
34
34
|
describe "error handling", :vcr do
|
35
35
|
let(:client) { Bcx::Client::HTTP.new(login: 'bcx-test-user', password: 'secret') }
|
36
|
-
|
37
|
-
it "should raise exception" do
|
36
|
+
it "should raise exception_with_array_error" do
|
38
37
|
expect { client.projects.create!(name: '') }.to raise_error { |response|
|
39
38
|
expect(response).to be_a Bcx::ResponseError
|
40
39
|
expect(response.status).to eq 422
|
41
40
|
expect(response.errors).to include("name can't be blank")
|
42
41
|
}
|
43
42
|
end
|
43
|
+
|
44
|
+
it "should raise exception_with_string_error" do
|
45
|
+
expect { client.projects.create!(name: '') }.to raise_error { |response|
|
46
|
+
expect(response).to be_a Bcx::ResponseError
|
47
|
+
expect(response.status).to eq 422
|
48
|
+
expect(response.errors).to include("name can't be blank")
|
49
|
+
}
|
50
|
+
end
|
44
51
|
end
|
45
52
|
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://basecamp.com/2274488/api/v1/projects.json
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: ! '{"name":""}'
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v0.8.7
|
12
|
+
Authorization:
|
13
|
+
- Basic YmN4LXRlc3QtdXNlcjpzZWNyZXQ=
|
14
|
+
Content-Type:
|
15
|
+
- application/json
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 422
|
19
|
+
message:
|
20
|
+
headers:
|
21
|
+
server:
|
22
|
+
- nginx
|
23
|
+
date:
|
24
|
+
- Fri, 21 Jun 2013 21:32:47 GMT
|
25
|
+
content-type:
|
26
|
+
- application/json; charset=utf-8
|
27
|
+
transfer-encoding:
|
28
|
+
- chunked
|
29
|
+
connection:
|
30
|
+
- close
|
31
|
+
status:
|
32
|
+
- 422 Unprocessable Entity
|
33
|
+
x-frame-options:
|
34
|
+
- SAMEORIGIN
|
35
|
+
x-xss-protection:
|
36
|
+
- 1; mode=block
|
37
|
+
x-content-type-options:
|
38
|
+
- nosniff
|
39
|
+
x-ua-compatible:
|
40
|
+
- chrome=1
|
41
|
+
x-xhr-current-location:
|
42
|
+
- /2274488/api/v1/projects.json
|
43
|
+
x-asset-paths:
|
44
|
+
- ! '{"application.js":"application-eb8afc75ba8fcbb36b8518826dd32bc5.js","application.css":"application-18059b31e3ebdcca82003cfaf2564179.css"}'
|
45
|
+
cache-control:
|
46
|
+
- no-cache
|
47
|
+
x-request-id:
|
48
|
+
- e203c487-d807-41b5-afd6-4f709fcb35e3
|
49
|
+
x-runtime:
|
50
|
+
- '0.145644'
|
51
|
+
body:
|
52
|
+
encoding: US-ASCII
|
53
|
+
string: ! '{"name":["can''t be blank","can''t be duplicate"]}'
|
54
|
+
http_version:
|
55
|
+
recorded_at: Fri, 21 Jun 2013 21:32:47 GMT
|
56
|
+
recorded_with: VCR 2.5.0
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,83 +1,83 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bcx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Springett
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rapidash
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.4.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.4.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: simplecov
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: vcr
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
description: Fully-fledged Ruby API wrapper for Basecamp Next
|
@@ -87,9 +87,9 @@ executables: []
|
|
87
87
|
extensions: []
|
88
88
|
extra_rdoc_files: []
|
89
89
|
files:
|
90
|
-
- .gitignore
|
91
|
-
- .rspec
|
92
|
-
- .travis.yml
|
90
|
+
- ".gitignore"
|
91
|
+
- ".rspec"
|
92
|
+
- ".travis.yml"
|
93
93
|
- Gemfile
|
94
94
|
- LICENSE
|
95
95
|
- README.md
|
@@ -143,7 +143,8 @@ files:
|
|
143
143
|
- spec/bcx/project_spec.rb
|
144
144
|
- spec/bcx/todo_spec.rb
|
145
145
|
- spec/bcx/todolist_spec.rb
|
146
|
-
- spec/cassettes/Bcx_Client/error_handling/
|
146
|
+
- spec/cassettes/Bcx_Client/error_handling/should_raise_exception_with_array_error.yml
|
147
|
+
- spec/cassettes/Bcx_Client/error_handling/should_raise_exception_with_string_error.yml
|
147
148
|
- spec/cassettes/Bcx_Resources_Access/DELETE_/projects/2951531/accesses/4996562_json/should_revoke_access.yml
|
148
149
|
- spec/cassettes/Bcx_Resources_Access/GET_/projects/2951531/accesses_json/first_access_should_have_the_correct_id.yml
|
149
150
|
- spec/cassettes/Bcx_Resources_Access/GET_/projects/2951531/accesses_json/should_be_an_array.yml
|
@@ -203,17 +204,17 @@ require_paths:
|
|
203
204
|
- lib
|
204
205
|
required_ruby_version: !ruby/object:Gem::Requirement
|
205
206
|
requirements:
|
206
|
-
- -
|
207
|
+
- - ">="
|
207
208
|
- !ruby/object:Gem::Version
|
208
209
|
version: '0'
|
209
210
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
210
211
|
requirements:
|
211
|
-
- -
|
212
|
+
- - ">="
|
212
213
|
- !ruby/object:Gem::Version
|
213
214
|
version: '0'
|
214
215
|
requirements: []
|
215
216
|
rubyforge_project:
|
216
|
-
rubygems_version: 2.4.
|
217
|
+
rubygems_version: 2.4.5
|
217
218
|
signing_key:
|
218
219
|
specification_version: 4
|
219
220
|
summary: Fully-fledged Ruby API wrapper for Basecamp Next. Uses the Rapidash gem under
|
@@ -228,7 +229,8 @@ test_files:
|
|
228
229
|
- spec/bcx/project_spec.rb
|
229
230
|
- spec/bcx/todo_spec.rb
|
230
231
|
- spec/bcx/todolist_spec.rb
|
231
|
-
- spec/cassettes/Bcx_Client/error_handling/
|
232
|
+
- spec/cassettes/Bcx_Client/error_handling/should_raise_exception_with_array_error.yml
|
233
|
+
- spec/cassettes/Bcx_Client/error_handling/should_raise_exception_with_string_error.yml
|
232
234
|
- spec/cassettes/Bcx_Resources_Access/DELETE_/projects/2951531/accesses/4996562_json/should_revoke_access.yml
|
233
235
|
- spec/cassettes/Bcx_Resources_Access/GET_/projects/2951531/accesses_json/first_access_should_have_the_correct_id.yml
|
234
236
|
- spec/cassettes/Bcx_Resources_Access/GET_/projects/2951531/accesses_json/should_be_an_array.yml
|
@@ -278,4 +280,3 @@ test_files:
|
|
278
280
|
- spec/cassettes/Bcx_Resources_Todolist/PUT_/projects/2956584/todolists/8268819_json/should_create_a_new_todolist.yml
|
279
281
|
- spec/cassettes/Bcx_Resources_Todolist/projects/123/todolists_json/should_create_a_new_todolist.yml
|
280
282
|
- spec/spec_helper.rb
|
281
|
-
has_rdoc:
|