Skip to content

Commit 1a0cf5b

Browse files
committed
Ran into an issue where the signature wasn't required since I used IP whitelisting. Talked with a tech at expedia and they mentioned a change on their end that if a signature is provided the ip whitelisting is ignored. This change will allow users to disable passing along the signature.
1 parent 4ce3a9b commit 1a0cf5b

File tree

6 files changed

+14
-4
lines changed

6 files changed

+14
-4
lines changed

README.textile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ Expedia.shared_secret = 'your_shared_secret'
3737
Expedia.locale = 'en_US'
3838
Expedia.currency_code = 'USD'
3939
Expedia.minor_rev = 13
40+
Expedia.use_signature = true # must be false if using ip whitelisting instead of signature
4041
# Optional configuration...
4142
Expedia.timeout = 1 # read timeout in sec
4243
Expedia.open_timeout = 1 # connection timeout in sec

lib/expedia.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,12 @@ module Expedia
2323
class << self
2424

2525
attr_accessor :cid, :api_key, :shared_secret, :format, :locale,
26-
:currency_code, :minor_rev, :timeout, :open_timeout
26+
:currency_code, :minor_rev, :timeout, :open_timeout, :use_signature
2727

2828
# Default way to setup Expedia. Run generator to create
2929
# a fresh initializer with all configuration values.
3030
def setup
31+
Expedia.use_signature = true #default
3132
yield self
3233
end
3334

lib/expedia/http_service.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,9 @@ def signature
9393
# Common Parameters required for every Call to Expedia Server.
9494
# @return [Hash] of all common parameters.
9595
def common_parameters
96-
{ :cid => Expedia.cid, :sig => signature, :apiKey => Expedia.api_key, :minorRev => Expedia.minor_rev,
97-
:_type => 'json', :locale => Expedia.locale, :currencyCode => Expedia.currency_code }
96+
params = { :cid => Expedia.cid, :apiKey => Expedia.api_key, :minorRev => Expedia.minor_rev, :_type => 'json', :locale => Expedia.locale, :currencyCode => Expedia.currency_code }
97+
params.merge!(:sig => signature) if Expedia.use_signature
98+
return params
9899
end
99100

100101
end

lib/expedia/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module Expedia
2-
VERSION = "0.0.6"
2+
VERSION = "0.0.7"
33
end

lib/generators/templates/expedia.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Expedia.setup do |config|
55
config.locale = 'en_US' # For Example 'de_DE'. Default is 'en_US'
66
config.currency_code = 'USD' # For Example 'EUR'. Default is 'USD'
77
config.minor_rev = 28 # between 4-28 as of Jan 2015. If not set, 4 is used by EAN.
8+
config.use_signature = true # An encoded signature is not required if ip whitelisting is used
89
# optional configurations...
910
config.timeout = 1 # read timeout in sec
1011
config.open_timeout = 1 # connection timeout in sec

spec/http_service_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
Expedia.cid = ''
4949
Expedia.api_key =''
5050
Expedia.shared_secret = ''
51+
Expedia.use_signature = true
5152

5253
end
5354

@@ -63,6 +64,11 @@
6364
Expedia::HTTPService.common_parameters.keys.should include(:sig)
6465
Expedia::HTTPService.common_parameters.keys.should include(:_type)
6566
end
67+
68+
it "checks to see if sig is removed from parameters" do
69+
Expedia.use_signature = false
70+
Expedia::HTTPService.common_parameters.keys.should_not include(:sig)
71+
end
6672
end
6773

6874
end

0 commit comments

Comments
 (0)