Class: Rpush::Daemon::Wns::PostRequest
- Inherits:
-
Object
- Object
- Rpush::Daemon::Wns::PostRequest
- Defined in:
- lib/rpush/daemon/wns/post_request.rb
Class Method Summary collapse
- .badge_notification?(notification) ⇒ Boolean
- .create(notification, access_token) ⇒ Object
- .raw_notification?(notification) ⇒ Boolean
- .stringify_keys(data) ⇒ Object
Class Method Details
.badge_notification?(notification) ⇒ Boolean
23 24 25 |
# File 'lib/rpush/daemon/wns/post_request.rb', line 23 def self.badge_notification?(notification) notification.class.name.match(/BadgeNotification/) end |
.create(notification, access_token) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/rpush/daemon/wns/post_request.rb', line 5 def self.create(notification, access_token) stringify_keys(notification.data) unless notification.data.nil? if raw_notification?(notification) RawRequest.create(notification, access_token) elsif badge_notification?(notification) BadgeRequest.create(notification, access_token) else ToastRequest.create(notification, access_token) end end |
.raw_notification?(notification) ⇒ Boolean
19 20 21 |
# File 'lib/rpush/daemon/wns/post_request.rb', line 19 def self.raw_notification?(notification) notification.class.name.match(/RawNotification/) end |
.stringify_keys(data) ⇒ Object
27 28 29 |
# File 'lib/rpush/daemon/wns/post_request.rb', line 27 def self.stringify_keys(data) data.keys.each { |key| data[key.to_s || key] = data.delete(key) } end |