wrapi 0.4.0 → 0.4.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 +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/wrapi/connection.rb +1 -1
- data/lib/wrapi/request.rb +19 -6
- data/lib/wrapi/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 893b19a80a388d0258ca30c2c170afa40c8f712cb767d7c5df4b066d1f59819a
|
4
|
+
data.tar.gz: 586720e6fe06df920b81fa5ed013dfb3fa6f12a51f0f74242561386d419178d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e1f86fe225c1787b85763d9b3c9a7dd570f24d2e2d2995c4e8e2a025b2aa31e7fccc9951fbf38bec6a6ae93c2c228abe8d93459060e2438269f0ed854d67e6a
|
7
|
+
data.tar.gz: f1e88c8ec6b4b4ad05fb8f53c63b7f6e779dc50d5a19b942f4fa2f84792511c5c910eb8ae7e249506e6f97a6ad9757d4857ef216203d5bc0dd3fb3e25560273f
|
data/CHANGELOG.md
CHANGED
@@ -25,3 +25,9 @@
|
|
25
25
|
request tests with mock including delete/put/post
|
26
26
|
- Entity fix issues returning json arrays
|
27
27
|
Request option to return raw response
|
28
|
+
|
29
|
+
## [0.4.1] - 2024-02-28
|
30
|
+
- fix issue with post body only supported as json
|
31
|
+
|
32
|
+
## [0.4.2] - 2024-03-03
|
33
|
+
- fix issue with escaping query parameters included in path
|
data/lib/wrapi/connection.rb
CHANGED
@@ -38,7 +38,7 @@ module WrAPI
|
|
38
38
|
|
39
39
|
# callback method to setup api authorization
|
40
40
|
def setup_authorization(connection)
|
41
|
-
connection.
|
41
|
+
connection.headers['Authorization'] = "Bearer #{access_token}" if access_token
|
42
42
|
end
|
43
43
|
|
44
44
|
# callback method to setup api headers
|
data/lib/wrapi/request.rb
CHANGED
@@ -19,7 +19,7 @@ module WrAPI
|
|
19
19
|
# @return nil if block given, otherwise complete concatenated json result set
|
20
20
|
def get_paged(path, options = {}, request_labda = nil)
|
21
21
|
raise ArgumentError,
|
22
|
-
"Pages requests should be json formatted (given format '#{format}')" unless
|
22
|
+
"Pages requests should be json formatted (given format '#{format}')" unless is_json?
|
23
23
|
|
24
24
|
result = []
|
25
25
|
pager = create_pager
|
@@ -71,6 +71,10 @@ module WrAPI
|
|
71
71
|
entity_response(response, raw)
|
72
72
|
end
|
73
73
|
|
74
|
+
def is_json?
|
75
|
+
format && 'json'.eql?(format.to_s)
|
76
|
+
end
|
77
|
+
|
74
78
|
private
|
75
79
|
|
76
80
|
def create_pager
|
@@ -82,20 +86,29 @@ module WrAPI
|
|
82
86
|
response = connection.send(method) do |request|
|
83
87
|
yield(request) if block_given?
|
84
88
|
uri = URI::Parser.new
|
89
|
+
_path = uri.parse(path)
|
85
90
|
case method
|
86
91
|
when :get, :delete
|
87
|
-
|
92
|
+
_path.path = uri.escape(_path.path)
|
93
|
+
request.url(_path.to_s, options)
|
88
94
|
when :post, :put
|
89
|
-
request.headers['Content-Type'] = "application/#{format}"
|
90
|
-
|
91
|
-
|
95
|
+
request.headers['Content-Type'] = "application/#{format}" unless request.headers['Content-Type']
|
96
|
+
_path.path = uri.escape(_path.path)
|
97
|
+
|
98
|
+
request.path = _path.to_s
|
99
|
+
|
100
|
+
if is_json? && !options.empty?
|
101
|
+
request.body = options.to_json
|
102
|
+
else
|
103
|
+
request.body = URI.encode_www_form(options) unless options.empty?
|
104
|
+
end
|
92
105
|
end
|
93
106
|
end
|
94
107
|
response
|
95
108
|
end
|
96
109
|
|
97
110
|
def entity_response(response, raw=false)
|
98
|
-
if
|
111
|
+
if is_json? && !raw
|
99
112
|
Entity.create(pagination_class.data(response.body))
|
100
113
|
else
|
101
114
|
response
|
data/lib/wrapi/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wrapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Janco Tanis
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|