api_wrapper 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +7 -0
  2. data/.rubocop.yml +7 -0
  3. data/CHANGELOG.md +18 -0
  4. data/CODE_OF_CONDUCT.md +84 -0
  5. data/Gemfile +22 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +153 -0
  8. data/Rakefile +31 -0
  9. data/api_wrapper.gemspec +34 -0
  10. data/doc/ApiWrapper/ApiManager.html +807 -0
  11. data/doc/ApiWrapper/Cache/CachePolicy.html +907 -0
  12. data/doc/ApiWrapper/Cache/CacheStore.html +674 -0
  13. data/doc/ApiWrapper/Cache.html +117 -0
  14. data/doc/ApiWrapper/Configuration.html +366 -0
  15. data/doc/ApiWrapper/HttpClient/BaseClient.html +349 -0
  16. data/doc/ApiWrapper/HttpClient/FaradayClient.html +299 -0
  17. data/doc/ApiWrapper/HttpClient.html +117 -0
  18. data/doc/ApiWrapper.html +543 -0
  19. data/doc/_index.html +195 -0
  20. data/doc/class_list.html +54 -0
  21. data/doc/css/common.css +1 -0
  22. data/doc/css/full_list.css +58 -0
  23. data/doc/css/style.css +503 -0
  24. data/doc/file.README.html +248 -0
  25. data/doc/file_list.html +59 -0
  26. data/doc/frames.html +22 -0
  27. data/doc/index.html +248 -0
  28. data/doc/js/app.js +344 -0
  29. data/doc/js/full_list.js +242 -0
  30. data/doc/js/jquery.js +4 -0
  31. data/doc/method_list.html +286 -0
  32. data/doc/top-level-namespace.html +110 -0
  33. data/lib/api_wrapper/api_manager.rb +86 -0
  34. data/lib/api_wrapper/cache/README.md +78 -0
  35. data/lib/api_wrapper/cache/cache_policy.rb +115 -0
  36. data/lib/api_wrapper/cache/cache_store.rb +84 -0
  37. data/lib/api_wrapper/cache/redis_cache_store.rb +3 -0
  38. data/lib/api_wrapper/http_client/base_client.rb +26 -0
  39. data/lib/api_wrapper/http_client/faraday_client.rb +81 -0
  40. data/lib/api_wrapper/version.rb +5 -0
  41. data/lib/api_wrapper.rb +83 -0
  42. metadata +121 -0
@@ -0,0 +1,807 @@
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
+ Class: ApiWrapper::ApiManager
8
+
9
+ &mdash; Documentation by YARD 0.9.37
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../css/style.css" type="text/css" />
14
+
15
+ <link rel="stylesheet" href="../css/common.css" type="text/css" />
16
+
17
+ <script type="text/javascript">
18
+ pathId = "ApiWrapper::ApiManager";
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)</a> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../ApiWrapper.html" title="ApiWrapper (module)">ApiWrapper</a></span></span>
41
+ &raquo;
42
+ <span class="title">ApiManager</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="../class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Class: ApiWrapper::ApiManager
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+ <dl>
70
+ <dt>Inherits:</dt>
71
+ <dd>
72
+ <span class="inheritName">Object</span>
73
+
74
+ <ul class="fullTree">
75
+ <li>Object</li>
76
+
77
+ <li class="next">ApiWrapper::ApiManager</li>
78
+
79
+ </ul>
80
+ <a href="#" class="inheritanceTree">show all</a>
81
+
82
+ </dd>
83
+ </dl>
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+ <dl>
96
+ <dt>Defined in:</dt>
97
+ <dd>lib/api_wrapper/api_manager.rb</dd>
98
+ </dl>
99
+
100
+ </div>
101
+
102
+ <h2>Overview</h2><div class="docstring">
103
+ <div class="discussion">
104
+
105
+ <p>ApiManager is responsible for managing API interactions, including fetching data from endpoints and handling caching behavior.</p>
106
+
107
+ <p>It supports configuration of caching policies, including specifying endpoints that should bypass the cache and setting custom TTL (time-to-live) values for individual endpoints. The class uses a Faraday client for making HTTP requests and integrates with a cache store for storing and retrieving cached data.</p>
108
+
109
+ <p>Usage:</p>
110
+
111
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_api_manager'>api_manager</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../ApiWrapper.html" title="ApiWrapper (module)">ApiWrapper</a></span></span><span class='op'>::</span><span class='const'>ApiManager</span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="#initialize-instance_method" title="ApiWrapper::ApiManager#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>path/to/api_configuration.yml</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
112
+
113
+ <span class='id identifier rubyid_response'>response</span> <span class='op'>=</span> <span class='id identifier rubyid_api_manager'>api_manager</span><span class='period'>.</span><span class='id identifier rubyid_fetch_data'>fetch_data</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>endpoint_key</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
114
+ <span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_response'>response</span><span class='period'>.</span><span class='id identifier rubyid_body'>body</span>
115
+ </code></pre>
116
+
117
+
118
+ </div>
119
+ </div>
120
+ <div class="tags">
121
+
122
+
123
+ </div>
124
+
125
+
126
+
127
+ <h2>Instance Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2>
128
+ <ul class="summary">
129
+
130
+ <li class="public ">
131
+ <span class="summary_signature">
132
+
133
+ <a href="#base_url-instance_method" title="#base_url (instance method)">#<strong>base_url</strong> &#x21d2; String </a>
134
+
135
+
136
+
137
+ </span>
138
+
139
+
140
+
141
+
142
+ <span class="note title readonly">readonly</span>
143
+
144
+
145
+
146
+
147
+
148
+
149
+
150
+
151
+
152
+ <span class="summary_desc"><div class='inline'>
153
+ <p>The base URL for API requests.</p>
154
+ </div></span>
155
+
156
+ </li>
157
+
158
+
159
+ <li class="public ">
160
+ <span class="summary_signature">
161
+
162
+ <a href="#cache_policy-instance_method" title="#cache_policy (instance method)">#<strong>cache_policy</strong> &#x21d2; CachePolicy </a>
163
+
164
+
165
+
166
+ </span>
167
+
168
+
169
+
170
+
171
+ <span class="note title readonly">readonly</span>
172
+
173
+
174
+
175
+
176
+
177
+
178
+
179
+
180
+
181
+ <span class="summary_desc"><div class='inline'>
182
+ <p>The cache policy used for caching data.</p>
183
+ </div></span>
184
+
185
+ </li>
186
+
187
+
188
+ <li class="public ">
189
+ <span class="summary_signature">
190
+
191
+ <a href="#client-instance_method" title="#client (instance method)">#<strong>client</strong> &#x21d2; FaradayClient </a>
192
+
193
+
194
+
195
+ </span>
196
+
197
+
198
+
199
+
200
+ <span class="note title readonly">readonly</span>
201
+
202
+
203
+
204
+
205
+
206
+
207
+
208
+
209
+
210
+ <span class="summary_desc"><div class='inline'>
211
+ <p>The Faraday client used for making HTTP requests.</p>
212
+ </div></span>
213
+
214
+ </li>
215
+
216
+
217
+ <li class="public ">
218
+ <span class="summary_signature">
219
+
220
+ <a href="#endpoints-instance_method" title="#endpoints (instance method)">#<strong>endpoints</strong> &#x21d2; Hash </a>
221
+
222
+
223
+
224
+ </span>
225
+
226
+
227
+
228
+
229
+ <span class="note title readonly">readonly</span>
230
+
231
+
232
+
233
+
234
+
235
+
236
+
237
+
238
+
239
+ <span class="summary_desc"><div class='inline'>
240
+ <p>The endpoints configuration loaded from the API configuration file.</p>
241
+ </div></span>
242
+
243
+ </li>
244
+
245
+
246
+ </ul>
247
+
248
+
249
+
250
+
251
+
252
+ <h2>
253
+ Instance Method Summary
254
+ <small><a href="#" class="summary_toggle">collapse</a></small>
255
+ </h2>
256
+
257
+ <ul class="summary">
258
+
259
+ <li class="public ">
260
+ <span class="summary_signature">
261
+
262
+ <a href="#fetch_data-instance_method" title="#fetch_data (instance method)">#<strong>fetch_data</strong>(endpoint_key, force_refresh: false) &#x21d2; Faraday::Response </a>
263
+
264
+
265
+
266
+ </span>
267
+
268
+
269
+
270
+
271
+
272
+
273
+
274
+
275
+
276
+ <span class="summary_desc"><div class='inline'>
277
+ <p>Fetches data from the specified API endpoint.</p>
278
+ </div></span>
279
+
280
+ </li>
281
+
282
+
283
+ <li class="public ">
284
+ <span class="summary_signature">
285
+
286
+ <a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(api_configuration_path, cache_store: nil) &#x21d2; ApiManager </a>
287
+
288
+
289
+
290
+ </span>
291
+
292
+
293
+ <span class="note title constructor">constructor</span>
294
+
295
+
296
+
297
+
298
+
299
+
300
+
301
+
302
+ <span class="summary_desc"><div class='inline'>
303
+ <p>Initializes a new instance of the ApiManager class.</p>
304
+ </div></span>
305
+
306
+ </li>
307
+
308
+
309
+ </ul>
310
+
311
+
312
+ <div id="constructor_details" class="method_details_list">
313
+ <h2>Constructor Details</h2>
314
+
315
+ <div class="method_details first">
316
+ <h3 class="signature first" id="initialize-instance_method">
317
+
318
+ #<strong>initialize</strong>(api_configuration_path, cache_store: nil) &#x21d2; <tt><span class='object_link'><a href="" title="ApiWrapper::ApiManager (class)">ApiManager</a></span></tt>
319
+
320
+
321
+
322
+
323
+
324
+ </h3><div class="docstring">
325
+ <div class="discussion">
326
+
327
+ <p>Initializes a new instance of the ApiManager class.</p>
328
+
329
+ <p>Defaults to in-memory cache if nil.</p>
330
+
331
+
332
+ </div>
333
+ </div>
334
+ <div class="tags">
335
+ <p class="tag_title">Parameters:</p>
336
+ <ul class="param">
337
+
338
+ <li>
339
+
340
+ <span class='name'>api_configuration_path</span>
341
+
342
+
343
+ <span class='type'>(<tt>String</tt>)</span>
344
+
345
+
346
+
347
+ &mdash;
348
+ <div class='inline'>
349
+ <p>Path to the API configuration file.</p>
350
+ </div>
351
+
352
+ </li>
353
+
354
+ <li>
355
+
356
+ <span class='name'>cache_store</span>
357
+
358
+
359
+ <span class='type'>(<tt>CacheStore</tt>, <tt>RedisCacheStore</tt>, <tt>nil</tt>)</span>
360
+
361
+
362
+ <em class="default">(defaults to: <tt>nil</tt>)</em>
363
+
364
+
365
+ &mdash;
366
+ <div class='inline'>
367
+ <p>The cache store to use for caching.</p>
368
+ </div>
369
+
370
+ </li>
371
+
372
+ </ul>
373
+
374
+
375
+ </div><table class="source_code">
376
+ <tr>
377
+ <td>
378
+ <pre class="lines">
379
+
380
+
381
+ 33
382
+ 34
383
+ 35
384
+ 36
385
+ 37
386
+ 38
387
+ 39
388
+ 40
389
+ 41
390
+ 42
391
+ 43
392
+ 44</pre>
393
+ </td>
394
+ <td>
395
+ <pre class="code"><span class="info file"># File 'lib/api_wrapper/api_manager.rb', line 33</span>
396
+
397
+ <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_api_configuration_path'>api_configuration_path</span><span class='comma'>,</span> <span class='label'>cache_store:</span> <span class='kw'>nil</span><span class='rparen'>)</span>
398
+ <span class='id identifier rubyid_load_api_configuration'>load_api_configuration</span><span class='lparen'>(</span><span class='id identifier rubyid_api_configuration_path'>api_configuration_path</span><span class='rparen'>)</span>
399
+
400
+ <span class='comment'># Initialize cache policy
401
+ </span> <span class='ivar'>@cache_policy</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../ApiWrapper.html" title="ApiWrapper (module)">ApiWrapper</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Cache.html" title="ApiWrapper::Cache (module)">Cache</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Cache/CachePolicy.html" title="ApiWrapper::Cache::CachePolicy (class)">CachePolicy</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Cache/CachePolicy.html#initialize-instance_method" title="ApiWrapper::Cache::CachePolicy#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_cache_store'>cache_store</span> <span class='op'>||</span> <span class='const'><span class='object_link'><a href="../ApiWrapper.html" title="ApiWrapper (module)">ApiWrapper</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Cache.html" title="ApiWrapper::Cache (module)">Cache</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Cache/CacheStore.html" title="ApiWrapper::Cache::CacheStore (class)">CacheStore</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Cache/CacheStore.html#initialize-instance_method" title="ApiWrapper::Cache::CacheStore#initialize (method)">new</a></span></span><span class='rparen'>)</span>
402
+
403
+ <span class='comment'># Configure cache policy
404
+ </span> <span class='id identifier rubyid_configure_cache_policy'>configure_cache_policy</span>
405
+
406
+ <span class='comment'># Initialize Faraday client
407
+ </span> <span class='ivar'>@client</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../ApiWrapper.html" title="ApiWrapper (module)">ApiWrapper</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="HttpClient.html" title="ApiWrapper::HttpClient (module)">HttpClient</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="HttpClient/FaradayClient.html" title="ApiWrapper::HttpClient::FaradayClient (class)">FaradayClient</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="HttpClient/BaseClient.html#initialize-instance_method" title="ApiWrapper::HttpClient::BaseClient#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='ivar'>@base_url</span><span class='comma'>,</span> <span class='ivar'>@cache_policy</span><span class='rparen'>)</span>
408
+ <span class='kw'>end</span></pre>
409
+ </td>
410
+ </tr>
411
+ </table>
412
+ </div>
413
+
414
+ </div>
415
+
416
+ <div id="instance_attr_details" class="attr_details">
417
+ <h2>Instance Attribute Details</h2>
418
+
419
+
420
+ <span id=""></span>
421
+ <div class="method_details first">
422
+ <h3 class="signature first" id="base_url-instance_method">
423
+
424
+ #<strong>base_url</strong> &#x21d2; <tt>String</tt> <span class="extras">(readonly)</span>
425
+
426
+
427
+
428
+
429
+
430
+ </h3><div class="docstring">
431
+ <div class="discussion">
432
+
433
+ <p>The base URL for API requests.</p>
434
+
435
+
436
+ </div>
437
+ </div>
438
+ <div class="tags">
439
+
440
+ <p class="tag_title">Returns:</p>
441
+ <ul class="return">
442
+
443
+ <li>
444
+
445
+
446
+ <span class='type'>(<tt>String</tt>)</span>
447
+
448
+
449
+
450
+ &mdash;
451
+ <div class='inline'>
452
+ <p>the current value of base_url</p>
453
+ </div>
454
+
455
+ </li>
456
+
457
+ </ul>
458
+
459
+ </div><table class="source_code">
460
+ <tr>
461
+ <td>
462
+ <pre class="lines">
463
+
464
+
465
+ 27
466
+ 28
467
+ 29</pre>
468
+ </td>
469
+ <td>
470
+ <pre class="code"><span class="info file"># File 'lib/api_wrapper/api_manager.rb', line 27</span>
471
+
472
+ <span class='kw'>def</span> <span class='id identifier rubyid_base_url'>base_url</span>
473
+ <span class='ivar'>@base_url</span>
474
+ <span class='kw'>end</span></pre>
475
+ </td>
476
+ </tr>
477
+ </table>
478
+ </div>
479
+
480
+
481
+ <span id=""></span>
482
+ <div class="method_details ">
483
+ <h3 class="signature " id="cache_policy-instance_method">
484
+
485
+ #<strong>cache_policy</strong> &#x21d2; <tt>CachePolicy</tt> <span class="extras">(readonly)</span>
486
+
487
+
488
+
489
+
490
+
491
+ </h3><div class="docstring">
492
+ <div class="discussion">
493
+
494
+ <p>The cache policy used for caching data.</p>
495
+
496
+
497
+ </div>
498
+ </div>
499
+ <div class="tags">
500
+
501
+ <p class="tag_title">Returns:</p>
502
+ <ul class="return">
503
+
504
+ <li>
505
+
506
+
507
+ <span class='type'>(<tt>CachePolicy</tt>)</span>
508
+
509
+
510
+
511
+ &mdash;
512
+ <div class='inline'>
513
+ <p>the current value of cache_policy</p>
514
+ </div>
515
+
516
+ </li>
517
+
518
+ </ul>
519
+
520
+ </div><table class="source_code">
521
+ <tr>
522
+ <td>
523
+ <pre class="lines">
524
+
525
+
526
+ 27
527
+ 28
528
+ 29</pre>
529
+ </td>
530
+ <td>
531
+ <pre class="code"><span class="info file"># File 'lib/api_wrapper/api_manager.rb', line 27</span>
532
+
533
+ <span class='kw'>def</span> <span class='id identifier rubyid_cache_policy'>cache_policy</span>
534
+ <span class='ivar'>@cache_policy</span>
535
+ <span class='kw'>end</span></pre>
536
+ </td>
537
+ </tr>
538
+ </table>
539
+ </div>
540
+
541
+
542
+ <span id=""></span>
543
+ <div class="method_details ">
544
+ <h3 class="signature " id="client-instance_method">
545
+
546
+ #<strong>client</strong> &#x21d2; <tt>FaradayClient</tt> <span class="extras">(readonly)</span>
547
+
548
+
549
+
550
+
551
+
552
+ </h3><div class="docstring">
553
+ <div class="discussion">
554
+
555
+ <p>The Faraday client used for making HTTP requests.</p>
556
+
557
+
558
+ </div>
559
+ </div>
560
+ <div class="tags">
561
+
562
+ <p class="tag_title">Returns:</p>
563
+ <ul class="return">
564
+
565
+ <li>
566
+
567
+
568
+ <span class='type'>(<tt>FaradayClient</tt>)</span>
569
+
570
+
571
+
572
+ &mdash;
573
+ <div class='inline'>
574
+ <p>the current value of client</p>
575
+ </div>
576
+
577
+ </li>
578
+
579
+ </ul>
580
+
581
+ </div><table class="source_code">
582
+ <tr>
583
+ <td>
584
+ <pre class="lines">
585
+
586
+
587
+ 27
588
+ 28
589
+ 29</pre>
590
+ </td>
591
+ <td>
592
+ <pre class="code"><span class="info file"># File 'lib/api_wrapper/api_manager.rb', line 27</span>
593
+
594
+ <span class='kw'>def</span> <span class='id identifier rubyid_client'>client</span>
595
+ <span class='ivar'>@client</span>
596
+ <span class='kw'>end</span></pre>
597
+ </td>
598
+ </tr>
599
+ </table>
600
+ </div>
601
+
602
+
603
+ <span id=""></span>
604
+ <div class="method_details ">
605
+ <h3 class="signature " id="endpoints-instance_method">
606
+
607
+ #<strong>endpoints</strong> &#x21d2; <tt>Hash</tt> <span class="extras">(readonly)</span>
608
+
609
+
610
+
611
+
612
+
613
+ </h3><div class="docstring">
614
+ <div class="discussion">
615
+
616
+ <p>The endpoints configuration loaded from the API configuration file.</p>
617
+
618
+
619
+ </div>
620
+ </div>
621
+ <div class="tags">
622
+
623
+ <p class="tag_title">Returns:</p>
624
+ <ul class="return">
625
+
626
+ <li>
627
+
628
+
629
+ <span class='type'>(<tt>Hash</tt>)</span>
630
+
631
+
632
+
633
+ &mdash;
634
+ <div class='inline'>
635
+ <p>the current value of endpoints</p>
636
+ </div>
637
+
638
+ </li>
639
+
640
+ </ul>
641
+
642
+ </div><table class="source_code">
643
+ <tr>
644
+ <td>
645
+ <pre class="lines">
646
+
647
+
648
+ 27
649
+ 28
650
+ 29</pre>
651
+ </td>
652
+ <td>
653
+ <pre class="code"><span class="info file"># File 'lib/api_wrapper/api_manager.rb', line 27</span>
654
+
655
+ <span class='kw'>def</span> <span class='id identifier rubyid_endpoints'>endpoints</span>
656
+ <span class='ivar'>@endpoints</span>
657
+ <span class='kw'>end</span></pre>
658
+ </td>
659
+ </tr>
660
+ </table>
661
+ </div>
662
+
663
+ </div>
664
+
665
+
666
+ <div id="instance_method_details" class="method_details_list">
667
+ <h2>Instance Method Details</h2>
668
+
669
+
670
+ <div class="method_details first">
671
+ <h3 class="signature first" id="fetch_data-instance_method">
672
+
673
+ #<strong>fetch_data</strong>(endpoint_key, force_refresh: false) &#x21d2; <tt>Faraday::Response</tt>
674
+
675
+
676
+
677
+
678
+
679
+ </h3><div class="docstring">
680
+ <div class="discussion">
681
+
682
+ <p>Fetches data from the specified API endpoint.</p>
683
+
684
+
685
+ </div>
686
+ </div>
687
+ <div class="tags">
688
+ <p class="tag_title">Parameters:</p>
689
+ <ul class="param">
690
+
691
+ <li>
692
+
693
+ <span class='name'>endpoint_key</span>
694
+
695
+
696
+ <span class='type'>(<tt>String</tt>)</span>
697
+
698
+
699
+
700
+ &mdash;
701
+ <div class='inline'>
702
+ <p>The key of the API endpoint to fetch data from.</p>
703
+ </div>
704
+
705
+ </li>
706
+
707
+ <li>
708
+
709
+ <span class='name'>force_refresh</span>
710
+
711
+
712
+ <span class='type'>(<tt>Boolean</tt>)</span>
713
+
714
+
715
+ <em class="default">(defaults to: <tt>false</tt>)</em>
716
+
717
+
718
+ &mdash;
719
+ <div class='inline'>
720
+ <p>Whether to force refresh the data, bypassing the cache.</p>
721
+ </div>
722
+
723
+ </li>
724
+
725
+ </ul>
726
+
727
+ <p class="tag_title">Returns:</p>
728
+ <ul class="return">
729
+
730
+ <li>
731
+
732
+
733
+ <span class='type'>(<tt>Faraday::Response</tt>)</span>
734
+
735
+
736
+
737
+ &mdash;
738
+ <div class='inline'>
739
+ <p>The response object containing the fetched data.</p>
740
+ </div>
741
+
742
+ </li>
743
+
744
+ </ul>
745
+ <p class="tag_title">Raises:</p>
746
+ <ul class="raise">
747
+
748
+ <li>
749
+
750
+
751
+ <span class='type'>(<tt>ArgumentError</tt>)</span>
752
+
753
+
754
+
755
+ &mdash;
756
+ <div class='inline'>
757
+ <p>If the provided endpoint key is invalid.</p>
758
+ </div>
759
+
760
+ </li>
761
+
762
+ </ul>
763
+
764
+ </div><table class="source_code">
765
+ <tr>
766
+ <td>
767
+ <pre class="lines">
768
+
769
+
770
+ 52
771
+ 53
772
+ 54
773
+ 55
774
+ 56
775
+ 57
776
+ 58
777
+ 59</pre>
778
+ </td>
779
+ <td>
780
+ <pre class="code"><span class="info file"># File 'lib/api_wrapper/api_manager.rb', line 52</span>
781
+
782
+ <span class='kw'>def</span> <span class='id identifier rubyid_fetch_data'>fetch_data</span><span class='lparen'>(</span><span class='id identifier rubyid_endpoint_key'>endpoint_key</span><span class='comma'>,</span> <span class='label'>force_refresh:</span> <span class='kw'>false</span><span class='rparen'>)</span>
783
+ <span class='id identifier rubyid_endpoint'>endpoint</span> <span class='op'>=</span> <span class='ivar'>@endpoints</span><span class='lbracket'>[</span><span class='id identifier rubyid_endpoint_key'>endpoint_key</span><span class='rbracket'>]</span>
784
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Invalid endpoint key: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_endpoint_key'>endpoint_key</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>unless</span> <span class='id identifier rubyid_endpoint'>endpoint</span>
785
+
786
+ <span class='ivar'>@cache_policy</span><span class='period'>.</span><span class='id identifier rubyid_fetch'>fetch</span><span class='lparen'>(</span><span class='id identifier rubyid_endpoint'>endpoint</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>path</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='label'>force_refresh:</span><span class='rparen'>)</span> <span class='kw'>do</span>
787
+ <span class='ivar'>@client</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span><span class='lparen'>(</span><span class='id identifier rubyid_endpoint'>endpoint</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>path</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='rparen'>)</span>
788
+ <span class='kw'>end</span>
789
+ <span class='kw'>end</span></pre>
790
+ </td>
791
+ </tr>
792
+ </table>
793
+ </div>
794
+
795
+ </div>
796
+
797
+ </div>
798
+
799
+ <div id="footer">
800
+ Generated on Mon Sep 16 23:22:30 2024 by
801
+ <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
802
+ 0.9.37 (ruby-3.2.2).
803
+ </div>
804
+
805
+ </div>
806
+ </body>
807
+ </html>