envia_ya 0.0.2 → 0.0.3
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 956b5e19e5e2d76fb23cf3645d41f975f3c3ced0d3878ebc6c1f6ecd5619ef05
|
4
|
+
data.tar.gz: ae9ab5314bb6b17d422ee1b25b3513ca5569c15b274b0c239457deddcf685980
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55bef7644ccc46081e3b7d20878e41d8ade749c6e0b915d0bf39bbddd8be797aac296bd7142db09fe0454da3d0ded86cdbcce70021abb3acadc5811ae09a315b
|
7
|
+
data.tar.gz: 3ef0831676c2713767fdb7682fcec83a285faca38f35e6fd2f075cc3de122a261ed36683277cd148913d1902ddfcbba5be97fa45d187a27bc658117b44113863
|
@@ -11,15 +11,15 @@ module EnviaYa
|
|
11
11
|
module HttpConnector
|
12
12
|
class HttpNetConnector < ::EnviaYa::Shared::Domain::Connectors::HttpConnector
|
13
13
|
def execute(uri, method: ::EnviaYa::Shared::Domain::ValueObjects::HttpMethodValueObject.new('GET'), body: {})
|
14
|
+
raise StandardError, "api_key has not been added. Please added via EnviaYa::Config.api_key = 'YOUR_API_KEY'" unless EnviaYa::Config.api_key
|
14
15
|
raise TypeError, "uri expected URI but got: #{uri.class}" unless uri.is_a?(URI)
|
15
16
|
raise TypeError, "method expected HttpMethodValueObject but got: #{method.class}" unless method.is_a?(::EnviaYa::Shared::Domain::ValueObjects::HttpMethodValueObject)
|
16
17
|
raise TypeError, "body expected Hash but got: #{body.class}" unless body.is_a?(Hash)
|
17
18
|
|
18
19
|
case method.to_s
|
19
20
|
when 'POST'
|
20
|
-
return Net::HTTP.post(uri, body.to_json, {
|
21
|
-
'Content-Type': 'application/json'
|
22
|
-
'Authorization': "Bearer #{EnviaYa::Config.api_key}"
|
21
|
+
return Net::HTTP.post(URI(uri.to_s.concat("?api_key=#{EnviaYa::Config.api_key}")), body.to_json, {
|
22
|
+
'Content-Type': 'application/json'
|
23
23
|
})
|
24
24
|
end
|
25
25
|
end
|