lib/rumour-ruby/client.rb in rumour-ruby-0.0.7 vs lib/rumour-ruby/client.rb in rumour-ruby-0.0.8
- old
+ new
@@ -14,17 +14,17 @@
@access_token = access_token || Rumour.configuration.access_token
raise Rumour::Errors::AuthenticationError.new('Missing access token') if @access_token.nil?
end
def send_text_message(sender, recipient, body)
- recipient = Rumour.configuration.intercept_text_message_recipient || recipient
+ recipient = intercept_tm_recipient || recipient
post('/text_messages', text_message: { from: sender, recipient: recipient, body: body })
end
- def send_push_notification(recipient, options= {})
- recipient = Rumour.configuration.intercept_push_notification_recipient || recipient
- post('/push_notifications', push_notification: { recipient: recipient }.merge(options))
+ def send_push_notification(recipients, options= {})
+ recipients = intercept_pn_recipients unless [intercept_pn_recipients].compact.empty?
+ post('/push_notifications', push_notification: { recipients: [recipients].flatten }.merge(options))
end
private
def post(url, params = {}, headers = {})
@@ -51,8 +51,16 @@
when 401
raise Rumour::Errors::AuthenticationError.new response_body['message']
when 500
raise Rumour::Errors::AuthenticationError.new response_body['message']
end
+ end
+
+ def intercept_tm_recipient
+ Rumour.configuration.intercept_text_message_recipient
+ end
+
+ def intercept_pn_recipients
+ Rumour.configuration.intercept_push_notification_recipients
end
end
end