api_consumer 0.0.4 → 0.0.5
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 +8 -8
- data/lib/api_consumer.rb +9 -4
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,15 +1,15 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            !binary "U0hBMQ==":
         | 
| 3 3 | 
             
              metadata.gz: !binary |-
         | 
| 4 | 
            -
                 | 
| 4 | 
            +
                OTZiMWQyYjk1NDFhZmMzZjU2ZTY3NzYwMjczNjE3MGQ5NWE4ZjZkNQ==
         | 
| 5 5 | 
             
              data.tar.gz: !binary |-
         | 
| 6 | 
            -
                 | 
| 6 | 
            +
                YTkyZmFkY2Q4MzhhNzkyNDhjNTEyNTU1MTIzM2E5NjFiYzM5Zjc0Ng==
         | 
| 7 7 | 
             
            SHA512:
         | 
| 8 8 | 
             
              metadata.gz: !binary |-
         | 
| 9 | 
            -
                 | 
| 10 | 
            -
                 | 
| 11 | 
            -
                 | 
| 9 | 
            +
                ZThlM2FhOWRlYzhkMGQ2Yjc5ZWJhZTFlZjJkOWEwMDc0MGY2MGQwZTk0MmZi
         | 
| 10 | 
            +
                MTUzNjIxNjcwZTE4Y2FiYjdiYTdhNTI2YjRlNjc3ZDgxYTQzY2NkNGI1NmIy
         | 
| 11 | 
            +
                NTk3MTRhMWQ5ZTE2OWRiMzAwMDI2MTEyMGM5ZmNiZDMzNzAxMGM=
         | 
| 12 12 | 
             
              data.tar.gz: !binary |-
         | 
| 13 | 
            -
                 | 
| 14 | 
            -
                 | 
| 15 | 
            -
                 | 
| 13 | 
            +
                NTA4MjE3ZjEyZjZjN2I4NjU3ZjcwNjE5ZTM5MmVhODg2ZTIzODdhMTk3NGI2
         | 
| 14 | 
            +
                ZGYzNmZjMmQwYTE3MTU4ZjIzNWUxNmVhNTJhMmVjY2MxYmM0ZTQ1MjZjMWU2
         | 
| 15 | 
            +
                ZTE5NjQ0OTY2MTVjNTM2N2RmMzE1Yzk4OTUwMzIyYTZjMTUwMWM=
         | 
    
        data/lib/api_consumer.rb
    CHANGED
    
    | @@ -88,6 +88,10 @@ class APIConsumer | |
| 88 88 | 
             
                    Net::HTTP::Get.new(path)
         | 
| 89 89 | 
             
                  elsif( opts[:method] == :post)
         | 
| 90 90 | 
             
                    Net::HTTP::Post.new(path)
         | 
| 91 | 
            +
                  elsif( opts[:method] == :delete)
         | 
| 92 | 
            +
                    Net::HTTP::Delete.new(path)
         | 
| 93 | 
            +
                  elsif( opts[:method] == :put)
         | 
| 94 | 
            +
                    Net::HTTP::Put.new(path)
         | 
| 91 95 | 
             
                  else
         | 
| 92 96 | 
             
                    log.error "BUG - method=>(#{opts[:method]})"
         | 
| 93 97 | 
             
                  end
         | 
| @@ -105,7 +109,7 @@ class APIConsumer | |
| 105 109 | 
             
                    if( settings[:type] == "json")
         | 
| 106 110 | 
             
                      results = JSON.parse(response.body)
         | 
| 107 111 | 
             
                      if ![200, 201].include?(response.code.to_i)
         | 
| 108 | 
            -
                        results = error_code(response.code, opts[:errors])
         | 
| 112 | 
            +
                        results = error_code(response.code, opts[:errors], results)
         | 
| 109 113 | 
             
                      end
         | 
| 110 114 | 
             
                      results = blk.call(results) if blk
         | 
| 111 115 | 
             
                      cache.obj_write(opts[:key], results, :ttl => opts[:ttl]) if opts[:key]
         | 
| @@ -169,9 +173,10 @@ class APIConsumer | |
| 169 173 | 
             
                  downcase
         | 
| 170 174 | 
             
                end
         | 
| 171 175 |  | 
| 172 | 
            -
                def error_code(code, errors = nil)
         | 
| 173 | 
            -
                   | 
| 174 | 
            -
                   | 
| 176 | 
            +
                def error_code(code, errors = nil, response = nil)
         | 
| 177 | 
            +
                  ret_val = {:error => true, :message => (errors && errors[code.to_s] ? errors[code.to_s] : "API error: #{code}" )}
         | 
| 178 | 
            +
                  ret_val[:response] = response if response
         | 
| 179 | 
            +
                  return ret_val
         | 
| 175 180 | 
             
                end
         | 
| 176 181 | 
             
              end
         | 
| 177 182 | 
             
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: api_consumer
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.0. | 
| 4 | 
            +
              version: 0.0.5
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Chris Reister
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2014- | 
| 11 | 
            +
            date: 2014-11-17 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: uber_cache
         |