Class: Rumour::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/rumour-ruby/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_tokenObject

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, options= {})
  recipients = intercept_pn_recipients unless [intercept_pn_recipients].flatten.compact.empty?
  post('/push_notifications', push_notification: { recipients: [recipients].flatten }.merge(options))
end

#send_text_message(sender, recipient, body) ⇒ Object



18
19
20
21
# File 'lib/rumour-ruby/client.rb', line 18

def send_text_message(sender, recipient, body)
  recipient = intercept_tm_recipient || recipient
  post('/text_messages', text_message: { from: sender, recipient: recipient, body: body })
end