Class: Smess::Ipx

Inherits:
Output show all
Includes:
Logging
Defined in:
lib/smess/outputs/ipx.rb

Direct Known Subclasses

Ipxus

Instance Attribute Summary collapse

Attributes inherited from Output

#config

Instance Method Summary collapse

Methods included from Logging

#logger

Methods inherited from Output

#initialize

Constructor Details

This class inherits a constructor from Smess::Output

Instance Attribute Details

#account_nameObject

Returns the value of attribute account_name.



5
6
7
# File 'lib/smess/outputs/ipx.rb', line 5

def 
  @account_name
end

#passwordObject

Returns the value of attribute password.



5
6
7
# File 'lib/smess/outputs/ipx.rb', line 5

def password
  @password
end

#service_meta_data_t_mobile_usObject

Returns the value of attribute service_meta_data_t_mobile_us.



5
6
7
# File 'lib/smess/outputs/ipx.rb', line 5

def 
  @service_meta_data_t_mobile_us
end

#service_meta_data_verizonObject

Returns the value of attribute service_meta_data_verizon.



5
6
7
# File 'lib/smess/outputs/ipx.rb', line 5

def 
  @service_meta_data_verizon
end

#service_nameObject

Returns the value of attribute service_name.



5
6
7
# File 'lib/smess/outputs/ipx.rb', line 5

def service_name
  @service_name
end

#shortcodeObject

Returns the value of attribute shortcode.



5
6
7
# File 'lib/smess/outputs/ipx.rb', line 5

def shortcode
  @shortcode
end

#sms_urlObject

Returns the value of attribute sms_url.



5
6
7
# File 'lib/smess/outputs/ipx.rb', line 5

def sms_url
  @sms_url
end

#usernameObject

Returns the value of attribute username.



5
6
7
# File 'lib/smess/outputs/ipx.rb', line 5

def username
  @username
end

Instance Method Details

#deliverObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/smess/outputs/ipx.rb', line 24

def deliver
  set_originator(sms.originator)
  perform_operator_adaptation(sms.to)

  parts.each_with_index do |part, i|
    populate_soap_body(part, i)
    results << send_one_sms

    # halt and use fallback on error...
    if last_result_was_error
      logger.info "IPX_ERROR: #{results.last}"
      return fallback_to_twilio || results.first
    end
  end

  # we don't actually return the status for any of additional messages which is cheating
  results.first
end

#validate_configObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/smess/outputs/ipx.rb', line 6

def validate_config
  @sms_url                       = config.fetch(:sms_url)
  @username                      = config.fetch(:username)
  @password                      = config.fetch(:password)
  @shortcode                     = config.fetch(:shortcode)
  @account_name                  = config.fetch(:account_name)
  @service_name                  = config.fetch(:service_name)
  @service_meta_data_verizon     = config.fetch(:service_meta_data_verizon, "")
  @service_meta_data_t_mobile_us = config.fetch(:service_meta_data_t_mobile_us, "")

  @results = []
  @endpoint = sms_url
  @credentials = {
    name: username,
    pass: password
  }
end