tddium_client 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE.txt ADDED
@@ -0,0 +1,13 @@
1
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
2
+ IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
3
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
4
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOLANO LABS BE LIABLE FOR
5
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
6
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
7
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
8
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
9
+ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
10
+ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
11
+ POSSIBILITY OF SUCH DAMAGE.
12
+
13
+ Copyright (c) 2011, 2012 Solano Labs All Rights Reserved
data/lib/tddium_client.rb CHANGED
@@ -1,10 +1,9 @@
1
- =begin
2
- Copyright (c) 2011 Solano Labs All Rights Reserved
3
- =end
1
+ # Copyright (c) 2011, 2012 Solano Labs All Rights Reserved
4
2
 
5
3
  require 'rubygems'
6
4
  require 'httparty'
7
5
  require 'json'
6
+ require 'securerandom'
8
7
  require File.expand_path("../tddium_client/version", __FILE__)
9
8
 
10
9
  module TddiumClient
@@ -115,15 +114,18 @@ module TddiumClient
115
114
  "caller_version" => caller_version}
116
115
  end
117
116
 
118
- def call_api(method, api_path, params = {}, api_key = nil, retries = 5)
117
+ def call_api(method, api_path, params = {}, api_key = nil, retries = 5, xid=nil)
119
118
  headers = {'Content-Type' => 'application/json'}
120
119
  headers.merge!(API_KEY_HEADER => api_key) if api_key
121
120
  headers.merge!(CLIENT_VERSION_HEADER => version_header)
122
121
 
122
+ xid ||= xid_gen
123
+ call_params = params.merge({:xid => xid})
124
+
123
125
  tries = 0
124
126
 
125
127
  begin
126
- http = self.class.send(method, tddium_uri(api_path), :body => params.to_json, :headers => headers)
128
+ http = self.class.send(method, tddium_uri(api_path), :body => call_params.to_json, :headers => headers)
127
129
  rescue Errno::ECONNREFUSED, Errno::ETIMEDOUT, Timeout::Error, OpenSSL::SSL::SSLError, OpenSSL::SSL::Session::SessionError
128
130
  tries += 1
129
131
  retry if retries > 0 && tries <= retries
@@ -142,6 +144,9 @@ module TddiumClient
142
144
  @tddium_config["caller_version"] = version
143
145
  end
144
146
 
147
+ def xid_gen
148
+ return SecureRandom.hex(8)
149
+ end
145
150
 
146
151
  protected
147
152
 
@@ -1,6 +1,4 @@
1
- =begin
2
- Copyright (c) 2011 Solano Labs All Rights Reserved
3
- =end
1
+ # Copyright (c) 2011, 2012 Solano Labs All Rights Reserved
4
2
 
5
3
  require 'fakefs'
6
4
 
@@ -1,7 +1,5 @@
1
- =begin
2
- Copyright (c) 2011 Solano Labs All Rights Reserved
3
- =end
1
+ # Copyright (c) 2011, 2012 Solano Labs All Rights Reserved
4
2
 
5
3
  module TddiumClient
6
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
7
5
  end
@@ -1,6 +1,4 @@
1
- =begin
2
- Copyright (c) 2011 Solano Labs All Rights Reserved
3
- =end
1
+ # Copyright (c) 2011, 2012 Solano Labs All Rights Reserved
4
2
 
5
3
  require "spec_helper"
6
4
 
@@ -349,7 +347,10 @@ describe "TddiumClient" do
349
347
  context "('#{EXAMPLE_HTTP_METHOD}', '#{EXAMPLE_TDDIUM_RESOURCE}') # without params" do
350
348
  it "should not include any request params" do
351
349
  tddium_client.call_api(EXAMPLE_HTTP_METHOD, EXAMPLE_TDDIUM_RESOURCE)
352
- parse_request_params.should == {}
350
+ params = parse_request_params
351
+ params.member?('xid').should be_true
352
+ params.delete('xid')
353
+ params.should == {}
353
354
  end
354
355
  end
355
356
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: tddium_client
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.0
5
+ version: 0.3.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jay Moorthi
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-04-01 00:00:00 Z
13
+ date: 2012-06-11 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: httparty
@@ -114,6 +114,7 @@ files:
114
114
  - .rspec
115
115
  - Gemfile
116
116
  - Gemfile.lock
117
+ - LICENSE.txt
117
118
  - README
118
119
  - Rakefile
119
120
  - config/environment.yml
@@ -149,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
149
150
  requirements: []
150
151
 
151
152
  rubyforge_project: tddium_client
152
- rubygems_version: 1.8.11
153
+ rubygems_version: 1.8.24
153
154
  signing_key:
154
155
  specification_version: 3
155
156
  summary: tddium Client Gem