wrapi 0.4.2 → 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: 893b19a80a388d0258ca30c2c170afa40c8f712cb767d7c5df4b066d1f59819a
4
- data.tar.gz: 586720e6fe06df920b81fa5ed013dfb3fa6f12a51f0f74242561386d419178d0
3
+ metadata.gz: 97aeddbe26edc1de844235ad80174e81dd4b87ab3f941349990b49d2822526cb
4
+ data.tar.gz: c80266d83ff3daf66525127ac22e5863a196411589976a212480f00145d31d53
5
5
  SHA512:
6
- metadata.gz: 2e1f86fe225c1787b85763d9b3c9a7dd570f24d2e2d2995c4e8e2a025b2aa31e7fccc9951fbf38bec6a6ae93c2c228abe8d93459060e2438269f0ed854d67e6a
7
- data.tar.gz: f1e88c8ec6b4b4ad05fb8f53c63b7f6e779dc50d5a19b942f4fa2f84792511c5c910eb8ae7e249506e6f97a6ad9757d4857ef216203d5bc0dd3fb3e25560273f
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
- ## [0.4.1] - 2024-02-28
30
- - fix issue with post body only supported as json
29
+ ## [0.4.1] - 2024-02-28
30
+ - fix issue with post body only supported as json
31
31
 
32
- ## [0.4.2] - 2024-03-03
33
- - fix issue with escaping query parameters included in path
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
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WrAPI
4
- VERSION = '0.4.2'
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.2
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-04 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