soapy_cake 1.16.1 → 1.16.2
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/soapy_cake/client.rb +4 -12
 - data/lib/soapy_cake/helper.rb +2 -2
 - data/lib/soapy_cake/request.rb +3 -3
 - data/lib/soapy_cake/response.rb +1 -1
 - data/lib/soapy_cake/response_value.rb +4 -5
 - data/lib/soapy_cake/time_converter.rb +1 -1
 - data/lib/soapy_cake/version.rb +1 -1
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 90fef756332d326320cff251efb995ae7ecbb552
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: ed0f70f712a51a60816ee644dfc37f2def6aff67
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 387dd15276c23c87bb7edda1b05af420df08b684fadf4e7a5321cab1f5aa73f57c15aaff8a93a5ad0bbda459a9f567e79e8db6692fe1a124c72dbf7dbc009dd0
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 3c89c8fc345633e689d1dac0ab9bdba2164f59be4fd3e44f09d1eea414da4055b05fc3972b7edb318e392c61ad7c7d364682cf3aa7382efbc44d4e95bfe59cd0
         
     | 
    
        data/lib/soapy_cake/client.rb
    CHANGED
    
    | 
         @@ -1,6 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module SoapyCake
         
     | 
| 
       2 
2 
     | 
    
         
             
              class Client
         
     | 
| 
       3 
     | 
    
         
            -
                 
     | 
| 
      
 3 
     | 
    
         
            +
                HEADERS = { 'Content-Type' => 'application/soap+xml;charset=UTF-8' }.freeze
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
                def initialize(opts = {})
         
     | 
| 
       6 
6 
     | 
    
         
             
                  @domain = opts.fetch(:domain, ENV['CAKE_DOMAIN']) || fail(Error, 'Cake domain missing')
         
     | 
| 
         @@ -19,7 +19,7 @@ module SoapyCake 
     | 
|
| 
       19 
19 
     | 
    
         | 
| 
       20 
20 
     | 
    
         
             
                protected
         
     | 
| 
       21 
21 
     | 
    
         | 
| 
       22 
     | 
    
         
            -
                attr_reader :opts
         
     | 
| 
      
 22 
     | 
    
         
            +
                attr_reader :domain, :api_key, :time_converter, :opts
         
     | 
| 
       23 
23 
     | 
    
         | 
| 
       24 
24 
     | 
    
         
             
                def run(request)
         
     | 
| 
       25 
25 
     | 
    
         
             
                  request.api_key = api_key
         
     | 
| 
         @@ -32,25 +32,17 @@ module SoapyCake 
     | 
|
| 
       32 
32 
     | 
    
         
             
                private
         
     | 
| 
       33 
33 
     | 
    
         | 
| 
       34 
34 
     | 
    
         
             
                def response_body(request)
         
     | 
| 
       35 
     | 
    
         
            -
                   
     | 
| 
       36 
     | 
    
         
            -
                    request.opts[:response]
         
     | 
| 
       37 
     | 
    
         
            -
                  else
         
     | 
| 
       38 
     | 
    
         
            -
                    http_response(request)
         
     | 
| 
       39 
     | 
    
         
            -
                  end
         
     | 
| 
      
 35 
     | 
    
         
            +
                  request.opts[:response].presence || http_response(request)
         
     | 
| 
       40 
36 
     | 
    
         
             
                end
         
     | 
| 
       41 
37 
     | 
    
         | 
| 
       42 
38 
     | 
    
         
             
                def http_response(request)
         
     | 
| 
       43 
39 
     | 
    
         
             
                  url = "https://#{domain}#{request.path}"
         
     | 
| 
       44 
     | 
    
         
            -
                  http_response = HTTParty.post(url, headers:  
     | 
| 
      
 40 
     | 
    
         
            +
                  http_response = HTTParty.post(url, headers: HEADERS, body: request.xml, timeout: NET_TIMEOUT)
         
     | 
| 
       45 
41 
     | 
    
         | 
| 
       46 
42 
     | 
    
         
             
                  fail RequestFailed, "Request failed with HTTP #{http_response.code}: " \
         
     | 
| 
       47 
43 
     | 
    
         
             
                    "#{http_response.body}" unless http_response.success?
         
     | 
| 
       48 
44 
     | 
    
         | 
| 
       49 
45 
     | 
    
         
             
                  http_response
         
     | 
| 
       50 
46 
     | 
    
         
             
                end
         
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
       52 
     | 
    
         
            -
                def headers
         
     | 
| 
       53 
     | 
    
         
            -
                  { 'Content-Type' => 'application/soap+xml;charset=UTF-8' }
         
     | 
| 
       54 
     | 
    
         
            -
                end
         
     | 
| 
       55 
47 
     | 
    
         
             
              end
         
     | 
| 
       56 
48 
     | 
    
         
             
            end
         
     | 
    
        data/lib/soapy_cake/helper.rb
    CHANGED
    
    
    
        data/lib/soapy_cake/request.rb
    CHANGED
    
    | 
         @@ -40,9 +40,9 @@ module SoapyCake 
     | 
|
| 
       40 
40 
     | 
    
         
             
                end
         
     | 
| 
       41 
41 
     | 
    
         | 
| 
       42 
42 
     | 
    
         
             
                def xml_params(xml)
         
     | 
| 
       43 
     | 
    
         
            -
                  xml.api_key 
     | 
| 
      
 43 
     | 
    
         
            +
                  xml.api_key(api_key)
         
     | 
| 
       44 
44 
     | 
    
         
             
                  opts.each do |k, v|
         
     | 
| 
       45 
     | 
    
         
            -
                    xml.public_send(k 
     | 
| 
      
 45 
     | 
    
         
            +
                    xml.public_send(k, format_param(k, v))
         
     | 
| 
       46 
46 
     | 
    
         
             
                  end
         
     | 
| 
       47 
47 
     | 
    
         
             
                end
         
     | 
| 
       48 
48 
     | 
    
         | 
| 
         @@ -56,7 +56,7 @@ module SoapyCake 
     | 
|
| 
       56 
56 
     | 
    
         
             
                def format_param(key, value)
         
     | 
| 
       57 
57 
     | 
    
         
             
                  return time_converter.to_cake(value) if DATE_CLASSES.include?(value.class)
         
     | 
| 
       58 
58 
     | 
    
         | 
| 
       59 
     | 
    
         
            -
                  if key.to_s.end_with?('_date')
         
     | 
| 
      
 59 
     | 
    
         
            +
                  if key.to_s.end_with?('_date'.freeze)
         
     | 
| 
       60 
60 
     | 
    
         
             
                    fail Error, "You need to use a Time/DateTime/Date object for '#{key}'"
         
     | 
| 
       61 
61 
     | 
    
         
             
                  end
         
     | 
| 
       62 
62 
     | 
    
         | 
    
        data/lib/soapy_cake/response.rb
    CHANGED
    
    
| 
         @@ -1,7 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module SoapyCake
         
     | 
| 
       2 
2 
     | 
    
         
             
              class ResponseValue
         
     | 
| 
       3 
     | 
    
         
            -
                attr_reader :value
         
     | 
| 
       4 
     | 
    
         
            -
                attr_reader :key
         
     | 
| 
      
 3 
     | 
    
         
            +
                attr_reader :key, :value
         
     | 
| 
       5 
4 
     | 
    
         | 
| 
       6 
5 
     | 
    
         
             
                # Known string ids that should not be parsed as integers
         
     | 
| 
       7 
6 
     | 
    
         
             
                STRING_IDS = %w(tax_id transaction_id).freeze
         
     | 
| 
         @@ -27,11 +26,11 @@ module SoapyCake 
     | 
|
| 
       27 
26 
     | 
    
         
             
                attr_reader :time_converter
         
     | 
| 
       28 
27 
     | 
    
         | 
| 
       29 
28 
     | 
    
         
             
                def false?
         
     | 
| 
       30 
     | 
    
         
            -
                  value == 'false'
         
     | 
| 
      
 29 
     | 
    
         
            +
                  value == 'false'.freeze
         
     | 
| 
       31 
30 
     | 
    
         
             
                end
         
     | 
| 
       32 
31 
     | 
    
         | 
| 
       33 
32 
     | 
    
         
             
                def true?
         
     | 
| 
       34 
     | 
    
         
            -
                  value == 'true'
         
     | 
| 
      
 33 
     | 
    
         
            +
                  value == 'true'.freeze
         
     | 
| 
       35 
34 
     | 
    
         
             
                end
         
     | 
| 
       36 
35 
     | 
    
         | 
| 
       37 
36 
     | 
    
         
             
                def date?
         
     | 
| 
         @@ -39,7 +38,7 @@ module SoapyCake 
     | 
|
| 
       39 
38 
     | 
    
         
             
                end
         
     | 
| 
       40 
39 
     | 
    
         | 
| 
       41 
40 
     | 
    
         
             
                def id?
         
     | 
| 
       42 
     | 
    
         
            -
                  key. 
     | 
| 
      
 41 
     | 
    
         
            +
                  key.end_with?('_id'.freeze)
         
     | 
| 
       43 
42 
     | 
    
         
             
                end
         
     | 
| 
       44 
43 
     | 
    
         | 
| 
       45 
44 
     | 
    
         
             
                def string_id?
         
     | 
    
        data/lib/soapy_cake/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: soapy_cake
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 1.16. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.16.2
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - ad2games GmbH
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2015-10- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2015-10-21 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: activesupport
         
     |