bcx 0.2.0 → 0.2.1

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.
@@ -0,0 +1,136 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <title>oauth.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 &hellip;</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="access.html">
43
+ access.rb
44
+ </a>
45
+
46
+
47
+ <a class="source" href="person.html">
48
+ person.rb
49
+ </a>
50
+
51
+
52
+ <a class="source" href="project.html">
53
+ project.rb
54
+ </a>
55
+
56
+
57
+ <a class="source" href="todo.html">
58
+ todo.rb
59
+ </a>
60
+
61
+
62
+ <a class="source" href="todolist.html">
63
+ todolist.rb
64
+ </a>
65
+
66
+
67
+ <a class="source" href="response_error.html">
68
+ response_error.rb
69
+ </a>
70
+
71
+
72
+ <a class="source" href="version.html">
73
+ version.rb
74
+ </a>
75
+
76
+ </div>
77
+ </li>
78
+ </ul>
79
+
80
+ <ul class="sections">
81
+
82
+ <li id="title">
83
+ <div class="annotation">
84
+ <h1>oauth.rb</h1>
85
+ </div>
86
+ </li>
87
+
88
+
89
+
90
+ <li id="section-1">
91
+ <div class="annotation">
92
+
93
+ <div class="pilwrap for-h2">
94
+ <a class="pilcrow" href="#section-1">&#182;</a>
95
+ </div>
96
+ <h2>Oauth Client</h2>
97
+ <p>Provides a client to access the Basecamp Next API via OAuth credentials</p>
98
+ <p>Example:</p>
99
+ <pre><code>client = Bcx::Client::OAuth.new(client_id: &#39;1234567890&#39;, client_secret: &#39;831994c4170&#39;, access_token: &#39;b02ff9345c3&#39;)</code></pre>
100
+
101
+ </div>
102
+
103
+ <div class="content"><div class='highlight'><pre><span class="class"><span class="keyword">module</span> <span class="title">Bcx</span></span>
104
+ <span class="class"><span class="keyword">module</span> <span class="title">Client</span></span>
105
+ <span class="class"><span class="keyword">class</span> <span class="title">OAuth</span> <span class="inheritance">&lt; <span class="parent">Rapidash::Client</span></span></span>
106
+ method <span class="symbol">:oauth</span>
107
+
108
+ extension <span class="symbol">:json</span>
109
+ encode_request_with <span class="symbol">:json</span>
110
+
111
+ raise_errors
112
+
113
+ resource <span class="symbol">:projects</span>, <span class="symbol">class_name:</span> <span class="string">'Bcx::Resources::Project'</span>
114
+ resource <span class="symbol">:todolists</span>, <span class="symbol">class_name:</span> <span class="string">'Bcx::Resources::Todolist'</span>
115
+ resource <span class="symbol">:people</span>, <span class="symbol">class_name:</span> <span class="string">'Bcx::Resources::Person'</span>
116
+
117
+ <span class="function"><span class="keyword">def</span> <span class="title">initialize</span><span class="params">(options = {})</span></span>
118
+ <span class="variable">@account</span> = <span class="constant">Bcx</span>.configuration.account
119
+ <span class="variable">@api_version</span> = <span class="constant">Bcx</span>.configuration.api_version
120
+
121
+ options[<span class="symbol">:site</span>] = <span class="string">"https://basecamp.com/<span class="subst">#{<span class="variable">@account</span>}</span>/api/<span class="subst">#{<span class="variable">@api_version</span>}</span>"</span>
122
+ options[<span class="symbol">:uid</span>] ||= options[<span class="symbol">:client_id</span>]
123
+ options[<span class="symbol">:secret</span>] ||= options[<span class="symbol">:client_secret</span>]
124
+
125
+ <span class="keyword">super</span>(options)
126
+ <span class="keyword">end</span>
127
+ <span class="keyword">end</span>
128
+ <span class="keyword">end</span>
129
+ <span class="keyword">end</span></pre></div></div>
130
+
131
+ </li>
132
+
133
+ </ul>
134
+ </div>
135
+ </body>
136
+ </html>
@@ -0,0 +1,130 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <title>person.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 &hellip;</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="access.html">
43
+ access.rb
44
+ </a>
45
+
46
+
47
+ <a class="source" href="person.html">
48
+ person.rb
49
+ </a>
50
+
51
+
52
+ <a class="source" href="project.html">
53
+ project.rb
54
+ </a>
55
+
56
+
57
+ <a class="source" href="todo.html">
58
+ todo.rb
59
+ </a>
60
+
61
+
62
+ <a class="source" href="todolist.html">
63
+ todolist.rb
64
+ </a>
65
+
66
+
67
+ <a class="source" href="response_error.html">
68
+ response_error.rb
69
+ </a>
70
+
71
+
72
+ <a class="source" href="version.html">
73
+ version.rb
74
+ </a>
75
+
76
+ </div>
77
+ </li>
78
+ </ul>
79
+
80
+ <ul class="sections">
81
+
82
+ <li id="title">
83
+ <div class="annotation">
84
+ <h1>person.rb</h1>
85
+ </div>
86
+ </li>
87
+
88
+
89
+
90
+ <li id="section-1">
91
+ <div class="annotation">
92
+
93
+ <div class="pilwrap for-h2">
94
+ <a class="pilcrow" href="#section-1">&#182;</a>
95
+ </div>
96
+ <h2>People</h2>
97
+ <p>Provides access to people resource</p>
98
+ <h4>Get all people on the account</h4>
99
+ <p><code>GET /people.json</code></p>
100
+ <pre><code>client.people!</code></pre>
101
+ <h4>Get a person</h4>
102
+ <p><code>GET /people/123.json</code></p>
103
+ <pre><code>client.people!(123)</code></pre>
104
+ <h4>Get the current person</h4>
105
+ <p><code>GET /people/me.json</code></p>
106
+ <pre><code>client.people.me!</code></pre>
107
+ <h4>Get assigned todos for a person</h4>
108
+ <p><code>GET /people/1/assigned_todos.json</code></p>
109
+ <pre><code>client.people(1).assigned_todos</code></pre>
110
+ <h4>Delete a person</h4>
111
+ <p><code>DELETE /people/123.json</code></p>
112
+ <pre><code>client.people(123).delete!</code></pre>
113
+
114
+ </div>
115
+
116
+ <div class="content"><div class='highlight'><pre><span class="class"><span class="keyword">module</span> <span class="title">Bcx</span></span>
117
+ <span class="class"><span class="keyword">module</span> <span class="title">Resources</span></span>
118
+ <span class="class"><span class="keyword">class</span> <span class="title">Person</span> <span class="inheritance">&lt; <span class="parent">Rapidash::Base</span></span></span>
119
+ url <span class="symbol">:people</span>
120
+ collection <span class="symbol">:me</span>
121
+ <span class="keyword">end</span>
122
+ <span class="keyword">end</span>
123
+ <span class="keyword">end</span></pre></div></div>
124
+
125
+ </li>
126
+
127
+ </ul>
128
+ </div>
129
+ </body>
130
+ </html>
@@ -0,0 +1,136 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <title>project.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 &hellip;</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="access.html">
43
+ access.rb
44
+ </a>
45
+
46
+
47
+ <a class="source" href="person.html">
48
+ person.rb
49
+ </a>
50
+
51
+
52
+ <a class="source" href="project.html">
53
+ project.rb
54
+ </a>
55
+
56
+
57
+ <a class="source" href="todo.html">
58
+ todo.rb
59
+ </a>
60
+
61
+
62
+ <a class="source" href="todolist.html">
63
+ todolist.rb
64
+ </a>
65
+
66
+
67
+ <a class="source" href="response_error.html">
68
+ response_error.rb
69
+ </a>
70
+
71
+
72
+ <a class="source" href="version.html">
73
+ version.rb
74
+ </a>
75
+
76
+ </div>
77
+ </li>
78
+ </ul>
79
+
80
+ <ul class="sections">
81
+
82
+ <li id="title">
83
+ <div class="annotation">
84
+ <h1>project.rb</h1>
85
+ </div>
86
+ </li>
87
+
88
+
89
+
90
+ <li id="section-1">
91
+ <div class="annotation">
92
+
93
+ <div class="pilwrap for-h2">
94
+ <a class="pilcrow" href="#section-1">&#182;</a>
95
+ </div>
96
+ <h2>Projects</h2>
97
+ <p>Provides access to projects resoource and other nested resources</p>
98
+ <h4>Fetch all projects</h4>
99
+ <p><code>GET /projects.json</code></p>
100
+ <pre><code>client.projects!</code></pre>
101
+ <h4>Fetch archived projects</h4>
102
+ <p><code>GET /projects/archived.json</code></p>
103
+ <pre><code>clients.projects.archived!</code></pre>
104
+ <h4>Fetch single project with ID of 123</h4>
105
+ <p><code>GET /projects/123.json</code></p>
106
+ <pre><code>client.projects!(123)</code></pre>
107
+ <h4>Create a project</h4>
108
+ <p><code>POST /projects.json</code></p>
109
+ <pre><code>client.projects.create!(name: &#39;Acme project&#39;, description: &#39;This is a new project&#39;)</code></pre>
110
+ <h4>Update an existing project</h4>
111
+ <p><code>PUT /projects/123.json</code></p>
112
+ <pre><code>client.projects(123).update!(description: &#39;A new description&#39;)</code></pre>
113
+ <h4>Delete a project</h4>
114
+ <p><code>DELETE /projects/123.json</code></p>
115
+ <pre><code>client.projects(123).delete!</code></pre>
116
+
117
+ </div>
118
+
119
+ <div class="content"><div class='highlight'><pre><span class="class"><span class="keyword">module</span> <span class="title">Bcx</span></span>
120
+ <span class="class"><span class="keyword">module</span> <span class="title">Resources</span></span>
121
+ <span class="class"><span class="keyword">class</span> <span class="title">Project</span> <span class="inheritance">&lt; <span class="parent">Rapidash::Base</span></span></span>
122
+ resource <span class="symbol">:todolists</span>
123
+ resource <span class="symbol">:todos</span>
124
+ resource <span class="symbol">:accesses</span>
125
+
126
+ collection <span class="symbol">:archived</span>
127
+ <span class="keyword">end</span>
128
+ <span class="keyword">end</span>
129
+ <span class="keyword">end</span></pre></div></div>
130
+
131
+ </li>
132
+
133
+ </ul>
134
+ </div>
135
+ </body>
136
+ </html>
@@ -33,11 +33,6 @@
33
33
  version.rb
34
34
  </a>
35
35
 
36
-
37
- <a class="source" href="collection.html">
38
- collection.rb
39
- </a>
40
-
41
36
  </div>
42
37
  </li>
43
38
  </ul>
@@ -55,10 +50,24 @@
55
50
  <li id="section-1">
56
51
  <div class="annotation">
57
52
 
58
- <div class="pilwrap ">
53
+ <div class="pilwrap for-h2">
59
54
  <a class="pilcrow" href="#section-1">&#182;</a>
60
55
  </div>
61
-
56
+ <h2>Response Error</h2>
57
+ <p>If the response whilst fetching a resource is a 4xx or 5xx, Bcx will raise a <code>Bcx::ResponseError</code> exception.</p>
58
+ <p>Examples:</p>
59
+ <pre><code>client.projects.create!(name: &#39;&#39;)
60
+ =&gt; Bcx::ResponseError: 422 POST https://basecamp.com/2274488/api/v1/projects.json | Errors: name can&#39;t be blank</code></pre>
61
+ <p>You can rescue this exception to grab the status, method, URL and errors individually.</p>
62
+ <pre><code>begin
63
+ client.projects.create!(name: &#39;&#39;)
64
+ rescue Bcx::ResponseError =&gt; response
65
+ response.method # =&gt; &quot;POST&quot;
66
+ response.status # =&gt; 422
67
+ response.url # =&gt; &quot;https://basecamp.com/2274488/api/v1/projects.json&quot;
68
+ response.errors # =&gt; [&quot;name can&#39;t be blank&quot;]
69
+ end</code></pre>
70
+
62
71
  </div>
63
72
 
64
73
  <div class="content"><div class='highlight'><pre><span class="class"><span class="keyword">module</span> <span class="title">Bcx</span></span>
@@ -0,0 +1,130 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <title>todo.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 &hellip;</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="access.html">
43
+ access.rb
44
+ </a>
45
+
46
+
47
+ <a class="source" href="person.html">
48
+ person.rb
49
+ </a>
50
+
51
+
52
+ <a class="source" href="project.html">
53
+ project.rb
54
+ </a>
55
+
56
+
57
+ <a class="source" href="todo.html">
58
+ todo.rb
59
+ </a>
60
+
61
+
62
+ <a class="source" href="todolist.html">
63
+ todolist.rb
64
+ </a>
65
+
66
+
67
+ <a class="source" href="response_error.html">
68
+ response_error.rb
69
+ </a>
70
+
71
+
72
+ <a class="source" href="version.html">
73
+ version.rb
74
+ </a>
75
+
76
+ </div>
77
+ </li>
78
+ </ul>
79
+
80
+ <ul class="sections">
81
+
82
+ <li id="title">
83
+ <div class="annotation">
84
+ <h1>todo.rb</h1>
85
+ </div>
86
+ </li>
87
+
88
+
89
+
90
+ <li id="section-1">
91
+ <div class="annotation">
92
+
93
+ <div class="pilwrap for-h2">
94
+ <a class="pilcrow" href="#section-1">&#182;</a>
95
+ </div>
96
+ <h2>Todo</h2>
97
+ <p>Provides access to todolist resoource both at the client level and per-project</p>
98
+ <h4>Get todos for a todolist</h4>
99
+ <p><code>GET /todolists/1.json</code></p>
100
+ <pre><code>todolist = client.todolists!(1)
101
+ todolist.todos.remaining
102
+ todolist.todos.completed</code></pre>
103
+ <h4>Get a specific todo</h4>
104
+ <p><code>GET /projects/1/todos/2.json</code></p>
105
+ <pre><code>client.projects(1).todos!(2)</code></pre>
106
+ <h4>Create a todo</h4>
107
+ <p><code>POST /projects/1/todolists/2/todos.json</code></p>
108
+ <pre><code>client.projects(1).todolists(2).todos.create!(content: &#39;Update copy text&#39;)</code></pre>
109
+ <h4>Update a todo</h4>
110
+ <p><code>PUT /projects/1/todos/2.json</code></p>
111
+ <pre><code>client.projects(1).todos(2).update!(completed: true)</code></pre>
112
+ <h4>Delete a todo</h4>
113
+ <p><code>DELETE /projects/1/todos/2.json</code></p>
114
+ <pre><code>client.projects(1).todos(2).delete!</code></pre>
115
+
116
+ </div>
117
+
118
+ <div class="content"><div class='highlight'><pre><span class="class"><span class="keyword">module</span> <span class="title">Bcx</span></span>
119
+ <span class="class"><span class="keyword">module</span> <span class="title">Resources</span></span>
120
+ <span class="class"><span class="keyword">class</span> <span class="title">Todo</span> <span class="inheritance">&lt; <span class="parent">Rapidash::Base</span></span></span>
121
+ <span class="keyword">end</span>
122
+ <span class="keyword">end</span>
123
+ <span class="keyword">end</span></pre></div></div>
124
+
125
+ </li>
126
+
127
+ </ul>
128
+ </div>
129
+ </body>
130
+ </html>