Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions app/controllers/itexmo_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@ def incoming
to = params["gateway"]

unknown_params = params.except(
'originator', 'gateway', 'message', 'timestamp', # iTexmo API specification
'originator', 'gateway', 'message', 'timestamp', 'reference_id', # iTexmo API specification
'account_name', 'channel_name', 'incoming_password', 'controller', 'action' # Rails-generated parameters
)

msg = AtMessage.new
msg.from = "sms://#{from}"
msg.to = "sms://#{to}"
msg.body = params["message"]
msg.channel_relative_id = params["reference_id"]

account.route_at msg, channel

Expand All @@ -56,17 +57,20 @@ def delivery
ao_message = channel.ao_messages.find_by_id(params[:ao_message_id])

case params['Status'].try :downcase
when 'accepted'
when 'accepted', 'sent'
ao_message.state = 'delivered' if ['queued', 'pending'].include?(ao_message.state)
when 'delivered'
ao_message.state = 'confirmed'
when 'rejected'
ao_message.state = 'failed'
else
channel.logger.warning :channel_id => channel.id, :ao_message_id => ao_message.id, :message => "Received unknown-status delivery notification for AO #{ao_message.id}: #{params.to_json}"
end

ao_message.custom_attributes["itexmo_network_submit_time"] = params['NetworkSubmitTime'] if params['NetworkSubmitTime']
ao_message.custom_attributes["itexmo_client_submit_time"] = params['ClientSubmitTime'] if params['ClientSubmitTime']
ao_message.custom_attributes["itexmo_done_time"] = params['DoneTime'] if params['DoneTime']
ao_message.custom_attributes["itexmo_recipient_network"] = params['RecipientNetwork'] if params['RecipientNetwork']
ao_message.channel_relative_id ||= params['LongID']

ao_message.save!
Expand Down
2 changes: 1 addition & 1 deletion app/models/itexmo/itexmo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

class Itexmo
# endpoint shared internally by iTexmo
SMS_SEND_URL = 'https://api.itexmo.com/api/broadcast/access-code'
SMS_SEND_URL = 'https://api.itexmo.com/api/broadcast'

def self.send_message_parameters(params)
{
Expand Down
Loading