cadooz 2.0.0 → 2.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2fb219a855dbef54fa310d71427f145600294b93
4
- data.tar.gz: ae10d8b1b9d05f31c3a6accc6482e1e3a5889bc4
3
+ metadata.gz: 4b948e4c69b934df883cf6f277c4bffc2060d502
4
+ data.tar.gz: 6f4d9443f5613b33d34dc3ab887a3ba660b6a719
5
5
  SHA512:
6
- metadata.gz: 352a18c44ea820ac5b1150eb4be54b517a2b4f7b009ccef0fe5ce41f98f1c4f82ff7a07b66622771c02983123fb5e163f68a8315ad4b41210477c2878838cbdf
7
- data.tar.gz: 26e837627e09278c5eb11cf82a227380f0d372cbae361bf5af61b7ce45fbf022ada1044c95c60202e82dd3c79a9f7b14f6c7e261c3736b1e7943687fb8f6427f
6
+ metadata.gz: 1bd38daf2d660e23c521cb273a3b537fbd166c812714c9d329d02b85d6df5fcc193f9deef443ff41014d46d4f2d566a873387c3516de2b93a5d8adb31c89e50d
7
+ data.tar.gz: 7f0e4976e7a5726928b454f68e5a28cba7fbc24a6ab9044c6f46166a56b1807997c3bc44a87c95ce192146bfe57034dd43b348ff92eeb049e3897aa88baceca7
@@ -127,18 +127,39 @@ class Cadooz::BusinessOrderService
127
127
  object = JSON.parse(body.to_json, object_class: OpenStruct)
128
128
  end
129
129
 
130
+ response_object = nil
131
+
130
132
  if object.class == Array
131
- response_wrapper.new(
133
+ wrapper = response_wrapper.new(
132
134
  object.each_with_object([]) { |o, arr| arr << Object::const_get(response_class.to_s).new(o) },
133
135
  response.xml
134
136
  )
137
+ response_object = wrapper unless nil_check(wrapper.object.first)
135
138
  elsif object.class == OpenStruct
136
- response_wrapper.new(
139
+ wrapper = response_wrapper.new(
137
140
  Object::const_get(response_class.to_s).new(object),
138
141
  response.xml
139
142
  )
143
+ response_object = wrapper unless nil_check(wrapper.object)
140
144
  else
141
145
  # TODO handle exception
142
146
  end
147
+
148
+ response_object
149
+ end
150
+
151
+ def nil_check(object)
152
+ object.instance_variables.each do |v|
153
+ value = object.instance_variable_get(v)
154
+ if value.class.to_s.include?('Cadooz::Immutable')
155
+ nil_check(value)
156
+ elsif value.class == Money
157
+ return false unless value.cents == 0
158
+ else
159
+ return false unless value.nil?
160
+ end
161
+ end
162
+
163
+ true
143
164
  end
144
165
  end
@@ -1,3 +1,3 @@
1
1
  module Cadooz
2
- VERSION = '2.0.0'
2
+ VERSION = '2.0.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cadooz
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Brown