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 +4 -4
- data/.rubocop.yml +3 -0
- data/CHANGELOG.md +5 -0
- data/README.md +4 -4
- data/lib/ueki/http_client/default_requester.rb +11 -7
- data/lib/ueki/http_client/request_body_converter.rb +1 -1
- data/lib/ueki/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: db67ac3ca853a1c4cfaa88e7e50a728ea818b781b3d9a35ab7a068201e8614d9
         | 
| 4 | 
            +
              data.tar.gz: 66cdc2140a71b5705c81c525b6bb3327a5c60662a0df45fae5163488b1ff1168
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 89cce1b559f36d50bb206960a8cd0c9023dbf614fff9e61b64e85988baa4788f266bab379c809c8a0e086c18001f03a4082c4cd430fd96819da3999802b147c7
         | 
| 7 | 
            +
              data.tar.gz: a91ca7b58fc2cec4a88fd8239e1c43e458f2d54c464ccc88f0c8f700031f9b7d7c9c7bc6e981daf2cdb85edbc4cb60bd9a70b09934d70da2966318fe8c697f32
         | 
    
        data/.rubocop.yml
    CHANGED
    
    
    
        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(' | 
| 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  | 
| 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(' | 
| 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(' | 
| 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 | 
            -
                   | 
| 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[ | 
| 23 | 
            -
                    params = request_body_converter.call(content_type: headers[ | 
| 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[ | 
| 32 | 
            -
                    params = request_body_converter.call(content_type: headers[ | 
| 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[ | 
| 41 | 
            -
                    params = request_body_converter.call(content_type: headers[ | 
| 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 |  | 
    
        data/lib/ueki/version.rb
    CHANGED
    
    
    
        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. | 
| 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- | 
| 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"
         |