futureshop 0.1.3 → 0.1.4

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
  SHA256:
3
- metadata.gz: a772346e853a3e3270613fdfdb1b80d7c1b8d6f56036a3894fb896755a2c9221
4
- data.tar.gz: e269cdf0e96e9ff4223def8c5629c1db17c3c28316a676aee7a6f8d1773eee9d
3
+ metadata.gz: 98c8d7b64e6c87c143bf69d49a3ca20c480b7bf07086fdf8c5fa45f1ede4b33a
4
+ data.tar.gz: b18b15af5c1790f11137305848888744bb88c3248b2aa9e2bc432584ba4e493f
5
5
  SHA512:
6
- metadata.gz: be1565f81d78c145a809516074f699e8a3e101c16a273bd43027cefb44ba8dba661341019e3f2847b27e4d10f252c39b6e4c4f60e695ba232286fa0276448eaf
7
- data.tar.gz: 7f0ba7fed584633bc70e8ed473d3521e2b377d8bda331274b6356960e71227c7861aa034cf504d7148b5d5dc1bf3900d32cc55287e290f642bc46e54b4fd0f24
6
+ metadata.gz: 40b81c3cd65ef881c8a14d8eb3120351c184e4971d893acb76dde46defb187a85527ffc85c4b01552751c8b1b640dbc6c8c3951877203645a1890ccd9124e7ec
7
+ data.tar.gz: fbedd017cec85d9fbb717d556a7727d47672a0c91611a14f62b93452e4bcb2a3ea0fb9c5a26c7cf56366740fc85b8e9cfc530811d9dfcad3f43189dcaa55010b
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.1.4] - 2021-10-11
4
+
5
+ - Handle order's couponList field, which was introduced on 2021-09-29
6
+
3
7
  ## [0.1.3] - 2021-08-25
4
8
 
5
9
  - Fix option passing
@@ -1,3 +1,3 @@
1
1
  module Futureshop
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
data/lib/futureshop.rb CHANGED
@@ -25,33 +25,40 @@ module Futureshop
25
25
  raise "Multiple shipmentList. orderNo: #{order["orderNo"]}" if order["shipmentList"].length > 1
26
26
  order["shipmentList"].each do |shipment|
27
27
  shipment["productList"].each do |product|
28
- csv << order.each_value.with_object([]) {|value, values|
28
+ csv << order.each_pair.with_object([]) {|(key, value), values|
29
29
  case value
30
30
  when Hash
31
31
  value.each_value do |v|
32
32
  values << v
33
33
  end
34
34
  when Array
35
- # only shipmentList is an Array and its length is 0
36
- shipment.each_value do |v|
37
- case v
38
- when Hash
39
- v.each_value do |ov|
40
- values << ov
41
- end
42
- when Array
43
- product.each_pair do |k, v|
44
- case k
45
- when "optionPriceList"
46
- v = v.collect {|optionPrice| "#{optionPrice['name']}:#{optionPrice['selectionName']}(#{optionPrice['price']})"}.join("/")
47
- when "optionList"
48
- v = v.collect {|option| [option["name"], option["selectionItem"]].join(":")}.join(",")
35
+ case key
36
+ when "shipmentList"
37
+ # shipmentList's length is 1
38
+ shipment.each_value do |v|
39
+ case v
40
+ when Hash
41
+ v.each_value do |ov|
42
+ values << ov
43
+ end
44
+ when Array
45
+ product.each_pair do |k, v|
46
+ case k
47
+ when "optionPriceList"
48
+ v = v.collect {|optionPrice| "#{optionPrice['name']}:#{optionPrice['selectionName']}(#{optionPrice['price']})"}.join("/")
49
+ when "optionList"
50
+ v = v.collect {|option| [option["name"], option["selectionItem"]].join(":")}.join(",")
51
+ end
52
+ values << v
49
53
  end
54
+ else
50
55
  values << v
51
56
  end
52
- else
53
- values << v
54
57
  end
58
+ when "couponList"
59
+ values << value.collect {|coupon| [coupon["id"], coupon["name"]].join(":")}.join("/")
60
+ else
61
+ raise "Unknown array field: #{key}"
55
62
  end
56
63
  else
57
64
  values << value
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: futureshop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kitaiti Makoto
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-08-25 00:00:00.000000000 Z
11
+ date: 2021-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake