Skip to content
Open
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
18 changes: 16 additions & 2 deletions lib/net/sms/bulksms.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require File.dirname(__FILE__) + '/bulksms/account'
require File.dirname(__FILE__) + '/bulksms/message'
require File.dirname(__FILE__) + '/bulksms/response'
require File.dirname(__FILE__) + '/bulksms/report'

module Net
module SMS
Expand All @@ -27,14 +28,17 @@ module BulkSMS
SPAIN = 'spain'
SAFRICA = 'safrica'
INTER = 'international'

class Service
# The port the message service rus on
MESSAGE_SERVICE_PORT = 80 #5567

# Path to the message service gateway
MESSAGE_SERVICE_PATH = '/eapi/submission/send_sms/2/2.0'

#path to the report service
REPORT_SERVICE_PATH = '/eapi/status_reports/get_report/2/2.0'

# returns an Account object for the credentials supplied to the service
attr_reader :account

Expand Down Expand Up @@ -68,7 +72,17 @@ def send_multiple(messages)
def send(message, recipient)
msg = Message.new(message, recipient)
self.send_message(msg)
end
end

#Get a message report
def get_report(batch_id)
payload = [@account.to_http_query, {:batch_id => batch_id}.to_query].join('&')
http = Net::HTTP.new(Service.bulksms_gateway(@country))
request = Net::HTTP::Get.new('/eapi/status_reports/get_report/2/2.0?' + payload)
response = http.request(request)
tokens = response.body.split('|')
Response.new(tokens[2].to_i, tokens[1], batch_id)
end

# Returns the gateway URL for the chosen country
def self.bulksms_gateway(country)
Expand Down
2 changes: 1 addition & 1 deletion lib/net/sms/bulksms/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module BulkSMS
class Account

# The port the account service runs on
SERVICE_PORT = 7512
SERVICE_PORT = 80#7512

# Path to the account service gateway
SERVICE_PATH = '/eapi/1.0/get_credits.mc'
Expand Down
4 changes: 2 additions & 2 deletions lib/net/sms/bulksms/message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ def initialize(message, recipient)
@message = message
@recipient = recipient
@msg_class = NORMAL_SMS
@want_report = 0
@want_report = 1
@routing_group = 2
@source_id = ''
@test_always_succeed = 0
@test_always_fail = 0
@concat_text_sms = 0
@concat_text_sms = 1
@concat_max_parts = 2
end

Expand Down
42 changes: 42 additions & 0 deletions lib/net/sms/bulksms/report.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
require 'net/http'
require 'uri'

module Net
module SMS
module BulkSMS
class Report
#Status from: http://developer.bulksms.com/eapi/status_reports/get_report/
STATUS_IN_PROGRESS = 0
STATUS_DELIVERED_UPSTREAM = 10
STATUS_DELIVERED_TO_MOBILE = 11
STATUS_DELIVERED_UPSTREAM_UNACKNOWLEDGED = 12
STATUS_INTERNAL_FATAL_ERROR = 22
STATUS_AUTH_FAILURE = 23
STATUS_DATA_VALIDATION_FAILURE = 24
STATUS_UNSUFICIENT_CREDITS = 25
STATUS_UPSTREAM_CREDITS_UNAVAILABLE = 26
STATUS_DAILY_QUOTA_EXCEEDED = 27
STATUS_UPSTREAM_QUOTA_EXCEEDED = 28
STATUS_MESSAGE_SENDING_CANCELED = 29
STATUS_UNROUTABLE = 31
STATUS_BLOCKED = 32
STATUS_CENSORED = 33
STATUS_TEMPORARILY_UNAVAILABLE = 40
STATUS_GENERIC_FAILURE = 50
STATUS_PHONE_DELIVERY_FAILED = 51
STATUS_NETWORK_DELIVERY_FAILED = 52
STATUS_MESSAGE_EXPIRED = 53
STATUS_FAILED_ON_REMOTE_NETWORK = 54
STATUS_REMOTELY_BLOCKED = 55
STATUS_REMOTELY_CENSORED = 56
STATUS_FAULT_ON_HANDSET = 57
STATUS_TRANSIENT_UPSTREAM_FAILURE = 60
STATUS_UPSTREAM_STATUS_FAILURE = 61
STATUS_UPSTREAM_CANCEL_FAILED = 62
STATUS_QUEUED_FOR_RETRY_AFTER_TEMPORARY_DELIVERY_FAILURE = 63
STATUS_QUEUED_FOR_RETRY_AFTER_TEMPORARY_DELIVERY_HANDSET_FAULT = 64
STATUS_UNKNOWN_UPSTREAM_STATUS = 70
end
end
end
end
Binary file added ruby-bulksms-0.4.4.gem
Binary file not shown.
3 changes: 2 additions & 1 deletion ruby-bulksms.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = "ruby-bulksms"
s.version = "0.4.3"
s.version = "0.4.5"
s.date = "2015-07-02"
s.summary = "Sending SMS using bulksms services"
s.email = "eng.basayel.said@gmail.com"
Expand All @@ -15,6 +15,7 @@ Gem::Specification.new do |s|
"lib/net/sms/bulksms/account.rb",
"lib/net/sms/bulksms/message.rb",
"lib/net/sms/bulksms/response.rb",
"lib/net/sms/bulksms/report.rb",
"lib/net/sms/bulksms.rb"
]
end