Module: TestHelpers::Tropo

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

Instance Method Summary collapse

Instance Method Details

#sample_delivery_receipt(options = {}) ⇒ Object

This is here simply so the current tests pass Tropo does not yet send delivery receipts



56
57
58
59
60
61
62
63
64
65
# File 'lib/action_sms_gateways/connection_adapters/test_helpers/tropo.rb', line 56

def sample_delivery_receipt(options = {})
  options[:message_id] ||= "123e71195545ad204bdd99f2070a7d86"
  options[:status] ||= "delivered"
  options[:date]   ||= "Mon Oct 11 09:21:38 UTC 2010"
  {
    "message_id"=> options[:message_id],
    "status"=> options[:status],
    "delivered_at"=> options[:date]
  }
end

#sample_delivery_response(options = {}) ⇒ Object



46
47
48
# File 'lib/action_sms_gateways/connection_adapters/test_helpers/tropo.rb', line 46

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

#sample_incoming_sms(options = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/action_sms_gateways/connection_adapters/test_helpers/tropo.rb', line 3

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

#sample_message_idObject



50
51
52
# File 'lib/action_sms_gateways/connection_adapters/test_helpers/tropo.rb', line 50

def sample_message_id
  "123e71195545ad204bdd99f2070a7d86"
end