ueki 1.0.0 → 1.1.0

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: a26fe40e5550c573ba85ceaf58122fa63cf27c358d579b14b9c72fbe985eb637
4
- data.tar.gz: e3391e1a4302b29ed51f0379f268bd4dfff89e05a1d406a04d4b87e8fcf8424d
3
+ metadata.gz: db67ac3ca853a1c4cfaa88e7e50a728ea818b781b3d9a35ab7a068201e8614d9
4
+ data.tar.gz: 66cdc2140a71b5705c81c525b6bb3327a5c60662a0df45fae5163488b1ff1168
5
5
  SHA512:
6
- metadata.gz: de1e9a7eb8b7a79609ff6e78f6b0a557e85a4b907f43348aba985a3dbee989061dbf0d10a6e35060e2ea02cd2b15a5161915ee70885c12e1928bee671622b882
7
- data.tar.gz: 1c6f4e75b67b4b7b9e5f77763bab3fcdd7411884fb9b0629018861831a0573602e13b6c074aa301e0ce835335663b16865cdb0e7e287eccb735f14ec96667052
6
+ metadata.gz: 89cce1b559f36d50bb206960a8cd0c9023dbf614fff9e61b64e85988baa4788f266bab379c809c8a0e086c18001f03a4082c4cd430fd96819da3999802b147c7
7
+ data.tar.gz: a91ca7b58fc2cec4a88fd8239e1c43e458f2d54c464ccc88f0c8f700031f9b7d7c9c7bc6e981daf2cdb85edbc4cb60bd9a70b09934d70da2966318fe8c697f32
data/.rubocop.yml CHANGED
@@ -32,6 +32,9 @@ Metrics/CyclomaticComplexity:
32
32
  Metrics/MethodLength:
33
33
  Enabled: false
34
34
 
35
+ Metrics/ModuleLength:
36
+ Enabled: false
37
+
35
38
  Metrics/ParameterLists:
36
39
  Enabled: false
37
40
 
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [1.1.0] - 2024-10-21
4
+
5
+ - [DefaultRequester] Convert request headers to string keys
6
+ - This solves the issue that `: “Content-Type” (symbol key)` is set even if `“Content-Type” (string key)` is specified in post/put/patch.
7
+
3
8
  ## [1.0.0] - 2024-08-04
4
9
 
5
10
  - Initial release
data/README.md CHANGED
@@ -23,7 +23,7 @@ Simply include the Module created by Ueki in your own HTTP Client Library.
23
23
 
24
24
  ```ruby
25
25
  class BookStoreClient
26
- include Ueki::HttpClient.new('http://example.com')
26
+ include Ueki::HttpClient.new('https://example.com')
27
27
 
28
28
  # Class Method
29
29
  def self.delete_book(id)
@@ -37,7 +37,7 @@ class BookStoreClient
37
37
 
38
38
  private
39
39
 
40
- def default_headers
40
+ def _default_headers
41
41
  h = super
42
42
  h['X-Request-Id'] = Current.request_id if Current.request_id.present?
43
43
  h
@@ -116,7 +116,7 @@ A. You can use [net_http_persistent](https://github.com/lostisland/faraday-net_h
116
116
  See [lib/ueki/http_client/default_requester.rb](https://github.com/tmimura39/ueki/blob/main/lib/ueki/http_client/default_requester.rb) for details.
117
117
  ```ruby
118
118
  class BookStoreClient
119
- include Ueki::HttpClient.new('http://example.com')
119
+ include Ueki::HttpClient.new('https://example.com')
120
120
 
121
121
  private
122
122
 
@@ -139,7 +139,7 @@ In this case, you can use "automatic exception class definition" and "exception
139
139
 
140
140
  ```ruby
141
141
  class BookStoreClient
142
- include Ueki::HttpClient.new('http://example.com', requester: CustomRequester)
142
+ include Ueki::HttpClient.new('https://example.com', requester: CustomRequester)
143
143
  end
144
144
  ```
145
145
 
@@ -8,7 +8,8 @@ module Ueki
8
8
  # You can also use your own Requester class with the same I/F.
9
9
  module DefaultRequester
10
10
  UNSPECIFIED = Object.new.freeze
11
- private_constant :UNSPECIFIED
11
+ CONTENT_TYPE_HEADER_KEY = "Content-Type"
12
+ private_constant :UNSPECIFIED, :CONTENT_TYPE_HEADER_KEY
12
13
 
13
14
  def get(path, params: nil, headers: {}, request_options: {}, response_body_parser: UNSPECIFIED)
14
15
  response_body_parser = default_response_body_parser_if_unspecifiied(response_body_parser)
@@ -18,27 +19,30 @@ module Ueki
18
19
  def post(path, params: nil, headers: {}, request_options: {}, request_body_converter: UNSPECIFIED, response_body_parser: UNSPECIFIED)
19
20
  response_body_parser = default_response_body_parser_if_unspecifiied(response_body_parser)
20
21
  request_body_converter = default_request_body_converter_if_unspecified(request_body_converter)
22
+ headers = headers.transform_keys(&:to_s)
21
23
 
22
- headers[:"Content-Type"] ||= "application/json" unless params.nil?
23
- params = request_body_converter.call(content_type: headers[:"Content-Type"], params:)
24
+ headers[CONTENT_TYPE_HEADER_KEY] ||= "application/json" unless params.nil?
25
+ params = request_body_converter.call(content_type: headers[CONTENT_TYPE_HEADER_KEY], params:)
24
26
  request(:post, path:, params:, headers:, request_options:, response_body_parser:)
25
27
  end
26
28
 
27
29
  def put(path, params: nil, headers: {}, request_options: {}, request_body_converter: UNSPECIFIED, response_body_parser: UNSPECIFIED)
28
30
  response_body_parser = default_response_body_parser_if_unspecifiied(response_body_parser)
29
31
  request_body_converter = default_request_body_converter_if_unspecified(request_body_converter)
32
+ headers = headers.transform_keys(&:to_s)
30
33
 
31
- headers[:"Content-Type"] ||= "application/json" unless params.nil?
32
- params = request_body_converter.call(content_type: headers[:"Content-Type"], params:)
34
+ headers[CONTENT_TYPE_HEADER_KEY] ||= "application/json" unless params.nil?
35
+ params = request_body_converter.call(content_type: headers[CONTENT_TYPE_HEADER_KEY], params:)
33
36
  request(:put, path:, params:, headers:, request_options:, response_body_parser:)
34
37
  end
35
38
 
36
39
  def patch(path, params: nil, headers: {}, request_options: {}, request_body_converter: UNSPECIFIED, response_body_parser: UNSPECIFIED)
37
40
  response_body_parser = default_response_body_parser_if_unspecifiied(response_body_parser)
38
41
  request_body_converter = default_request_body_converter_if_unspecified(request_body_converter)
42
+ headers = headers.transform_keys(&:to_s)
39
43
 
40
- headers[:"Content-Type"] ||= "application/json" unless params.nil?
41
- params = request_body_converter.call(content_type: headers[:"Content-Type"], params:)
44
+ headers[CONTENT_TYPE_HEADER_KEY] ||= "application/json" unless params.nil?
45
+ params = request_body_converter.call(content_type: headers[CONTENT_TYPE_HEADER_KEY], params:)
42
46
  request(:patch, path:, params:, headers:, request_options:, response_body_parser:)
43
47
  end
44
48
 
@@ -13,7 +13,7 @@ module Ueki
13
13
 
14
14
  case content_type
15
15
  when "application/json"
16
- params&.to_json
16
+ params.to_json
17
17
  when "application/x-www-form-urlencoded"
18
18
  URI.encode_www_form(params)
19
19
  else
data/lib/ueki/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ueki
4
- VERSION = "1.0.0"
4
+ VERSION = "1.1.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ueki
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomohiko Mimura
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-08-05 00:00:00.000000000 Z
11
+ date: 2024-10-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Ueki provides "simple request method" and "error exception class definition
14
14
  and handling"