Skip to content

Commit

Permalink
Merge pull request #19 from KellyMahan/master
Browse files Browse the repository at this point in the history
Don't include Signature when IP White-listing is being used.
  • Loading branch information
zaidakram committed Aug 3, 2015
2 parents 4ce3a9b + 1a0cf5b commit c4a8275
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.textile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Expedia.shared_secret = 'your_shared_secret'
Expedia.locale = 'en_US'
Expedia.currency_code = 'USD'
Expedia.minor_rev = 13
Expedia.use_signature = true # must be false if using ip whitelisting instead of signature
# Optional configuration...
Expedia.timeout = 1 # read timeout in sec
Expedia.open_timeout = 1 # connection timeout in sec
Expand Down
3 changes: 2 additions & 1 deletion lib/expedia.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ module Expedia
class << self

attr_accessor :cid, :api_key, :shared_secret, :format, :locale,
:currency_code, :minor_rev, :timeout, :open_timeout
:currency_code, :minor_rev, :timeout, :open_timeout, :use_signature

# Default way to setup Expedia. Run generator to create
# a fresh initializer with all configuration values.
def setup
Expedia.use_signature = true #default
yield self
end

Expand Down
5 changes: 3 additions & 2 deletions lib/expedia/http_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,9 @@ def signature
# Common Parameters required for every Call to Expedia Server.
# @return [Hash] of all common parameters.
def common_parameters
{ :cid => Expedia.cid, :sig => signature, :apiKey => Expedia.api_key, :minorRev => Expedia.minor_rev,
:_type => 'json', :locale => Expedia.locale, :currencyCode => Expedia.currency_code }
params = { :cid => Expedia.cid, :apiKey => Expedia.api_key, :minorRev => Expedia.minor_rev, :_type => 'json', :locale => Expedia.locale, :currencyCode => Expedia.currency_code }
params.merge!(:sig => signature) if Expedia.use_signature
return params
end

end
Expand Down
2 changes: 1 addition & 1 deletion lib/expedia/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Expedia
VERSION = "0.0.6"
VERSION = "0.0.7"
end
1 change: 1 addition & 0 deletions lib/generators/templates/expedia.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Expedia.setup do |config|
config.locale = 'en_US' # For Example 'de_DE'. Default is 'en_US'
config.currency_code = 'USD' # For Example 'EUR'. Default is 'USD'
config.minor_rev = 28 # between 4-28 as of Jan 2015. If not set, 4 is used by EAN.
config.use_signature = true # An encoded signature is not required if ip whitelisting is used
# optional configurations...
config.timeout = 1 # read timeout in sec
config.open_timeout = 1 # connection timeout in sec
Expand Down
6 changes: 6 additions & 0 deletions spec/http_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
Expedia.cid = ''
Expedia.api_key =''
Expedia.shared_secret = ''
Expedia.use_signature = true

end

Expand All @@ -63,6 +64,11 @@
Expedia::HTTPService.common_parameters.keys.should include(:sig)
Expedia::HTTPService.common_parameters.keys.should include(:_type)
end

it "checks to see if sig is removed from parameters" do
Expedia.use_signature = false
Expedia::HTTPService.common_parameters.keys.should_not include(:sig)
end
end

end

0 comments on commit c4a8275

Please sign in to comment.