Class: Smess::Mblox
- Includes:
- Logging
- Defined in:
- lib/smess/outputs/mblox.rb
Instance Attribute Summary collapse
-
#password ⇒ Object
Returns the value of attribute password.
-
#profile_id ⇒ Object
Returns the value of attribute profile_id.
-
#shortcode ⇒ Object
Returns the value of attribute shortcode.
-
#sid ⇒ Object
Returns the value of attribute sid.
-
#username ⇒ Object
Returns the value of attribute username.
Attributes inherited from Output
Instance Method Summary collapse
- #deliver ⇒ Object
- #hash_data_for(xml_params) ⇒ Object
-
#initialize(config) ⇒ Mblox
constructor
A new instance of Mblox.
- #validate_config ⇒ Object
Methods included from Logging
Constructor Details
#initialize(config) ⇒ Mblox
Returns a new instance of Mblox.
8 9 10 11 |
# File 'lib/smess/outputs/mblox.rb', line 8 def initialize(config) super @results = [] end |
Instance Attribute Details
#password ⇒ Object
Returns the value of attribute password.
28 29 30 |
# File 'lib/smess/outputs/mblox.rb', line 28 def password @password end |
#profile_id ⇒ Object
Returns the value of attribute profile_id.
28 29 30 |
# File 'lib/smess/outputs/mblox.rb', line 28 def profile_id @profile_id end |
#shortcode ⇒ Object
Returns the value of attribute shortcode.
28 29 30 |
# File 'lib/smess/outputs/mblox.rb', line 28 def shortcode @shortcode end |
#sid ⇒ Object
Returns the value of attribute sid.
28 29 30 |
# File 'lib/smess/outputs/mblox.rb', line 28 def sid @sid end |
#username ⇒ Object
Returns the value of attribute username.
28 29 30 |
# File 'lib/smess/outputs/mblox.rb', line 28 def username @username end |
Instance Method Details
#deliver ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/smess/outputs/mblox.rb', line 13 def deliver xml_params = { subscriber_number: sms.to, message: "" } parts.each_with_index do |part, i| xml_params[:message] = part xml_params[:udh] = concatenation_udh(i+1, parts.length) if parts.length > 1 results << send_one_sms(xml_params) end results.first end |
#hash_data_for(xml_params) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/smess/outputs/mblox.rb', line 38 def hash_data_for(xml_params) rand = (SecureRandom.random_number*100000000).to_i @message_id = rand xml_hash = { notification_request: { notification_header: { partner_name: username, partner_password: password }, notification_list: { notification: { message: xml_params[:message], profile: profile_id, udh: xml_params.fetch(:udh,""), sender_i_d: from, # expire_date: "", # operator: "", # tariff: "", subscriber: { subscriber_number: xml_params[:subscriber_number], session_id: "" }, # tags: '<Tag Name=”Number”>56</Tag><Tag Name=”City”>Paris</Tag>', # service_desc: "", # content_type: "", service_id: sid, attributes!: { sender_i_d: { "Type" => "Shortcode" } } }, attributes!: { notification: { "SequenceNumber" => "1", "MessageType" => "SMS" } } # FlashSMS }, attributes!: { notification_list: { "BatchID" => @message_id } } }, attributes!: { notification_request: { "Version" => "3.5" } } } xml_hash[:notification_request][:notification_list][:notification].delete :udh unless xml_params.key? :udh xml_hash end |
#validate_config ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/smess/outputs/mblox.rb', line 29 def validate_config @username = config.fetch(:username) @password = config.fetch(:password) @shortcode = config.fetch(:shortcode) @profile_id = config.fetch(:profile_id) @sid = config.fetch(:sid) end |