expedia 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e0bf61f60677e53b4b72d7f71dd317598d9f89af
4
- data.tar.gz: 8e7e52d75105b1700525ad01bf60bbaa25f6bdc4
3
+ metadata.gz: ccf1ce4946c74fe5bf410bb1233ec0e4a2843ce6
4
+ data.tar.gz: ac8f8962e58013fe545abe46698736239db8b654
5
5
  SHA512:
6
- metadata.gz: 73fe7866b28ecb559b2c9ad683418b52470948cf8b7480e80e3b21258fd1649daa1b89fa25b6602f4ba7852b9eff1b70e2a6283ac857b3e491dfd003b76c4708
7
- data.tar.gz: 6431d464ea5522a20b15e05e3a691c9429f8087588fd0c50bd541368faac2aaddd34596a47985cb7165583ccdae95b2c26b5ebc38082b1d66ea1524cdb4aa37e
6
+ metadata.gz: b3670577a70da4abda79ff55c962f00ddf4ace1c822950cbfa4a1e1531650f182d5d4a5a66f56ee4d92ceadb36a26f7162fea8ae7a455ecdee23da85223bddf3
7
+ data.tar.gz: 42902849d59db49d22a0ff2a0d71b0dac8b65a8a441750320625f1404f34706682465efd84e04e0a769d5a4f0d152387d0eeb8fd02bdfeb70ba0b1049e9365dd
@@ -0,0 +1,11 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - "1.9.2"
5
+ - "1.9.3"
6
+ - "2.0.0"
7
+ - "2.1"
8
+ - jruby-19mode # JRuby in 1.9 mode
9
+ - rbx
10
+
11
+ sudo: false
@@ -1,4 +1,4 @@
1
- h1. Expedia !https://travis-ci.org/zaidakram/expedia.svg?branch=master(Expedia)!:https://travis-ci.org/zaidakram/expedia
1
+ h1. Expedia !https://travis-ci.org/zaidakram/expedia.svg?branch=master(Expedia)!:https://travis-ci.org/zaidakram/expedia !https://badge.fury.io/rb/expedia.svg!:http://badge.fury.io/rb/expedia
2
2
 
3
3
  Expedia is a ruby wrapper for ["EAN - Expedia Affiliate Network":http://www.expediaaffiliate.com] APIs.
4
4
 
@@ -135,3 +135,10 @@ Expedia::Utils.logger = Rails.logger
135
135
  </pre>
136
136
 
137
137
 
138
+ h3. Contributing
139
+
140
+ 1. Fork it
141
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
142
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
143
+ 4. Push to the branch (`git push origin my-new-feature`)
144
+ 5. Create new Pull Request
@@ -23,7 +23,7 @@ module Expedia
23
23
  class << self
24
24
 
25
25
  attr_accessor :cid, :api_key, :shared_secret, :format, :locale,
26
- :currency_code, :minor_rev
26
+ :currency_code, :minor_rev, :timeout, :open_timeout
27
27
 
28
28
  # Default way to setup Expedia. Run generator to create
29
29
  # a fresh initializer with all configuration values.
@@ -6,11 +6,9 @@ module Expedia
6
6
  # @param args [Hash] All the params required for 'get_list' call
7
7
  # @return [Expedia::HTTPService::Response] on success. A response object representing the results from Expedia
8
8
  # @return [Expedia::APIError] on Error.
9
- # @note A POST request is made instead of GET if 'numberOfResults' > 200
9
+ # @note A POST request is made instead of GET if 'hotelIdList' length > 200
10
10
  def get_list(args)
11
- no_of_results = 'numberOfResults'
12
- method = (args[no_of_results.to_sym].to_i > 200 || args[no_of_results].to_i > 200) ||
13
- args[no_of_results.downcase.to_sym].to_i > 200 || args[no_of_results.downcase].to_i > 200 ? :post : :get
11
+ method = (args[:hotelIdList] || args["hotelIdList"] || []).length > 200 ? :post : :get
14
12
  services('/ean-services/rs/hotel/v3/list', args, method)
15
13
  end
16
14
 
@@ -43,7 +41,7 @@ module Expedia
43
41
  end
44
42
 
45
43
  def get_reservation(args)
46
- HTTPService.make_request('/ean-services/rs/hotel/v3/res', args, :post, { :reservation_api => true, :use_ssl => true })
44
+ HTTPService.make_request('/ean-services/rs/hotel/v3/res', args, :post, { :reservation_api => true, :use_ssl => true, :ignore_timeout => true })
47
45
  end
48
46
 
49
47
  def get_payment_info(args)
@@ -27,6 +27,22 @@ module Expedia
27
27
  "#{options[:use_ssl] ? "https" : "http"}://#{server}"
28
28
  end
29
29
 
30
+
31
+ # Adding open and read timeouts
32
+ #
33
+ # open timeout - the amount of time you are willing to wait for 'opening a connection'
34
+ # (read) timeout - the amount of time you are willing to wait for some data to be received from the connected party.
35
+ # @param conn - Faraday connection object
36
+ #
37
+ # @return the connection obj with the timeouts set if they have been initialized
38
+ def add_timeouts(conn, options)
39
+ if !options[:ignore_timeout]
40
+ conn.options.timeout = Expedia.timeout.to_i if Expedia.timeout.present?
41
+ conn.options.open_timeout = Expedia.open_timeout.to_i if Expedia.open_timeout.present?
42
+ end
43
+ conn
44
+ end
45
+
30
46
  # Makes a request directly to Expedia.
31
47
  # @note You'll rarely need to call this method directly.
32
48
  #
@@ -47,6 +63,7 @@ module Expedia
47
63
  request_options = {:params => (verb == :get ? args : {})}
48
64
  # set up our Faraday connection
49
65
  conn = Faraday.new(server(options), request_options)
66
+ conn = add_timeouts(conn, options)
50
67
  response = conn.send(verb, path, (verb == :post ? args : {}))
51
68
 
52
69
  # Log URL and params information
@@ -61,36 +78,18 @@ module Expedia
61
78
  end
62
79
  end
63
80
 
64
- # Encodes a given hash into a query string.
65
- #
66
- # @param params_hash a hash of values to CGI-encode and appropriately join
67
- #
68
- # @example
69
- # Expedia.http_service.encode_params({:a => 2, :b => "My String"})
70
- # => "a=2&b=My+String"
71
- #
72
- # @return the appropriately-encoded string
73
- # Method currently not in use.
74
- def encode_params(param_hash)
75
- ((param_hash || {}).sort_by{|k, v| k.to_s}.collect do |key_and_value|
76
- key_and_value[1] = MultiJson.dump(key_and_value[1]) unless key_and_value[1].is_a? String
77
- "#{key_and_value[0].to_s}=#{CGI.escape key_and_value[1]}"
78
- end).join("&")
79
- end
80
-
81
-
82
81
  # Creates a Signature for Expedia using MD5 Checksum Auth.
83
82
  # Shared and Api keys are required for Signature along with the current utc time.
84
83
  def signature
85
84
  if Expedia.cid && Expedia.api_key && Expedia.shared_secret
86
- Digest::MD5.hexdigest(Expedia.api_key+Expedia.shared_secret+Time.now.utc.to_i.to_s)
85
+ Digest::MD5.hexdigest(Expedia.api_key + Expedia.shared_secret + Time.now.utc.to_i.to_s)
87
86
  else
88
87
  raise Expedia::AuthCredentialsError, "cid, api_key and shared_secret are required for Expedia Authentication."
89
88
  end
90
89
  end
91
90
 
92
91
  # Common Parameters required for every Call to Expedia Server.
93
- #
92
+ # @return [Hash] of all common parameters.
94
93
  def common_parameters
95
94
  { :cid => Expedia.cid, :sig => signature, :apiKey => Expedia.api_key, :minorRev => Expedia.minor_rev,
96
95
  :_type => 'json', :locale => Expedia.locale, :currencyCode => Expedia.currency_code }
@@ -1,3 +1,3 @@
1
1
  module Expedia
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -4,5 +4,8 @@ Expedia.setup do |config|
4
4
  config.shared_secret = 'your_shared_secret'
5
5
  config.locale = 'en_US' # For Example 'de_DE'. Default is 'en_US'
6
6
  config.currency_code = 'USD' # For Example 'EUR'. Default is 'USD'
7
- config.minor_rev = 26 # between 4-26 as of July 2014. Default is 4. 26 being latest
7
+ config.minor_rev = 28 # between 4-28 as of Jan 2015. If not set, 4 is used by EAN.
8
+ # optional configurations...
9
+ config.timeout = 1 # read timeout in sec
10
+ config.open_timeout = 1 # connection timeout in sec
8
11
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: expedia
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zaid Akram
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-15 00:00:00.000000000 Z
11
+ date: 2015-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -76,6 +76,7 @@ extra_rdoc_files: []
76
76
  files:
77
77
  - .gitignore
78
78
  - .rspec
79
+ - .travis.yml
79
80
  - Gemfile
80
81
  - LICENSE.txt
81
82
  - README.textile