bcx 0.0.2 → 0.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.
- data/.travis.yml +6 -0
- data/README.md +57 -4
- data/docs/bcx.html +171 -0
- data/docs/configuration.html +128 -0
- data/docs/docco.css +500 -0
- data/docs/http.html +125 -0
- data/docs/oauth.html +127 -0
- data/docs/person.html +125 -0
- data/docs/project.html +143 -0
- data/docs/public/fonts/aller-bold.eot +0 -0
- data/docs/public/fonts/aller-bold.ttf +0 -0
- data/docs/public/fonts/aller-bold.woff +0 -0
- data/docs/public/fonts/aller-light.eot +0 -0
- data/docs/public/fonts/aller-light.ttf +0 -0
- data/docs/public/fonts/aller-light.woff +0 -0
- data/docs/public/fonts/fleurons.eot +0 -0
- data/docs/public/fonts/fleurons.ttf +0 -0
- data/docs/public/fonts/fleurons.woff +0 -0
- data/docs/public/fonts/novecento-bold.eot +0 -0
- data/docs/public/fonts/novecento-bold.ttf +0 -0
- data/docs/public/fonts/novecento-bold.woff +0 -0
- data/docs/public/images/gray.png +0 -0
- data/docs/public/stylesheets/normalize.css +375 -0
- data/docs/response_error.html +117 -0
- data/docs/todo.html +138 -0
- data/docs/todolist.html +148 -0
- data/docs/version.html +103 -0
- data/lib/bcx/client/http.rb +25 -0
- data/lib/bcx/client/oauth.rb +27 -0
- data/lib/bcx/resources/person.rb +30 -7
- data/lib/bcx/resources/project.rb +7 -10
- data/lib/bcx/resources/todolist.rb +11 -4
- data/lib/bcx/version.rb +1 -1
- data/lib/bcx.rb +12 -1
- data/spec/bcx/client_spec.rb +24 -19
- data/spec/bcx/person_spec.rb +55 -0
- data/spec/bcx/project_spec.rb +1 -1
- data/spec/bcx/todo_spec.rb +43 -0
- data/spec/bcx/todolist_spec.rb +19 -3
- data/spec/cassettes/Bcx_Client/error_handling/should_raise_exception.yml +56 -0
- data/spec/cassettes/Bcx_Resources_Person/DELETE_/people/4904728_json/should_delete_a_todolist.yml +101 -0
- data/spec/cassettes/Bcx_Resources_Person/GET_/people/4666033_json/should_have_the_correct_id.yml +58 -0
- data/spec/cassettes/Bcx_Resources_Person/GET_/people/4666033_json/should_return_a_hash.yml +58 -0
- data/spec/cassettes/Bcx_Resources_Person/GET_/people/me_json/should_have_assigned_todos.yml +58 -0
- data/spec/cassettes/Bcx_Resources_Person/GET_/people/me_json/should_have_the_correct_id.yml +58 -0
- data/spec/cassettes/Bcx_Resources_Person/GET_/people/me_json/should_return_a_hash.yml +58 -0
- data/spec/cassettes/Bcx_Resources_Person/GET_/people_json/first_person_should_have_the_correct_id.yml +56 -0
- data/spec/cassettes/Bcx_Resources_Person/GET_/people_json/should_be_an_array.yml +56 -0
- data/spec/cassettes/Bcx_Resources_Todo/DELETE_/projects/2951531/todos/48545200_json/should_delete_the_given_todo.yml +101 -0
- data/spec/cassettes/Bcx_Resources_Todo/GET_/projects/2951531/todos/48545200_json/should_have_the_correct_id.yml +61 -0
- data/spec/cassettes/Bcx_Resources_Todo/GET_/projects/2951531/todos/48545200_json/should_return_a_hash.yml +61 -0
- data/spec/cassettes/Bcx_Resources_Todo/POST_/projects/2951531/todolists/2951531/todos_json/should_create_a_new_todo.yml +56 -0
- data/spec/cassettes/Bcx_Resources_Todo/POST_/projects/2951531/todolists/8268819/todos_json/should_create_a_new_todo.yml +62 -0
- data/spec/cassettes/Bcx_Resources_Todo/PUT_/projects/2951531/todos/48545200_json/should_update_an_existing_todo.yml +61 -0
- data/spec/cassettes/Bcx_Resources_Todolist/DELETE_/projects/2956584/todolists/8268819_json/should_create_a_new_todolist.yml +66 -0
- data/spec/cassettes/Bcx_Resources_Todolist/DELETE_/projects/2956584/todolists/8268819_json/should_delete_a_todolist.yml +101 -0
- data/spec/cassettes/Bcx_Resources_Todolist/POST_/projects/123/todolists_json/should_create_a_new_todolist.yml +62 -0
- data/spec/cassettes/Bcx_Resources_Todolist/PUT_/projects/2956584/todolists/8268819_json/should_create_a_new_todolist.yml +186 -0
- metadata +88 -14
- data/lib/bcx/client.rb +0 -24
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
## Bcx
|
2
2
|
|
3
|
-
> NB. This is still alpha software and may not work as expected. It's also missing a lot of the Basecamp endpoints. Please feel free to contribute!
|
3
|
+
> NB. This is still alpha software and may not work as expected. It's also missing a lot of the Basecamp endpoints. Please feel free [to contribute!](#contributing)
|
4
4
|
|
5
5
|
Fully-fledged Ruby API wrapper for Basecamp Next
|
6
6
|
|
@@ -13,6 +13,8 @@ Fully-fledged Ruby API wrapper for Basecamp Next
|
|
13
13
|
\/ \/ \_/
|
14
14
|
```
|
15
15
|
|
16
|
+
[](https://travis-ci.org/paulspringett/bcx)
|
17
|
+
|
16
18
|
### Installation
|
17
19
|
|
18
20
|
```shell
|
@@ -32,13 +34,13 @@ You can connect to the Basecamp API using the Bcx client. The client provides au
|
|
32
34
|
#### HTTP Basic Auth
|
33
35
|
|
34
36
|
```ruby
|
35
|
-
client = Bcx::Client.new(
|
37
|
+
client = Bcx::Client::HTTP.new(login: 'username', password: 'secret')
|
36
38
|
```
|
37
39
|
|
38
40
|
#### OAuth
|
39
41
|
|
40
42
|
```ruby
|
41
|
-
client = Bcx::Client.new(
|
43
|
+
client = Bcx::Client::OAuth.new(client_id: '1234567890', client_secret: '831994c4170', access_token: 'b02ff9345c3')
|
42
44
|
```
|
43
45
|
|
44
46
|
You can get a `client_id` and `client_secret` from https://integrate.37signals.com/
|
@@ -68,11 +70,62 @@ client.projects(123).todolists!
|
|
68
70
|
# => [#<Hashie::Mash id=456 ...>, #<Hashie::Mash id=789 ...>]
|
69
71
|
```
|
70
72
|
|
73
|
+
### Error handling
|
74
|
+
|
75
|
+
If the response whilst fetching a resource is a 4xx or 5xx, Bcx will raise a `Bcx::ResponseError` exception.
|
76
|
+
|
77
|
+
```ruby
|
78
|
+
client.projects.create!(name: '')
|
79
|
+
# => Bcx::ResponseError: 422 POST https://basecamp.com/2274488/api/v1/projects.json | Errors: name can't be blank
|
80
|
+
```
|
81
|
+
|
82
|
+
You can rescue this exception to grab the status, method, URL and errors individually.
|
83
|
+
|
84
|
+
```ruby
|
85
|
+
begin
|
86
|
+
client.projects.create!(name: '')
|
87
|
+
rescue Bcx::ResponseError => response
|
88
|
+
response.method # => "POST"
|
89
|
+
response.status # => 422
|
90
|
+
response.url # => "https://basecamp.com/2274488/api/v1/projects.json"
|
91
|
+
response.errors # => ["name can't be blank"]
|
92
|
+
end
|
93
|
+
```
|
94
|
+
|
95
|
+
### Documentation
|
96
|
+
|
97
|
+
See the full [annotated source code](http://paulspringett.github.io/bcx).
|
98
|
+
|
99
|
+
The docs are generated using [Docco](http://jashkenas.github.io/docco/). To generate the docs, run:
|
100
|
+
|
101
|
+
```bash
|
102
|
+
$ git checkout master
|
103
|
+
$ npm install -g docco
|
104
|
+
$ docco lib/**/*.rb
|
105
|
+
$ git commit -am "Updated docs"
|
106
|
+
|
107
|
+
$ git checkout gh-pages
|
108
|
+
$ git checkout master -- docs/ # Copy docs changes across and stage
|
109
|
+
$ git commit -m "Updated docs on gh-pages"
|
110
|
+
```
|
111
|
+
|
71
112
|
### Contributing
|
72
113
|
|
114
|
+
The following endpoints are implemented and tested:
|
115
|
+
|
116
|
+
* People
|
117
|
+
* Projects
|
118
|
+
* Todolists
|
119
|
+
* Todos
|
120
|
+
|
121
|
+
All other endpoints still need implementing, see the official
|
122
|
+
[Basecamp Next API docs](https://github.com/37signals/bcx-api) for details on what to implement.
|
123
|
+
|
124
|
+
### How to contribute
|
125
|
+
|
73
126
|
1. Fork it
|
74
127
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
75
128
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
76
129
|
4. Write your tests and check everything passes
|
77
130
|
5. Push to the branch (`git push origin my-new-feature`)
|
78
|
-
6. Create new Pull Request (into the
|
131
|
+
6. Create new Pull Request (into the master branch)
|
data/docs/bcx.html
ADDED
@@ -0,0 +1,171 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<title>bcx.rb</title>
|
6
|
+
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
7
|
+
<meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
|
8
|
+
<link rel="stylesheet" media="all" href="docco.css" />
|
9
|
+
</head>
|
10
|
+
<body>
|
11
|
+
<div id="container">
|
12
|
+
<div id="background"></div>
|
13
|
+
|
14
|
+
<ul id="jump_to">
|
15
|
+
<li>
|
16
|
+
<a class="large" href="javascript:void(0);">Jump To …</a>
|
17
|
+
<a class="small" href="javascript:void(0);">+</a>
|
18
|
+
<div id="jump_wrapper">
|
19
|
+
<div id="jump_page">
|
20
|
+
|
21
|
+
|
22
|
+
<a class="source" href="bcx.html">
|
23
|
+
bcx.rb
|
24
|
+
</a>
|
25
|
+
|
26
|
+
|
27
|
+
<a class="source" href="http.html">
|
28
|
+
http.rb
|
29
|
+
</a>
|
30
|
+
|
31
|
+
|
32
|
+
<a class="source" href="oauth.html">
|
33
|
+
oauth.rb
|
34
|
+
</a>
|
35
|
+
|
36
|
+
|
37
|
+
<a class="source" href="configuration.html">
|
38
|
+
configuration.rb
|
39
|
+
</a>
|
40
|
+
|
41
|
+
|
42
|
+
<a class="source" href="person.html">
|
43
|
+
person.rb
|
44
|
+
</a>
|
45
|
+
|
46
|
+
|
47
|
+
<a class="source" href="project.html">
|
48
|
+
project.rb
|
49
|
+
</a>
|
50
|
+
|
51
|
+
|
52
|
+
<a class="source" href="todo.html">
|
53
|
+
todo.rb
|
54
|
+
</a>
|
55
|
+
|
56
|
+
|
57
|
+
<a class="source" href="todolist.html">
|
58
|
+
todolist.rb
|
59
|
+
</a>
|
60
|
+
|
61
|
+
|
62
|
+
<a class="source" href="response_error.html">
|
63
|
+
response_error.rb
|
64
|
+
</a>
|
65
|
+
|
66
|
+
|
67
|
+
<a class="source" href="version.html">
|
68
|
+
version.rb
|
69
|
+
</a>
|
70
|
+
|
71
|
+
</div>
|
72
|
+
</li>
|
73
|
+
</ul>
|
74
|
+
|
75
|
+
<ul class="sections">
|
76
|
+
|
77
|
+
<li id="title">
|
78
|
+
<div class="annotation">
|
79
|
+
<h1>bcx.rb</h1>
|
80
|
+
</div>
|
81
|
+
</li>
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
<li id="section-1">
|
86
|
+
<div class="annotation">
|
87
|
+
|
88
|
+
<div class="pilwrap ">
|
89
|
+
<a class="pilcrow" href="#section-1">¶</a>
|
90
|
+
</div>
|
91
|
+
|
92
|
+
</div>
|
93
|
+
|
94
|
+
<div class="content"><div class='highlight'><pre><span class="keyword">require</span> <span class="string">'rapidash'</span>
|
95
|
+
<span class="keyword">require</span> <span class="string">'bcx/version'</span></pre></div></div>
|
96
|
+
|
97
|
+
</li>
|
98
|
+
|
99
|
+
|
100
|
+
<li id="section-2">
|
101
|
+
<div class="annotation">
|
102
|
+
|
103
|
+
<div class="pilwrap for-h1">
|
104
|
+
<a class="pilcrow" href="#section-2">¶</a>
|
105
|
+
</div>
|
106
|
+
<h1>Bcx</h1>
|
107
|
+
<p>Fully-fledged Ruby API wrapper for Basecamp Next</p>
|
108
|
+
<p> See the <a href="https://github.com/paulspringett/bcx#readme">README</a> for usage</p>
|
109
|
+
|
110
|
+
</div>
|
111
|
+
|
112
|
+
<div class="content"><div class='highlight'><pre><span class="class"><span class="keyword">module</span> <span class="title">Bcx</span></span>
|
113
|
+
autoload <span class="symbol">:Configuration</span>, <span class="string">'bcx/configuration'</span>
|
114
|
+
|
115
|
+
<span class="class"><span class="keyword">module</span> <span class="title">Resources</span></span>
|
116
|
+
autoload <span class="symbol">:Todo</span>, <span class="string">'bcx/resources/todo'</span>
|
117
|
+
autoload <span class="symbol">:Todolist</span>, <span class="string">'bcx/resources/todolist'</span>
|
118
|
+
autoload <span class="symbol">:Project</span>, <span class="string">'bcx/resources/project'</span>
|
119
|
+
autoload <span class="symbol">:Person</span>, <span class="string">'bcx/resources/person'</span>
|
120
|
+
<span class="keyword">end</span>
|
121
|
+
|
122
|
+
<span class="class"><span class="keyword">module</span> <span class="title">Client</span></span>
|
123
|
+
autoload <span class="symbol">:HTTP</span>, <span class="string">'bcx/client/http'</span>
|
124
|
+
autoload <span class="symbol">:OAuth</span>, <span class="string">'bcx/client/oauth'</span>
|
125
|
+
<span class="keyword">end</span>
|
126
|
+
|
127
|
+
<span class="class"><span class="keyword">class</span> <span class="inheritance"><</span><span class="inheritance">< <span class="parent">self</span></span></span>
|
128
|
+
attr_accessor <span class="symbol">:configuration</span>
|
129
|
+
<span class="keyword">end</span></pre></div></div>
|
130
|
+
|
131
|
+
</li>
|
132
|
+
|
133
|
+
|
134
|
+
<li id="section-3">
|
135
|
+
<div class="annotation">
|
136
|
+
|
137
|
+
<div class="pilwrap ">
|
138
|
+
<a class="pilcrow" href="#section-3">¶</a>
|
139
|
+
</div>
|
140
|
+
<p>Expose configuration block</p>
|
141
|
+
|
142
|
+
</div>
|
143
|
+
|
144
|
+
<div class="content"><div class='highlight'><pre> <span class="function"><span class="keyword">def</span> <span class="title"><span class="keyword">self</span></span>.<span class="title">configure</span></span>
|
145
|
+
<span class="keyword">self</span>.configuration ||= <span class="constant">Configuration</span>.new
|
146
|
+
<span class="keyword">yield</span>(configuration)
|
147
|
+
<span class="keyword">end</span>
|
148
|
+
<span class="keyword">end</span></pre></div></div>
|
149
|
+
|
150
|
+
</li>
|
151
|
+
|
152
|
+
|
153
|
+
<li id="section-4">
|
154
|
+
<div class="annotation">
|
155
|
+
|
156
|
+
<div class="pilwrap ">
|
157
|
+
<a class="pilcrow" href="#section-4">¶</a>
|
158
|
+
</div>
|
159
|
+
<p>Use custom <code>Bcx::ResponseError</code> on top of Rapidash's error handling</p>
|
160
|
+
|
161
|
+
</div>
|
162
|
+
|
163
|
+
<div class="content"><div class='highlight'><pre><span class="keyword">require</span> <span class="string">'bcx/response_error'</span>
|
164
|
+
<span class="constant">Rapidash</span>.response_exception_class = <span class="constant">Bcx::ResponseError</span></pre></div></div>
|
165
|
+
|
166
|
+
</li>
|
167
|
+
|
168
|
+
</ul>
|
169
|
+
</div>
|
170
|
+
</body>
|
171
|
+
</html>
|
@@ -0,0 +1,128 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<title>configuration.rb</title>
|
6
|
+
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
7
|
+
<meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
|
8
|
+
<link rel="stylesheet" media="all" href="docco.css" />
|
9
|
+
</head>
|
10
|
+
<body>
|
11
|
+
<div id="container">
|
12
|
+
<div id="background"></div>
|
13
|
+
|
14
|
+
<ul id="jump_to">
|
15
|
+
<li>
|
16
|
+
<a class="large" href="javascript:void(0);">Jump To …</a>
|
17
|
+
<a class="small" href="javascript:void(0);">+</a>
|
18
|
+
<div id="jump_wrapper">
|
19
|
+
<div id="jump_page">
|
20
|
+
|
21
|
+
|
22
|
+
<a class="source" href="bcx.html">
|
23
|
+
bcx.rb
|
24
|
+
</a>
|
25
|
+
|
26
|
+
|
27
|
+
<a class="source" href="http.html">
|
28
|
+
http.rb
|
29
|
+
</a>
|
30
|
+
|
31
|
+
|
32
|
+
<a class="source" href="oauth.html">
|
33
|
+
oauth.rb
|
34
|
+
</a>
|
35
|
+
|
36
|
+
|
37
|
+
<a class="source" href="configuration.html">
|
38
|
+
configuration.rb
|
39
|
+
</a>
|
40
|
+
|
41
|
+
|
42
|
+
<a class="source" href="person.html">
|
43
|
+
person.rb
|
44
|
+
</a>
|
45
|
+
|
46
|
+
|
47
|
+
<a class="source" href="project.html">
|
48
|
+
project.rb
|
49
|
+
</a>
|
50
|
+
|
51
|
+
|
52
|
+
<a class="source" href="todo.html">
|
53
|
+
todo.rb
|
54
|
+
</a>
|
55
|
+
|
56
|
+
|
57
|
+
<a class="source" href="todolist.html">
|
58
|
+
todolist.rb
|
59
|
+
</a>
|
60
|
+
|
61
|
+
|
62
|
+
<a class="source" href="response_error.html">
|
63
|
+
response_error.rb
|
64
|
+
</a>
|
65
|
+
|
66
|
+
|
67
|
+
<a class="source" href="version.html">
|
68
|
+
version.rb
|
69
|
+
</a>
|
70
|
+
|
71
|
+
</div>
|
72
|
+
</li>
|
73
|
+
</ul>
|
74
|
+
|
75
|
+
<ul class="sections">
|
76
|
+
|
77
|
+
<li id="title">
|
78
|
+
<div class="annotation">
|
79
|
+
<h1>configuration.rb</h1>
|
80
|
+
</div>
|
81
|
+
</li>
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
<li id="section-1">
|
86
|
+
<div class="annotation">
|
87
|
+
|
88
|
+
<div class="pilwrap ">
|
89
|
+
<a class="pilcrow" href="#section-1">¶</a>
|
90
|
+
</div>
|
91
|
+
|
92
|
+
</div>
|
93
|
+
|
94
|
+
<div class="content"><div class='highlight'><pre><span class="class"><span class="keyword">module</span> <span class="title">Bcx</span></span></pre></div></div>
|
95
|
+
|
96
|
+
</li>
|
97
|
+
|
98
|
+
|
99
|
+
<li id="section-2">
|
100
|
+
<div class="annotation">
|
101
|
+
|
102
|
+
<div class="pilwrap ">
|
103
|
+
<a class="pilcrow" href="#section-2">¶</a>
|
104
|
+
</div>
|
105
|
+
<p>Bcx::Configuration
|
106
|
+
Provides a configuration block for setting up the Bcx client
|
107
|
+
Example:</p>
|
108
|
+
<p> Bcx.configure do |config|
|
109
|
+
config.account = '1234567890'
|
110
|
+
end</p>
|
111
|
+
|
112
|
+
</div>
|
113
|
+
|
114
|
+
<div class="content"><div class='highlight'><pre> <span class="class"><span class="keyword">class</span> <span class="title">Configuration</span></span>
|
115
|
+
attr_accessor <span class="symbol">:account</span>, <span class="symbol">:api_version</span>
|
116
|
+
|
117
|
+
<span class="function"><span class="keyword">def</span> <span class="title">initialize</span></span>
|
118
|
+
<span class="variable">@api_version</span> = <span class="string">'v1'</span>
|
119
|
+
<span class="keyword">end</span>
|
120
|
+
<span class="keyword">end</span>
|
121
|
+
<span class="keyword">end</span></pre></div></div>
|
122
|
+
|
123
|
+
</li>
|
124
|
+
|
125
|
+
</ul>
|
126
|
+
</div>
|
127
|
+
</body>
|
128
|
+
</html>
|