itrp-client 1.1.1 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c3cc5dc93a1f84864b1550821fca09d2305b220e
4
- data.tar.gz: 8586c686d6519573534a9991288bb7bfe3ac7bf8
3
+ metadata.gz: a3f55cdbfd736e209d4e107fd750fecb819d34bb
4
+ data.tar.gz: 4b883ab29f9afb6b1fa055c95645fe43384d3c9f
5
5
  SHA512:
6
- metadata.gz: 2e7b2e85e0ab75834e490f0917cb7dd7e1fbae1fe0126519771349d244bec66e2422f9c483cd813bfb648e7745dfe5fefc13d710ff8531268c4c45ef7cec1c06
7
- data.tar.gz: e51bdaf000aca2f5b471428ca9575d488516766ea2626cfcc92400917b25b76468c53d3476023ae731bca7401c10699839d16efec78716019f14c2b3ff0207fa
6
+ metadata.gz: c53088678d9bdb63533a8380a83440adc2e10231719539af9415fd8944a882fb53e6ce0d4909b2cba7cc95b10ef7a95aab91a1fc3d64aafa76c33b83b8b4ed0f
7
+ data.tar.gz: ea7aa517b1cf619bc4e6118e16b8e7a2949cc95b78109f5972c799be79127601ad4a230a47362803536c7aa6b544c395c73a3bcb28e64ca34b2c9b01a5a12cf1
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- itrp-client (1.1.0)
4
+ itrp-client (1.1.1)
5
5
  activesupport
6
6
  gem_config
7
7
  mime-types
@@ -310,17 +310,17 @@ module Itrp
310
310
  Client.send(:prepend, SendWithRateLimitBlock)
311
311
 
312
312
  module SendWithRetries
313
- # Wraps the _send method with retries when the server does not responsd, see +initialize+ option +:retries+
313
+ # Wraps the _send method with retries when the server does not respond, see +initialize+ option +:retries+
314
314
  def _send(request, domain = @domain, port = @port, ssl = @ssl)
315
315
  retries = 0
316
316
  sleep_time = 2
317
317
  total_retry_time = 0
318
318
  begin
319
319
  _response = super(request, domain, port, ssl)
320
- @logger.warn { "Request failed, retry ##{retries += 1} in #{sleep_time} seconds: #{_response.message}" } and sleep(sleep_time) if _response.empty? && option(:max_retry_time) > 0
320
+ @logger.warn { "Request failed, retry ##{retries += 1} in #{sleep_time} seconds: #{_response.message}" } and sleep(sleep_time) if (_response.raw.code.to_s != '204' && _response.empty?) && option(:max_retry_time) > 0
321
321
  total_retry_time += sleep_time
322
322
  sleep_time *= 2
323
- end while _response.empty? && total_retry_time < option(:max_retry_time)
323
+ end while (_response.raw.code.to_s != '204' && _response.empty?) && total_retry_time < option(:max_retry_time)
324
324
  _response
325
325
  end
326
326
  end
@@ -50,7 +50,7 @@ module Itrp
50
50
 
51
51
  # +true+ if the server did not respond at all
52
52
  def empty?
53
- @response.body.nil?
53
+ @response.body.blank?
54
54
  end
55
55
 
56
56
  # +true+ if no 'message' is given (and the JSON could be parsed)
@@ -1,5 +1,5 @@
1
1
  module Itrp
2
2
  class Client
3
- VERSION = '1.1.1'
3
+ VERSION = '1.1.2'
4
4
  end
5
5
  end
@@ -218,9 +218,11 @@ describe Itrp::Client do
218
218
  context 'delete' do
219
219
  it 'should send delete requests with parameters and headers' do
220
220
  client = Itrp::Client.new(api_token: 'secret', max_retry_time: -1)
221
- stub = stub_request(:delete, 'https://api.itrp.com/v1/people?id=value').with(basic_auth: ['secret', 'x']).with(headers: {'X-ITRP-Custom' => 'custom'}).to_return(body: {id: 101}.to_json)
222
- client.delete('people', {id: 'value'}, {'X-ITRP-Custom' => 'custom'})
221
+ stub = stub_request(:delete, 'https://api.itrp.com/v1/people?id=value').with(basic_auth: ['secret', 'x']).with(headers: {'X-ITRP-Custom' => 'custom'}).to_return(body: '', status: 204)
222
+ response = client.delete('people', {id: 'value'}, {'X-ITRP-Custom' => 'custom'})
223
223
  expect(stub).to have_been_requested
224
+ expect(response.valid?).to be_truthy
225
+ expect(response.json).to eq({})
224
226
  end
225
227
  end
226
228
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: itrp-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - ITRP
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-16 00:00:00.000000000 Z
11
+ date: 2017-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gem_config
@@ -171,7 +171,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
171
171
  version: '0'
172
172
  requirements: []
173
173
  rubyforge_project:
174
- rubygems_version: 2.4.6
174
+ rubygems_version: 2.2.2
175
175
  signing_key:
176
176
  specification_version: 4
177
177
  summary: Client for accessing the ITRP REST API