Module: ActionSms::ConnectionAdapters::TestHelpers::Tropo

Defined in:
lib/action_sms/connection_adapters/test_helpers/tropo.rb

Instance Method Summary collapse

Instance Method Details

#sample_configuration(options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/action_sms/connection_adapters/test_helpers/tropo.rb', line 6

def sample_configuration(options = {})
  config = {
    :adapter => "tropo",
    :outgoing_token => "Tropo Outgoing Token"
  }
  config.merge!(
    :authentication_key => "My Unique Authentication Key"
  ) if options[:authentication_key]
  config
end

#sample_delivery_response(options = {}) ⇒ Object



17
18
19
# File 'lib/action_sms/connection_adapters/test_helpers/tropo.rb', line 17

def sample_delivery_response(options = {})
  options[:failed] ? "<session><success>false</success><token></token><reason>FAILED TO ROUTE TOKEN</reason></session>" : "<session><success>true</success></session>"
end

#sample_incoming_sms(options = {}) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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
# File 'lib/action_sms/connection_adapters/test_helpers/tropo.rb', line 21

def sample_incoming_sms(options = {})
  options[:message] ||= "Endia kasdf ofeao"
  options[:to]      ||= "61447100308"
  options[:from]    ||= "61447100399"
  options[:date]    ||= "Mon Oct 11 09:21:38 UTC 2010"
  params = {
    "session" => {
      "id"=>"12349516546e59746d6a89a990466789",
      "account_id"=>"12345",
      "timestamp"=> options[:date],
      "user_type"=>"HUMAN",
      "initial_text"=> options[:message],
      "call_id"=>"123e71195545ad204bdd99f2070a7d86",
      "to"=>{
        "id"=> options[:to],
        "name"=>"unknown",
        "channel"=>"TEXT",
        "network"=>"SMS"
      },
      "from" => {
        "id"=> options[:from],
        "name"=>"unknown",
        "channel"=>"TEXT",
        "network"=>"SMS"
      },
      "headers" => {
        "_max-_forwards"=>"70",
        "_content-_length"=>"124",
        "_contact"=>"<sip:11.8.93.101:5066;transport=udp>",
        "_to"=>"<sip:[email protected]:5061;to=#{options[:to]}>",
        "_c_seq"=>"1 INVITE",
        "_via"=>"SIP/2.0/UDP 11.8.93.101:5066;branch=h0hG4bKk5sy1e",
        "_call-_i_d"=>"ieeg18",
        "_content-_type"=>"application/sdp",

  "_from"=>"<sip:[email protected];channel=private;user=#{options[:to]};msg=#{options[:message]};network=SMS;step=1>;tag=zm13kt"
      }
    }
  }
  params.merge!("authentication_key" => @config[:authentication_key]) unless options[:authentic] == false
  params
end