outbound 0.2 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/outbound.rb +9 -3
- metadata +1 -1
data/lib/outbound.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
require 'logger'
|
2
|
+
require 'json'
|
3
|
+
require 'net/http'
|
4
|
+
require 'uri'
|
2
5
|
|
3
6
|
module Outbound
|
4
|
-
VERSION = '0.2'
|
7
|
+
VERSION = '0.2.1'
|
5
8
|
BASE_URL = 'https://api.outbound.io/v2'
|
6
9
|
|
7
10
|
ERROR_USER_ID = "User ID must be a string or number."
|
@@ -146,9 +149,12 @@ module Outbound
|
|
146
149
|
headers = HEADERS
|
147
150
|
headers['X-Outbound-Key'] = api_key
|
148
151
|
payload = JSON.generate data
|
149
|
-
|
152
|
+
uri = URI("#{BASE_URL}#{path}")
|
153
|
+
|
154
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
155
|
+
http.use_ssl = uri.scheme == 'https'
|
156
|
+
res = http.post(uri.path, payload, headers)
|
150
157
|
|
151
|
-
res = @http.request(request, payload)
|
152
158
|
status = res.code.to_i
|
153
159
|
rescue Exception => e
|
154
160
|
res = Result.new Outbound::ERROR_CONNECTION, false
|