push_to_devices 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.
- data/lib/push_to_devices.rb +16 -19
- data/push_to_devices.gemspec +1 -1
- metadata +1 -1
data/lib/push_to_devices.rb
CHANGED
@@ -5,7 +5,7 @@ require "cgi"
|
|
5
5
|
module PushToDevices
|
6
6
|
|
7
7
|
module Config
|
8
|
-
VERSION = '0.1.
|
8
|
+
VERSION = '0.1.2'
|
9
9
|
end
|
10
10
|
|
11
11
|
class Exception < ::StandardError
|
@@ -41,15 +41,7 @@ module PushToDevices
|
|
41
41
|
def get(endpoint, params={})
|
42
42
|
|
43
43
|
# Set up the HTTP connection
|
44
|
-
http =
|
45
|
-
host,
|
46
|
-
api_port
|
47
|
-
)
|
48
|
-
http.use_ssl = (use_ssl == true)
|
49
|
-
if debug == true
|
50
|
-
http.set_debug_output($stdout)
|
51
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
52
|
-
end
|
44
|
+
http = generate_http
|
53
45
|
|
54
46
|
uri = self.generate_uri_from_params(endpoint, params)
|
55
47
|
|
@@ -73,15 +65,7 @@ module PushToDevices
|
|
73
65
|
def post(endpoint, params = {})
|
74
66
|
|
75
67
|
# Set up the HTTP connection
|
76
|
-
http =
|
77
|
-
host,
|
78
|
-
api_port
|
79
|
-
)
|
80
|
-
http.use_ssl = (use_ssl == true)
|
81
|
-
if debug == true
|
82
|
-
http.set_debug_output($stdout)
|
83
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
84
|
-
end
|
68
|
+
http = generate_http
|
85
69
|
|
86
70
|
request = Net::HTTP::Post.new("/"+endpoint, initheader = {'Content-Type' =>'application/json'})
|
87
71
|
request.body = params.to_json
|
@@ -100,6 +84,19 @@ module PushToDevices
|
|
100
84
|
self.handle_response(response)
|
101
85
|
end
|
102
86
|
|
87
|
+
def generate_http
|
88
|
+
http = Net::HTTP.new(
|
89
|
+
host,
|
90
|
+
api_port
|
91
|
+
)
|
92
|
+
http.use_ssl = (use_ssl == true)
|
93
|
+
if debug == true
|
94
|
+
http.set_debug_output($stdout)
|
95
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
96
|
+
end
|
97
|
+
http
|
98
|
+
end
|
99
|
+
|
103
100
|
def api_port
|
104
101
|
if port
|
105
102
|
port
|
data/push_to_devices.gemspec
CHANGED