crapi 1.0.0 → 1.0.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.
@@ -6,13 +6,13 @@
6
6
  <title>
7
7
  File: README
8
8
 
9
- &mdash; Documentation by YARD 0.9.28
9
+ &mdash; Documentation by YARD 0.9.44
10
10
 
11
11
  </title>
12
12
 
13
- <link rel="stylesheet" href="css/style.css" type="text/css" />
13
+ <link rel="stylesheet" href="css/style.css" type="text/css">
14
14
 
15
- <link rel="stylesheet" href="css/common.css" type="text/css" />
15
+ <link rel="stylesheet" href="css/common.css" type="text/css">
16
16
 
17
17
  <script type="text/javascript">
18
18
  pathId = "README";
@@ -27,6 +27,8 @@
27
27
 
28
28
  </head>
29
29
  <body>
30
+ <div id="main_progress" aria-hidden="true"></div>
31
+
30
32
  <div class="nav_wrap">
31
33
  <iframe id="nav" src="file_list.html?1"></iframe>
32
34
  <div id="resizer"></div>
@@ -59,114 +61,88 @@
59
61
 
60
62
  <div id="content"><div id='filecontents'><p><a href="https://rubygems.org/gems/crapi"><img src="https://img.shields.io/github/v/release/nestor-custodio/crapi?color=green&amp;label=gem%20version" alt="Gem Version" /></a>
61
63
  <a href="https://tldrlegal.com/license/mit-license"><img src="https://img.shields.io/github/license/nestor-custodio/crapi" alt="MIT License" /></a></p>
62
-
63
- <h1 id="crapi">CrAPI</h1>
64
-
65
- <p>CrAPI is yet another <u>Cr</u>ud <u>API</u> client wrapper. Yes, there is no shortage of these out there, but no other API wrapper gem (that I could find) provided the kind of functionality you get from the CrAPI::Proxy class, which is really the biggest benefit here.</p>
66
-
67
- <p><strong>CrAPI::Client</strong> will connect to the target system and handily provides a base path for you (because some APIs and services have a path that is always part of every request), <strong>CrAPI::Proxy</strong> lets you add to the root client’s base path or default set of headers without having to create any new connections.</p>
68
-
69
- <h2 id="installation">Installation</h2>
70
-
71
- <p>Add this line to your application’s Gemfile:</p>
72
-
73
- <p><code>ruby
74
- gem 'crapi'
75
- </code></p>
76
-
64
+ <h1 id="CrAPI">CrAPI</h1>
65
+ <p>CrAPI is yet another <strong>Cr</strong>ud <strong>API</strong> client wrapper. Yes, there is no shortage of these out there, but no other API wrapper gem (that I could find) provided the kind of functionality you get from the CrAPI::Proxy class, which is really the biggest benefit here.</p>
66
+ <p><strong>CrAPI::Client</strong> will connect to the target system and handily provides a base path for you (because some APIs and services have a path that is always part of every request), <strong>CrAPI::Proxy</strong> lets you add to the root client's base path or default set of headers without having to create any new connections.</p>
67
+ <h2 id="Installation">Installation</h2>
68
+ <p>Add this line to your application's Gemfile:</p>
69
+ <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>
70
+ </code></pre>
77
71
  <p>And then execute:</p>
78
-
79
72
  <pre class="code ruby"><code class="ruby">$ bundle
80
73
  </code></pre>
81
-
82
74
  <p>Or install it yourself as:</p>
83
-
84
75
  <pre class="code ruby"><code class="ruby">$ gem install crapi
85
76
  </code></pre>
86
-
87
- <h2 id="using-the-crapi-tools">Using The CrAPI Tools</h2>
88
-
89
- <h3 id="client-usage">Client Usage</h3>
90
-
91
- <p>```ruby
92
- # Connect to an API.</p>
93
-
94
- <p>api = CrAPI::Client.new(‘https://jsonplaceholder.typicode.com/’)</p>
95
-
96
- <h1 id="issue-requests-against-the-api">Issue requests against the API.</h1>
97
-
98
- <p>api.get(‘users/1’) # GETs /users/1; returns a Hash.</p>
99
-
100
- <p>api.get(‘posts’, query: { userId: 2 }) # GETs /posts?userId=2; returns an Array.</p>
101
-
102
- <p>mew_comment = { user: ‘megapwner’, text: ‘FRIST!!1!’ }
103
- api.post(‘comments’, payload: new_comment) # POSTs to /comments; returns a Hash.
104
- ```</p>
105
-
77
+ <h2 id="Using_The_CrAPI_Tools">Using The CrAPI Tools</h2>
78
+ <h3 id="Client_Usage">Client Usage</h3>
79
+ <pre class="code ruby"><code class="ruby"><span class='comment'># Connect to an API.
80
+ </span>
81
+ <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>
82
+
83
+
84
+ <span class='comment'># Issue requests against the API.
85
+ </span>
86
+ <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.
87
+ </span>
88
+ <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.
89
+ </span>
90
+ <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>
91
+ <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.
92
+ </span></code></pre>
106
93
  <hr />
94
+ <h3 id="Proxy_Usage">Proxy Usage</h3>
95
+ <pre class="code ruby"><code class="ruby"><span class='comment'># Connect to an API.
96
+ </span>
97
+ <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>
107
98
 
108
- <h3 id="proxy-usage">Proxy Usage</h3>
109
-
110
- <p>```ruby
111
- # Connect to an API.</p>
112
-
113
- <p>api = CrAPI::Client.new(‘https://versioned.fake-api.com/api/’)</p>
114
-
115
- <h1 id="back-in-the-v1-days-versioning-of-this-api-was-via-the-url-">Back in the v1 days, versioning of this API was via the URL …</h1>
116
99
 
117
- <p>v1 = api.new_proxy(‘/v1’)</p>
100
+ <span class='comment'># Back in the v1 days, versioning of this API was via the URL ...
101
+ </span>
102
+ <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>
118
103
 
119
- <p>v1.get(data) # GETs /api/v1/data; pretty straight-forward.
120
- v1.post(data’, payload: values) # POSTs <em>values</em> to /api/v1/data.</p>
104
+ <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.
105
+ </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.
106
+ </span>
121
107
 
122
- <h1 id="for-api-v2-they-switched-to-an-accept-header-approach-">For API v2, they switched to an Accept header approach …</h1>
108
+ <span class='comment'># For API v2, they switched to an Accept header approach ...
109
+ </span>
110
+ <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>
123
111
 
124
- <p>v2 = api.new_proxy(‘/’, headers: { Accept: ‘application/vnd.fake-api.v2+json’ })</p>
112
+ <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.
113
+ </span>
125
114
 
126
- <p>v2.get(‘data’) # GETs /api/data with the v2 header.</p>
115
+ <span class='comment'># API v3 keeps the Accept header approach ...
116
+ </span>
117
+ <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>
127
118
 
128
- <h1 id="api-v3-keeps-the-accept-header-approach-">API v3 keeps the Accept header approach …</h1>
129
-
130
- <p>v3 = api.new_proxy(‘/’, headers: { Accept: ‘application/vnd.fake-api.v3+json’ })</p>
131
-
132
- <p>v3.get(‘data’) # GETs /api/data with the v3 header.</p>
133
-
134
- <h1 id="note-that-only-one-connection-to-the-client-is-made-and-you-can-easily-make">Note that only one connection to the client is made and you can easily make</h1>
135
- <p># v1, v2, and v3 API calls ad hoc without having to juggle paths/headers yourself.
136
- ```</p>
119
+ <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.
120
+ </span>
137
121
 
122
+ <span class='comment'># Note that only one connection to the client is made and you can easily make
123
+ </span><span class='comment'># v1, v2, and v3 API calls ad hoc without having to juggle paths/headers yourself.
124
+ </span></code></pre>
138
125
  <hr />
139
-
140
- <p><a href="http://nestor-custodio.github.io/crapi/CrAPI.html">Consult the repo docs for the full CrAPI documentation.</a></p>
141
-
142
- <h2 id="feature-roadmap--future-development">Feature Roadmap / Future Development</h2>
143
-
126
+ <p><a href="https://nestor-custodio.github.io/crapi/CrAPI.html">Consult the repo docs for the full CrAPI documentation.</a></p>
127
+ <h2 id="Feature_Roadmap___Future_Development">Feature Roadmap / Future Development</h2>
144
128
  <p>Additional features/options coming in the future:</p>
145
-
146
129
  <ul>
147
- <li>Cleaner handling of non-body-returning calls.</li>
148
- <li>More resilient serializing of non-String paylods when using custom Content-Type headers.</li>
130
+ <li>Cleaner handling of non-body-returning calls.</li>
131
+ <li>More resilient serializing of non-String paylods when using custom Content-Type headers.</li>
149
132
  </ul>
150
-
151
- <h2 id="contribution--development">Contribution / Development</h2>
152
-
153
- <p>Bug reports and pull requests are welcome at: <a href="https://github.com/nestor-custodio/crapi">https://github.com/nestor-custodio/crapi</a></p>
154
-
133
+ <h2 id="Contribution___Development">Contribution / Development</h2>
134
+ <p>Bug reports and pull requests are welcome at: <a href="https://github.com/nestor-custodio/crapi"><a href="https://github.com/nestor-custodio/crapi">https://github.com/nestor-custodio/crapi</a></a></p>
155
135
  <p>After checking out the repo, run <code>bin/setup</code> to install dependencies. Then, run <code>bundle exec rspec</code> to run the tests. You can also run <code>bin/console</code> for an interactive prompt that will allow you to experiment.</p>
156
-
157
136
  <p>Linting is courtesy of <a href="https://docs.rubocop.org/">Rubocop</a> (<code>bundle exec rubocop</code>) and documentation is built using <a href="https://yardoc.org/">Yard</a> (<code>bundle exec yard</code>). Please ensure you have a clean bill of health from Rubocop and that any new features and/or changes to behaviour are reflected in the documentation before submitting a pull request.</p>
158
-
159
- <h2 id="license">License</h2>
160
-
161
- <p>CrAPI is available as open source under the terms of the <a href="https://tldrlegal.com/license/mit-license">MIT License</a>.</p>
162
- </div></div>
137
+ <h2 id="License">License</h2>
138
+ <p>CrAPI is available as open source under the terms of the <a href="https://tldrlegal.com/license/mit-license">MIT License</a>.</p></div></div>
163
139
 
164
140
  <div id="footer">
165
- Generated on Mon Jan 2 15:16:45 2023 by
141
+ Generated on Sun Jul 5 14:46:38 2026 by
166
142
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
167
- 0.9.28 (ruby-3.0.4).
143
+ 0.9.44 (ruby-3.4.8).
168
144
  </div>
169
145
 
170
146
  </div>
171
147
  </body>
172
- </html>
148
+ </html>
data/docs/file_list.html CHANGED
@@ -1,12 +1,12 @@
1
1
  <!DOCTYPE html>
2
- <html>
2
+ <html >
3
3
  <head>
4
4
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
5
- <meta charset="utf-8" />
5
+ <meta charset="utf-8">
6
6
 
7
- <link rel="stylesheet" href="css/full_list.css" type="text/css" media="screen" />
7
+ <link rel="stylesheet" href="css/full_list.css" type="text/css" media="screen">
8
8
 
9
- <link rel="stylesheet" href="css/common.css" type="text/css" media="screen" />
9
+ <link rel="stylesheet" href="css/common.css" type="text/css" media="screen">
10
10
 
11
11
 
12
12
 
@@ -16,7 +16,7 @@
16
16
 
17
17
 
18
18
  <title>File List</title>
19
- <base id="base_target" target="_parent" />
19
+ <base id="base_target" target="_parent">
20
20
  </head>
21
21
  <body>
22
22
  <div id="content">
@@ -38,7 +38,10 @@
38
38
 
39
39
  </div>
40
40
 
41
- <div id="search">Search: <input type="text" /></div>
41
+ <div id="search">
42
+ <label for="search-class">Search:</label>
43
+ <input id="search-class" type="text">
44
+ </div>
42
45
  </div>
43
46
 
44
47
  <ul id="full_list" class="file">
data/docs/frames.html CHANGED
@@ -2,13 +2,18 @@
2
2
  <html>
3
3
  <head>
4
4
  <meta charset="utf-8">
5
- <title>Documentation by YARD 0.9.28</title>
5
+ <title>Documentation by YARD 0.9.44</title>
6
6
  </head>
7
7
  <script type="text/javascript">
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;
8
+ var mainUrl = 'index.html';
9
+ try {
10
+ var match = decodeURIComponent(window.location.hash).match(/^#!(.+)/);
11
+ var name = match ? match[1] : mainUrl;
12
+ var url = new URL(name, location.href);
13
+ window.top.location.replace(url.origin === location.origin ? name : mainUrl);
14
+ } catch (e) {
15
+ window.top.location.replace(mainUrl);
16
+ }
12
17
  </script>
13
18
  <noscript>
14
19
  <h1>Oops!</h1>
data/docs/index.html CHANGED
@@ -6,13 +6,13 @@
6
6
  <title>
7
7
  File: README
8
8
 
9
- &mdash; Documentation by YARD 0.9.28
9
+ &mdash; Documentation by YARD 0.9.44
10
10
 
11
11
  </title>
12
12
 
13
- <link rel="stylesheet" href="css/style.css" type="text/css" />
13
+ <link rel="stylesheet" href="css/style.css" type="text/css">
14
14
 
15
- <link rel="stylesheet" href="css/common.css" type="text/css" />
15
+ <link rel="stylesheet" href="css/common.css" type="text/css">
16
16
 
17
17
  <script type="text/javascript">
18
18
  pathId = "README";
@@ -27,6 +27,8 @@
27
27
 
28
28
  </head>
29
29
  <body>
30
+ <div id="main_progress" aria-hidden="true"></div>
31
+
30
32
  <div class="nav_wrap">
31
33
  <iframe id="nav" src="class_list.html?1"></iframe>
32
34
  <div id="resizer"></div>
@@ -59,114 +61,88 @@
59
61
 
60
62
  <div id="content"><div id='filecontents'><p><a href="https://rubygems.org/gems/crapi"><img src="https://img.shields.io/github/v/release/nestor-custodio/crapi?color=green&amp;label=gem%20version" alt="Gem Version" /></a>
61
63
  <a href="https://tldrlegal.com/license/mit-license"><img src="https://img.shields.io/github/license/nestor-custodio/crapi" alt="MIT License" /></a></p>
62
-
63
- <h1 id="crapi">CrAPI</h1>
64
-
65
- <p>CrAPI is yet another <u>Cr</u>ud <u>API</u> client wrapper. Yes, there is no shortage of these out there, but no other API wrapper gem (that I could find) provided the kind of functionality you get from the CrAPI::Proxy class, which is really the biggest benefit here.</p>
66
-
67
- <p><strong>CrAPI::Client</strong> will connect to the target system and handily provides a base path for you (because some APIs and services have a path that is always part of every request), <strong>CrAPI::Proxy</strong> lets you add to the root client’s base path or default set of headers without having to create any new connections.</p>
68
-
69
- <h2 id="installation">Installation</h2>
70
-
71
- <p>Add this line to your application’s Gemfile:</p>
72
-
73
- <p><code>ruby
74
- gem 'crapi'
75
- </code></p>
76
-
64
+ <h1 id="CrAPI">CrAPI</h1>
65
+ <p>CrAPI is yet another <strong>Cr</strong>ud <strong>API</strong> client wrapper. Yes, there is no shortage of these out there, but no other API wrapper gem (that I could find) provided the kind of functionality you get from the CrAPI::Proxy class, which is really the biggest benefit here.</p>
66
+ <p><strong>CrAPI::Client</strong> will connect to the target system and handily provides a base path for you (because some APIs and services have a path that is always part of every request), <strong>CrAPI::Proxy</strong> lets you add to the root client's base path or default set of headers without having to create any new connections.</p>
67
+ <h2 id="Installation">Installation</h2>
68
+ <p>Add this line to your application's Gemfile:</p>
69
+ <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>
70
+ </code></pre>
77
71
  <p>And then execute:</p>
78
-
79
72
  <pre class="code ruby"><code class="ruby">$ bundle
80
73
  </code></pre>
81
-
82
74
  <p>Or install it yourself as:</p>
83
-
84
75
  <pre class="code ruby"><code class="ruby">$ gem install crapi
85
76
  </code></pre>
86
-
87
- <h2 id="using-the-crapi-tools">Using The CrAPI Tools</h2>
88
-
89
- <h3 id="client-usage">Client Usage</h3>
90
-
91
- <p>```ruby
92
- # Connect to an API.</p>
93
-
94
- <p>api = CrAPI::Client.new(‘https://jsonplaceholder.typicode.com/’)</p>
95
-
96
- <h1 id="issue-requests-against-the-api">Issue requests against the API.</h1>
97
-
98
- <p>api.get(‘users/1’) # GETs /users/1; returns a Hash.</p>
99
-
100
- <p>api.get(‘posts’, query: { userId: 2 }) # GETs /posts?userId=2; returns an Array.</p>
101
-
102
- <p>mew_comment = { user: ‘megapwner’, text: ‘FRIST!!1!’ }
103
- api.post(‘comments’, payload: new_comment) # POSTs to /comments; returns a Hash.
104
- ```</p>
105
-
77
+ <h2 id="Using_The_CrAPI_Tools">Using The CrAPI Tools</h2>
78
+ <h3 id="Client_Usage">Client Usage</h3>
79
+ <pre class="code ruby"><code class="ruby"><span class='comment'># Connect to an API.
80
+ </span>
81
+ <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>
82
+
83
+
84
+ <span class='comment'># Issue requests against the API.
85
+ </span>
86
+ <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.
87
+ </span>
88
+ <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.
89
+ </span>
90
+ <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>
91
+ <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.
92
+ </span></code></pre>
106
93
  <hr />
94
+ <h3 id="Proxy_Usage">Proxy Usage</h3>
95
+ <pre class="code ruby"><code class="ruby"><span class='comment'># Connect to an API.
96
+ </span>
97
+ <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>
107
98
 
108
- <h3 id="proxy-usage">Proxy Usage</h3>
109
-
110
- <p>```ruby
111
- # Connect to an API.</p>
112
-
113
- <p>api = CrAPI::Client.new(‘https://versioned.fake-api.com/api/’)</p>
114
-
115
- <h1 id="back-in-the-v1-days-versioning-of-this-api-was-via-the-url-">Back in the v1 days, versioning of this API was via the URL …</h1>
116
99
 
117
- <p>v1 = api.new_proxy(‘/v1’)</p>
100
+ <span class='comment'># Back in the v1 days, versioning of this API was via the URL ...
101
+ </span>
102
+ <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>
118
103
 
119
- <p>v1.get(data) # GETs /api/v1/data; pretty straight-forward.
120
- v1.post(data’, payload: values) # POSTs <em>values</em> to /api/v1/data.</p>
104
+ <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.
105
+ </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.
106
+ </span>
121
107
 
122
- <h1 id="for-api-v2-they-switched-to-an-accept-header-approach-">For API v2, they switched to an Accept header approach …</h1>
108
+ <span class='comment'># For API v2, they switched to an Accept header approach ...
109
+ </span>
110
+ <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>
123
111
 
124
- <p>v2 = api.new_proxy(‘/’, headers: { Accept: ‘application/vnd.fake-api.v2+json’ })</p>
112
+ <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.
113
+ </span>
125
114
 
126
- <p>v2.get(‘data’) # GETs /api/data with the v2 header.</p>
115
+ <span class='comment'># API v3 keeps the Accept header approach ...
116
+ </span>
117
+ <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>
127
118
 
128
- <h1 id="api-v3-keeps-the-accept-header-approach-">API v3 keeps the Accept header approach …</h1>
129
-
130
- <p>v3 = api.new_proxy(‘/’, headers: { Accept: ‘application/vnd.fake-api.v3+json’ })</p>
131
-
132
- <p>v3.get(‘data’) # GETs /api/data with the v3 header.</p>
133
-
134
- <h1 id="note-that-only-one-connection-to-the-client-is-made-and-you-can-easily-make">Note that only one connection to the client is made and you can easily make</h1>
135
- <p># v1, v2, and v3 API calls ad hoc without having to juggle paths/headers yourself.
136
- ```</p>
119
+ <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.
120
+ </span>
137
121
 
122
+ <span class='comment'># Note that only one connection to the client is made and you can easily make
123
+ </span><span class='comment'># v1, v2, and v3 API calls ad hoc without having to juggle paths/headers yourself.
124
+ </span></code></pre>
138
125
  <hr />
139
-
140
- <p><a href="http://nestor-custodio.github.io/crapi/CrAPI.html">Consult the repo docs for the full CrAPI documentation.</a></p>
141
-
142
- <h2 id="feature-roadmap--future-development">Feature Roadmap / Future Development</h2>
143
-
126
+ <p><a href="https://nestor-custodio.github.io/crapi/CrAPI.html">Consult the repo docs for the full CrAPI documentation.</a></p>
127
+ <h2 id="Feature_Roadmap___Future_Development">Feature Roadmap / Future Development</h2>
144
128
  <p>Additional features/options coming in the future:</p>
145
-
146
129
  <ul>
147
- <li>Cleaner handling of non-body-returning calls.</li>
148
- <li>More resilient serializing of non-String paylods when using custom Content-Type headers.</li>
130
+ <li>Cleaner handling of non-body-returning calls.</li>
131
+ <li>More resilient serializing of non-String paylods when using custom Content-Type headers.</li>
149
132
  </ul>
150
-
151
- <h2 id="contribution--development">Contribution / Development</h2>
152
-
153
- <p>Bug reports and pull requests are welcome at: <a href="https://github.com/nestor-custodio/crapi">https://github.com/nestor-custodio/crapi</a></p>
154
-
133
+ <h2 id="Contribution___Development">Contribution / Development</h2>
134
+ <p>Bug reports and pull requests are welcome at: <a href="https://github.com/nestor-custodio/crapi"><a href="https://github.com/nestor-custodio/crapi">https://github.com/nestor-custodio/crapi</a></a></p>
155
135
  <p>After checking out the repo, run <code>bin/setup</code> to install dependencies. Then, run <code>bundle exec rspec</code> to run the tests. You can also run <code>bin/console</code> for an interactive prompt that will allow you to experiment.</p>
156
-
157
136
  <p>Linting is courtesy of <a href="https://docs.rubocop.org/">Rubocop</a> (<code>bundle exec rubocop</code>) and documentation is built using <a href="https://yardoc.org/">Yard</a> (<code>bundle exec yard</code>). Please ensure you have a clean bill of health from Rubocop and that any new features and/or changes to behaviour are reflected in the documentation before submitting a pull request.</p>
158
-
159
- <h2 id="license">License</h2>
160
-
161
- <p>CrAPI is available as open source under the terms of the <a href="https://tldrlegal.com/license/mit-license">MIT License</a>.</p>
162
- </div></div>
137
+ <h2 id="License">License</h2>
138
+ <p>CrAPI is available as open source under the terms of the <a href="https://tldrlegal.com/license/mit-license">MIT License</a>.</p></div></div>
163
139
 
164
140
  <div id="footer">
165
- Generated on Mon Jan 2 15:16:45 2023 by
141
+ Generated on Sun Jul 5 14:46:38 2026 by
166
142
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
167
- 0.9.28 (ruby-3.0.4).
143
+ 0.9.44 (ruby-3.4.8).
168
144
  </div>
169
145
 
170
146
  </div>
171
147
  </body>
172
- </html>
148
+ </html>