soapy_cake 1.16.1 → 1.16.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 63fdc8810fe8b169af3d888ef35d4867043165c2
4
- data.tar.gz: ce660c0e1a57dc2ad55632762864c8ad2b90acdd
3
+ metadata.gz: 90fef756332d326320cff251efb995ae7ecbb552
4
+ data.tar.gz: ed0f70f712a51a60816ee644dfc37f2def6aff67
5
5
  SHA512:
6
- metadata.gz: dbffa9ea80e754406f6543a506734aa2ed8e4975d845aab1c34eb6024358a8a0501018712a0778c628a8345b494bc2f38294a7bdf6aa87a32fd05698638649a6
7
- data.tar.gz: 33b5fd240b3ce865603ade69d96b1c31c85eeac19842b694e1eb20a3170763fc535ff01726ef8084f7a05318dc38c84aca4cbdd1b9eacb4f0f90e455a62342f2
6
+ metadata.gz: 387dd15276c23c87bb7edda1b05af420df08b684fadf4e7a5321cab1f5aa73f57c15aaff8a93a5ad0bbda459a9f567e79e8db6692fe1a124c72dbf7dbc009dd0
7
+ data.tar.gz: 3c89c8fc345633e689d1dac0ab9bdba2164f59be4fd3e44f09d1eea414da4055b05fc3972b7edb318e392c61ad7c7d364682cf3aa7382efbc44d4e95bfe59cd0
@@ -1,6 +1,6 @@
1
1
  module SoapyCake
2
2
  class Client
3
- attr_reader :domain, :api_key, :time_converter
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
- if request.opts[:response].present?
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: headers, body: request.xml, timeout: NET_TIMEOUT)
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
@@ -26,8 +26,8 @@ module SoapyCake
26
26
  def translate_booleans(opts)
27
27
  opts.transform_values do |v|
28
28
  case v
29
- when true then 'on'
30
- when false then 'off'
29
+ when true then 'on'.freeze
30
+ when false then 'off'.freeze
31
31
  else v
32
32
  end
33
33
  end
@@ -40,9 +40,9 @@ module SoapyCake
40
40
  end
41
41
 
42
42
  def xml_params(xml)
43
- xml.api_key api_key
43
+ xml.api_key(api_key)
44
44
  opts.each do |k, v|
45
- xml.public_send(k.to_sym, format_param(k, v))
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
 
@@ -64,7 +64,7 @@ module SoapyCake
64
64
  end
65
65
 
66
66
  def error_check_success!
67
- return if sax.for_tag(:success).first == 'true'
67
+ return if sax.for_tag(:success).first == 'true'.freeze
68
68
  fail RequestFailed, error_message
69
69
  end
70
70
 
@@ -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.to_s.end_with?('_id')
41
+ key.end_with?('_id'.freeze)
43
42
  end
44
43
 
45
44
  def string_id?
@@ -14,7 +14,7 @@ module SoapyCake
14
14
 
15
15
  def to_cake(date)
16
16
  date = date.to_datetime if date.is_a?(Date)
17
- date.in_time_zone(zone).strftime('%Y-%m-%dT%H:%M:%S')
17
+ date.in_time_zone(zone).strftime('%Y-%m-%dT%H:%M:%S'.freeze)
18
18
  end
19
19
 
20
20
  def from_cake(value)
@@ -1,3 +1,3 @@
1
1
  module SoapyCake
2
- VERSION = '1.16.1'.freeze
2
+ VERSION = '1.16.2'.freeze
3
3
  end
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.1
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-19 00:00:00.000000000 Z
11
+ date: 2015-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport