push_to_devices 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/push_to_devices.rb +10 -11
- data/push_to_devices.gemspec +1 -1
- metadata +2 -2
data/lib/push_to_devices.rb
CHANGED
@@ -5,16 +5,15 @@ require "cgi"
|
|
5
5
|
module PushToDevices
|
6
6
|
|
7
7
|
module Config
|
8
|
-
VERSION = '0.1.
|
8
|
+
VERSION = '0.1.4'
|
9
9
|
end
|
10
10
|
|
11
11
|
class Exception < ::StandardError
|
12
12
|
attr_accessor :response_code, :response_body
|
13
13
|
|
14
|
-
# Pretty self explanatory stuff here...
|
15
14
|
def initialize(response_code, response_body)
|
16
|
-
|
17
|
-
|
15
|
+
self.response_code = response_code
|
16
|
+
self.response_body = response_body
|
18
17
|
super "Response was #{response_code}, #{response_body}"
|
19
18
|
end
|
20
19
|
end
|
@@ -43,7 +42,7 @@ module PushToDevices
|
|
43
42
|
# Set up the HTTP connection
|
44
43
|
http = generate_http
|
45
44
|
|
46
|
-
uri =
|
45
|
+
uri = generate_uri_from_params(endpoint, params)
|
47
46
|
|
48
47
|
# Set up the request
|
49
48
|
request = Net::HTTP::Get.new(uri)
|
@@ -59,7 +58,7 @@ module PushToDevices
|
|
59
58
|
http.request request
|
60
59
|
}
|
61
60
|
|
62
|
-
|
61
|
+
handle_response(response)
|
63
62
|
end
|
64
63
|
|
65
64
|
def post(endpoint, params = {})
|
@@ -81,7 +80,7 @@ module PushToDevices
|
|
81
80
|
http.request request
|
82
81
|
}
|
83
82
|
|
84
|
-
|
83
|
+
handle_response(response)
|
85
84
|
end
|
86
85
|
|
87
86
|
def generate_http
|
@@ -140,7 +139,7 @@ module PushToDevices
|
|
140
139
|
# GETS to service/me
|
141
140
|
# Returns the body
|
142
141
|
def get_service_info(params = {})
|
143
|
-
|
142
|
+
get('services/me')
|
144
143
|
end
|
145
144
|
|
146
145
|
# POSTS to users/:unique_hash/notifications
|
@@ -156,7 +155,7 @@ module PushToDevices
|
|
156
155
|
# }
|
157
156
|
# }
|
158
157
|
def post_notification_to_user(params = {})
|
159
|
-
|
158
|
+
post("users/#{params.delete(:unique_hash)}/notifications", params.delete(:notification_data))
|
160
159
|
end
|
161
160
|
|
162
161
|
# POSTS to users/notifications
|
@@ -172,7 +171,7 @@ module PushToDevices
|
|
172
171
|
# }
|
173
172
|
# }
|
174
173
|
def post_notification_to_users(params = {})
|
175
|
-
|
174
|
+
post("users/notifications", params)
|
176
175
|
end
|
177
176
|
|
178
177
|
# POSTS to users/ to register a user for push notifications
|
@@ -183,7 +182,7 @@ module PushToDevices
|
|
183
182
|
# gcm_registration_id: gcm_registration_id
|
184
183
|
# }
|
185
184
|
def register_user_for_push(params = {})
|
186
|
-
|
185
|
+
post("users/", params)
|
187
186
|
end
|
188
187
|
end
|
189
188
|
|
data/push_to_devices.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: push_to_devices
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -112,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
112
|
version: '0'
|
113
113
|
requirements: []
|
114
114
|
rubyforge_project:
|
115
|
-
rubygems_version: 1.8.
|
115
|
+
rubygems_version: 1.8.25
|
116
116
|
signing_key:
|
117
117
|
specification_version: 3
|
118
118
|
summary: A Ruby library for interfacing with push_to_devices
|