Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

version bump

  • Loading branch information...
commit 1a438bc33d0d2c7082df74d78b50f618cb68083d 2 parents 8da4722 + ae6599a
Hemant Bhanoo authored
4 .gitignore
View
@@ -1,2 +1,4 @@
*~
-pkg/*
+pkg/*
+test/*
+*.svn
8 History.txt
View
@@ -1,6 +1,10 @@
-=== 1.1.4 / 2011-02-19
+=== 1.1.5 / 2010-06-02
-Various updates based on latest twilio docs
+* test support for call guid/call status
+
+=== 1.1.4 / 2010-05-09
+
+Backwards-compatible support for environment-specific twilio configuration
=== 1.1.1 / 2010-03-16
2  lib/trails.rb
View
@@ -1,5 +1,5 @@
module Trails
- VERSION = '1.1.4'
+ VERSION = '1.1.6'
end
begin
TwilioRest
37 lib/trails/test_helper.rb
View
@@ -1,4 +1,5 @@
require 'ostruct'
+require 'securerandom'
module Trails
module TestHelper
@@ -78,12 +79,15 @@ def modify_session_with_twilio_opts( session, as_twilio_opts )
header_modifier = lambda{ |h,o| modify_headers_with_twilio_opts( h, o ) }
param_modifier = lambda{ |p,o| modify_params_with_twilio_opts( p, o ) }
+ session_twilio_opts = as_twilio_opts.dup
+ session_twilio_opts[:call_guid] ||= generate_call_guid
+
session.metaclass.send( :define_method, :process_with_twilio_as_caller ) do |method, path, params, headers|
params ||= {}
headers ||= {}
- header_modifier.call( headers, as_twilio_opts )
- param_modifier.call( params, as_twilio_opts )
+ header_modifier.call( headers, session_twilio_opts )
+ param_modifier.call( params, session_twilio_opts )
process_without_twilio_as_caller( method, path, params, headers )
end # define process_with_twilio_as_caller
@@ -101,24 +105,29 @@ def modify_headers_with_twilio_opts( headers, as_twilio_opts )
end
def modify_params_with_twilio_opts( params, as_twilio_opts )
- options = as_twilio_opts.dup
-
- options[ 'Caller' ] = options.delete(:caller) || '4155551212'
- options[ 'Called' ] = options.delete(:called) || '6155556161'
- options[ 'From' ] = options.delete(:from) || '6665554321'
- options[ 'To' ] = options.delete(:to) || '3334445678'
- options['SmsMessageSid'] = 'DummyMessageSid' if( options[:sms] )
-
- valid_options = Hash[ *( options.select{ |k,v|
- Trails::Twilio::Incoming.const_get( 'INCOMING_VARS' ).
- include?( k ) }.flatten ) ]
- params.merge!( valid_options )
+ caller = as_twilio_opts[:caller] || '4155551212'
+ called = as_twilio_opts[:called] || '6155556161'
+ from = as_twilio_opts[:from] || '6665554321'
+ to = as_twilio_opts[:to] || '3334445678'
+ status = as_twilio_opts[:call_status] || 'in-progress'
+ guid = as_twilio_opts[ :call_guid ] || generate_call_guid
+ params['Caller'] = caller
+ params['Called'] = called
+ params['From'] = from
+ params['To'] = to
+ params['CallStatus'] ||= status
+ params['CallGuid'] ||= guid
+ params['SmsMessageSid'] = 'DummyMessageSid' if( as_twilio_opts[:sms] )
end
private
module IntegrationDSL
end
+ def generate_call_guid
+ 'CA_FAKE_' + SecureRandom.hex( 12 )
+ end
+
end # module TestHelper
end # module Trails
10 lib/trails/twilio/account.rb
View
@@ -178,7 +178,15 @@ def self.logger
return @logger
end
def self.config
- @@cfg ||= YAML::load_file( config_file )
+ @@all_cfg ||= YAML::load_file( config_file ).freeze
+ # allow per-environment configuration
+ @@cfg ||= if ( @@all_cfg.has_key?( RAILS_ENV ) )
+ @@all_cfg[ RAILS_ENV ]
+ elsif( @@all_cfg.has_key?( 'default' ) )
+ @@all_cfg['default']
+ else
+ @@all_cfg
+ end
end
def self.config_file
5 lib/trails/twilio/incoming.rb
View
@@ -15,11 +15,14 @@ def is_sms?
!sms_message_sid.blank?
end
+ def complete?
+ 'completed' == self.call_status.downcase
+ end
+
protected
attr_reader :request
INCOMING_VARS = [
- # Always available:
# Always available:
'CallSid', # A unique identifier for this call, generated by Twilio.
'AccountSid', # Your Twilio account id. It is 34 characters long, and always starts with the letters AC.
Please sign in to comment.
Something went wrong with that request. Please try again.