Class: Jung::Drivers::Infobip::Api
- Inherits:
-
Object
- Object
- Jung::Drivers::Infobip::Api
- Defined in:
- lib/jung/drivers/infobip/api.rb
Instance Attribute Summary collapse
-
#api_url ⇒ Object
readonly
Returns the value of attribute api_url.
-
#error_messages ⇒ Object
readonly
Returns the value of attribute error_messages.
-
#errors ⇒ Object
Returns the value of attribute errors.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
-
#initialize(config) ⇒ Api
constructor
A new instance of Api.
- #send_sms(address, message, sender, options = {}) ⇒ Object
Constructor Details
#initialize(config) ⇒ Api
Returns a new instance of Api.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/jung/drivers/infobip/api.rb', line 10 def initialize(config) @username = config.["username"] @password = config.["password"] @api_url = config.["api_url"] @errors = [] @error_messages = { -2 => "Not enough credits", -3 => "Network not covered", -5 => "Invalid username or password", -6 => "Missing destination address", -7 => "Missing SMS text", -8 => "Missing sender name", -9 => "Invalid format of destination address", -10 => "Missing username", -11 => "Missing password", -13 => "Invalid destination address" } end |
Instance Attribute Details
#api_url ⇒ Object (readonly)
Returns the value of attribute api_url.
7 8 9 |
# File 'lib/jung/drivers/infobip/api.rb', line 7 def api_url @api_url end |
#error_messages ⇒ Object (readonly)
Returns the value of attribute error_messages.
7 8 9 |
# File 'lib/jung/drivers/infobip/api.rb', line 7 def @error_messages end |
#errors ⇒ Object
Returns the value of attribute errors.
8 9 10 |
# File 'lib/jung/drivers/infobip/api.rb', line 8 def errors @errors end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
7 8 9 |
# File 'lib/jung/drivers/infobip/api.rb', line 7 def password @password end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
7 8 9 |
# File 'lib/jung/drivers/infobip/api.rb', line 7 def username @username end |
Instance Method Details
#send_sms(address, message, sender, options = {}) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/jung/drivers/infobip/api.rb', line 30 def send_sms(address, , sender, = {}) count = Jung::Drivers::Infobip::SmsCounter.count .to_s type = count[:messages] > 1 ? 'LongSMS' : nil if count[:encoding] == :utf16 data_coding = 8 encoding = 'UTF-8' else data_coding = 1 encoding = nil = GSMEncoder.encode end do_get_request :sendsms, { :GSM => address, :SMSText => , :sender => sender, :Type => type, :DataCoding => data_coding, :encoding => encoding, }.merge() end |