nice_http 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/lib/nice_http.rb +127 -97
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b7b94ecb393c3395796636b8e9308bcea20dde7ca9e314ddeae7dd3129ac8bd
|
4
|
+
data.tar.gz: c760b6830a3f2f6a1d681ef731df55d47f555c67a2a5b38709f1a61af5943ce9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87ab72b2e991b77c83a82a12e114ed070544202805afa5aeceec1ae07fa0cd28a2ca514e5118b2a5bfb5a5832cb39477feeeb57df1f8bf156394a5e5a76b3db3
|
7
|
+
data.tar.gz: 30bbd18f121e0502e83ea5bacce0c998cc1aafcb7fa23162333028484873379653c054dfc7f203dadd74e37d5d2702913e453abe721a4d03ec5c45ee02ef8c39
|
data/README.md
CHANGED
data/lib/nice_http.rb
CHANGED
@@ -41,26 +41,49 @@ class NiceHttp
|
|
41
41
|
end
|
42
42
|
|
43
43
|
######################################################
|
44
|
-
#
|
45
|
-
#
|
46
|
-
#
|
47
|
-
#
|
48
|
-
#
|
49
|
-
#
|
50
|
-
#
|
51
|
-
#
|
52
|
-
#
|
44
|
+
# Creates a new http connection.
|
45
|
+
#
|
46
|
+
# @param args [] If no parameter supplied, by default will access how is setup on defaults
|
47
|
+
# @example
|
48
|
+
# http = NiceHttp.new()
|
49
|
+
# @param args [String]. The url to create the connection.
|
50
|
+
# @example
|
51
|
+
# http = NiceHttp.new("https://www.example.com")
|
52
|
+
# @example
|
53
|
+
# http = NiceHttp.new("example.com:8999")
|
54
|
+
# @example
|
55
|
+
# http = NiceHttp.new("localhost:8322")
|
56
|
+
# @param args [Hash] containing these possible keys:
|
57
|
+
#
|
53
58
|
# host -- example.com. (default blank screen)
|
59
|
+
#
|
54
60
|
# port -- port for the connection. 80 (default)
|
61
|
+
#
|
55
62
|
# ssl -- true, false (default)
|
63
|
+
#
|
56
64
|
# headers -- hash with the header key:values
|
65
|
+
#
|
57
66
|
# debug -- true, false (default)
|
67
|
+
#
|
58
68
|
# log -- :no, :screen, :file, :fix_file (default).
|
69
|
+
#
|
59
70
|
# A string with a path can be supplied.
|
71
|
+
#
|
60
72
|
# If :fix_file: nice_http.log
|
73
|
+
#
|
61
74
|
# In case :file it will be generated a log file with name: nice_http_YY-mm-dd-HHMMSS.log
|
75
|
+
#
|
62
76
|
# proxy_host
|
77
|
+
#
|
63
78
|
# proxy_port
|
79
|
+
# @example
|
80
|
+
# http2 = NiceHttp.new( host: "reqres.in", port: 443, ssl: true )
|
81
|
+
# @example
|
82
|
+
# my_server = {host: "example.com",
|
83
|
+
# port: 80,
|
84
|
+
# headers: {"api-key": "zdDDdjkck"}
|
85
|
+
# }
|
86
|
+
# http3 = NiceHttp.new my_server
|
64
87
|
######################################################
|
65
88
|
def initialize(args = {})
|
66
89
|
require 'net/http'
|
@@ -175,20 +198,25 @@ class NiceHttp
|
|
175
198
|
|
176
199
|
######################################################
|
177
200
|
# Get data from path
|
178
|
-
#
|
179
|
-
#
|
180
|
-
#
|
181
|
-
#
|
182
|
-
#
|
183
|
-
#
|
184
|
-
#
|
185
|
-
#
|
186
|
-
#
|
187
|
-
#
|
188
|
-
#
|
189
|
-
#
|
190
|
-
#
|
191
|
-
#
|
201
|
+
#
|
202
|
+
# @param arg [Hash] containing at least key :path
|
203
|
+
# @param arg [String] the path
|
204
|
+
#
|
205
|
+
# @return [Hash] response
|
206
|
+
# Including at least the symbol keys:
|
207
|
+
# :data = the response data body.
|
208
|
+
# :message = plain text response.
|
209
|
+
# :code = code response (200=ok,500=wrong...).
|
210
|
+
# All keys in response are lowercase.
|
211
|
+
# data, message and code can also be accessed as attributes like .message .code .data
|
212
|
+
# @return [Symbol] in case of error returns :error
|
213
|
+
#
|
214
|
+
# @example
|
215
|
+
# resp = @http.get(Requests::Customer.get_profile)
|
216
|
+
# assert resp.code == 200
|
217
|
+
# @example
|
218
|
+
# resp = @http.get("/customers/1223")
|
219
|
+
# assert resp.message == "OK"
|
192
220
|
######################################################
|
193
221
|
def get(arg)
|
194
222
|
begin
|
@@ -287,22 +315,28 @@ class NiceHttp
|
|
287
315
|
|
288
316
|
######################################################
|
289
317
|
# Post data to path
|
290
|
-
#
|
291
|
-
#
|
292
|
-
#
|
293
|
-
#
|
294
|
-
#
|
295
|
-
#
|
296
|
-
#
|
297
|
-
#
|
298
|
-
#
|
299
|
-
#
|
300
|
-
#
|
301
|
-
#
|
302
|
-
#
|
303
|
-
#
|
304
|
-
#
|
305
|
-
#
|
318
|
+
# @param arguments [Hash] containing at least keys :data and :path
|
319
|
+
# @param arguments [Array<path, data ,additional_headers]
|
320
|
+
# path (string)
|
321
|
+
# data (json data for example)
|
322
|
+
# additional_headers (Hash key=>value)
|
323
|
+
# @return [Hash] response
|
324
|
+
# Including at least the symbol keys:
|
325
|
+
# :data = the response data body.
|
326
|
+
# :message = plain text response.
|
327
|
+
# :code = code response (200=ok,500=wrong...).
|
328
|
+
# All keys in response are lowercase.
|
329
|
+
# data, message and code can also be accessed as attributes like .message .code .data
|
330
|
+
# @return [Symbol] in case of error returns :error
|
331
|
+
# @example
|
332
|
+
# resp = @http.post(Requests::Customer.update_customer)
|
333
|
+
# assert resp.code == 201
|
334
|
+
# @example
|
335
|
+
# resp = http.post( {
|
336
|
+
# path: "/api/users",
|
337
|
+
# data: {name: "morpheus", job: "leader"}
|
338
|
+
# } )
|
339
|
+
# pp resp.data.json
|
306
340
|
######################################################
|
307
341
|
def post(*arguments)
|
308
342
|
begin
|
@@ -375,25 +409,23 @@ class NiceHttp
|
|
375
409
|
|
376
410
|
end
|
377
411
|
|
378
|
-
|
379
412
|
######################################################
|
380
413
|
# Put data to path
|
381
|
-
#
|
382
|
-
#
|
383
|
-
#
|
384
|
-
#
|
385
|
-
#
|
386
|
-
#
|
387
|
-
#
|
388
|
-
#
|
389
|
-
#
|
390
|
-
#
|
391
|
-
#
|
392
|
-
#
|
393
|
-
#
|
394
|
-
#
|
395
|
-
#
|
396
|
-
# assert resp.code==200
|
414
|
+
# @param arguments [Hash] containing at least keys :data and :path
|
415
|
+
# @param arguments [Array<path, data ,additional_headers]
|
416
|
+
# path (string)
|
417
|
+
# data (json data for example)
|
418
|
+
# additional_headers (Hash key=>value)
|
419
|
+
# @return [Hash] response
|
420
|
+
# Including at least the symbol keys:
|
421
|
+
# :data = the response data body.
|
422
|
+
# :message = plain text response.
|
423
|
+
# :code = code response (200=ok,500=wrong...).
|
424
|
+
# All keys in response are lowercase.
|
425
|
+
# data, message and code can also be accessed as attributes like .message .code .data
|
426
|
+
# @return [Symbol] in case of error returns :error
|
427
|
+
# @example
|
428
|
+
# resp = @http.put(Requests::Customer.remove_phone)
|
397
429
|
######################################################
|
398
430
|
def put(*arguments)
|
399
431
|
begin
|
@@ -446,22 +478,21 @@ class NiceHttp
|
|
446
478
|
|
447
479
|
######################################################
|
448
480
|
# Patch data to path
|
449
|
-
#
|
450
|
-
#
|
451
|
-
#
|
452
|
-
#
|
453
|
-
#
|
454
|
-
#
|
455
|
-
#
|
456
|
-
#
|
457
|
-
#
|
458
|
-
#
|
459
|
-
#
|
460
|
-
#
|
461
|
-
#
|
462
|
-
#
|
463
|
-
#
|
464
|
-
# assert resp.code==200
|
481
|
+
# @param arguments [Hash] containing at least keys :data and :path
|
482
|
+
# @param arguments [Array<path, data ,additional_headers]
|
483
|
+
# path (string)
|
484
|
+
# data (json data for example)
|
485
|
+
# additional_headers (Hash key=>value)
|
486
|
+
# @return [Hash] response
|
487
|
+
# Including at least the symbol keys:
|
488
|
+
# :data = the response data body.
|
489
|
+
# :message = plain text response.
|
490
|
+
# :code = code response (200=ok,500=wrong...).
|
491
|
+
# All keys in response are lowercase.
|
492
|
+
# data, message and code can also be accessed as attributes like .message .code .data
|
493
|
+
# @return [Symbol] in case of error returns :error
|
494
|
+
# @example
|
495
|
+
# resp = @http.patch(Requests::Customer.unrelease_account)
|
465
496
|
######################################################
|
466
497
|
def patch(*arguments)
|
467
498
|
begin
|
@@ -526,23 +557,22 @@ class NiceHttp
|
|
526
557
|
|
527
558
|
end
|
528
559
|
|
529
|
-
|
530
560
|
######################################################
|
531
561
|
# Delete an existing resource
|
532
|
-
#
|
533
|
-
#
|
534
|
-
#
|
535
|
-
#
|
536
|
-
#
|
537
|
-
#
|
538
|
-
#
|
539
|
-
#
|
540
|
-
#
|
541
|
-
#
|
542
|
-
#
|
543
|
-
#
|
544
|
-
#
|
545
|
-
#
|
562
|
+
# @param arg [Hash] containing at least key :path
|
563
|
+
# @param arg [String] the path
|
564
|
+
#
|
565
|
+
# @return [Hash] response
|
566
|
+
# Including at least the symbol keys:
|
567
|
+
# :data = the response data body.
|
568
|
+
# :message = plain text response.
|
569
|
+
# :code = code response (200=ok,500=wrong...).
|
570
|
+
# All keys in response are lowercase.
|
571
|
+
# data, message and code can also be accessed as attributes like .message .code .data
|
572
|
+
# @return [Symbol] in case of error returns :error
|
573
|
+
# @example
|
574
|
+
# resp = @http.delete(Requests::Customer.remove_session)
|
575
|
+
# assert resp.code == 204
|
546
576
|
######################################################
|
547
577
|
def delete(argument)
|
548
578
|
begin
|
@@ -599,16 +629,16 @@ class NiceHttp
|
|
599
629
|
# Implementation of the http HEAD method.
|
600
630
|
# Asks for the response identical to the one that would correspond to a GET request, but without the response body.
|
601
631
|
# This is useful for retrieving meta-information written in response headers, without having to transport the entire content.
|
602
|
-
#
|
603
|
-
#
|
604
|
-
#
|
605
|
-
#
|
606
|
-
#
|
607
|
-
#
|
608
|
-
#
|
609
|
-
#
|
610
|
-
#
|
611
|
-
#
|
632
|
+
# @param arg [Hash] containing at least key :path
|
633
|
+
# @param arg [String] the path
|
634
|
+
#
|
635
|
+
# @return [Hash] response
|
636
|
+
# Including at least the symbol keys:
|
637
|
+
# :message = plain text response.
|
638
|
+
# :code = code response (200=ok,500=wrong...).
|
639
|
+
# All keys in response are lowercase.
|
640
|
+
# message and code can also be accessed as attributes like .message .code
|
641
|
+
# @return [Symbol] in case of error returns :error
|
612
642
|
######################################################
|
613
643
|
def head(argument)
|
614
644
|
begin
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nice_http
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mario Ruiz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-01-
|
11
|
+
date: 2019-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nice_hash
|