Class: Nuntius::MessageBirdSmsProvider

Inherits:
BaseProvider show all
Defined in:
app/providers/nuntius/message_bird_sms_provider.rb

Overview

Send SMS messages using messagebird.com

Instance Attribute Summary

Attributes inherited from BaseProvider

#message

Instance Method Summary collapse

Methods inherited from BaseProvider

all_settings, #callback, class_from_name, #initialize, #name, setting_reader, states, transport

Constructor Details

This class inherits a constructor from Nuntius::BaseProvider

Instance Method Details

#deliverObject



16
17
18
19
20
21
# File 'app/providers/nuntius/message_bird_sms_provider.rb', line 16

def deliver
  response = client.message_create(message.from.present? ? message.from : from, message.to, message.text)
  message.provider_id = response.id
  message.status = translated_status(response.recipients["items"].first.status)
  message
end

#refreshObject



23
24
25
26
27
28
29
30
31
# File 'app/providers/nuntius/message_bird_sms_provider.rb', line 23

def refresh
  response = client.message(message.provider_id)
  message.provider_id = response.id
  message.status = translated_status(response.recipients["items"].first.status)
  Nuntius.config.logger.call.info "SMS #{message.to} status: #{message.status}"
  message
rescue => _e
  message
end