selida-wlc-ruby 0.2 → 0.2.1
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/lib/wlc.rb +1 -0
 - data/lib/wlc/configuration.rb +1 -0
 - data/lib/wlc/error.rb +5 -0
 - data/lib/wlc/request.rb +20 -2
 - data/lib/wlc/version.rb +1 -1
 - metadata +4 -3
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 6d994b5999a43d0f4e0cb1b924b07963496b28efaa535d6a1167345b48af4570
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 8f4f1db68a601983379e566e83847a47e528d8368568fa3f7f6050dc8587531c
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: b7b959f7135c0353ae9caaf5b9aa2ae49a3db2c234fcd197351530c2f188fe8d16bcce3f57b919e2af59dbc143235c06f07b9bfe7e5e6fdc1992a62801bc8e0a
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 5cd74469effb0b2910a3e0c4522e8df6d2852f21412561e5e48176faea4789bc9381e23f9f5ec5382bd9a9b596ca42347730fc6079926398b8a6fd9489f61281
         
     | 
    
        data/lib/wlc.rb
    CHANGED
    
    
    
        data/lib/wlc/configuration.rb
    CHANGED
    
    
    
        data/lib/wlc/error.rb
    ADDED
    
    
    
        data/lib/wlc/request.rb
    CHANGED
    
    | 
         @@ -9,19 +9,37 @@ module Wlc 
     | 
|
| 
       9 
9 
     | 
    
         
             
                    builder.headers['Content-Type'] = 'application/json'
         
     | 
| 
       10 
10 
     | 
    
         
             
                    builder.headers['Authorization'] = Auth.new(client).header
         
     | 
| 
       11 
11 
     | 
    
         
             
                    builder.adapter Faraday.default_adapter
         
     | 
| 
      
 12 
     | 
    
         
            +
                    builder.options[:timeout] = timeout_option
         
     | 
| 
       12 
13 
     | 
    
         
             
                  end
         
     | 
| 
       13 
14 
     | 
    
         
             
                end
         
     | 
| 
       14 
15 
     | 
    
         | 
| 
       15 
16 
     | 
    
         
             
                def get(url, params = {})
         
     | 
| 
       16 
     | 
    
         
            -
                   
     | 
| 
      
 17 
     | 
    
         
            +
                  watch_timeout(url) do
         
     | 
| 
      
 18 
     | 
    
         
            +
                    Response.new connection.get(request_path(url), params)
         
     | 
| 
      
 19 
     | 
    
         
            +
                  end
         
     | 
| 
       17 
20 
     | 
    
         
             
                end
         
     | 
| 
       18 
21 
     | 
    
         | 
| 
       19 
22 
     | 
    
         
             
                def post(url, resource = {})
         
     | 
| 
       20 
     | 
    
         
            -
                   
     | 
| 
      
 23 
     | 
    
         
            +
                  watch_timeout(url) do
         
     | 
| 
      
 24 
     | 
    
         
            +
                    Response.new connection.post(request_path(url), resource_to_post(resource))
         
     | 
| 
      
 25 
     | 
    
         
            +
                  end
         
     | 
| 
       21 
26 
     | 
    
         
             
                end
         
     | 
| 
       22 
27 
     | 
    
         | 
| 
       23 
28 
     | 
    
         
             
                private
         
     | 
| 
       24 
29 
     | 
    
         | 
| 
      
 30 
     | 
    
         
            +
                def timeout_option
         
     | 
| 
      
 31 
     | 
    
         
            +
                  timeout = Wlc.configuration.timeout
         
     | 
| 
      
 32 
     | 
    
         
            +
                  timeout.to_i unless timeout.nil?
         
     | 
| 
      
 33 
     | 
    
         
            +
                end
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                def watch_timeout(url)
         
     | 
| 
      
 36 
     | 
    
         
            +
                  start_time = Time.now.to_f
         
     | 
| 
      
 37 
     | 
    
         
            +
                  yield if block_given?
         
     | 
| 
      
 38 
     | 
    
         
            +
                rescue Faraday::TimeoutError
         
     | 
| 
      
 39 
     | 
    
         
            +
                  seconds = (Time.now.to_f - start_time).to_i
         
     | 
| 
      
 40 
     | 
    
         
            +
                  raise TimeoutError, "The following address took longer than #{seconds}s to reply: '#{Client.host + url}'"
         
     | 
| 
      
 41 
     | 
    
         
            +
                end
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
       25 
43 
     | 
    
         
             
                def resource_to_post(resource)
         
     | 
| 
       26 
44 
     | 
    
         
             
                  serialize_resource_keys(resource).to_json
         
     | 
| 
       27 
45 
     | 
    
         
             
                end
         
     | 
    
        data/lib/wlc/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: selida-wlc-ruby
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version:  
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.2.1
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Ellen Fiscina
         
     | 
| 
         @@ -9,7 +9,7 @@ authors: 
     | 
|
| 
       9 
9 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       10 
10 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       11 
11 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       12 
     | 
    
         
            -
            date:  
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2019-01-15 00:00:00.000000000 Z
         
     | 
| 
       13 
13 
     | 
    
         
             
            dependencies:
         
     | 
| 
       14 
14 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       15 
15 
     | 
    
         
             
              name: faraday
         
     | 
| 
         @@ -123,6 +123,7 @@ files: 
     | 
|
| 
       123 
123 
     | 
    
         
             
            - lib/wlc/awrence.rb
         
     | 
| 
       124 
124 
     | 
    
         
             
            - lib/wlc/client.rb
         
     | 
| 
       125 
125 
     | 
    
         
             
            - lib/wlc/configuration.rb
         
     | 
| 
      
 126 
     | 
    
         
            +
            - lib/wlc/error.rb
         
     | 
| 
       126 
127 
     | 
    
         
             
            - lib/wlc/request.rb
         
     | 
| 
       127 
128 
     | 
    
         
             
            - lib/wlc/resources/order.rb
         
     | 
| 
       128 
129 
     | 
    
         
             
            - lib/wlc/resources/product.rb
         
     | 
| 
         @@ -150,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       150 
151 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       151 
152 
     | 
    
         
             
            requirements: []
         
     | 
| 
       152 
153 
     | 
    
         
             
            rubyforge_project: 
         
     | 
| 
       153 
     | 
    
         
            -
            rubygems_version: 2.7. 
     | 
| 
      
 154 
     | 
    
         
            +
            rubygems_version: 2.7.8
         
     | 
| 
       154 
155 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       155 
156 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       156 
157 
     | 
    
         
             
            summary: ''
         
     |