wrapi 0.4.1 → 0.4.3

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
2
  SHA256:
3
- metadata.gz: d7a1a27203e141d7bbc0f20e3e65f18dafc255c33a051d3e03786cdb88fefa6f
4
- data.tar.gz: b9cb8227c911fcb9ef133c8816c41e5dee626f3c0ea9ee4f1d5538f7c48f61cd
3
+ metadata.gz: 97aeddbe26edc1de844235ad80174e81dd4b87ab3f941349990b49d2822526cb
4
+ data.tar.gz: c80266d83ff3daf66525127ac22e5863a196411589976a212480f00145d31d53
5
5
  SHA512:
6
- metadata.gz: 65296ac28b6371f30ef67d7c6c4736d7a1a75820f5c33488acd9eaa370eecb63e5407dad016484e13e05b184faf99b853cac0c4c2f0e6ccd1e527cadb5a9212e
7
- data.tar.gz: 18ab1a6603f10c89191c3fdf5345b7dbf22a2862bf251e1477b8d0da092679bdc8a1698f87b65e8e9cae68e69f8ff111e758822cb1ddb2560da594d4472cf56b
6
+ metadata.gz: 00b16d27142172f649374484cdd7a05177057a24c92fb81cc7b090543f39d23ec4d5e3cd5e7125dfd077985f1a92270acede8aabfe9eb0ae644ec53c552a3235
7
+ data.tar.gz: 000f1f156009059626f8be2d0528ab9f8980e57349f10e749763d685bbd68b208c0ba24f1d6bdc67c4b0a671c23bbd76bd93cc57153edf90f7cd7b330906ccca
data/CHANGELOG.md CHANGED
@@ -28,3 +28,9 @@
28
28
 
29
29
  ## [0.4.1] - 2024-02-28
30
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
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
- @_raw.to_json
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.map do |item|
70
- #item.is_a?(Hash) ? self.class.new(item) : item
71
- Entity.create(item)
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
@@ -70,7 +70,7 @@ module WrAPI
70
70
  end
71
71
  entity_response(response, raw)
72
72
  end
73
-
73
+
74
74
  def is_json?
75
75
  format && 'json'.eql?(format.to_s)
76
76
  end
@@ -85,13 +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
90
+ _path = uri.parse(path)
91
+ _path.path = uri.escape(_path.path)
89
92
  case method
90
93
  when :get, :delete
91
- request.url(uri.escape(path), options)
94
+ request.url(_path.to_s, options)
92
95
  when :post, :put
93
- request.headers['Content-Type'] = "application/#{format}"
94
- request.path = uri.escape(path)
96
+ request.path = _path.to_s
95
97
  if is_json? && !options.empty?
96
98
  request.body = options.to_json
97
99
  else
data/lib/wrapi/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WrAPI
4
- VERSION = '0.4.1'
4
+ VERSION = '0.4.3'
5
5
  end
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.1
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-02-28 00:00:00.000000000 Z
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.12
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