Module: Pushpad
- Defined in:
- lib/pushpad.rb
Defined Under Namespace
Classes: Notification
Constant Summary collapse
- @@auth_token =
nil- @@project_id =
nil
Class Method Summary collapse
- .auth_token ⇒ Object
- .auth_token=(auth_token) ⇒ Object
- .path(options = {}) ⇒ Object
- .path_for(user, options = {}) ⇒ Object
- .project_id ⇒ Object
- .project_id=(project_id) ⇒ Object
- .signature_for(data) ⇒ Object
Class Method Details
.auth_token ⇒ Object
9 10 11 |
# File 'lib/pushpad.rb', line 9 def self.auth_token @@auth_token end |
.auth_token=(auth_token) ⇒ Object
13 14 15 |
# File 'lib/pushpad.rb', line 13 def self.auth_token=(auth_token) @@auth_token = auth_token end |
.path(options = {}) ⇒ Object
30 31 32 33 34 |
# File 'lib/pushpad.rb', line 30 def self.path( = {}) project_id = [:project_id] || self.project_id raise "You must set project_id" unless project_id "https://pushpad.xyz/projects/#{self.project_id}/subscription/edit" end |
.path_for(user, options = {}) ⇒ Object
36 37 38 39 40 |
# File 'lib/pushpad.rb', line 36 def self.path_for(user, = {}) uid = user.respond_to?(:id) ? user.id : user uid_signature = self.signature_for(uid.to_s) "#{self.path(options)}?uid=#{uid}&uid_signature=#{uid_signature}" end |
.project_id ⇒ Object
17 18 19 |
# File 'lib/pushpad.rb', line 17 def self.project_id @@project_id end |
.project_id=(project_id) ⇒ Object
21 22 23 |
# File 'lib/pushpad.rb', line 21 def self.project_id=(project_id) @@project_id = project_id end |
.signature_for(data) ⇒ Object
25 26 27 28 |
# File 'lib/pushpad.rb', line 25 def self.signature_for(data) raise "You must set Pushpad.auth_token" unless Pushpad.auth_token OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha1'), self.auth_token, data.to_s) end |