crapi 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,191 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ File: README
8
+
9
+ &mdash; Documentation by YARD 0.9.12
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ pathId = "README";
19
+ relpath = '';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="file_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="_index.html">Index</a> &raquo;
40
+ <span class="title">File: README</span>
41
+
42
+ </div>
43
+
44
+ <div id="search">
45
+
46
+ <a class="full_list_link" id="class_list_link"
47
+ href="class_list.html">
48
+
49
+ <svg width="24" height="24">
50
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
51
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
52
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
53
+ </svg>
54
+ </a>
55
+
56
+ </div>
57
+ <div class="clear"></div>
58
+ </div>
59
+
60
+ <div id="content"><div id='filecontents'>
61
+ <h1 id="label-Crapi+rdoc-image-3Ahttps-3A-2F-2Fbadge.fury.io-2Frb-2Fcrapi.svg">Crapi <a href="https://badge.fury.io/rb/crapi"><img src="https://badge.fury.io/rb/crapi.svg"></a></h1>
62
+
63
+ <p>Crapi is yet another API wrapper. Yes, there is no shortage of these out
64
+ there, but no other API wrapper gem (that I could find) provided the kind
65
+ of functionality you get from the Crapi::Proxy class, which is really the
66
+ biggest benefit here.</p>
67
+
68
+ <p><strong>Crapi::Client</strong> will connect to the target system and
69
+ handily provides a base path for you (becaue some APIs and services have a
70
+ path that is always part of every request), <strong>Crapi::Proxy</strong>
71
+ lets you add to the root client&#39;s base path or default set of headers
72
+ without having to create any new connections.</p>
73
+
74
+ <p>Why “crapi”? Because it&#39;s a &lt;u&gt;CR&lt;/u&gt;UD
75
+ &lt;u&gt;API&lt;/u&gt; client, and (honestly) “… It could be better.”™️</p>
76
+
77
+ <h2 id="label-Installation">Installation</h2>
78
+
79
+ <p>Add this line to your application&#39;s Gemfile:</p>
80
+
81
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_gem'>gem</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>crapi</span><span class='tstring_end'>&#39;</span></span>
82
+ </code></pre>
83
+
84
+ <p>And then execute:</p>
85
+
86
+ <pre class="code ruby"><code class="ruby">$ bundle
87
+ </code></pre>
88
+
89
+ <p>Or install it yourself as:</p>
90
+
91
+ <pre class="code ruby"><code class="ruby">$ gem install crapi
92
+ </code></pre>
93
+
94
+ <h2 id="label-Using+The+Crapi+Tools">Using The Crapi Tools</h2>
95
+
96
+ <h3 id="label-Client+Usage">Client Usage</h3>
97
+
98
+ <pre class="code ruby"><code class="ruby"><span class='comment'>## Connect to an API.
99
+ </span>
100
+ <span class='id identifier rubyid_api'>api</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Crapi.html" title="Crapi (module)">Crapi</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Crapi/Client.html" title="Crapi::Client (class)">Client</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Crapi/Client.html#initialize-instance_method" title="Crapi::Client#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>https://jsonplaceholder.typicode.com/</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
101
+
102
+
103
+ <span class='comment'>## Issue requests against the API.
104
+ </span>
105
+ <span class='id identifier rubyid_api'>api</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>users/1</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span> <span class='comment'>## GETs /users/1; returns a Hash.
106
+ </span>
107
+ <span class='id identifier rubyid_api'>api</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>posts</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>query:</span> <span class='lbrace'>{</span> <span class='label'>userId:</span> <span class='int'>2</span> <span class='rbrace'>}</span><span class='rparen'>)</span> <span class='comment'>## GETs /posts?userId=2; returns an Array.
108
+ </span>
109
+ <span class='id identifier rubyid_mew_comment'>mew_comment</span> <span class='op'>=</span> <span class='lbrace'>{</span> <span class='label'>user:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>megapwner</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>text:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>FRIST!!1!</span><span class='tstring_end'>&#39;</span></span> <span class='rbrace'>}</span>
110
+ <span class='id identifier rubyid_api'>api</span><span class='period'>.</span><span class='id identifier rubyid_post'>post</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>comments</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>payload:</span> <span class='id identifier rubyid_new_comment'>new_comment</span><span class='rparen'>)</span> <span class='comment'>## POSTs to /comments; returns a Hash.
111
+ </span></code></pre>
112
+ <hr>
113
+
114
+ <h3 id="label-Proxy+Usage">Proxy Usage</h3>
115
+
116
+ <pre class="code ruby"><code class="ruby"><span class='comment'>## Connect to an API.
117
+ </span>
118
+ <span class='id identifier rubyid_api'>api</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Crapi.html" title="Crapi (module)">Crapi</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Crapi/Client.html" title="Crapi::Client (class)">Client</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Crapi/Client.html#initialize-instance_method" title="Crapi::Client#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>https://versioned.fake-api.com/api/</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
119
+
120
+
121
+ <span class='comment'>## Back in the v1 days, versioning of this API was via the URL ...
122
+ </span>
123
+ <span class='id identifier rubyid_v1'>v1</span> <span class='op'>=</span> <span class='id identifier rubyid_api'>api</span><span class='period'>.</span><span class='id identifier rubyid_new_proxy'>new_proxy</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>/v1</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
124
+
125
+ <span class='id identifier rubyid_v1'>v1</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>data</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span> <span class='comment'>## GETs /api/v1/data; pretty straight-forward.
126
+ </span><span class='id identifier rubyid_v1'>v1</span><span class='period'>.</span><span class='id identifier rubyid_post'>post</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>data</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>payload:</span> <span class='id identifier rubyid_values'>values</span><span class='rparen'>)</span> <span class='comment'>## POSTs *values* to /api/v1/data.
127
+ </span>
128
+
129
+ <span class='comment'>## For API v2, they switched to an Accept header approach ...
130
+ </span>
131
+ <span class='id identifier rubyid_v2'>v2</span> <span class='op'>=</span> <span class='id identifier rubyid_api'>api</span><span class='period'>.</span><span class='id identifier rubyid_new_proxy'>new_proxy</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>/</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>headers:</span> <span class='lbrace'>{</span> <span class='label'>Accept:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>application/vnd.fake-api.v2+json</span><span class='tstring_end'>&#39;</span></span> <span class='rbrace'>}</span><span class='rparen'>)</span>
132
+
133
+ <span class='id identifier rubyid_v2'>v2</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>data</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span> <span class='comment'>## GETs /api/data with the v2 header.
134
+ </span>
135
+
136
+ <span class='comment'>## API v3 keeps the Accept header approach ...
137
+ </span>
138
+ <span class='id identifier rubyid_v3'>v3</span> <span class='op'>=</span> <span class='id identifier rubyid_api'>api</span><span class='period'>.</span><span class='id identifier rubyid_new_proxy'>new_proxy</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>/</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>headers:</span> <span class='lbrace'>{</span> <span class='label'>Accept:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>application/vnd.fake-api.v3+json</span><span class='tstring_end'>&#39;</span></span> <span class='rbrace'>}</span><span class='rparen'>)</span>
139
+
140
+ <span class='id identifier rubyid_v3'>v3</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>data</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span> <span class='comment'>## GETs /api/data with the v3 header.
141
+ </span>
142
+
143
+ <span class='comment'>## Note that only one connection to the client is made and you can easily make
144
+ </span><span class='comment'>## v1, v2, and v3 API calls ad hoc without having to juggle paths/headers yourself.
145
+ </span></code></pre>
146
+ <hr>
147
+
148
+ <p><a href="http://nestor-custodio.github.io/crapi/Crapi.html">Consult the
149
+ repo docs for the full Crapi documentation.</a></p>
150
+
151
+ <h2 id="label-Feature+Roadmap+-2F+Future+Development">Feature Roadmap / Future Development</h2>
152
+
153
+ <p>Additional features/options coming in the future:</p>
154
+ <ul><li>
155
+ <p>Cleaner handling of non-body-returning calls.</p>
156
+ </li><li>
157
+ <p>More resilient serializing of non-String paylods when using custom
158
+ Content-Type headers.</p>
159
+ </li></ul>
160
+
161
+ <h2 id="label-Contribution+-2F+Development">Contribution / Development</h2>
162
+
163
+ <p>Bug reports and pull requests are welcome on GitHub at <a
164
+ href="https://github.com/nestor-custodio/crapi">github.com/nestor-custodio/crapi</a>.</p>
165
+
166
+ <p>After checking out the repo, run <code>bin/setup</code> to install
167
+ dependencies. Then, run <code>rake spec</code> to run the tests. You can
168
+ also run <code>bin/console</code> for an interactive prompt that will allow
169
+ you to experiment.</p>
170
+
171
+ <p>Linting is courtesy of <a
172
+ href="https://github.com/bbatsov/rubocop">Rubocop</a> and documentation is
173
+ built using <a href="https://yardoc.org/">Yard</a>. Neither is included in
174
+ the Gemspec; you&#39;ll need to install these locally (<code>gem install
175
+ rubocop yard</code>) to take advantage.</p>
176
+
177
+ <h2 id="label-License">License</h2>
178
+
179
+ <p>The gem is available as open source under the terms of the <a
180
+ href="https://opensource.org/licenses/MIT">MIT License</a>.</p>
181
+ </div></div>
182
+
183
+ <div id="footer">
184
+ Generated on Wed May 30 16:20:53 2018 by
185
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
186
+ 0.9.12 (ruby-2.5.1).
187
+ </div>
188
+
189
+ </div>
190
+ </body>
191
+ </html>
@@ -0,0 +1,56 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
5
+ <meta charset="utf-8" />
6
+
7
+ <link rel="stylesheet" href="css/full_list.css" type="text/css" media="screen" charset="utf-8" />
8
+
9
+ <link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
10
+
11
+
12
+
13
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
14
+
15
+ <script type="text/javascript" charset="utf-8" src="js/full_list.js"></script>
16
+
17
+
18
+ <title>File List</title>
19
+ <base id="base_target" target="_parent" />
20
+ </head>
21
+ <body>
22
+ <div id="content">
23
+ <div class="fixed_header">
24
+ <h1 id="full_list_header">File List</h1>
25
+ <div id="full_list_nav">
26
+
27
+ <span><a target="_self" href="class_list.html">
28
+ Classes
29
+ </a></span>
30
+
31
+ <span><a target="_self" href="method_list.html">
32
+ Methods
33
+ </a></span>
34
+
35
+ <span><a target="_self" href="file_list.html">
36
+ Files
37
+ </a></span>
38
+
39
+ </div>
40
+
41
+ <div id="search">Search: <input type="text" /></div>
42
+ </div>
43
+
44
+ <ul id="full_list" class="file">
45
+
46
+
47
+ <li id="object_README" class="odd">
48
+ <div class="item"><span class="object_link"><a href="index.html" title="README">README</a></span></div>
49
+ </li>
50
+
51
+
52
+
53
+ </ul>
54
+ </div>
55
+ </body>
56
+ </html>
@@ -0,0 +1,17 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>Documentation by YARD 0.9.12</title>
6
+ </head>
7
+ <script type="text/javascript" charset="utf-8">
8
+ var match = unescape(window.location.hash).match(/^#!(.+)/);
9
+ var name = match ? match[1] : 'index.html';
10
+ name = name.replace(/^(\w+):\/\//, '').replace(/^\/\//, '');
11
+ window.top.location = name;
12
+ </script>
13
+ <noscript>
14
+ <h1>Oops!</h1>
15
+ <h2>YARD requires JavaScript!</h2>
16
+ </noscript>
17
+ </html>
@@ -0,0 +1,191 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ File: README
8
+
9
+ &mdash; Documentation by YARD 0.9.12
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ pathId = "README";
19
+ relpath = '';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="_index.html">Index</a> &raquo;
40
+ <span class="title">File: README</span>
41
+
42
+ </div>
43
+
44
+ <div id="search">
45
+
46
+ <a class="full_list_link" id="class_list_link"
47
+ href="class_list.html">
48
+
49
+ <svg width="24" height="24">
50
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
51
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
52
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
53
+ </svg>
54
+ </a>
55
+
56
+ </div>
57
+ <div class="clear"></div>
58
+ </div>
59
+
60
+ <div id="content"><div id='filecontents'>
61
+ <h1 id="label-Crapi+rdoc-image-3Ahttps-3A-2F-2Fbadge.fury.io-2Frb-2Fcrapi.svg">Crapi <a href="https://badge.fury.io/rb/crapi"><img src="https://badge.fury.io/rb/crapi.svg"></a></h1>
62
+
63
+ <p>Crapi is yet another API wrapper. Yes, there is no shortage of these out
64
+ there, but no other API wrapper gem (that I could find) provided the kind
65
+ of functionality you get from the Crapi::Proxy class, which is really the
66
+ biggest benefit here.</p>
67
+
68
+ <p><strong>Crapi::Client</strong> will connect to the target system and
69
+ handily provides a base path for you (becaue some APIs and services have a
70
+ path that is always part of every request), <strong>Crapi::Proxy</strong>
71
+ lets you add to the root client&#39;s base path or default set of headers
72
+ without having to create any new connections.</p>
73
+
74
+ <p>Why “crapi”? Because it&#39;s a &lt;u&gt;CR&lt;/u&gt;UD
75
+ &lt;u&gt;API&lt;/u&gt; client, and (honestly) “… It could be better.”™️</p>
76
+
77
+ <h2 id="label-Installation">Installation</h2>
78
+
79
+ <p>Add this line to your application&#39;s Gemfile:</p>
80
+
81
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_gem'>gem</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>crapi</span><span class='tstring_end'>&#39;</span></span>
82
+ </code></pre>
83
+
84
+ <p>And then execute:</p>
85
+
86
+ <pre class="code ruby"><code class="ruby">$ bundle
87
+ </code></pre>
88
+
89
+ <p>Or install it yourself as:</p>
90
+
91
+ <pre class="code ruby"><code class="ruby">$ gem install crapi
92
+ </code></pre>
93
+
94
+ <h2 id="label-Using+The+Crapi+Tools">Using The Crapi Tools</h2>
95
+
96
+ <h3 id="label-Client+Usage">Client Usage</h3>
97
+
98
+ <pre class="code ruby"><code class="ruby"><span class='comment'>## Connect to an API.
99
+ </span>
100
+ <span class='id identifier rubyid_api'>api</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Crapi.html" title="Crapi (module)">Crapi</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Crapi/Client.html" title="Crapi::Client (class)">Client</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Crapi/Client.html#initialize-instance_method" title="Crapi::Client#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>https://jsonplaceholder.typicode.com/</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
101
+
102
+
103
+ <span class='comment'>## Issue requests against the API.
104
+ </span>
105
+ <span class='id identifier rubyid_api'>api</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>users/1</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span> <span class='comment'>## GETs /users/1; returns a Hash.
106
+ </span>
107
+ <span class='id identifier rubyid_api'>api</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>posts</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>query:</span> <span class='lbrace'>{</span> <span class='label'>userId:</span> <span class='int'>2</span> <span class='rbrace'>}</span><span class='rparen'>)</span> <span class='comment'>## GETs /posts?userId=2; returns an Array.
108
+ </span>
109
+ <span class='id identifier rubyid_mew_comment'>mew_comment</span> <span class='op'>=</span> <span class='lbrace'>{</span> <span class='label'>user:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>megapwner</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>text:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>FRIST!!1!</span><span class='tstring_end'>&#39;</span></span> <span class='rbrace'>}</span>
110
+ <span class='id identifier rubyid_api'>api</span><span class='period'>.</span><span class='id identifier rubyid_post'>post</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>comments</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>payload:</span> <span class='id identifier rubyid_new_comment'>new_comment</span><span class='rparen'>)</span> <span class='comment'>## POSTs to /comments; returns a Hash.
111
+ </span></code></pre>
112
+ <hr>
113
+
114
+ <h3 id="label-Proxy+Usage">Proxy Usage</h3>
115
+
116
+ <pre class="code ruby"><code class="ruby"><span class='comment'>## Connect to an API.
117
+ </span>
118
+ <span class='id identifier rubyid_api'>api</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Crapi.html" title="Crapi (module)">Crapi</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Crapi/Client.html" title="Crapi::Client (class)">Client</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Crapi/Client.html#initialize-instance_method" title="Crapi::Client#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>https://versioned.fake-api.com/api/</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
119
+
120
+
121
+ <span class='comment'>## Back in the v1 days, versioning of this API was via the URL ...
122
+ </span>
123
+ <span class='id identifier rubyid_v1'>v1</span> <span class='op'>=</span> <span class='id identifier rubyid_api'>api</span><span class='period'>.</span><span class='id identifier rubyid_new_proxy'>new_proxy</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>/v1</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
124
+
125
+ <span class='id identifier rubyid_v1'>v1</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>data</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span> <span class='comment'>## GETs /api/v1/data; pretty straight-forward.
126
+ </span><span class='id identifier rubyid_v1'>v1</span><span class='period'>.</span><span class='id identifier rubyid_post'>post</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>data</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>payload:</span> <span class='id identifier rubyid_values'>values</span><span class='rparen'>)</span> <span class='comment'>## POSTs *values* to /api/v1/data.
127
+ </span>
128
+
129
+ <span class='comment'>## For API v2, they switched to an Accept header approach ...
130
+ </span>
131
+ <span class='id identifier rubyid_v2'>v2</span> <span class='op'>=</span> <span class='id identifier rubyid_api'>api</span><span class='period'>.</span><span class='id identifier rubyid_new_proxy'>new_proxy</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>/</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>headers:</span> <span class='lbrace'>{</span> <span class='label'>Accept:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>application/vnd.fake-api.v2+json</span><span class='tstring_end'>&#39;</span></span> <span class='rbrace'>}</span><span class='rparen'>)</span>
132
+
133
+ <span class='id identifier rubyid_v2'>v2</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>data</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span> <span class='comment'>## GETs /api/data with the v2 header.
134
+ </span>
135
+
136
+ <span class='comment'>## API v3 keeps the Accept header approach ...
137
+ </span>
138
+ <span class='id identifier rubyid_v3'>v3</span> <span class='op'>=</span> <span class='id identifier rubyid_api'>api</span><span class='period'>.</span><span class='id identifier rubyid_new_proxy'>new_proxy</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>/</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>headers:</span> <span class='lbrace'>{</span> <span class='label'>Accept:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>application/vnd.fake-api.v3+json</span><span class='tstring_end'>&#39;</span></span> <span class='rbrace'>}</span><span class='rparen'>)</span>
139
+
140
+ <span class='id identifier rubyid_v3'>v3</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>data</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span> <span class='comment'>## GETs /api/data with the v3 header.
141
+ </span>
142
+
143
+ <span class='comment'>## Note that only one connection to the client is made and you can easily make
144
+ </span><span class='comment'>## v1, v2, and v3 API calls ad hoc without having to juggle paths/headers yourself.
145
+ </span></code></pre>
146
+ <hr>
147
+
148
+ <p><a href="http://nestor-custodio.github.io/crapi/Crapi.html">Consult the
149
+ repo docs for the full Crapi documentation.</a></p>
150
+
151
+ <h2 id="label-Feature+Roadmap+-2F+Future+Development">Feature Roadmap / Future Development</h2>
152
+
153
+ <p>Additional features/options coming in the future:</p>
154
+ <ul><li>
155
+ <p>Cleaner handling of non-body-returning calls.</p>
156
+ </li><li>
157
+ <p>More resilient serializing of non-String paylods when using custom
158
+ Content-Type headers.</p>
159
+ </li></ul>
160
+
161
+ <h2 id="label-Contribution+-2F+Development">Contribution / Development</h2>
162
+
163
+ <p>Bug reports and pull requests are welcome on GitHub at <a
164
+ href="https://github.com/nestor-custodio/crapi">github.com/nestor-custodio/crapi</a>.</p>
165
+
166
+ <p>After checking out the repo, run <code>bin/setup</code> to install
167
+ dependencies. Then, run <code>rake spec</code> to run the tests. You can
168
+ also run <code>bin/console</code> for an interactive prompt that will allow
169
+ you to experiment.</p>
170
+
171
+ <p>Linting is courtesy of <a
172
+ href="https://github.com/bbatsov/rubocop">Rubocop</a> and documentation is
173
+ built using <a href="https://yardoc.org/">Yard</a>. Neither is included in
174
+ the Gemspec; you&#39;ll need to install these locally (<code>gem install
175
+ rubocop yard</code>) to take advantage.</p>
176
+
177
+ <h2 id="label-License">License</h2>
178
+
179
+ <p>The gem is available as open source under the terms of the <a
180
+ href="https://opensource.org/licenses/MIT">MIT License</a>.</p>
181
+ </div></div>
182
+
183
+ <div id="footer">
184
+ Generated on Wed May 30 16:20:52 2018 by
185
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
186
+ 0.9.12 (ruby-2.5.1).
187
+ </div>
188
+
189
+ </div>
190
+ </body>
191
+ </html>