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,1294 @@
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::HTTPAdapter
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/HTTPAdapter.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">HTTPAdapter</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::HTTPAdapter
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::HTTPAdapter</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_adapter.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 Adapter 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="#password-instance_method" title="#password (instance method)">- (Object) <strong>password</strong> </a>
124
+
125
+
126
+
127
+ </span>
128
+
129
+
130
+
131
+
132
+ <span class="note title readonly">readonly</span>
133
+
134
+
135
+
136
+
137
+
138
+
139
+
140
+
141
+
142
+ <span class="summary_desc"><div class='inline'>
143
+ <p>Contains the password used for Basic Auth requests.</p>
144
+ </div></span>
145
+
146
+ </li>
147
+
148
+
149
+ <li class="public ">
150
+ <span class="summary_signature">
151
+
152
+ <a href="#username-instance_method" title="#username (instance method)">- (Object) <strong>username</strong> </a>
153
+
154
+
155
+
156
+ </span>
157
+
158
+
159
+
160
+
161
+ <span class="note title readonly">readonly</span>
162
+
163
+
164
+
165
+
166
+
167
+
168
+
169
+
170
+
171
+ <span class="summary_desc"><div class='inline'>
172
+ <p>Contains the username used for Basic Auth requests.</p>
173
+ </div></span>
174
+
175
+ </li>
176
+
177
+
178
+ </ul>
179
+
180
+
181
+
182
+
183
+
184
+ <h2>
185
+ Instance Method Summary
186
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
187
+ </h2>
188
+
189
+ <ul class="summary">
190
+
191
+ <li class="private ">
192
+ <span class="summary_signature">
193
+
194
+ <a href="#create_http-instance_method" title="#create_http (instance method)">- (Net::HTTP) <strong>create_http</strong>(uri) </a>
195
+
196
+
197
+
198
+ </span>
199
+
200
+
201
+
202
+ <span class="note title private">private</span>
203
+
204
+
205
+
206
+
207
+
208
+ <span class="summary_desc"><div class='inline'>
209
+ <p>Creates a Net:HTTP instance with ssl activated with URI-object.</p>
210
+ </div></span>
211
+
212
+ </li>
213
+
214
+
215
+ <li class="private ">
216
+ <span class="summary_signature">
217
+
218
+ <a href="#create_request-instance_method" title="#create_request (instance method)">- (Mixed) <strong>create_request</strong>(method, uri, data = nil) </a>
219
+
220
+
221
+
222
+ </span>
223
+
224
+
225
+
226
+ <span class="note title private">private</span>
227
+
228
+
229
+
230
+
231
+
232
+ <span class="summary_desc"><div class='inline'>
233
+ <p>Create Request object by method and uri.</p>
234
+ </div></span>
235
+
236
+ </li>
237
+
238
+
239
+ <li class="public ">
240
+ <span class="summary_signature">
241
+
242
+ <a href="#delete-instance_method" title="#delete (instance method)">- (HTTP::Response) <strong>delete</strong>(uri) </a>
243
+
244
+
245
+
246
+ </span>
247
+
248
+
249
+
250
+
251
+
252
+
253
+
254
+
255
+
256
+ <span class="summary_desc"><div class='inline'>
257
+ <p>DELETE-request (Not implemented).</p>
258
+ </div></span>
259
+
260
+ </li>
261
+
262
+
263
+ <li class="private ">
264
+ <span class="summary_signature">
265
+
266
+ <a href="#execute-instance_method" title="#execute (instance method)">- (HTTP::Response) <strong>execute</strong>(method, uri, data = nil) </a>
267
+
268
+
269
+
270
+ </span>
271
+
272
+
273
+
274
+ <span class="note title private">private</span>
275
+
276
+
277
+
278
+
279
+
280
+ <span class="summary_desc"><div class='inline'>
281
+ <p>Execute request.</p>
282
+ </div></span>
283
+
284
+ </li>
285
+
286
+
287
+ <li class="public ">
288
+ <span class="summary_signature">
289
+
290
+ <a href="#get-instance_method" title="#get (instance method)">- (HTTP::Response) <strong>get</strong>(uri) </a>
291
+
292
+
293
+
294
+ </span>
295
+
296
+
297
+
298
+
299
+
300
+
301
+
302
+
303
+
304
+ <span class="summary_desc"><div class='inline'>
305
+ <p>GET-request.</p>
306
+ </div></span>
307
+
308
+ </li>
309
+
310
+
311
+ <li class="public ">
312
+ <span class="summary_signature">
313
+
314
+ <a href="#post-instance_method" title="#post (instance method)">- (HTTP::Response) <strong>post</strong>(uri, data) </a>
315
+
316
+
317
+
318
+ </span>
319
+
320
+
321
+
322
+
323
+
324
+
325
+
326
+
327
+
328
+ <span class="summary_desc"><div class='inline'>
329
+ <p>POST-request (Not implemented).</p>
330
+ </div></span>
331
+
332
+ </li>
333
+
334
+
335
+ <li class="public ">
336
+ <span class="summary_signature">
337
+
338
+ <a href="#put-instance_method" title="#put (instance method)">- (HTTP::Response) <strong>put</strong>(uri, data) </a>
339
+
340
+
341
+
342
+ </span>
343
+
344
+
345
+
346
+
347
+
348
+
349
+
350
+
351
+
352
+ <span class="summary_desc"><div class='inline'>
353
+ <p>PUT-request (Not implemented).</p>
354
+ </div></span>
355
+
356
+ </li>
357
+
358
+
359
+ <li class="public ">
360
+ <span class="summary_signature">
361
+
362
+ <a href="#set_auth-instance_method" title="#set_auth (instance method)">- (Object) <strong>set_auth</strong>(username, password) </a>
363
+
364
+
365
+
366
+ </span>
367
+
368
+
369
+
370
+
371
+
372
+
373
+
374
+
375
+
376
+ <span class="summary_desc"><div class='inline'>
377
+ <p>Set credentials for basic auth.</p>
378
+ </div></span>
379
+
380
+ </li>
381
+
382
+
383
+ </ul>
384
+
385
+
386
+
387
+ <div id="instance_attr_details" class="attr_details">
388
+ <h2>Instance Attribute Details</h2>
389
+
390
+
391
+ <span id=""></span>
392
+ <div class="method_details first">
393
+ <h3 class="signature first" id="password-instance_method">
394
+
395
+ - (<tt>Object</tt>) <strong>password</strong> <span class="extras">(readonly)</span>
396
+
397
+
398
+
399
+
400
+
401
+ </h3><div class="docstring">
402
+ <div class="discussion">
403
+
404
+ <p>Contains the password used for Basic Auth requests</p>
405
+
406
+
407
+ </div>
408
+ </div>
409
+ <div class="tags">
410
+
411
+
412
+ </div><table class="source_code">
413
+ <tr>
414
+ <td>
415
+ <pre class="lines">
416
+
417
+
418
+ 14
419
+ 15
420
+ 16</pre>
421
+ </td>
422
+ <td>
423
+ <pre class="code"><span class="info file"># File 'lib/clx_api/http_adapter.rb', line 14</span>
424
+
425
+ <span class='kw'>def</span> <span class='id identifier rubyid_password'>password</span>
426
+ <span class='ivar'>@password</span>
427
+ <span class='kw'>end</span></pre>
428
+ </td>
429
+ </tr>
430
+ </table>
431
+ </div>
432
+
433
+
434
+ <span id=""></span>
435
+ <div class="method_details ">
436
+ <h3 class="signature " id="username-instance_method">
437
+
438
+ - (<tt>Object</tt>) <strong>username</strong> <span class="extras">(readonly)</span>
439
+
440
+
441
+
442
+
443
+
444
+ </h3><div class="docstring">
445
+ <div class="discussion">
446
+
447
+ <p>Contains the username used for Basic Auth requests</p>
448
+
449
+
450
+ </div>
451
+ </div>
452
+ <div class="tags">
453
+
454
+
455
+ </div><table class="source_code">
456
+ <tr>
457
+ <td>
458
+ <pre class="lines">
459
+
460
+
461
+ 10
462
+ 11
463
+ 12</pre>
464
+ </td>
465
+ <td>
466
+ <pre class="code"><span class="info file"># File 'lib/clx_api/http_adapter.rb', line 10</span>
467
+
468
+ <span class='kw'>def</span> <span class='id identifier rubyid_username'>username</span>
469
+ <span class='ivar'>@username</span>
470
+ <span class='kw'>end</span></pre>
471
+ </td>
472
+ </tr>
473
+ </table>
474
+ </div>
475
+
476
+ </div>
477
+
478
+
479
+ <div id="instance_method_details" class="method_details_list">
480
+ <h2>Instance Method Details</h2>
481
+
482
+
483
+ <div class="method_details first">
484
+ <h3 class="signature first" id="create_http-instance_method">
485
+
486
+ - (<tt>Net::HTTP</tt>) <strong>create_http</strong>(uri) <span class="extras">(private)</span>
487
+
488
+
489
+
490
+
491
+
492
+ </h3><div class="docstring">
493
+ <div class="discussion">
494
+
495
+ <p>Creates a Net:HTTP instance with ssl activated with URI-object</p>
496
+
497
+
498
+ </div>
499
+ </div>
500
+ <div class="tags">
501
+ <p class="tag_title">Parameters:</p>
502
+ <ul class="param">
503
+
504
+ <li>
505
+
506
+ <span class='name'>uri</span>
507
+
508
+
509
+ <span class='type'>(<tt>URI</tt>)</span>
510
+
511
+
512
+
513
+ </li>
514
+
515
+ </ul>
516
+
517
+ <p class="tag_title">Returns:</p>
518
+ <ul class="return">
519
+
520
+ <li>
521
+
522
+
523
+ <span class='type'>(<tt>Net::HTTP</tt>)</span>
524
+
525
+
526
+
527
+ &mdash;
528
+ <div class='inline'>
529
+ <p>http</p>
530
+ </div>
531
+
532
+ </li>
533
+
534
+ </ul>
535
+
536
+ </div><table class="source_code">
537
+ <tr>
538
+ <td>
539
+ <pre class="lines">
540
+
541
+
542
+ 118
543
+ 119
544
+ 120
545
+ 121
546
+ 122
547
+ 123
548
+ 124
549
+ 125</pre>
550
+ </td>
551
+ <td>
552
+ <pre class="code"><span class="info file"># File 'lib/clx_api/http_adapter.rb', line 118</span>
553
+
554
+ <span class='kw'>def</span> <span class='id identifier rubyid_create_http'>create_http</span><span class='lparen'>(</span><span class='id identifier rubyid_uri'>uri</span><span class='rparen'>)</span>
555
+ <span class='id identifier rubyid_http'>http</span> <span class='op'>=</span> <span class='const'>Net</span><span class='op'>::</span><span class='const'>HTTP</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_uri'>uri</span><span class='period'>.</span><span class='id identifier rubyid_host'>host</span><span class='comma'>,</span> <span class='id identifier rubyid_uri'>uri</span><span class='period'>.</span><span class='id identifier rubyid_port'>port</span><span class='rparen'>)</span>
556
+ <span class='kw'>if</span> <span class='id identifier rubyid_uri'>uri</span><span class='period'>.</span><span class='id identifier rubyid_instance_of?'>instance_of?</span> <span class='const'>URI</span><span class='op'>::</span><span class='const'>HTTPS</span>
557
+ <span class='id identifier rubyid_http'>http</span><span class='period'>.</span><span class='id identifier rubyid_use_ssl'>use_ssl</span> <span class='op'>=</span> <span class='kw'>true</span>
558
+ <span class='id identifier rubyid_http'>http</span><span class='period'>.</span><span class='id identifier rubyid_verify_mode'>verify_mode</span> <span class='op'>=</span> <span class='const'>OpenSSL</span><span class='op'>::</span><span class='const'>SSL</span><span class='op'>::</span><span class='const'>VERIFY_NONE</span>
559
+ <span class='kw'>end</span>
560
+ <span class='kw'>return</span> <span class='id identifier rubyid_http'>http</span>
561
+ <span class='kw'>end</span></pre>
562
+ </td>
563
+ </tr>
564
+ </table>
565
+ </div>
566
+
567
+ <div class="method_details ">
568
+ <h3 class="signature " id="create_request-instance_method">
569
+
570
+ - (<tt>Mixed</tt>) <strong>create_request</strong>(method, uri, data = nil) <span class="extras">(private)</span>
571
+
572
+
573
+
574
+
575
+
576
+ </h3><div class="docstring">
577
+ <div class="discussion">
578
+
579
+ <p>Create Request object by method and uri</p>
580
+
581
+
582
+ </div>
583
+ </div>
584
+ <div class="tags">
585
+
586
+ <div class="examples">
587
+ <p class="tag_title">Examples:</p>
588
+
589
+
590
+ <pre class="example code"><code><span class='id identifier rubyid_request'>request</span> <span class='op'>=</span> <span class='id identifier rubyid_create_request'>create_request</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>GET</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>http://some.url</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span></code></pre>
591
+
592
+ </div>
593
+ <p class="tag_title">Parameters:</p>
594
+ <ul class="param">
595
+
596
+ <li>
597
+
598
+ <span class='name'>method</span>
599
+
600
+
601
+ <span class='type'>(<tt>String</tt>)</span>
602
+
603
+
604
+
605
+ &mdash;
606
+ <div class='inline'>
607
+ <p>HTTP</p>
608
+ </div>
609
+
610
+ </li>
611
+
612
+ <li>
613
+
614
+ <span class='name'>uri</span>
615
+
616
+
617
+ <span class='type'>(<tt>URI</tt>)</span>
618
+
619
+
620
+
621
+ </li>
622
+
623
+ <li>
624
+
625
+ <span class='name'>data</span>
626
+
627
+
628
+ <span class='type'>(<tt>Hash</tt>)</span>
629
+
630
+
631
+ <em class="default">(defaults to: <tt>nil</tt>)</em>
632
+
633
+
634
+ </li>
635
+
636
+ </ul>
637
+
638
+ <p class="tag_title">Returns:</p>
639
+ <ul class="return">
640
+
641
+ <li>
642
+
643
+
644
+ <span class='type'>(<tt>Mixed</tt>)</span>
645
+
646
+
647
+
648
+ &mdash;
649
+ <div class='inline'>
650
+ <p>request Net::HTTP::Get, Net::HTTP::Post, Net::HTTP::Put, Net::HTTP::Delete</p>
651
+ </div>
652
+
653
+ </li>
654
+
655
+ </ul>
656
+ <p class="tag_title">Raises:</p>
657
+ <ul class="raise">
658
+
659
+ <li>
660
+
661
+
662
+ <span class='type'>(<tt><span class='object_link'><a href="CLXException.html" title="CLX::CLXException (class)">CLXException</a></span></tt>)</span>
663
+
664
+
665
+
666
+ &mdash;
667
+ <div class='inline'>
668
+ <p>If an invalid HTTP-method was passed</p>
669
+ </div>
670
+
671
+ </li>
672
+
673
+ </ul>
674
+
675
+ </div><table class="source_code">
676
+ <tr>
677
+ <td>
678
+ <pre class="lines">
679
+
680
+
681
+ 96
682
+ 97
683
+ 98
684
+ 99
685
+ 100
686
+ 101
687
+ 102
688
+ 103
689
+ 104
690
+ 105
691
+ 106
692
+ 107
693
+ 108
694
+ 109
695
+ 110
696
+ 111
697
+ 112
698
+ 113</pre>
699
+ </td>
700
+ <td>
701
+ <pre class="code"><span class="info file"># File 'lib/clx_api/http_adapter.rb', line 96</span>
702
+
703
+ <span class='kw'>def</span> <span class='id identifier rubyid_create_request'>create_request</span><span class='lparen'>(</span><span class='id identifier rubyid_method'>method</span><span class='comma'>,</span> <span class='id identifier rubyid_uri'>uri</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>
704
+ <span class='id identifier rubyid_method'>method</span> <span class='op'>=</span> <span class='id identifier rubyid_method'>method</span><span class='period'>.</span><span class='id identifier rubyid_upcase'>upcase</span>
705
+ <span class='kw'>if</span><span class='lparen'>(</span><span class='id identifier rubyid_method'>method</span> <span class='op'>==</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>GET</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
706
+ <span class='kw'>return</span> <span class='const'>Net</span><span class='op'>::</span><span class='const'>HTTP</span><span class='op'>::</span><span class='const'>Get</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_uri'>uri</span><span class='rparen'>)</span>
707
+ <span class='kw'>elsif</span><span class='lparen'>(</span><span class='id identifier rubyid_method'>method</span> <span class='op'>==</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>POST</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
708
+ <span class='id identifier rubyid_request'>request</span> <span class='op'>=</span> <span class='const'>Net</span><span class='op'>::</span><span class='const'>HTTP</span><span class='op'>::</span><span class='const'>Post</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_uri'>uri</span><span class='rparen'>)</span>
709
+ <span class='id identifier rubyid_request'>request</span><span class='period'>.</span><span class='id identifier rubyid_body'>body</span> <span class='op'>=</span> <span class='id identifier rubyid_data'>data</span><span class='period'>.</span><span class='id identifier rubyid_to_json'>to_json</span>
710
+ <span class='kw'>return</span> <span class='id identifier rubyid_request'>request</span>
711
+ <span class='kw'>elsif</span><span class='lparen'>(</span><span class='id identifier rubyid_method'>method</span> <span class='op'>==</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>PUT</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
712
+ <span class='id identifier rubyid_request'>request</span> <span class='op'>=</span> <span class='const'>Net</span><span class='op'>::</span><span class='const'>HTTP</span><span class='op'>::</span><span class='const'>Put</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_uri'>uri</span><span class='rparen'>)</span>
713
+ <span class='id identifier rubyid_request'>request</span><span class='period'>.</span><span class='id identifier rubyid_body'>body</span> <span class='op'>=</span> <span class='id identifier rubyid_data'>data</span><span class='period'>.</span><span class='id identifier rubyid_to_json'>to_json</span>
714
+ <span class='kw'>return</span> <span class='id identifier rubyid_request'>request</span>
715
+ <span class='kw'>elsif</span><span class='lparen'>(</span><span class='id identifier rubyid_method'>method</span> <span class='op'>==</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>DELETE</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
716
+ <span class='kw'>return</span> <span class='const'>Net</span><span class='op'>::</span><span class='const'>HTTP</span><span class='op'>::</span><span class='const'>Delete</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_uri'>uri</span><span class='rparen'>)</span>
717
+ <span class='kw'>else</span>
718
+ <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'>Unknown HTTP method</span><span class='tstring_end'>&#39;</span></span>
719
+ <span class='kw'>end</span>
720
+ <span class='kw'>end</span></pre>
721
+ </td>
722
+ </tr>
723
+ </table>
724
+ </div>
725
+
726
+ <div class="method_details ">
727
+ <h3 class="signature " id="delete-instance_method">
728
+
729
+ - (<tt>HTTP::Response</tt>) <strong>delete</strong>(uri)
730
+
731
+
732
+
733
+
734
+
735
+ </h3><div class="docstring">
736
+ <div class="discussion">
737
+
738
+ <p>DELETE-request</p>
739
+
740
+ <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>
741
+
742
+
743
+ </div>
744
+ </div>
745
+ <div class="tags">
746
+ <p class="tag_title">Parameters:</p>
747
+ <ul class="param">
748
+
749
+ <li>
750
+
751
+ <span class='name'>uri</span>
752
+
753
+
754
+ <span class='type'>(<tt>URI</tt>)</span>
755
+
756
+
757
+
758
+ &mdash;
759
+ <div class='inline'>
760
+ <p>Ruby URI object with full API URL</p>
761
+ </div>
762
+
763
+ </li>
764
+
765
+ </ul>
766
+
767
+ <p class="tag_title">Returns:</p>
768
+ <ul class="return">
769
+
770
+ <li>
771
+
772
+
773
+ <span class='type'>(<tt>HTTP::Response</tt>)</span>
774
+
775
+
776
+
777
+ </li>
778
+
779
+ </ul>
780
+
781
+ </div><table class="source_code">
782
+ <tr>
783
+ <td>
784
+ <pre class="lines">
785
+
786
+
787
+ 64
788
+ 65
789
+ 66</pre>
790
+ </td>
791
+ <td>
792
+ <pre class="code"><span class="info file"># File 'lib/clx_api/http_adapter.rb', line 64</span>
793
+
794
+ <span class='kw'>def</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>
795
+ <span class='kw'>return</span> <span class='id identifier rubyid_execute'>execute</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>delete</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_uri'>uri</span><span class='rparen'>)</span>
796
+ <span class='kw'>end</span></pre>
797
+ </td>
798
+ </tr>
799
+ </table>
800
+ </div>
801
+
802
+ <div class="method_details ">
803
+ <h3 class="signature " id="execute-instance_method">
804
+
805
+ - (<tt>HTTP::Response</tt>) <strong>execute</strong>(method, uri, data = nil) <span class="extras">(private)</span>
806
+
807
+
808
+
809
+
810
+
811
+ </h3><div class="docstring">
812
+ <div class="discussion">
813
+
814
+ <p>Execute request</p>
815
+
816
+
817
+ </div>
818
+ </div>
819
+ <div class="tags">
820
+ <p class="tag_title">Parameters:</p>
821
+ <ul class="param">
822
+
823
+ <li>
824
+
825
+ <span class='name'>method</span>
826
+
827
+
828
+ <span class='type'>(<tt>String</tt>)</span>
829
+
830
+
831
+
832
+ </li>
833
+
834
+ <li>
835
+
836
+ <span class='name'>uri</span>
837
+
838
+
839
+ <span class='type'>(<tt>String</tt>)</span>
840
+
841
+
842
+
843
+ &mdash;
844
+ <div class='inline'>
845
+ <p>Full API-path</p>
846
+ </div>
847
+
848
+ </li>
849
+
850
+ <li>
851
+
852
+ <span class='name'>data</span>
853
+
854
+
855
+ <span class='type'>(<tt>Hash</tt>)</span>
856
+
857
+
858
+ <em class="default">(defaults to: <tt>nil</tt>)</em>
859
+
860
+
861
+ </li>
862
+
863
+ </ul>
864
+
865
+ <p class="tag_title">Returns:</p>
866
+ <ul class="return">
867
+
868
+ <li>
869
+
870
+
871
+ <span class='type'>(<tt>HTTP::Response</tt>)</span>
872
+
873
+
874
+
875
+ &mdash;
876
+ <div class='inline'>
877
+ <p>result</p>
878
+ </div>
879
+
880
+ </li>
881
+
882
+ </ul>
883
+ <p class="tag_title">Raises:</p>
884
+ <ul class="raise">
885
+
886
+ <li>
887
+
888
+
889
+ <span class='type'>(<tt><span class='object_link'><a href="CLXException.html" title="CLX::CLXException (class)">CLXException</a></span></tt>)</span>
890
+
891
+
892
+
893
+ &mdash;
894
+ <div class='inline'>
895
+ <p>if he request fails</p>
896
+ </div>
897
+
898
+ </li>
899
+
900
+ </ul>
901
+
902
+ </div><table class="source_code">
903
+ <tr>
904
+ <td>
905
+ <pre class="lines">
906
+
907
+
908
+ 77
909
+ 78
910
+ 79
911
+ 80
912
+ 81
913
+ 82
914
+ 83
915
+ 84</pre>
916
+ </td>
917
+ <td>
918
+ <pre class="code"><span class="info file"># File 'lib/clx_api/http_adapter.rb', line 77</span>
919
+
920
+ <span class='kw'>def</span> <span class='id identifier rubyid_execute'>execute</span><span class='lparen'>(</span><span class='id identifier rubyid_method'>method</span><span class='comma'>,</span> <span class='id identifier rubyid_uri'>uri</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>
921
+ <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'>uri must be instance of URI</span><span class='tstring_end'>&#39;</span></span> <span class='kw'>unless</span> <span class='id identifier rubyid_uri'>uri</span><span class='period'>.</span><span class='id identifier rubyid_instance_of?'>instance_of?</span><span class='lparen'>(</span><span class='const'>URI</span><span class='op'>::</span><span class='const'>HTTPS</span><span class='rparen'>)</span> <span class='op'>||</span> <span class='id identifier rubyid_uri'>uri</span><span class='period'>.</span><span class='id identifier rubyid_instance_of?'>instance_of?</span><span class='lparen'>(</span><span class='const'>URI</span><span class='op'>::</span><span class='const'>HTTP</span><span class='rparen'>)</span>
922
+ <span class='id identifier rubyid_request'>request</span> <span class='op'>=</span> <span class='id identifier rubyid_create_request'>create_request</span><span class='lparen'>(</span><span class='id identifier rubyid_method'>method</span><span class='comma'>,</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>
923
+ <span class='id identifier rubyid_request'>request</span><span class='period'>.</span><span class='id identifier rubyid_basic_auth'>basic_auth</span><span class='lparen'>(</span><span class='ivar'>@username</span><span class='comma'>,</span> <span class='ivar'>@password</span><span class='rparen'>)</span>
924
+ <span class='id identifier rubyid_http'>http</span> <span class='op'>=</span> <span class='id identifier rubyid_create_http'>create_http</span><span class='lparen'>(</span><span class='id identifier rubyid_uri'>uri</span><span class='rparen'>)</span><span class='semicolon'>;</span>
925
+
926
+ <span class='kw'>return</span> <span class='id identifier rubyid_http'>http</span><span class='period'>.</span><span class='id identifier rubyid_request'>request</span><span class='lparen'>(</span><span class='id identifier rubyid_request'>request</span><span class='rparen'>)</span>
927
+ <span class='kw'>end</span></pre>
928
+ </td>
929
+ </tr>
930
+ </table>
931
+ </div>
932
+
933
+ <div class="method_details ">
934
+ <h3 class="signature " id="get-instance_method">
935
+
936
+ - (<tt>HTTP::Response</tt>) <strong>get</strong>(uri)
937
+
938
+
939
+
940
+
941
+
942
+ </h3><div class="docstring">
943
+ <div class="discussion">
944
+
945
+ <p>GET-request</p>
946
+
947
+
948
+ </div>
949
+ </div>
950
+ <div class="tags">
951
+ <p class="tag_title">Parameters:</p>
952
+ <ul class="param">
953
+
954
+ <li>
955
+
956
+ <span class='name'>uri</span>
957
+
958
+
959
+ <span class='type'>(<tt>URI</tt>)</span>
960
+
961
+
962
+
963
+ &mdash;
964
+ <div class='inline'>
965
+ <p>Ruby URI object with full API URL</p>
966
+ </div>
967
+
968
+ </li>
969
+
970
+ </ul>
971
+
972
+ <p class="tag_title">Returns:</p>
973
+ <ul class="return">
974
+
975
+ <li>
976
+
977
+
978
+ <span class='type'>(<tt>HTTP::Response</tt>)</span>
979
+
980
+
981
+
982
+ </li>
983
+
984
+ </ul>
985
+
986
+ </div><table class="source_code">
987
+ <tr>
988
+ <td>
989
+ <pre class="lines">
990
+
991
+
992
+ 33
993
+ 34
994
+ 35</pre>
995
+ </td>
996
+ <td>
997
+ <pre class="code"><span class="info file"># File 'lib/clx_api/http_adapter.rb', line 33</span>
998
+
999
+ <span class='kw'>def</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>
1000
+ <span class='kw'>return</span> <span class='id identifier rubyid_execute'>execute</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>get</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_uri'>uri</span><span class='rparen'>)</span>
1001
+ <span class='kw'>end</span></pre>
1002
+ </td>
1003
+ </tr>
1004
+ </table>
1005
+ </div>
1006
+
1007
+ <div class="method_details ">
1008
+ <h3 class="signature " id="post-instance_method">
1009
+
1010
+ - (<tt>HTTP::Response</tt>) <strong>post</strong>(uri, data)
1011
+
1012
+
1013
+
1014
+
1015
+
1016
+ </h3><div class="docstring">
1017
+ <div class="discussion">
1018
+
1019
+ <p>POST-request</p>
1020
+
1021
+ <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>
1022
+
1023
+
1024
+ </div>
1025
+ </div>
1026
+ <div class="tags">
1027
+ <p class="tag_title">Parameters:</p>
1028
+ <ul class="param">
1029
+
1030
+ <li>
1031
+
1032
+ <span class='name'>uri</span>
1033
+
1034
+
1035
+ <span class='type'>(<tt>URI</tt>)</span>
1036
+
1037
+
1038
+
1039
+ &mdash;
1040
+ <div class='inline'>
1041
+ <p>Ruby URI object with full API URL</p>
1042
+ </div>
1043
+
1044
+ </li>
1045
+
1046
+ <li>
1047
+
1048
+ <span class='name'>data</span>
1049
+
1050
+
1051
+ <span class='type'>(<tt>Hash</tt>)</span>
1052
+
1053
+
1054
+
1055
+ &mdash;
1056
+ <div class='inline'>
1057
+ <p>POST-data</p>
1058
+ </div>
1059
+
1060
+ </li>
1061
+
1062
+ </ul>
1063
+
1064
+ <p class="tag_title">Returns:</p>
1065
+ <ul class="return">
1066
+
1067
+ <li>
1068
+
1069
+
1070
+ <span class='type'>(<tt>HTTP::Response</tt>)</span>
1071
+
1072
+
1073
+
1074
+ </li>
1075
+
1076
+ </ul>
1077
+
1078
+ </div><table class="source_code">
1079
+ <tr>
1080
+ <td>
1081
+ <pre class="lines">
1082
+
1083
+
1084
+ 44
1085
+ 45
1086
+ 46</pre>
1087
+ </td>
1088
+ <td>
1089
+ <pre class="code"><span class="info file"># File 'lib/clx_api/http_adapter.rb', line 44</span>
1090
+
1091
+ <span class='kw'>def</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>
1092
+ <span class='kw'>return</span> <span class='id identifier rubyid_execute'>execute</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>post</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</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>
1093
+ <span class='kw'>end</span></pre>
1094
+ </td>
1095
+ </tr>
1096
+ </table>
1097
+ </div>
1098
+
1099
+ <div class="method_details ">
1100
+ <h3 class="signature " id="put-instance_method">
1101
+
1102
+ - (<tt>HTTP::Response</tt>) <strong>put</strong>(uri, data)
1103
+
1104
+
1105
+
1106
+
1107
+
1108
+ </h3><div class="docstring">
1109
+ <div class="discussion">
1110
+
1111
+ <p>PUT-request</p>
1112
+
1113
+ <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>
1114
+
1115
+
1116
+ </div>
1117
+ </div>
1118
+ <div class="tags">
1119
+ <p class="tag_title">Parameters:</p>
1120
+ <ul class="param">
1121
+
1122
+ <li>
1123
+
1124
+ <span class='name'>uri</span>
1125
+
1126
+
1127
+ <span class='type'>(<tt>URI</tt>)</span>
1128
+
1129
+
1130
+
1131
+ &mdash;
1132
+ <div class='inline'>
1133
+ <p>Ruby URI object with full API URL</p>
1134
+ </div>
1135
+
1136
+ </li>
1137
+
1138
+ <li>
1139
+
1140
+ <span class='name'>data</span>
1141
+
1142
+
1143
+ <span class='type'>(<tt>Hash</tt>)</span>
1144
+
1145
+
1146
+
1147
+ &mdash;
1148
+ <div class='inline'>
1149
+ <p>PUT-data</p>
1150
+ </div>
1151
+
1152
+ </li>
1153
+
1154
+ </ul>
1155
+
1156
+ <p class="tag_title">Returns:</p>
1157
+ <ul class="return">
1158
+
1159
+ <li>
1160
+
1161
+
1162
+ <span class='type'>(<tt>HTTP::Response</tt>)</span>
1163
+
1164
+
1165
+
1166
+ </li>
1167
+
1168
+ </ul>
1169
+
1170
+ </div><table class="source_code">
1171
+ <tr>
1172
+ <td>
1173
+ <pre class="lines">
1174
+
1175
+
1176
+ 55
1177
+ 56
1178
+ 57</pre>
1179
+ </td>
1180
+ <td>
1181
+ <pre class="code"><span class="info file"># File 'lib/clx_api/http_adapter.rb', line 55</span>
1182
+
1183
+ <span class='kw'>def</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>
1184
+ <span class='kw'>return</span> <span class='id identifier rubyid_execute'>execute</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>put</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</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>
1185
+ <span class='kw'>end</span></pre>
1186
+ </td>
1187
+ </tr>
1188
+ </table>
1189
+ </div>
1190
+
1191
+ <div class="method_details ">
1192
+ <h3 class="signature " id="set_auth-instance_method">
1193
+
1194
+ - (<tt>Object</tt>) <strong>set_auth</strong>(username, password)
1195
+
1196
+
1197
+
1198
+
1199
+
1200
+ </h3><div class="docstring">
1201
+ <div class="discussion">
1202
+
1203
+ <p>Set credentials for basic auth</p>
1204
+
1205
+
1206
+ </div>
1207
+ </div>
1208
+ <div class="tags">
1209
+ <p class="tag_title">Parameters:</p>
1210
+ <ul class="param">
1211
+
1212
+ <li>
1213
+
1214
+ <span class='name'>username</span>
1215
+
1216
+
1217
+ <span class='type'>(<tt>String</tt>)</span>
1218
+
1219
+
1220
+
1221
+ </li>
1222
+
1223
+ <li>
1224
+
1225
+ <span class='name'>password</span>
1226
+
1227
+
1228
+ <span class='type'>(<tt>String</tt>)</span>
1229
+
1230
+
1231
+
1232
+ </li>
1233
+
1234
+ </ul>
1235
+
1236
+ <p class="tag_title">Raises:</p>
1237
+ <ul class="raise">
1238
+
1239
+ <li>
1240
+
1241
+
1242
+ <span class='type'>(<tt><span class='object_link'><a href="CLXException.html" title="CLX::CLXException (class)">CLXException</a></span></tt>)</span>
1243
+
1244
+
1245
+
1246
+ </li>
1247
+
1248
+ </ul>
1249
+
1250
+ </div><table class="source_code">
1251
+ <tr>
1252
+ <td>
1253
+ <pre class="lines">
1254
+
1255
+
1256
+ 19
1257
+ 20
1258
+ 21
1259
+ 22
1260
+ 23
1261
+ 24
1262
+ 25
1263
+ 26
1264
+ 27</pre>
1265
+ </td>
1266
+ <td>
1267
+ <pre class="code"><span class="info file"># File 'lib/clx_api/http_adapter.rb', line 19</span>
1268
+
1269
+ <span class='kw'>def</span> <span class='id identifier rubyid_set_auth'>set_auth</span><span class='lparen'>(</span><span class='id identifier rubyid_username'>username</span><span class='comma'>,</span> <span class='id identifier rubyid_password'>password</span><span class='rparen'>)</span>
1270
+ <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'>Username must be a string</span><span class='tstring_end'>&#39;</span></span> <span class='kw'>unless</span> <span class='id identifier rubyid_username'>username</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span> <span class='const'>String</span>
1271
+ <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'>Password must be a string</span><span class='tstring_end'>&#39;</span></span> <span class='kw'>unless</span> <span class='id identifier rubyid_password'>password</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span> <span class='const'>String</span>
1272
+ <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'>Username can not be an empty string</span><span class='tstring_end'>&#39;</span></span> <span class='kw'>unless</span> <span class='id identifier rubyid_username'>username</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>&gt;</span> <span class='int'>0</span>
1273
+ <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'>Password can not be an empty string</span><span class='tstring_end'>&#39;</span></span> <span class='kw'>unless</span> <span class='id identifier rubyid_password'>password</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>&gt;</span> <span class='int'>0</span>
1274
+
1275
+ <span class='ivar'>@username</span> <span class='op'>=</span> <span class='id identifier rubyid_username'>username</span>
1276
+ <span class='ivar'>@password</span> <span class='op'>=</span> <span class='id identifier rubyid_password'>password</span>
1277
+ <span class='kw'>end</span></pre>
1278
+ </td>
1279
+ </tr>
1280
+ </table>
1281
+ </div>
1282
+
1283
+ </div>
1284
+
1285
+ </div>
1286
+
1287
+ <div id="footer">
1288
+ Generated on Mon May 25 12:34:50 2015 by
1289
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1290
+ 0.8.7.6 (ruby-2.1.5).
1291
+ </div>
1292
+
1293
+ </body>
1294
+ </html>