crapi 0.1.3 → 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.
- checksums.yaml +4 -4
- data/.circleci/config.yml +64 -0
- data/.gitignore +3 -0
- data/.rubocop.yml +53 -70
- data/.ruby-version +1 -1
- data/Gemfile.lock +138 -43
- data/README.md +29 -27
- data/crapi.gemspec +17 -17
- data/docs/{Crapi → CrAPI}/ArgumentError.html +21 -19
- data/docs/{Crapi → CrAPI}/BadHttpResponseError.html +21 -19
- data/docs/{Crapi → CrAPI}/Client.html +150 -222
- data/docs/{Crapi → CrAPI}/Error.html +19 -18
- data/docs/{Crapi → CrAPI}/Proxy.html +71 -114
- data/docs/CrAPI.html +157 -0
- data/docs/Net/HTTP.html +24 -29
- data/docs/_index.html +22 -20
- data/docs/class_list.html +10 -7
- data/docs/css/common.css +1 -1
- data/docs/css/full_list.css +201 -53
- data/docs/css/style.css +991 -401
- data/docs/file.README.html +51 -94
- data/docs/file_list.html +9 -6
- data/docs/frames.html +11 -6
- data/docs/index.html +51 -94
- data/docs/js/app.js +799 -246
- data/docs/js/full_list.js +332 -214
- data/docs/method_list.html +41 -38
- data/docs/top-level-namespace.html +11 -9
- data/lib/crapi/client.rb +224 -228
- data/lib/crapi/errors.rb +7 -7
- data/lib/crapi/proxy.rb +82 -82
- data/lib/crapi/version.rb +10 -10
- data/lib/crapi.rb +3 -1
- metadata +56 -55
- data/.travis.yml +0 -5
- data/docs/Crapi.html +0 -153
data/docs/file.README.html
CHANGED
|
@@ -6,15 +6,15 @@
|
|
|
6
6
|
<title>
|
|
7
7
|
File: README
|
|
8
8
|
|
|
9
|
-
— Documentation by YARD 0.9.
|
|
9
|
+
— 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
|
-
<script type="text/javascript"
|
|
17
|
+
<script type="text/javascript">
|
|
18
18
|
pathId = "README";
|
|
19
19
|
relpath = '';
|
|
20
20
|
</script>
|
|
@@ -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>
|
|
@@ -57,135 +59,90 @@
|
|
|
57
59
|
<div class="clear"></div>
|
|
58
60
|
</div>
|
|
59
61
|
|
|
60
|
-
<div id="content"><div id='filecontents'>
|
|
61
|
-
<
|
|
62
|
-
|
|
63
|
-
<p>
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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's base path or default set of headers
|
|
72
|
-
without having to create any new connections.</p>
|
|
73
|
-
|
|
74
|
-
<p>Why “crapi”? Because it's a <u>CR</u>UD
|
|
75
|
-
<u>API</u> 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's Gemfile:</p>
|
|
80
|
-
|
|
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&label=gem%20version" alt="Gem Version" /></a>
|
|
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>
|
|
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>
|
|
81
69
|
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_gem'>gem</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>crapi</span><span class='tstring_end'>'</span></span>
|
|
82
70
|
</code></pre>
|
|
83
|
-
|
|
84
71
|
<p>And then execute:</p>
|
|
85
|
-
|
|
86
72
|
<pre class="code ruby"><code class="ruby">$ bundle
|
|
87
73
|
</code></pre>
|
|
88
|
-
|
|
89
74
|
<p>Or install it yourself as:</p>
|
|
90
|
-
|
|
91
75
|
<pre class="code ruby"><code class="ruby">$ gem install crapi
|
|
92
76
|
</code></pre>
|
|
93
|
-
|
|
94
|
-
<
|
|
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.
|
|
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.
|
|
99
80
|
</span>
|
|
100
|
-
<span class='id identifier rubyid_api'>api</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="
|
|
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'>'</span><span class='tstring_content'>https://jsonplaceholder.typicode.com/</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
|
101
82
|
|
|
102
83
|
|
|
103
|
-
<span class='comment'
|
|
84
|
+
<span class='comment'># Issue requests against the API.
|
|
104
85
|
</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'>'</span><span class='tstring_content'>users/1</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='comment'
|
|
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'>'</span><span class='tstring_content'>users/1</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='comment'># GETs /users/1; returns a Hash.
|
|
106
87
|
</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'>'</span><span class='tstring_content'>posts</span><span class='tstring_end'>'</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'
|
|
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'>'</span><span class='tstring_content'>posts</span><span class='tstring_end'>'</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
89
|
</span>
|
|
109
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'>'</span><span class='tstring_content'>megapwner</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>text:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>FRIST!!1!</span><span class='tstring_end'>'</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'>'</span><span class='tstring_content'>comments</span><span class='tstring_end'>'</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'
|
|
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'>'</span><span class='tstring_content'>comments</span><span class='tstring_end'>'</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
92
|
</span></code></pre>
|
|
112
|
-
<hr
|
|
113
|
-
|
|
114
|
-
<
|
|
115
|
-
|
|
116
|
-
<pre class="code ruby"><code class="ruby"><span class='comment'>## Connect to an API.
|
|
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.
|
|
117
96
|
</span>
|
|
118
|
-
<span class='id identifier rubyid_api'>api</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="
|
|
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'>'</span><span class='tstring_content'>https://versioned.fake-api.com/api/</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
|
119
98
|
|
|
120
99
|
|
|
121
|
-
<span class='comment'
|
|
100
|
+
<span class='comment'># Back in the v1 days, versioning of this API was via the URL ...
|
|
122
101
|
</span>
|
|
123
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'>'</span><span class='tstring_content'>/v1</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
|
124
103
|
|
|
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'>'</span><span class='tstring_content'>data</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='comment'
|
|
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'>'</span><span class='tstring_content'>data</span><span class='tstring_end'>'</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'
|
|
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'>'</span><span class='tstring_content'>data</span><span class='tstring_end'>'</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'>'</span><span class='tstring_content'>data</span><span class='tstring_end'>'</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
106
|
</span>
|
|
128
107
|
|
|
129
|
-
<span class='comment'
|
|
108
|
+
<span class='comment'># For API v2, they switched to an Accept header approach ...
|
|
130
109
|
</span>
|
|
131
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'>'</span><span class='tstring_content'>/</span><span class='tstring_end'>'</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'>'</span><span class='tstring_content'>application/vnd.fake-api.v2+json</span><span class='tstring_end'>'</span></span> <span class='rbrace'>}</span><span class='rparen'>)</span>
|
|
132
111
|
|
|
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'>'</span><span class='tstring_content'>data</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='comment'
|
|
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'>'</span><span class='tstring_content'>data</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='comment'># GETs /api/data with the v2 header.
|
|
134
113
|
</span>
|
|
135
114
|
|
|
136
|
-
<span class='comment'
|
|
115
|
+
<span class='comment'># API v3 keeps the Accept header approach ...
|
|
137
116
|
</span>
|
|
138
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'>'</span><span class='tstring_content'>/</span><span class='tstring_end'>'</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'>'</span><span class='tstring_content'>application/vnd.fake-api.v3+json</span><span class='tstring_end'>'</span></span> <span class='rbrace'>}</span><span class='rparen'>)</span>
|
|
139
118
|
|
|
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'>'</span><span class='tstring_content'>data</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='comment'
|
|
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'>'</span><span class='tstring_content'>data</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='comment'># GETs /api/data with the v3 header.
|
|
141
120
|
</span>
|
|
142
121
|
|
|
143
|
-
<span class='comment'
|
|
144
|
-
</span><span class='comment'
|
|
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.
|
|
145
124
|
</span></code></pre>
|
|
146
|
-
<hr
|
|
147
|
-
|
|
148
|
-
<
|
|
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
|
-
|
|
125
|
+
<hr />
|
|
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>
|
|
153
128
|
<p>Additional features/options coming in the future:</p>
|
|
154
|
-
<ul
|
|
155
|
-
<
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
</
|
|
160
|
-
|
|
161
|
-
<
|
|
162
|
-
|
|
163
|
-
<p>
|
|
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'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>
|
|
129
|
+
<ul>
|
|
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>
|
|
132
|
+
</ul>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
182
139
|
|
|
183
140
|
<div id="footer">
|
|
184
|
-
Generated on
|
|
185
|
-
<a href="
|
|
186
|
-
0.9.
|
|
141
|
+
Generated on Sun Jul 5 14:46:38 2026 by
|
|
142
|
+
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
143
|
+
0.9.44 (ruby-3.4.8).
|
|
187
144
|
</div>
|
|
188
145
|
|
|
189
146
|
</div>
|
|
190
147
|
</body>
|
|
191
|
-
</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">
|
|
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.
|
|
5
|
+
<title>Documentation by YARD 0.9.44</title>
|
|
6
6
|
</head>
|
|
7
|
-
<script type="text/javascript"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
<script type="text/javascript">
|
|
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,15 +6,15 @@
|
|
|
6
6
|
<title>
|
|
7
7
|
File: README
|
|
8
8
|
|
|
9
|
-
— Documentation by YARD 0.9.
|
|
9
|
+
— 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
|
-
<script type="text/javascript"
|
|
17
|
+
<script type="text/javascript">
|
|
18
18
|
pathId = "README";
|
|
19
19
|
relpath = '';
|
|
20
20
|
</script>
|
|
@@ -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>
|
|
@@ -57,135 +59,90 @@
|
|
|
57
59
|
<div class="clear"></div>
|
|
58
60
|
</div>
|
|
59
61
|
|
|
60
|
-
<div id="content"><div id='filecontents'>
|
|
61
|
-
<
|
|
62
|
-
|
|
63
|
-
<p>
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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's base path or default set of headers
|
|
72
|
-
without having to create any new connections.</p>
|
|
73
|
-
|
|
74
|
-
<p>Why “crapi”? Because it's a <u>CR</u>UD
|
|
75
|
-
<u>API</u> 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's Gemfile:</p>
|
|
80
|
-
|
|
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&label=gem%20version" alt="Gem Version" /></a>
|
|
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>
|
|
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>
|
|
81
69
|
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_gem'>gem</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>crapi</span><span class='tstring_end'>'</span></span>
|
|
82
70
|
</code></pre>
|
|
83
|
-
|
|
84
71
|
<p>And then execute:</p>
|
|
85
|
-
|
|
86
72
|
<pre class="code ruby"><code class="ruby">$ bundle
|
|
87
73
|
</code></pre>
|
|
88
|
-
|
|
89
74
|
<p>Or install it yourself as:</p>
|
|
90
|
-
|
|
91
75
|
<pre class="code ruby"><code class="ruby">$ gem install crapi
|
|
92
76
|
</code></pre>
|
|
93
|
-
|
|
94
|
-
<
|
|
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.
|
|
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.
|
|
99
80
|
</span>
|
|
100
|
-
<span class='id identifier rubyid_api'>api</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="
|
|
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'>'</span><span class='tstring_content'>https://jsonplaceholder.typicode.com/</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
|
101
82
|
|
|
102
83
|
|
|
103
|
-
<span class='comment'
|
|
84
|
+
<span class='comment'># Issue requests against the API.
|
|
104
85
|
</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'>'</span><span class='tstring_content'>users/1</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='comment'
|
|
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'>'</span><span class='tstring_content'>users/1</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='comment'># GETs /users/1; returns a Hash.
|
|
106
87
|
</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'>'</span><span class='tstring_content'>posts</span><span class='tstring_end'>'</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'
|
|
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'>'</span><span class='tstring_content'>posts</span><span class='tstring_end'>'</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
89
|
</span>
|
|
109
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'>'</span><span class='tstring_content'>megapwner</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>text:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>FRIST!!1!</span><span class='tstring_end'>'</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'>'</span><span class='tstring_content'>comments</span><span class='tstring_end'>'</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'
|
|
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'>'</span><span class='tstring_content'>comments</span><span class='tstring_end'>'</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
92
|
</span></code></pre>
|
|
112
|
-
<hr
|
|
113
|
-
|
|
114
|
-
<
|
|
115
|
-
|
|
116
|
-
<pre class="code ruby"><code class="ruby"><span class='comment'>## Connect to an API.
|
|
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.
|
|
117
96
|
</span>
|
|
118
|
-
<span class='id identifier rubyid_api'>api</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="
|
|
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'>'</span><span class='tstring_content'>https://versioned.fake-api.com/api/</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
|
119
98
|
|
|
120
99
|
|
|
121
|
-
<span class='comment'
|
|
100
|
+
<span class='comment'># Back in the v1 days, versioning of this API was via the URL ...
|
|
122
101
|
</span>
|
|
123
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'>'</span><span class='tstring_content'>/v1</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
|
124
103
|
|
|
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'>'</span><span class='tstring_content'>data</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='comment'
|
|
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'>'</span><span class='tstring_content'>data</span><span class='tstring_end'>'</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'
|
|
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'>'</span><span class='tstring_content'>data</span><span class='tstring_end'>'</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'>'</span><span class='tstring_content'>data</span><span class='tstring_end'>'</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
106
|
</span>
|
|
128
107
|
|
|
129
|
-
<span class='comment'
|
|
108
|
+
<span class='comment'># For API v2, they switched to an Accept header approach ...
|
|
130
109
|
</span>
|
|
131
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'>'</span><span class='tstring_content'>/</span><span class='tstring_end'>'</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'>'</span><span class='tstring_content'>application/vnd.fake-api.v2+json</span><span class='tstring_end'>'</span></span> <span class='rbrace'>}</span><span class='rparen'>)</span>
|
|
132
111
|
|
|
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'>'</span><span class='tstring_content'>data</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='comment'
|
|
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'>'</span><span class='tstring_content'>data</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='comment'># GETs /api/data with the v2 header.
|
|
134
113
|
</span>
|
|
135
114
|
|
|
136
|
-
<span class='comment'
|
|
115
|
+
<span class='comment'># API v3 keeps the Accept header approach ...
|
|
137
116
|
</span>
|
|
138
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'>'</span><span class='tstring_content'>/</span><span class='tstring_end'>'</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'>'</span><span class='tstring_content'>application/vnd.fake-api.v3+json</span><span class='tstring_end'>'</span></span> <span class='rbrace'>}</span><span class='rparen'>)</span>
|
|
139
118
|
|
|
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'>'</span><span class='tstring_content'>data</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='comment'
|
|
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'>'</span><span class='tstring_content'>data</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='comment'># GETs /api/data with the v3 header.
|
|
141
120
|
</span>
|
|
142
121
|
|
|
143
|
-
<span class='comment'
|
|
144
|
-
</span><span class='comment'
|
|
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.
|
|
145
124
|
</span></code></pre>
|
|
146
|
-
<hr
|
|
147
|
-
|
|
148
|
-
<
|
|
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
|
-
|
|
125
|
+
<hr />
|
|
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>
|
|
153
128
|
<p>Additional features/options coming in the future:</p>
|
|
154
|
-
<ul
|
|
155
|
-
<
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
</
|
|
160
|
-
|
|
161
|
-
<
|
|
162
|
-
|
|
163
|
-
<p>
|
|
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'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>
|
|
129
|
+
<ul>
|
|
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>
|
|
132
|
+
</ul>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
182
139
|
|
|
183
140
|
<div id="footer">
|
|
184
|
-
Generated on
|
|
185
|
-
<a href="
|
|
186
|
-
0.9.
|
|
141
|
+
Generated on Sun Jul 5 14:46:38 2026 by
|
|
142
|
+
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
143
|
+
0.9.44 (ruby-3.4.8).
|
|
187
144
|
</div>
|
|
188
145
|
|
|
189
146
|
</div>
|
|
190
147
|
</body>
|
|
191
|
-
</html>
|
|
148
|
+
</html>
|