api_client 0.5.18 → 0.5.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/CHANGELOG.md +5 -0
- data/lib/api_client/base.rb +1 -1
- data/lib/api_client/connection/abstract.rb +11 -0
- data/lib/api_client/connection/basic.rb +13 -0
- data/lib/api_client/connection/middlewares/request/logger.rb +16 -4
- data/lib/api_client/scope.rb +4 -0
- data/lib/api_client/version.rb +1 -1
- data/spec/api_client/base/delegation_spec.rb +1 -1
- data/spec/api_client/connection/basic_spec.rb +8 -0
- data/spec/api_client/scope_spec.rb +5 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8eeb2b5ca77044aee74791f6fe2602caf0ec55fa
|
4
|
+
data.tar.gz: fc1580088fa93289ccff7c1c0f02aeb2ebd520da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34872ccc6e39ca70e0e00be9f80f387562beee0c26ac1e59ce14f936b379449ad262b141bd2be5f3589bff82c3489b20d62c1612078f66678dabe83f172acadc
|
7
|
+
data.tar.gz: 535cb5860e13acbe078d742430b182312e459663b8760c523b4ba23e9c8f0e9f53c10c2c2853d5f7f171d06cde06a491278bac86fdf1b7527042939e8aa334be
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
data/lib/api_client/base.rb
CHANGED
@@ -11,7 +11,7 @@ module ApiClient
|
|
11
11
|
extend ApiClient::Mixins::Delegation
|
12
12
|
extend ApiClient::Mixins::Configuration
|
13
13
|
|
14
|
-
delegate :fetch, :get, :put, :post, :delete, :headers, :endpoint, :options, :adapter, :params, :raw, :to => :scope
|
14
|
+
delegate :fetch, :get, :put, :post, :patch, :delete, :headers, :endpoint, :options, :adapter, :params, :raw, :to => :scope
|
15
15
|
|
16
16
|
dsl_accessor :format, :namespace
|
17
17
|
|
@@ -38,6 +38,17 @@ module ApiClient
|
|
38
38
|
def post(path, data = {}, headers = {})
|
39
39
|
end
|
40
40
|
|
41
|
+
#### ApiClient::Connection::Abstract#patch
|
42
|
+
# Performs a PATCH request
|
43
|
+
# Accepts three parameters:
|
44
|
+
#
|
45
|
+
# * path - the path request should go to
|
46
|
+
# * data - (optional) data sent in the request
|
47
|
+
# * headers - (optional) headers sent along in the request
|
48
|
+
#
|
49
|
+
def patch(path, data = {}, headers = {})
|
50
|
+
end
|
51
|
+
|
41
52
|
#### ApiClient::Connection::Abstract#put
|
42
53
|
# Performs a PUT request
|
43
54
|
# Accepts three parameters:
|
@@ -43,6 +43,19 @@ module ApiClient
|
|
43
43
|
exec_request(:post, path, data, headers)
|
44
44
|
end
|
45
45
|
|
46
|
+
#### ApiClient::Connection::Abstract#patch
|
47
|
+
# Performs a PATCH request
|
48
|
+
# Accepts three parameters:
|
49
|
+
#
|
50
|
+
# * path - the path request should go to
|
51
|
+
# * data - (optional) data sent in the request
|
52
|
+
# * headers - (optional) headers sent along in the request
|
53
|
+
#
|
54
|
+
# This method automatically adds the application token header
|
55
|
+
def patch(path, data = {}, headers = {})
|
56
|
+
exec_request(:patch, path, data, headers)
|
57
|
+
end
|
58
|
+
|
46
59
|
#### ApiClient::Connection::Abstract#put
|
47
60
|
# Performs a PUT request
|
48
61
|
# Accepts three parameters:
|
@@ -7,9 +7,9 @@ class ApiClient::Connection::Middlewares::Request::Logger < Faraday::Middleware
|
|
7
7
|
|
8
8
|
gather_request_debug_lines(env, debug_lines) if should_log_details
|
9
9
|
|
10
|
-
start =
|
10
|
+
start = CurrentTimestamp.milis
|
11
11
|
response = @app.call(env)
|
12
|
-
taken_sec = (
|
12
|
+
taken_sec = (CurrentTimestamp.milis - start) / 1000.0
|
13
13
|
|
14
14
|
gather_response_debug_lines(response, taken_sec, debug_lines) if response && should_log_details
|
15
15
|
|
@@ -46,7 +46,19 @@ class ApiClient::Connection::Middlewares::Request::Logger < Faraday::Middleware
|
|
46
46
|
debug_lines
|
47
47
|
end
|
48
48
|
|
49
|
-
|
50
|
-
|
49
|
+
class CurrentTimestamp
|
50
|
+
class << self
|
51
|
+
version = RUBY_VERSION.split('.').map(&:to_i)
|
52
|
+
|
53
|
+
if (version[0] < 2) || (version[0] == 2 && version[1] < 2)
|
54
|
+
def milis
|
55
|
+
(Time.now.to_f * 1000).to_i
|
56
|
+
end
|
57
|
+
else
|
58
|
+
def milis
|
59
|
+
Process.clock_gettime(Process::CLOCK_MONOTONIC, :millisecond)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
51
63
|
end
|
52
64
|
end
|
data/lib/api_client/scope.rb
CHANGED
data/lib/api_client/version.rb
CHANGED
@@ -5,7 +5,7 @@ describe ApiClient::Base do
|
|
5
5
|
it "delegates methods to scope" do
|
6
6
|
scope = double
|
7
7
|
ApiClient::Base.stub(:scope).and_return(scope)
|
8
|
-
[:fetch, :get, :put, :post, :delete, :headers, :endpoint, :options, :adapter, :params, :raw].each do |method|
|
8
|
+
[:fetch, :get, :put, :post, :patch, :delete, :headers, :endpoint, :options, :adapter, :params, :raw].each do |method|
|
9
9
|
scope.should_receive(method)
|
10
10
|
ApiClient::Base.send(method)
|
11
11
|
end
|
@@ -58,6 +58,14 @@ describe ApiClient::Connection::Basic do
|
|
58
58
|
@instance.post "/home", @params, @headers
|
59
59
|
end
|
60
60
|
|
61
|
+
it "can perform PATCH requests" do
|
62
|
+
@instance.handler.
|
63
|
+
should_receive(:run_request).
|
64
|
+
with(:patch, '/home', @params, @headers).
|
65
|
+
and_return(@response)
|
66
|
+
@instance.patch "/home", @params, @headers
|
67
|
+
end
|
68
|
+
|
61
69
|
it "can perform PUT requests" do
|
62
70
|
@instance.handler.
|
63
71
|
should_receive(:run_request).
|
@@ -147,6 +147,11 @@ describe ApiClient::Scope do
|
|
147
147
|
result.should == {"a"=> "1"}
|
148
148
|
end
|
149
149
|
|
150
|
+
it "makes a PATCH request" do
|
151
|
+
result = test_request :patch
|
152
|
+
result.should == {"a"=> "1"}
|
153
|
+
end
|
154
|
+
|
150
155
|
it "makes a PUT request" do
|
151
156
|
result = test_request :put
|
152
157
|
result.should == {"a"=> "1"}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: api_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcin Bunsch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -165,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
165
165
|
version: '0'
|
166
166
|
requirements: []
|
167
167
|
rubyforge_project: api_client
|
168
|
-
rubygems_version: 2.
|
168
|
+
rubygems_version: 2.4.5.5
|
169
169
|
signing_key:
|
170
170
|
specification_version: 3
|
171
171
|
summary: API client builder
|