clx_api 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +13 -0
  3. data/.yardopts +1 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +55 -0
  7. data/Rakefile +7 -0
  8. data/clx_api.gemspec +26 -0
  9. data/doc/CLX.html +305 -0
  10. data/doc/CLX/API.html +1491 -0
  11. data/doc/CLX/CLXAPIException.html +411 -0
  12. data/doc/CLX/CLXException.html +134 -0
  13. data/doc/CLX/HTTPAdapter.html +1294 -0
  14. data/doc/CLX/HTTPClient.html +1058 -0
  15. data/doc/ClxApi.html +141 -0
  16. data/doc/_index.html +161 -0
  17. data/doc/class_list.html +58 -0
  18. data/doc/css/common.css +1 -0
  19. data/doc/css/full_list.css +57 -0
  20. data/doc/css/style.css +339 -0
  21. data/doc/file.README.html +112 -0
  22. data/doc/file_list.html +60 -0
  23. data/doc/frames.html +26 -0
  24. data/doc/index.html +112 -0
  25. data/doc/js/app.js +219 -0
  26. data/doc/js/full_list.js +181 -0
  27. data/doc/js/jquery.js +4 -0
  28. data/doc/method_list.html +279 -0
  29. data/doc/top-level-namespace.html +112 -0
  30. data/examples/get_gateway_by_id.rb +16 -0
  31. data/examples/get_gateways.rb +18 -0
  32. data/examples/get_operator_by_id.rb +21 -0
  33. data/examples/get_operators.rb +23 -0
  34. data/examples/get_price_entries_by_gateway_id.rb +19 -0
  35. data/examples/get_price_entries_by_gateway_id_and_operator_id.rb +17 -0
  36. data/examples/get_price_entries_by_gateway_id_and_operator_id_and_date.rb +18 -0
  37. data/examples/readme.md +167 -0
  38. data/lib/clx_api.rb +35 -0
  39. data/lib/clx_api/api.rb +132 -0
  40. data/lib/clx_api/exceptions/clx_api_exception.rb +25 -0
  41. data/lib/clx_api/exceptions/clx_exception.rb +8 -0
  42. data/lib/clx_api/http_adapter.rb +129 -0
  43. data/lib/clx_api/http_client.rb +163 -0
  44. data/lib/clx_api/version.rb +4 -0
  45. data/test/adapter/test_adapter.rb +67 -0
  46. data/test/api_test.rb +306 -0
  47. data/test/http_adapter_test.rb +211 -0
  48. data/test/http_client_test.rb +173 -0
  49. data/test/test_helper.rb +7 -0
  50. metadata +168 -0
@@ -0,0 +1,1058 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
+ <title>
7
+ Class: CLX::HTTPClient
8
+
9
+ &mdash; Documentation by YARD 0.8.7.6
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ hasFrames = window.top.frames.main ? true : false;
19
+ relpath = '../';
20
+ framesUrl = "../frames.html#!CLX/HTTPClient.html";
21
+ </script>
22
+
23
+
24
+ <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
25
+
26
+ <script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
27
+
28
+
29
+ </head>
30
+ <body>
31
+ <div id="header">
32
+ <div id="menu">
33
+
34
+ <a href="../_index.html">Index (H)</a> &raquo;
35
+ <span class='title'><span class='object_link'><a href="../CLX.html" title="CLX (module)">CLX</a></span></span>
36
+ &raquo;
37
+ <span class="title">HTTPClient</span>
38
+
39
+
40
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
41
+ </div>
42
+
43
+ <div id="search">
44
+
45
+ <a class="full_list_link" id="class_list_link"
46
+ href="../class_list.html">
47
+ Class List
48
+ </a>
49
+
50
+ <a class="full_list_link" id="method_list_link"
51
+ href="../method_list.html">
52
+ Method List
53
+ </a>
54
+
55
+ <a class="full_list_link" id="file_list_link"
56
+ href="../file_list.html">
57
+ File List
58
+ </a>
59
+
60
+ </div>
61
+ <div class="clear"></div>
62
+ </div>
63
+
64
+ <iframe id="search_frame"></iframe>
65
+
66
+ <div id="content"><h1>Class: CLX::HTTPClient
67
+
68
+
69
+
70
+ </h1>
71
+
72
+ <dl class="box">
73
+
74
+ <dt class="r1">Inherits:</dt>
75
+ <dd class="r1">
76
+ <span class="inheritName">Object</span>
77
+
78
+ <ul class="fullTree">
79
+ <li>Object</li>
80
+
81
+ <li class="next">CLX::HTTPClient</li>
82
+
83
+ </ul>
84
+ <a href="#" class="inheritanceTree">show all</a>
85
+
86
+ </dd>
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+ <dt class="r2 last">Defined in:</dt>
97
+ <dd class="r2 last">lib/clx_api/http_client.rb</dd>
98
+
99
+ </dl>
100
+ <div class="clear"></div>
101
+
102
+ <h2>Overview</h2><div class="docstring">
103
+ <div class="discussion">
104
+
105
+ <p>HTTP Client class for making RESTful HTTP-requests</p>
106
+
107
+
108
+ </div>
109
+ </div>
110
+ <div class="tags">
111
+
112
+
113
+ </div>
114
+
115
+
116
+
117
+ <h2>Instance Attribute Summary <small>(<a href="#" class="summary_toggle">collapse</a>)</small></h2>
118
+ <ul class="summary">
119
+
120
+ <li class="public ">
121
+ <span class="summary_signature">
122
+
123
+ <a href="#base_url-instance_method" title="#base_url (instance method)">- (Object) <strong>base_url</strong> </a>
124
+
125
+
126
+
127
+ </span>
128
+
129
+
130
+
131
+
132
+
133
+
134
+
135
+
136
+
137
+
138
+
139
+
140
+ <span class="summary_desc"><div class='inline'>
141
+ <p>Gives access to base_url so this can be modified.</p>
142
+ </div></span>
143
+
144
+ </li>
145
+
146
+
147
+ <li class="public ">
148
+ <span class="summary_signature">
149
+
150
+ <a href="#http_adapter-instance_method" title="#http_adapter (instance method)">- (Object) <strong>http_adapter</strong> </a>
151
+
152
+
153
+
154
+ </span>
155
+
156
+
157
+
158
+
159
+
160
+
161
+
162
+
163
+
164
+
165
+
166
+
167
+ <span class="summary_desc"><div class='inline'>
168
+ <p>Gives access to the adapter so Auth credentials can be monipulated.</p>
169
+ </div></span>
170
+
171
+ </li>
172
+
173
+
174
+ </ul>
175
+
176
+
177
+
178
+
179
+
180
+ <h2>
181
+ Instance Method Summary
182
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
183
+ </h2>
184
+
185
+ <ul class="summary">
186
+
187
+ <li class="public ">
188
+ <span class="summary_signature">
189
+
190
+ <a href="#delete-instance_method" title="#delete (instance method)">- (Object) <strong>delete</strong>(url) </a>
191
+
192
+
193
+
194
+ </span>
195
+
196
+
197
+
198
+
199
+
200
+
201
+
202
+
203
+
204
+ <span class="summary_desc"><div class='inline'>
205
+ <p>Make a DELETE-request to specified API-path (Not implemented).</p>
206
+ </div></span>
207
+
208
+ </li>
209
+
210
+
211
+ <li class="public ">
212
+ <span class="summary_signature">
213
+
214
+ <a href="#get-instance_method" title="#get (instance method)">- (hash) <strong>get</strong>(url) </a>
215
+
216
+
217
+
218
+ </span>
219
+
220
+
221
+
222
+
223
+
224
+
225
+
226
+
227
+
228
+ <span class="summary_desc"><div class='inline'>
229
+ <p>Make a GET-request to specified API-path.</p>
230
+ </div></span>
231
+
232
+ </li>
233
+
234
+
235
+ <li class="private ">
236
+ <span class="summary_signature">
237
+
238
+ <a href="#get_full_url-instance_method" title="#get_full_url (instance method)">- (Mixed) <strong>get_full_url</strong>(url) </a>
239
+
240
+
241
+
242
+ </span>
243
+
244
+
245
+
246
+ <span class="note title private">private</span>
247
+
248
+
249
+
250
+
251
+
252
+ <span class="summary_desc"><div class='inline'>
253
+ <p>Build the full API request URL.</p>
254
+ </div></span>
255
+
256
+ </li>
257
+
258
+
259
+ <li class="public ">
260
+ <span class="summary_signature">
261
+
262
+ <a href="#initialize-instance_method" title="#initialize (instance method)">- (HTTPClient) <strong>initialize</strong>(base_url, http_adapter) </a>
263
+
264
+
265
+
266
+ </span>
267
+
268
+
269
+ <span class="note title constructor">constructor</span>
270
+
271
+
272
+
273
+
274
+
275
+
276
+
277
+
278
+ <span class="summary_desc"><div class='inline'>
279
+ <p>Initializer.</p>
280
+ </div></span>
281
+
282
+ </li>
283
+
284
+
285
+ <li class="private ">
286
+ <span class="summary_signature">
287
+
288
+ <a href="#parseResponse-instance_method" title="#parseResponse (instance method)">- (JSON) <strong>parseResponse</strong>(response) </a>
289
+
290
+
291
+
292
+ </span>
293
+
294
+
295
+
296
+ <span class="note title private">private</span>
297
+
298
+
299
+
300
+
301
+
302
+ <span class="summary_desc"><div class='inline'>
303
+ <p>Parse response from a request and return body content as JSON.</p>
304
+ </div></span>
305
+
306
+ </li>
307
+
308
+
309
+ <li class="public ">
310
+ <span class="summary_signature">
311
+
312
+ <a href="#post-instance_method" title="#post (instance method)">- (Object) <strong>post</strong>(url, data = nil) </a>
313
+
314
+
315
+
316
+ </span>
317
+
318
+
319
+
320
+
321
+
322
+
323
+
324
+
325
+
326
+ <span class="summary_desc"><div class='inline'>
327
+ <p>Make a POST-request to specified API-path (Not implemented).</p>
328
+ </div></span>
329
+
330
+ </li>
331
+
332
+
333
+ <li class="public ">
334
+ <span class="summary_signature">
335
+
336
+ <a href="#put-instance_method" title="#put (instance method)">- (Object) <strong>put</strong>(url, data = nil) </a>
337
+
338
+
339
+
340
+ </span>
341
+
342
+
343
+
344
+
345
+
346
+
347
+
348
+
349
+
350
+ <span class="summary_desc"><div class='inline'>
351
+ <p>Make a PUT-request to specified API-path (Not implemented).</p>
352
+ </div></span>
353
+
354
+ </li>
355
+
356
+
357
+ </ul>
358
+
359
+
360
+ <div id="constructor_details" class="method_details_list">
361
+ <h2>Constructor Details</h2>
362
+
363
+ <div class="method_details first">
364
+ <h3 class="signature first" id="initialize-instance_method">
365
+
366
+ - (<tt><span class='object_link'><a href="" title="CLX::HTTPClient (class)">HTTPClient</a></span></tt>) <strong>initialize</strong>(base_url, http_adapter)
367
+
368
+
369
+
370
+
371
+
372
+ </h3><div class="docstring">
373
+ <div class="discussion">
374
+
375
+ <p>Initializer</p>
376
+
377
+
378
+ </div>
379
+ </div>
380
+ <div class="tags">
381
+ <p class="tag_title">Parameters:</p>
382
+ <ul class="param">
383
+
384
+ <li>
385
+
386
+ <span class='name'>base_url</span>
387
+
388
+
389
+ <span class='type'>(<tt>String</tt>)</span>
390
+
391
+
392
+
393
+ </li>
394
+
395
+ <li>
396
+
397
+ <span class='name'>http_adapter</span>
398
+
399
+
400
+ <span class='type'>(<tt><span class='object_link'><a href="HTTPAdapter.html" title="CLX::HTTPAdapter (class)">HTTPAdapter</a></span></tt>)</span>
401
+
402
+
403
+
404
+ </li>
405
+
406
+ </ul>
407
+
408
+
409
+ </div><table class="source_code">
410
+ <tr>
411
+ <td>
412
+ <pre class="lines">
413
+
414
+
415
+ 17
416
+ 18
417
+ 19
418
+ 20</pre>
419
+ </td>
420
+ <td>
421
+ <pre class="code"><span class="info file"># File 'lib/clx_api/http_client.rb', line 17</span>
422
+
423
+ <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_base_url'>base_url</span><span class='comma'>,</span> <span class='id identifier rubyid_http_adapter'>http_adapter</span><span class='rparen'>)</span>
424
+ <span class='ivar'>@base_url</span> <span class='op'>=</span> <span class='id identifier rubyid_base_url'>base_url</span>
425
+ <span class='ivar'>@http_adapter</span> <span class='op'>=</span> <span class='id identifier rubyid_http_adapter'>http_adapter</span>
426
+ <span class='kw'>end</span></pre>
427
+ </td>
428
+ </tr>
429
+ </table>
430
+ </div>
431
+
432
+ </div>
433
+
434
+ <div id="instance_attr_details" class="attr_details">
435
+ <h2>Instance Attribute Details</h2>
436
+
437
+
438
+ <span id="base_url=-instance_method"></span>
439
+ <div class="method_details first">
440
+ <h3 class="signature first" id="base_url-instance_method">
441
+
442
+ - (<tt>Object</tt>) <strong>base_url</strong>
443
+
444
+
445
+
446
+
447
+
448
+ </h3><div class="docstring">
449
+ <div class="discussion">
450
+
451
+ <p>Gives access to base_url so this can be modified</p>
452
+
453
+
454
+ </div>
455
+ </div>
456
+ <div class="tags">
457
+
458
+
459
+ </div><table class="source_code">
460
+ <tr>
461
+ <td>
462
+ <pre class="lines">
463
+
464
+
465
+ 8
466
+ 9
467
+ 10</pre>
468
+ </td>
469
+ <td>
470
+ <pre class="code"><span class="info file"># File 'lib/clx_api/http_client.rb', line 8</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="http_adapter=-instance_method"></span>
482
+ <div class="method_details ">
483
+ <h3 class="signature " id="http_adapter-instance_method">
484
+
485
+ - (<tt>Object</tt>) <strong>http_adapter</strong>
486
+
487
+
488
+
489
+
490
+
491
+ </h3><div class="docstring">
492
+ <div class="discussion">
493
+
494
+ <p>Gives access to the adapter so Auth credentials can be monipulated</p>
495
+
496
+
497
+ </div>
498
+ </div>
499
+ <div class="tags">
500
+
501
+
502
+ </div><table class="source_code">
503
+ <tr>
504
+ <td>
505
+ <pre class="lines">
506
+
507
+
508
+ 12
509
+ 13
510
+ 14</pre>
511
+ </td>
512
+ <td>
513
+ <pre class="code"><span class="info file"># File 'lib/clx_api/http_client.rb', line 12</span>
514
+
515
+ <span class='kw'>def</span> <span class='id identifier rubyid_http_adapter'>http_adapter</span>
516
+ <span class='ivar'>@http_adapter</span>
517
+ <span class='kw'>end</span></pre>
518
+ </td>
519
+ </tr>
520
+ </table>
521
+ </div>
522
+
523
+ </div>
524
+
525
+
526
+ <div id="instance_method_details" class="method_details_list">
527
+ <h2>Instance Method Details</h2>
528
+
529
+
530
+ <div class="method_details first">
531
+ <h3 class="signature first" id="delete-instance_method">
532
+
533
+ - (<tt>Object</tt>) <strong>delete</strong>(url)
534
+
535
+
536
+
537
+
538
+
539
+ </h3><div class="docstring">
540
+ <div class="discussion">
541
+
542
+ <p>Make a DELETE-request to specified API-path</p>
543
+
544
+ <pre class="code ruby"><code class="ruby"><span class='lparen'>(</span><span class='const'>Not</span> <span class='id identifier rubyid_implemented'>implemented</span><span class='rparen'>)</span></code></pre>
545
+
546
+
547
+ </div>
548
+ </div>
549
+ <div class="tags">
550
+ <p class="tag_title">Parameters:</p>
551
+ <ul class="param">
552
+
553
+ <li>
554
+
555
+ <span class='name'>url</span>
556
+
557
+
558
+ <span class='type'>(<tt>String</tt>)</span>
559
+
560
+
561
+
562
+ &mdash;
563
+ <div class='inline'>
564
+ <p>API-path</p>
565
+ </div>
566
+
567
+ </li>
568
+
569
+ </ul>
570
+
571
+
572
+ </div><table class="source_code">
573
+ <tr>
574
+ <td>
575
+ <pre class="lines">
576
+
577
+
578
+ 60
579
+ 61
580
+ 62
581
+ 63
582
+ 64</pre>
583
+ </td>
584
+ <td>
585
+ <pre class="code"><span class="info file"># File 'lib/clx_api/http_client.rb', line 60</span>
586
+
587
+ <span class='kw'>def</span> <span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_url'>url</span><span class='rparen'>)</span>
588
+ <span class='id identifier rubyid_uri'>uri</span> <span class='op'>=</span> <span class='id identifier rubyid_get_full_url'>get_full_url</span><span class='lparen'>(</span><span class='id identifier rubyid_url'>url</span><span class='rparen'>)</span>
589
+ <span class='id identifier rubyid_response'>response</span> <span class='op'>=</span> <span class='ivar'>@http_adapter</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_uri'>uri</span><span class='rparen'>)</span>
590
+ <span class='kw'>return</span> <span class='id identifier rubyid_parseResponse'>parseResponse</span><span class='lparen'>(</span><span class='id identifier rubyid_response'>response</span><span class='rparen'>)</span>
591
+ <span class='kw'>end</span></pre>
592
+ </td>
593
+ </tr>
594
+ </table>
595
+ </div>
596
+
597
+ <div class="method_details ">
598
+ <h3 class="signature " id="get-instance_method">
599
+
600
+ - (<tt>hash</tt>) <strong>get</strong>(url)
601
+
602
+
603
+
604
+
605
+
606
+ </h3><div class="docstring">
607
+ <div class="discussion">
608
+
609
+ <p>Make a GET-request to specified API-path</p>
610
+
611
+
612
+ </div>
613
+ </div>
614
+ <div class="tags">
615
+ <p class="tag_title">Parameters:</p>
616
+ <ul class="param">
617
+
618
+ <li>
619
+
620
+ <span class='name'>url</span>
621
+
622
+
623
+ <span class='type'>(<tt>String</tt>)</span>
624
+
625
+
626
+
627
+ &mdash;
628
+ <div class='inline'>
629
+ <p>API-path</p>
630
+ </div>
631
+
632
+ </li>
633
+
634
+ </ul>
635
+
636
+ <p class="tag_title">Returns:</p>
637
+ <ul class="return">
638
+
639
+ <li>
640
+
641
+
642
+ <span class='type'>(<tt>hash</tt>)</span>
643
+
644
+
645
+
646
+ &mdash;
647
+ <div class='inline'>
648
+ <p>result</p>
649
+ </div>
650
+
651
+ </li>
652
+
653
+ </ul>
654
+
655
+ </div><table class="source_code">
656
+ <tr>
657
+ <td>
658
+ <pre class="lines">
659
+
660
+
661
+ 26
662
+ 27
663
+ 28
664
+ 29
665
+ 30</pre>
666
+ </td>
667
+ <td>
668
+ <pre class="code"><span class="info file"># File 'lib/clx_api/http_client.rb', line 26</span>
669
+
670
+ <span class='kw'>def</span> <span class='id identifier rubyid_get'>get</span><span class='lparen'>(</span><span class='id identifier rubyid_url'>url</span><span class='rparen'>)</span>
671
+ <span class='id identifier rubyid_uri'>uri</span> <span class='op'>=</span> <span class='id identifier rubyid_get_full_url'>get_full_url</span><span class='lparen'>(</span><span class='id identifier rubyid_url'>url</span><span class='rparen'>)</span>
672
+ <span class='id identifier rubyid_response'>response</span> <span class='op'>=</span> <span class='ivar'>@http_adapter</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span><span class='lparen'>(</span><span class='id identifier rubyid_uri'>uri</span><span class='rparen'>)</span>
673
+ <span class='kw'>return</span> <span class='id identifier rubyid_parseResponse'>parseResponse</span><span class='lparen'>(</span><span class='id identifier rubyid_response'>response</span><span class='rparen'>)</span>
674
+ <span class='kw'>end</span></pre>
675
+ </td>
676
+ </tr>
677
+ </table>
678
+ </div>
679
+
680
+ <div class="method_details ">
681
+ <h3 class="signature " id="get_full_url-instance_method">
682
+
683
+ - (<tt>Mixed</tt>) <strong>get_full_url</strong>(url) <span class="extras">(private)</span>
684
+
685
+
686
+
687
+
688
+
689
+ </h3><div class="docstring">
690
+ <div class="discussion">
691
+
692
+ <p>Build the full API request URL</p>
693
+
694
+
695
+ </div>
696
+ </div>
697
+ <div class="tags">
698
+
699
+ <div class="examples">
700
+ <p class="tag_title">Examples:</p>
701
+
702
+
703
+ <pre class="example code"><code><span class='id identifier rubyid_uri'>uri</span> <span class='op'>=</span> <span class='id identifier rubyid_get_full_url'>get_full_url</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>/gateway/1/operator/</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span></code></pre>
704
+
705
+ </div>
706
+ <p class="tag_title">Parameters:</p>
707
+ <ul class="param">
708
+
709
+ <li>
710
+
711
+ <span class='name'>url</span>
712
+
713
+
714
+ <span class='type'>(<tt>string</tt>)</span>
715
+
716
+
717
+
718
+ &mdash;
719
+ <div class='inline'>
720
+ <p>API-path</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>Mixed</tt>)</span>
734
+
735
+
736
+
737
+ &mdash;
738
+ <div class='inline'>
739
+ <p>uri URI::HTTP or URI::HTTPS</p>
740
+ </div>
741
+
742
+ </li>
743
+
744
+ </ul>
745
+
746
+ </div><table class="source_code">
747
+ <tr>
748
+ <td>
749
+ <pre class="lines">
750
+
751
+
752
+ 75
753
+ 76
754
+ 77
755
+ 78</pre>
756
+ </td>
757
+ <td>
758
+ <pre class="code"><span class="info file"># File 'lib/clx_api/http_client.rb', line 75</span>
759
+
760
+ <span class='kw'>def</span> <span class='id identifier rubyid_get_full_url'>get_full_url</span><span class='lparen'>(</span><span class='id identifier rubyid_url'>url</span><span class='rparen'>)</span>
761
+ <span class='id identifier rubyid_full_url'>full_url</span> <span class='op'>=</span> <span class='ivar'>@base_url</span> <span class='op'>+</span> <span class='id identifier rubyid_url'>url</span>
762
+ <span class='kw'>return</span> <span class='const'>URI</span><span class='lparen'>(</span><span class='const'>URI</span><span class='period'>.</span><span class='id identifier rubyid_encode'>encode</span><span class='lparen'>(</span><span class='id identifier rubyid_full_url'>full_url</span><span class='rparen'>)</span><span class='rparen'>)</span>
763
+ <span class='kw'>end</span></pre>
764
+ </td>
765
+ </tr>
766
+ </table>
767
+ </div>
768
+
769
+ <div class="method_details ">
770
+ <h3 class="signature " id="parseResponse-instance_method">
771
+
772
+ - (<tt>JSON</tt>) <strong>parseResponse</strong>(response) <span class="extras">(private)</span>
773
+
774
+
775
+
776
+
777
+
778
+ </h3><div class="docstring">
779
+ <div class="discussion">
780
+
781
+ <p>Parse response from a request and return body content as JSON</p>
782
+
783
+
784
+ </div>
785
+ </div>
786
+ <div class="tags">
787
+ <p class="tag_title">Parameters:</p>
788
+ <ul class="param">
789
+
790
+ <li>
791
+
792
+ <span class='name'>response</span>
793
+
794
+
795
+ <span class='type'>(<tt>NET::HTTP::response</tt>)</span>
796
+
797
+
798
+
799
+ </li>
800
+
801
+ </ul>
802
+
803
+ <p class="tag_title">Returns:</p>
804
+ <ul class="return">
805
+
806
+ <li>
807
+
808
+
809
+ <span class='type'>(<tt>JSON</tt>)</span>
810
+
811
+
812
+
813
+ &mdash;
814
+ <div class='inline'>
815
+ <p>json</p>
816
+ </div>
817
+
818
+ </li>
819
+
820
+ </ul>
821
+
822
+ </div><table class="source_code">
823
+ <tr>
824
+ <td>
825
+ <pre class="lines">
826
+
827
+
828
+ 83
829
+ 84
830
+ 85
831
+ 86
832
+ 87
833
+ 88
834
+ 89
835
+ 90
836
+ 91
837
+ 92
838
+ 93
839
+ 94
840
+ 95
841
+ 96
842
+ 97
843
+ 98
844
+ 99
845
+ 100
846
+ 101
847
+ 102</pre>
848
+ </td>
849
+ <td>
850
+ <pre class="code"><span class="info file"># File 'lib/clx_api/http_client.rb', line 83</span>
851
+
852
+ <span class='kw'>def</span> <span class='id identifier rubyid_parseResponse'>parseResponse</span><span class='lparen'>(</span><span class='id identifier rubyid_response'>response</span><span class='rparen'>)</span>
853
+
854
+ <span class='kw'>begin</span>
855
+ <span class='id identifier rubyid_result'>result</span> <span class='op'>=</span> <span class='const'>JSON</span><span class='period'>.</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='id identifier rubyid_response'>response</span><span class='period'>.</span><span class='id identifier rubyid_body'>body</span><span class='comma'>,</span> <span class='label'>object_class:</span> <span class='const'>OpenStruct</span><span class='rparen'>)</span>
856
+ <span class='kw'>rescue</span>
857
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'>CLXException</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Unable to parse JSON response</span><span class='tstring_end'>&#39;</span></span>
858
+ <span class='kw'>end</span>
859
+
860
+ <span class='kw'>if</span><span class='lparen'>(</span><span class='id identifier rubyid_response'>response</span><span class='period'>.</span><span class='id identifier rubyid_code'>code</span> <span class='op'>&gt;</span> <span class='int'>399</span><span class='rparen'>)</span>
861
+ <span class='id identifier rubyid_error_message'>error_message</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='id identifier rubyid_result'>result</span><span class='period'>.</span><span class='id identifier rubyid_error'>error</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_result'>result</span><span class='period'>.</span><span class='id identifier rubyid_error'>error</span><span class='period'>.</span><span class='id identifier rubyid_message'>message</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_result'>result</span><span class='period'>.</span><span class='id identifier rubyid_error'>error</span><span class='period'>.</span><span class='id identifier rubyid_message'>message</span> <span class='op'>:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>No error message available</span><span class='tstring_end'>&#39;</span></span>
862
+ <span class='id identifier rubyid_code'>code</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='id identifier rubyid_result'>result</span><span class='period'>.</span><span class='id identifier rubyid_error'>error</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_result'>result</span><span class='period'>.</span><span class='id identifier rubyid_error'>error</span><span class='period'>.</span><span class='id identifier rubyid_code'>code</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_result'>result</span><span class='period'>.</span><span class='id identifier rubyid_error'>error</span><span class='period'>.</span><span class='id identifier rubyid_code'>code</span> <span class='op'>:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>No error code available</span><span class='tstring_end'>&#39;</span></span>
863
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'>CLXAPIException</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_error_message'>error_message</span><span class='comma'>,</span> <span class='id identifier rubyid_code'>code</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>400: Bad request</span><span class='tstring_end'>&#39;</span></span> <span class='kw'>if</span> <span class='id identifier rubyid_response'>response</span><span class='period'>.</span><span class='id identifier rubyid_code'>code</span> <span class='op'>==</span> <span class='int'>400</span>
864
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'>CLXAPIException</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_error_message'>error_message</span><span class='comma'>,</span> <span class='id identifier rubyid_code'>code</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>401: Unauthorized</span><span class='tstring_end'>&#39;</span></span> <span class='kw'>if</span> <span class='id identifier rubyid_response'>response</span><span class='period'>.</span><span class='id identifier rubyid_code'>code</span> <span class='op'>==</span> <span class='int'>401</span>
865
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'>CLXAPIException</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_error_message'>error_message</span><span class='comma'>,</span> <span class='id identifier rubyid_code'>code</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>403: Forbidden</span><span class='tstring_end'>&#39;</span></span> <span class='kw'>if</span> <span class='id identifier rubyid_response'>response</span><span class='period'>.</span><span class='id identifier rubyid_code'>code</span> <span class='op'>==</span> <span class='int'>403</span>
866
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'>CLXAPIException</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_error_message'>error_message</span><span class='comma'>,</span> <span class='id identifier rubyid_code'>code</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>404: Not Found</span><span class='tstring_end'>&#39;</span></span> <span class='kw'>if</span> <span class='id identifier rubyid_response'>response</span><span class='period'>.</span><span class='id identifier rubyid_code'>code</span> <span class='op'>==</span> <span class='int'>404</span>
867
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'>CLXAPIException</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_error_message'>error_message</span><span class='comma'>,</span> <span class='id identifier rubyid_code'>code</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Unknown error</span><span class='tstring_end'>&#39;</span></span>
868
+ <span class='kw'>end</span>
869
+
870
+ <span class='kw'>return</span> <span class='id identifier rubyid_result'>result</span>
871
+ <span class='kw'>end</span></pre>
872
+ </td>
873
+ </tr>
874
+ </table>
875
+ </div>
876
+
877
+ <div class="method_details ">
878
+ <h3 class="signature " id="post-instance_method">
879
+
880
+ - (<tt>Object</tt>) <strong>post</strong>(url, data = nil)
881
+
882
+
883
+
884
+
885
+
886
+ </h3><div class="docstring">
887
+ <div class="discussion">
888
+
889
+ <p>Make a POST-request to specified API-path</p>
890
+
891
+ <pre class="code ruby"><code class="ruby"><span class='lparen'>(</span><span class='const'>Not</span> <span class='id identifier rubyid_implemented'>implemented</span><span class='rparen'>)</span></code></pre>
892
+
893
+
894
+ </div>
895
+ </div>
896
+ <div class="tags">
897
+ <p class="tag_title">Parameters:</p>
898
+ <ul class="param">
899
+
900
+ <li>
901
+
902
+ <span class='name'>url</span>
903
+
904
+
905
+ <span class='type'>(<tt>String</tt>)</span>
906
+
907
+
908
+
909
+ &mdash;
910
+ <div class='inline'>
911
+ <p>API-path</p>
912
+ </div>
913
+
914
+ </li>
915
+
916
+ <li>
917
+
918
+ <span class='name'>data</span>
919
+
920
+
921
+ <span class='type'>(<tt>Hash</tt>)</span>
922
+
923
+
924
+ <em class="default">(defaults to: <tt>nil</tt>)</em>
925
+
926
+
927
+ &mdash;
928
+ <div class='inline'>
929
+ <p>POST data</p>
930
+ </div>
931
+
932
+ </li>
933
+
934
+ </ul>
935
+
936
+
937
+ </div><table class="source_code">
938
+ <tr>
939
+ <td>
940
+ <pre class="lines">
941
+
942
+
943
+ 38
944
+ 39
945
+ 40
946
+ 41
947
+ 42</pre>
948
+ </td>
949
+ <td>
950
+ <pre class="code"><span class="info file"># File 'lib/clx_api/http_client.rb', line 38</span>
951
+
952
+ <span class='kw'>def</span> <span class='id identifier rubyid_post'>post</span><span class='lparen'>(</span><span class='id identifier rubyid_url'>url</span><span class='comma'>,</span> <span class='id identifier rubyid_data'>data</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
953
+ <span class='id identifier rubyid_uri'>uri</span> <span class='op'>=</span> <span class='id identifier rubyid_get_full_url'>get_full_url</span><span class='lparen'>(</span><span class='id identifier rubyid_url'>url</span><span class='rparen'>)</span>
954
+ <span class='id identifier rubyid_response'>response</span> <span class='op'>=</span> <span class='ivar'>@http_adapter</span><span class='period'>.</span><span class='id identifier rubyid_post'>post</span><span class='lparen'>(</span><span class='id identifier rubyid_uri'>uri</span><span class='comma'>,</span> <span class='id identifier rubyid_data'>data</span><span class='rparen'>)</span>
955
+ <span class='kw'>return</span> <span class='id identifier rubyid_parseResponse'>parseResponse</span><span class='lparen'>(</span><span class='id identifier rubyid_response'>response</span><span class='rparen'>)</span>
956
+ <span class='kw'>end</span></pre>
957
+ </td>
958
+ </tr>
959
+ </table>
960
+ </div>
961
+
962
+ <div class="method_details ">
963
+ <h3 class="signature " id="put-instance_method">
964
+
965
+ - (<tt>Object</tt>) <strong>put</strong>(url, data = nil)
966
+
967
+
968
+
969
+
970
+
971
+ </h3><div class="docstring">
972
+ <div class="discussion">
973
+
974
+ <p>Make a PUT-request to specified API-path</p>
975
+
976
+ <pre class="code ruby"><code class="ruby"><span class='lparen'>(</span><span class='const'>Not</span> <span class='id identifier rubyid_implemented'>implemented</span><span class='rparen'>)</span></code></pre>
977
+
978
+
979
+ </div>
980
+ </div>
981
+ <div class="tags">
982
+ <p class="tag_title">Parameters:</p>
983
+ <ul class="param">
984
+
985
+ <li>
986
+
987
+ <span class='name'>url</span>
988
+
989
+
990
+ <span class='type'>(<tt>String</tt>)</span>
991
+
992
+
993
+
994
+ &mdash;
995
+ <div class='inline'>
996
+ <p>API-path</p>
997
+ </div>
998
+
999
+ </li>
1000
+
1001
+ <li>
1002
+
1003
+ <span class='name'>data</span>
1004
+
1005
+
1006
+ <span class='type'>(<tt>Hash</tt>)</span>
1007
+
1008
+
1009
+ <em class="default">(defaults to: <tt>nil</tt>)</em>
1010
+
1011
+
1012
+ &mdash;
1013
+ <div class='inline'>
1014
+ <p>PUT-data</p>
1015
+ </div>
1016
+
1017
+ </li>
1018
+
1019
+ </ul>
1020
+
1021
+
1022
+ </div><table class="source_code">
1023
+ <tr>
1024
+ <td>
1025
+ <pre class="lines">
1026
+
1027
+
1028
+ 50
1029
+ 51
1030
+ 52
1031
+ 53
1032
+ 54</pre>
1033
+ </td>
1034
+ <td>
1035
+ <pre class="code"><span class="info file"># File 'lib/clx_api/http_client.rb', line 50</span>
1036
+
1037
+ <span class='kw'>def</span> <span class='id identifier rubyid_put'>put</span><span class='lparen'>(</span><span class='id identifier rubyid_url'>url</span><span class='comma'>,</span> <span class='id identifier rubyid_data'>data</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
1038
+ <span class='id identifier rubyid_uri'>uri</span> <span class='op'>=</span> <span class='id identifier rubyid_get_full_url'>get_full_url</span><span class='lparen'>(</span><span class='id identifier rubyid_url'>url</span><span class='rparen'>)</span>
1039
+ <span class='id identifier rubyid_response'>response</span> <span class='op'>=</span> <span class='ivar'>@http_adapter</span><span class='period'>.</span><span class='id identifier rubyid_put'>put</span><span class='lparen'>(</span><span class='id identifier rubyid_uri'>uri</span><span class='comma'>,</span> <span class='id identifier rubyid_data'>data</span><span class='rparen'>)</span>
1040
+ <span class='kw'>return</span> <span class='id identifier rubyid_parseResponse'>parseResponse</span><span class='lparen'>(</span><span class='id identifier rubyid_response'>response</span><span class='rparen'>)</span>
1041
+ <span class='kw'>end</span></pre>
1042
+ </td>
1043
+ </tr>
1044
+ </table>
1045
+ </div>
1046
+
1047
+ </div>
1048
+
1049
+ </div>
1050
+
1051
+ <div id="footer">
1052
+ Generated on Mon May 25 12:34:50 2015 by
1053
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1054
+ 0.8.7.6 (ruby-2.1.5).
1055
+ </div>
1056
+
1057
+ </body>
1058
+ </html>