interage-request 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3a94a4ed4c99f9f7b1439bf4693b8c24115b4e13795c6048fa9fdd1211f409d1
4
- data.tar.gz: 34c6eae55db89e762fb45a4c619a826c71e5884ae81506c236f38c1b0e7396bd
3
+ metadata.gz: aa35a29ecff41fe709f0f479d513ff7c3a4a391d28aa4890d0b359bc9f89f773
4
+ data.tar.gz: 724fd932cc340d1e51b8413aa81ec0b30d09aaed909ebae09fc062e05f140a0b
5
5
  SHA512:
6
- metadata.gz: fa43808d0f187a5d565d49d2b88892e0e5e45cbf5b852081f762310430b117a76cc812e908296096793528247edfc03f29af4ab5a4030e61a2139e7980675b3a
7
- data.tar.gz: fc3c11173461eb85a1a2fef45a05565767f4d047e7bf48a01a5066f30aa7e4a32a195ad88f8f133b9ae85412c24b3ae60ed0ed7eebc4b24cbb397d0e3d338687
6
+ metadata.gz: cf10904943d0ccae3c669929d398cb8c01b86da80dab54d81f7ca58d9b01873f6ab603bc8356e54443354d89b73829545f2723d68c39b0cc517e105e17511d18
7
+ data.tar.gz: 1d887b990d822e89f3df22b86ab5cbc3f9faffefebe4ab43981a8112b82a916f981564282397b4e455a30e3128c102ffd1c4432a5831a498d03a5b615df18ff7
data/CHANGES CHANGED
@@ -1,3 +1,7 @@
1
+ Version 0.1.1:
2
+ - Empacota a versão 0.1.1
3
+ - Verifica se a resposta do find não é nula
4
+
1
5
  Version 0.1.0
2
6
  - Renomea e reimplmenta gem para application request
3
7
  - Adiciona comando dos geradores na documentação
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
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.new(uri)
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Interage
4
4
  module Request
5
- VERSION = '0.1.1'
5
+ VERSION = '0.1.2'
6
6
  end
7
7
  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.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-04-29 00:00:00.000000000 Z
11
+ date: 2019-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler