wrapi 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -4
- data/lib/wrapi/entity.rb +8 -7
- data/lib/wrapi/request.rb +2 -5
- data/lib/wrapi/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97aeddbe26edc1de844235ad80174e81dd4b87ab3f941349990b49d2822526cb
|
4
|
+
data.tar.gz: c80266d83ff3daf66525127ac22e5863a196411589976a212480f00145d31d53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00b16d27142172f649374484cdd7a05177057a24c92fb81cc7b090543f39d23ec4d5e3cd5e7125dfd077985f1a92270acede8aabfe9eb0ae644ec53c552a3235
|
7
|
+
data.tar.gz: 000f1f156009059626f8be2d0528ab9f8980e57349f10e749763d685bbd68b208c0ba24f1d6bdc67c4b0a671c23bbd76bd93cc57153edf90f7cd7b330906ccca
|
data/CHANGELOG.md
CHANGED
@@ -26,8 +26,11 @@
|
|
26
26
|
- Entity fix issues returning json arrays
|
27
27
|
Request option to return raw response
|
28
28
|
|
29
|
-
|
30
|
-
|
29
|
+
## [0.4.1] - 2024-02-28
|
30
|
+
- fix issue with post body only supported as json
|
31
31
|
|
32
|
-
|
33
|
-
|
32
|
+
## [0.4.2] - 2024-03-03
|
33
|
+
- fix issue with escaping query parameters included in path
|
34
|
+
|
35
|
+
## [0.4.3] - 2024-03-07
|
36
|
+
- fix issue json generation for updated attributes
|
data/lib/wrapi/entity.rb
CHANGED
@@ -8,7 +8,6 @@ module WrAPI
|
|
8
8
|
|
9
9
|
# factory method to create entity or array of entities
|
10
10
|
def self.create(attributes)
|
11
|
-
|
12
11
|
if attributes.is_a? Array
|
13
12
|
Entity.entify(attributes)
|
14
13
|
else
|
@@ -17,8 +16,6 @@ module WrAPI
|
|
17
16
|
end
|
18
17
|
|
19
18
|
def initialize(attributes)
|
20
|
-
@_raw = attributes
|
21
|
-
|
22
19
|
case attributes
|
23
20
|
when Hash
|
24
21
|
@attributes = attributes.clone.transform_keys(&:to_s)
|
@@ -50,7 +47,7 @@ module WrAPI
|
|
50
47
|
end
|
51
48
|
|
52
49
|
def to_json(options = {})
|
53
|
-
@
|
50
|
+
@attributes.to_json
|
54
51
|
end
|
55
52
|
|
56
53
|
def accessor(method)
|
@@ -66,9 +63,13 @@ module WrAPI
|
|
66
63
|
end
|
67
64
|
|
68
65
|
def self.entify(a)
|
69
|
-
a.
|
70
|
-
|
71
|
-
|
66
|
+
if ( a.count > 0 ) && ( a.first.is_a? Hash )
|
67
|
+
a.dup.map do |item|
|
68
|
+
#item.is_a?(Hash) ? self.class.new(item) : item
|
69
|
+
Entity.create(item)
|
70
|
+
end
|
71
|
+
else
|
72
|
+
a
|
72
73
|
end
|
73
74
|
end
|
74
75
|
end
|
data/lib/wrapi/request.rb
CHANGED
@@ -85,18 +85,15 @@ module WrAPI
|
|
85
85
|
def request(method, path, options)
|
86
86
|
response = connection.send(method) do |request|
|
87
87
|
yield(request) if block_given?
|
88
|
+
request.headers['Content-Type'] = "application/#{format}" unless request.headers['Content-Type']
|
88
89
|
uri = URI::Parser.new
|
89
90
|
_path = uri.parse(path)
|
91
|
+
_path.path = uri.escape(_path.path)
|
90
92
|
case method
|
91
93
|
when :get, :delete
|
92
|
-
_path.path = uri.escape(_path.path)
|
93
94
|
request.url(_path.to_s, options)
|
94
95
|
when :post, :put
|
95
|
-
request.headers['Content-Type'] = "application/#{format}" unless request.headers['Content-Type']
|
96
|
-
_path.path = uri.escape(_path.path)
|
97
|
-
|
98
96
|
request.path = _path.to_s
|
99
|
-
|
100
97
|
if is_json? && !options.empty?
|
101
98
|
request.body = options.to_json
|
102
99
|
else
|
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.3
|
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-03-
|
11
|
+
date: 2024-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -124,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: '0'
|
126
126
|
requirements: []
|
127
|
-
rubygems_version: 3.2.
|
127
|
+
rubygems_version: 3.2.3
|
128
128
|
signing_key:
|
129
129
|
specification_version: 4
|
130
130
|
summary: A Ruby api wrapper code extracted from real world api clients
|