api_caller 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/api_caller.rb +4 -4
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 966d31e325d50c9e2c5786c282d531228a370e3c
4
- data.tar.gz: 18303294b3d62cc372585f60bab55dccb4f2d9a8
3
+ metadata.gz: 077e20b3662922aa2d58c4641f3d4b1cba6be5f0
4
+ data.tar.gz: fd067314aef0190c51f34c483e78ed123752bb2a
5
5
  SHA512:
6
- metadata.gz: a728f172483994b090654c1cdc314da4958622d4c7a7d810d403b007151f6d1b37ebdb166860e322b07d7ee787ae21382fdaf98faecaa05887aab574acee2c42
7
- data.tar.gz: 02c737d1b8ffe7777732c9688dc3f5d527f49b89c74fe160f14cead494299226981821e78086e65c9ddcf61d79602d1c361a059693b92595a5307fa100d472c9
6
+ metadata.gz: 6f0cca408a5b1c534f1987003bf9312c313f6bbd94d407e4d8a6367dd598a96f6dc9c0d35c9dc808b2c21b64342965883916177c7c6574a6db91fef35cf4d20f
7
+ data.tar.gz: deeb49a13d588fc283c628cdbcc57ab392f18504dd774b0b32a55508ce3f84ab5587db2895593698583e96ab96dd67e48fdd96acc59c327b700dd30ba2d0b237
data/lib/api_caller.rb CHANGED
@@ -2,7 +2,7 @@ require 'net/http'
2
2
 
3
3
  class ApiCaller
4
4
 
5
- def self.get(uri_string, logger = nil)
5
+ def self.get(uri_string:, logger: nil)
6
6
  response = nil
7
7
 
8
8
  uri = URI(uri_string)
@@ -18,13 +18,13 @@ class ApiCaller
18
18
  response.is_a?(Net::HTTPSuccess) ? response.body.force_encoding(Encoding::UTF_8) : nil
19
19
  end
20
20
 
21
- def self.post(uri_string, params, content_type = {'Content-Type' => 'application/json'}, logger = nil)
21
+ def self.post(uri_string:, params:, content_type: nil, logger: nil)
22
22
  response = nil
23
23
 
24
24
  uri = URI(uri_string)
25
25
  begin
26
26
  Net::HTTP.start(uri.host, uri.port, {use_ssl: uri.scheme == 'https', open_timeout: 1}) do |http|
27
- request = Net::HTTP::Post.new(uri, content_type)
27
+ request = content_type ? Net::HTTP::Post.new(uri, content_type) : Net::HTTP::Post.new(uri)
28
28
  request.body = params
29
29
  response = http.request(request)
30
30
  end
@@ -36,4 +36,4 @@ class ApiCaller
36
36
  end
37
37
 
38
38
 
39
- end
39
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: api_caller
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Team Nautilus
@@ -10,7 +10,7 @@ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2016-07-27 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: Call api safely for get o post method.
13
+ description: Call APIs safely for get or post methods.
14
14
  email: nautilus@trovaprezzi.it
15
15
  executables: []
16
16
  extensions: []
@@ -40,5 +40,5 @@ rubyforge_project:
40
40
  rubygems_version: 2.5.1
41
41
  signing_key:
42
42
  specification_version: 4
43
- summary: Call api safely.
43
+ summary: Call APIs safely.
44
44
  test_files: []