whiplash-app 0.3.1 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/whiplash/app/connections.rb +54 -12
- data/lib/whiplash/app/version.rb +1 -1
- data/lib/whiplash/app.rb +2 -2
- metadata +3 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 369384d86e1a0027cef90b9d5bea67045c893f536993f56be5da2f0175e3fb44
|
4
|
+
data.tar.gz: 6026a3632e9a147bd1dab24357764967f582681635b5e25ddd48c0d909b1bfe2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 299b99f6deff5b2db76c6f43d3e1ba8ffe36b97cb778d6ff665cfe2dd1102a0c452f2183a80607510da51d3b31caae68430d177eb5aefee7cd112c95001fd210
|
7
|
+
data.tar.gz: '03359e08c25cf40976e93331b7b3519c1a5146ca44818bae79cd884ed7c7ca1e93dfe1eb01c0ce3a8350c3f835a8bb469473a4a35f2bc3d3cae935babd31a03a'
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module Whiplash
|
2
2
|
module App
|
3
3
|
module Connections
|
4
|
+
PER_PAGE_REQUEST_LIMIT = 50
|
4
5
|
|
5
6
|
def app_request(options = {})
|
6
7
|
if options[:params][:id]
|
@@ -8,38 +9,79 @@ module Whiplash
|
|
8
9
|
else
|
9
10
|
endpoint = options[:endpoint]
|
10
11
|
end
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
|
13
|
+
if options.dig(:options, :version)
|
14
|
+
version = options.dig(:options, :version)
|
15
|
+
else
|
16
|
+
version = "api/v2"
|
17
|
+
end
|
18
|
+
|
19
|
+
connection(version).send(options[:method],
|
20
|
+
endpoint,
|
21
|
+
options[:params],
|
22
|
+
sanitize_headers(options[:headers]))
|
23
|
+
end
|
24
|
+
|
25
|
+
def multi_page_get!(endpoint, params = {}, headers = nil)
|
26
|
+
results = []
|
27
|
+
page = 1
|
28
|
+
params[:per_page] = PER_PAGE_REQUEST_LIMIT
|
29
|
+
|
30
|
+
loop do
|
31
|
+
partial_results_request = app_request!(
|
32
|
+
method: :get,
|
33
|
+
endpoint: endpoint,
|
34
|
+
params: params,
|
35
|
+
headers: headers
|
36
|
+
).body
|
37
|
+
|
38
|
+
results << partial_results_request
|
39
|
+
results.flatten!
|
40
|
+
|
41
|
+
page += 1
|
42
|
+
params[:page] = page
|
43
|
+
|
44
|
+
break if partial_results_request.size == 0
|
45
|
+
break if partial_results_request.size < PER_PAGE_REQUEST_LIMIT
|
46
|
+
end
|
47
|
+
|
48
|
+
results
|
15
49
|
end
|
16
50
|
|
17
|
-
def delete(endpoint, params = {}, headers = nil)
|
51
|
+
def delete(endpoint, params = {}, headers = nil, options = {})
|
18
52
|
app_request(method: :delete,
|
19
53
|
endpoint: endpoint,
|
20
54
|
params: params,
|
21
|
-
headers: headers
|
55
|
+
headers: headers,
|
56
|
+
options: options
|
57
|
+
)
|
22
58
|
end
|
23
59
|
|
24
|
-
def get(endpoint, params = {}, headers = nil)
|
60
|
+
def get(endpoint, params = {}, headers = nil, options = {})
|
25
61
|
app_request(method: :get,
|
26
62
|
endpoint: endpoint,
|
27
63
|
params: params,
|
28
|
-
headers: headers
|
64
|
+
headers: headers,
|
65
|
+
options: options
|
66
|
+
)
|
29
67
|
end
|
30
68
|
|
31
|
-
def post(endpoint, params = {}, headers = nil)
|
69
|
+
def post(endpoint, params = {}, headers = nil, options = {})
|
32
70
|
app_request(method: :post,
|
33
71
|
endpoint: endpoint,
|
34
72
|
params: params,
|
35
|
-
headers: headers
|
73
|
+
headers: headers,
|
74
|
+
options: options
|
75
|
+
)
|
36
76
|
end
|
37
77
|
|
38
|
-
def put(endpoint, params = {}, headers = nil)
|
78
|
+
def put(endpoint, params = {}, headers = nil, options = {})
|
39
79
|
app_request(method: :put,
|
40
80
|
endpoint: endpoint,
|
41
81
|
params: params,
|
42
|
-
headers: headers
|
82
|
+
headers: headers,
|
83
|
+
options: options
|
84
|
+
)
|
43
85
|
end
|
44
86
|
|
45
87
|
def sanitize_headers(headers)
|
data/lib/whiplash/app/version.rb
CHANGED
data/lib/whiplash/app.rb
CHANGED
@@ -23,8 +23,8 @@ module Whiplash
|
|
23
23
|
OAuth2::Client.new(ENV["WHIPLASH_CLIENT_ID"], ENV["WHIPLASH_CLIENT_SECRET"], site: api_url)
|
24
24
|
end
|
25
25
|
|
26
|
-
def connection
|
27
|
-
out = Faraday.new [api_url,
|
26
|
+
def connection(version = "api/v2")
|
27
|
+
out = Faraday.new [api_url, version].join("/") do |conn|
|
28
28
|
conn.request :oauth2, token, token_type: "bearer"
|
29
29
|
conn.request :json
|
30
30
|
conn.response :json, :content_type => /\bjson$/
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: whiplash-app
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Don Sullivan, Mark Dickson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oauth2
|
@@ -137,11 +137,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
139
|
requirements: []
|
140
|
-
|
141
|
-
rubygems_version: 2.4.5.1
|
140
|
+
rubygems_version: 3.4.6
|
142
141
|
signing_key:
|
143
142
|
specification_version: 4
|
144
143
|
summary: this gem provides connectivity to the Whiplash API for authentication and
|
145
144
|
REST requests.
|
146
145
|
test_files: []
|
147
|
-
has_rdoc:
|