Class: Rumour::Client
- Inherits:
-
Object
- Object
- Rumour::Client
- Includes:
- HTTParty
- Defined in:
- lib/rumour-ruby/client.rb
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Returns the value of attribute access_token.
Instance Method Summary collapse
-
#initialize(access_token = nil) ⇒ Client
constructor
A new instance of Client.
- #send_push_notification(recipients, options = {}) ⇒ Object
- #send_text_message(sender, recipient, body) ⇒ Object
Constructor Details
#initialize(access_token = nil) ⇒ Client
Returns a new instance of Client.
13 14 15 16 |
# File 'lib/rumour-ruby/client.rb', line 13 def initialize(access_token = nil) @access_token = access_token || Rumour.configuration.access_token raise Rumour::Errors::AuthenticationError.new('Missing access token') if @access_token.nil? end |
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token.
11 12 13 |
# File 'lib/rumour-ruby/client.rb', line 11 def access_token @access_token end |
Instance Method Details
#send_push_notification(recipients, options = {}) ⇒ Object
23 24 25 26 |
# File 'lib/rumour-ruby/client.rb', line 23 def send_push_notification(recipients, = {}) recipients = intercept_pn_recipients unless [intercept_pn_recipients].flatten.compact.empty? post('/push_notifications', push_notification: { recipients: [recipients].flatten }.merge()) end |
#send_text_message(sender, recipient, body) ⇒ Object
18 19 20 21 |
# File 'lib/rumour-ruby/client.rb', line 18 def (sender, recipient, body) recipient = intercept_tm_recipient || recipient post('/text_messages', text_message: { from: sender, recipient: recipient, body: body }) end |