wrapi 0.4.2 → 0.4.4
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/CHANGELOG.md +10 -4
 - data/lib/wrapi/entity.rb +15 -8
 - 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: cbba7a5999de019875c356dc158b4061bd417cc4f2d21364c2e18bdcac715ac2
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 8932fd54e9872f43b3e64b4b31554ca71e55987fc35a096bcc10162022773036
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 0f95131accc766c77a6e81ffa8702dc501137478e5fc8d58589e058f30de4886afbc1b1c469f38a33a06c0b2b4177f26db701be033122000a901485b9c02ecb8
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 885c32718e57b86b9bf395d392263bc0c60044929dc7cf86dba5f80209ba1b7d1c7815fc345ff904836c0838af51e39fe408d4a7f49678eae62da1c93ecf1f64
         
     | 
    
        data/CHANGELOG.md
    CHANGED
    
    | 
         @@ -26,8 +26,14 @@ 
     | 
|
| 
       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
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
            ## [0.4.4] - 2024-03-12
         
     | 
| 
      
 39 
     | 
    
         
            +
            - fix typo and implement clone for entities
         
     | 
    
        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)
         
     | 
| 
         @@ -30,7 +27,7 @@ module WrAPI 
     | 
|
| 
       30 
27 
     | 
    
         
             
                  def method_missing(method_sym, *arguments, &block)
         
     | 
| 
       31 
28 
     | 
    
         
             
                    # assignment
         
     | 
| 
       32 
29 
     | 
    
         
             
                    if (method = method_sym[/.*(?==\z)/m])
         
     | 
| 
       33 
     | 
    
         
            -
                      raise 
     | 
| 
      
 30 
     | 
    
         
            +
                      raise ArgumentError, "wrong number of arguments (given #{arguments.length}, expected 1)", caller(1) unless arguments.length == 1
         
     | 
| 
       34 
31 
     | 
    
         | 
| 
       35 
32 
     | 
    
         
             
                      @attributes[method] = arguments[0]
         
     | 
| 
       36 
33 
     | 
    
         
             
                    elsif @attributes.include? method_sym.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)
         
     | 
| 
         @@ -64,11 +61,21 @@ module WrAPI 
     | 
|
| 
       64 
61 
     | 
    
         
             
                        @attributes[method]
         
     | 
| 
       65 
62 
     | 
    
         
             
                      end
         
     | 
| 
       66 
63 
     | 
    
         
             
                  end
         
     | 
| 
      
 64 
     | 
    
         
            +
                  
         
     | 
| 
      
 65 
     | 
    
         
            +
                  def clone
         
     | 
| 
      
 66 
     | 
    
         
            +
                    c = super
         
     | 
| 
      
 67 
     | 
    
         
            +
                    c.attributes = @attributes.clone
         
     | 
| 
      
 68 
     | 
    
         
            +
                    c
         
     | 
| 
      
 69 
     | 
    
         
            +
                  end
         
     | 
| 
       67 
70 
     | 
    
         | 
| 
       68 
71 
     | 
    
         
             
                  def self.entify(a)
         
     | 
| 
       69 
     | 
    
         
            -
                    a. 
     | 
| 
       70 
     | 
    
         
            -
                       
     | 
| 
       71 
     | 
    
         
            -
             
     | 
| 
      
 72 
     | 
    
         
            +
                    if ( a.count > 0 ) && ( a.first.is_a? Hash )
         
     | 
| 
      
 73 
     | 
    
         
            +
                      a.dup.map do |item|
         
     | 
| 
      
 74 
     | 
    
         
            +
                        #item.is_a?(Hash) ? self.class.new(item) : item
         
     | 
| 
      
 75 
     | 
    
         
            +
                        Entity.create(item)
         
     | 
| 
      
 76 
     | 
    
         
            +
                      end
         
     | 
| 
      
 77 
     | 
    
         
            +
                    else
         
     | 
| 
      
 78 
     | 
    
         
            +
                      a
         
     | 
| 
       72 
79 
     | 
    
         
             
                    end
         
     | 
| 
       73 
80 
     | 
    
         
             
                  end
         
     | 
| 
       74 
81 
     | 
    
         
             
                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.4
         
     | 
| 
       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-12 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
         
     |