Class: MetaSms::Smsbox

Inherits:
ISmsProvider show all
Defined in:
lib/meta_sms/providers/smsbox.rb

Overview

This is a sms provider class which inherits ISmsProvider.

Author:

  • Shobhit Dixit

Constant Summary collapse

SMSBOX_PUBLIC_API_URI =
"http://smsbox.in/SecureApi.aspx?"
REQ_CONFIG_PARAMS =

Smsbox required config params = smsbox_user_name, smsbox_key, route, from Smsbox optional config params = type, logging

[:smsbox_user_name, :smsbox_key, :route, :from]

Constants inherited from ISmsProvider

ISmsProvider::REQUIRED_OPTIONS

Instance Method Summary collapse

Methods inherited from ISmsProvider

#check_for_valid_mobile_number, #check_required_option, #initialize

Constructor Details

This class inherits a constructor from MetaSms::ISmsProvider

Instance Method Details

#api_urlString

This method will make an api url

Returns:

  • (String)

    api_url

Author:

  • Shobhit Dixit



40
41
42
# File 'lib/meta_sms/providers/smsbox.rb', line 40

def api_url
  "#{SMSBOX_PUBLIC_API_URI}usr=#{smsbox_user_name}&key=#{smsbox_key}&smstype=#{MetaSms.config.type}&to=#{mobile_number}&msg=#{message_text}&rout=#{route}&from=#{from}"
end

#parsed_uriObject



32
33
34
# File 'lib/meta_sms/providers/smsbox.rb', line 32

def parsed_uri
  URI.parse(URI.encode(api_url.strip))
end

#send_smsType

Description of method

Returns:

  • (Type)

    description of returned object

Author:

  • Shobhit Dixit



21
22
23
24
25
26
27
28
29
30
# File 'lib/meta_sms/providers/smsbox.rb', line 21

def send_sms
  res = Net::HTTP.get parsed_uri
  case res
  when "Error : Authentication Failed. Please Try Again"
    ProviderUtility.authentication_error
  when "Error : Your balance is low for sending message."
    ProviderUtility.raise_low_balance_exception
  end
  res
end