interage-request 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES +4 -0
- data/VERSION +1 -1
- data/lib/interage/application_request.rb +30 -6
- data/lib/interage/request/version.rb +1 -1
- 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: aa35a29ecff41fe709f0f479d513ff7c3a4a391d28aa4890d0b359bc9f89f773
|
4
|
+
data.tar.gz: 724fd932cc340d1e51b8413aa81ec0b30d09aaed909ebae09fc062e05f140a0b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf10904943d0ccae3c669929d398cb8c01b86da80dab54d81f7ca58d9b01873f6ab603bc8356e54443354d89b73829545f2723d68c39b0cc517e105e17511d18
|
7
|
+
data.tar.gz: 1d887b990d822e89f3df22b86ab5cbc3f9faffefebe4ab43981a8112b82a916f981564282397b4e455a30e3128c102ffd1c4432a5831a498d03a5b615df18ff7
|
data/CHANGES
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
@@ -20,7 +20,7 @@ module Interage
|
|
20
20
|
post(base_path, body)
|
21
21
|
end
|
22
22
|
|
23
|
-
def update(id)
|
23
|
+
def update(id, body)
|
24
24
|
put(member_path(id), body)
|
25
25
|
end
|
26
26
|
|
@@ -63,18 +63,33 @@ module Interage
|
|
63
63
|
start_request(Net::HTTP::Delete, path)
|
64
64
|
end
|
65
65
|
|
66
|
-
def start_request(klass, path, body = {})
|
66
|
+
def start_request(klass, path, body = {}, use_ssl=false, verify_ssl=true)
|
67
|
+
return start_https_request(klass, path, body, verify_ssl) if use_ssl
|
68
|
+
return start_http_request(klass, path, body)
|
69
|
+
end
|
70
|
+
|
71
|
+
def start_http_request(klass, path, body)
|
67
72
|
uri = URI(base_url(path: path))
|
68
|
-
request = klass
|
69
|
-
request.body = body.to_json
|
70
|
-
request.content_type = 'application/json'
|
71
|
-
headers.map { |key, value| request[key] = value }
|
73
|
+
request = http_request(klass, path, body)
|
72
74
|
|
73
75
|
Net::HTTP.start(uri.hostname, uri.port) do |http|
|
74
76
|
http.request(request)
|
75
77
|
end
|
76
78
|
end
|
77
79
|
|
80
|
+
def start_https_request(klass, path, body, verify_ssl)
|
81
|
+
uri = URI(base_url(path: path))
|
82
|
+
request = http_request(klass, path, body, uri)
|
83
|
+
|
84
|
+
http = Net::HTTP.new uri.hostname, 443
|
85
|
+
http.use_ssl = true
|
86
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE unless verify_ssl
|
87
|
+
|
88
|
+
http.start do |http|
|
89
|
+
http.request(request)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
78
93
|
def headers
|
79
94
|
{}
|
80
95
|
end
|
@@ -82,5 +97,14 @@ module Interage
|
|
82
97
|
def plural_key_name
|
83
98
|
key_name.to_s.pluralize.to_sym
|
84
99
|
end
|
100
|
+
|
101
|
+
def http_request(klass, path, body, uri)
|
102
|
+
request = klass.new(uri)
|
103
|
+
request.body = body.to_json
|
104
|
+
request.content_type = 'application/json'
|
105
|
+
headers.map { |key, value| request[key] = value }
|
106
|
+
|
107
|
+
request
|
108
|
+
end
|
85
109
|
end
|
86
110
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: interage-request
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Walmir Neto
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-08-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|