whiplash-app 0.3.1 → 0.3.4

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
- SHA1:
3
- metadata.gz: 9acc3cba8b3e4cef52a2068e9fe3f16c81d7815f
4
- data.tar.gz: c351232810577e3f357512c9c4b7e550bf0dbb2b
2
+ SHA256:
3
+ metadata.gz: cd3b64628b99161af910828d6ebd9e5f07db20394b92d1b075ff69ffc913a323
4
+ data.tar.gz: d5f7700773c10a71ae5a8f2e450cffb1f333dad0c5f38c2ad1a82d271cad52e7
5
5
  SHA512:
6
- metadata.gz: f4bc91939f74965a430b4c5d6f21ca888d568fe9e31fa3e9ef67d94f45324768f983693e8db756836408768ad40cfa7fd9047ffa352fcaabcc88c44332dcc02a
7
- data.tar.gz: 25b613c592e8c728bf9b447624df347e2989bf2b04e2109b371ea200ae57a494883d2382c2a90b56abd8d4e62a56e43bdcb30765aea81b68e5b99d0cb44493f9
6
+ metadata.gz: 554c41b60a38f3762cf11172842942efe564d9dd929d35298c39647083917f36f85a28b80941bf8c6e10abdad6629e69fc8907f89c74e7f48107e609913a5a3d
7
+ data.tar.gz: a40d77b5a296b0d98291bb42158e098d34d9e9dd5945d4257774332ad7ad49d15d5305496413119ae1763dc972e12706a4fa80916e0d547ae029a6c2ab1e628d
@@ -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
- connection.send(options[:method],
12
- endpoint,
13
- options[:params],
14
- sanitize_headers(options[:headers]))
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)
@@ -1,5 +1,5 @@
1
1
  module Whiplash
2
2
  module App
3
- VERSION = "0.3.1"
3
+ VERSION = "0.3.4"
4
4
  end
5
5
  end
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, "api/v2"].join("/") do |conn|
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.1
4
+ version: 0.3.4
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: 2017-07-17 00:00:00.000000000 Z
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
- rubyforge_project:
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: