Class: BoxcarAPI::Provider
- Inherits:
-
Object
- Object
- BoxcarAPI::Provider
- Includes:
- HTTParty
- Defined in:
- lib/boxcar_api.rb
Overview
For Providers - boxcar.io/help/api/providers
Instance Attribute Summary collapse
-
#provider_key ⇒ Object
Returns the value of attribute provider_key.
-
#provider_secret ⇒ Object
Returns the value of attribute provider_secret.
-
#screen_name ⇒ Object
Returns the value of attribute screen_name.
Instance Method Summary collapse
- #batch_notify(emails, message, options = {:from_screen_name => screen_name, :from_remote_service_id => nil, :source_url => nil, :icon_url => nil}) ⇒ Object
- #broadcast(message, options = {:from_screen_name => screen_name, :from_remote_service_id => nil, :source_url => nil, :icon_url => nil}) ⇒ Object
-
#initialize(provider_key = {}, provider_secret = nil, screen_name = nil) ⇒ Provider
constructor
A new instance of Provider.
- #notify(email, message, options = {:from_screen_name => screen_name, :from_remote_service_id => nil, :source_url => nil, :icon_url => nil}) ⇒ Object
- #subscribe(email) ⇒ Object
Constructor Details
#initialize(provider_key = {}, provider_secret = nil, screen_name = nil) ⇒ Provider
Returns a new instance of Provider.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/boxcar_api.rb', line 11 def initialize(provider_key ={}, provider_secret = nil, screen_name = nil) if provider_key.kind_of? Hash url = provider_key[:url] url.chop! if url.end_with? '/' @provider_key = url.match(/https?:\/\/\S+\/(.*)$/)[1] self.class.base_uri(url + "/notifications") else @provider_key = provider_key @provider_secret = provider_secret @screen_name = screen_name self.class.base_uri "https://boxcar.io/devices/providers/#{@provider_key}/notifications" end end |
Instance Attribute Details
#provider_key ⇒ Object
Returns the value of attribute provider_key.
9 10 11 |
# File 'lib/boxcar_api.rb', line 9 def provider_key @provider_key end |
#provider_secret ⇒ Object
Returns the value of attribute provider_secret.
9 10 11 |
# File 'lib/boxcar_api.rb', line 9 def provider_secret @provider_secret end |
#screen_name ⇒ Object
Returns the value of attribute screen_name.
9 10 11 |
# File 'lib/boxcar_api.rb', line 9 def screen_name @screen_name end |
Instance Method Details
#batch_notify(emails, message, options = {:from_screen_name => screen_name, :from_remote_service_id => nil, :source_url => nil, :icon_url => nil}) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/boxcar_api.rb', line 59 def batch_notify(emails, , = {:from_screen_name => screen_name, :from_remote_service_id => nil, :source_url => nil, :icon_url => nil}) params = { :body => { :emails => emails, :notification => { :message => , :from_screen_name => [:from_screen_name], :from_remote_service_id => [:from_remote_service_id], :source_url => [:source_url], :icon_url => [:icon_url] } }} self.class.post("/", params) end |
#broadcast(message, options = {:from_screen_name => screen_name, :from_remote_service_id => nil, :source_url => nil, :icon_url => nil}) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/boxcar_api.rb', line 31 def broadcast(, = {:from_screen_name => screen_name, :from_remote_service_id => nil, :source_url => nil, :icon_url => nil}) params = { :body => { :secret => provider_secret, :notification => { :message => , :from_screen_name => [:from_screen_name], :from_remote_service_id => [:from_remote_service_id], :source_url => [:source_url], :icon_url => [:icon_url] } }} self.class.post("/broadcast", params) end |
#notify(email, message, options = {:from_screen_name => screen_name, :from_remote_service_id => nil, :source_url => nil, :icon_url => nil}) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/boxcar_api.rb', line 45 def notify(email, , = {:from_screen_name => screen_name, :from_remote_service_id => nil, :source_url => nil, :icon_url => nil}) params = { :body => { :email => email, :notification => { :message => , :from_screen_name => [:from_screen_name], :from_remote_service_id => [:from_remote_service_id], :source_url => [:source_url], :icon_url => [:icon_url] } }} self.class.post("/", params) end |
#subscribe(email) ⇒ Object
26 27 28 29 |
# File 'lib/boxcar_api.rb', line 26 def subscribe(email) params = { :body => { :email => email } } self.class.post("/subscribe", params) end |