item_builder 0.1.2 → 0.1.3
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/item_builder/modes.rb +29 -0
- data/lib/item_builder/modes/active_service.rb +8 -3
- data/lib/item_builder/modes/price_service.rb +8 -3
- data/lib/item_builder/modes/quantity_service.rb +8 -7
- data/lib/item_builder/modes/simple_service.rb +14 -11
- data/lib/item_builder/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c92a9679076c8b127303bb9fc809ba3567424193373552d5675aa1db4f582595
|
4
|
+
data.tar.gz: 2701fcce867981222ce0abc80194043c8a7ec05ba126709d90d4879cebfa7484
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b42422beea0ceae242ab2f80d8f8777967eaae82153be8feda2941a8bd7fe1e5819bfcd0a4d105bd2c44fd45d303e4ad722555d128b765ba1661fbc50651a550
|
7
|
+
data.tar.gz: 324aa9b16a344e7b9adb67454767bafb43b8a4253057681446d68bb5d54194a02dde8183117d1ae201dc860af6bacf349c2b3bff66db91cdebeae8f2c52e3fca
|
data/lib/item_builder/modes.rb
CHANGED
@@ -10,6 +10,7 @@ module ItemBuilder
|
|
10
10
|
attr_reader :listing
|
11
11
|
def initialize(args)
|
12
12
|
@listing = args.fetch(:listing)
|
13
|
+
warehouse
|
13
14
|
end
|
14
15
|
|
15
16
|
def base
|
@@ -20,5 +21,33 @@ module ItemBuilder
|
|
20
21
|
sku: listing.sku
|
21
22
|
}
|
22
23
|
end
|
24
|
+
|
25
|
+
def warehouse
|
26
|
+
warehouse_spaces.each do |warehouse_space|
|
27
|
+
warehouses << to_h(warehouse_space)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def warehouse_spaces
|
32
|
+
WarehouseSpace.where(item_variant_id: listing.variant_id)
|
33
|
+
end
|
34
|
+
|
35
|
+
def warehouse_mapping(warehouse_id)
|
36
|
+
WarehouseMapping
|
37
|
+
.where(profile_channel_association_id:
|
38
|
+
listing.profile_channel_association_id,
|
39
|
+
warehouse_id: warehouse_id)
|
40
|
+
end
|
41
|
+
|
42
|
+
def wh_mapping(warehouse_id)
|
43
|
+
data = warehouse_mapping(warehouse_id)
|
44
|
+
return nil if data.empty?
|
45
|
+
|
46
|
+
warehouse_mapping(warehouse_id)[0].channel_warehouse_id
|
47
|
+
end
|
48
|
+
|
49
|
+
def warehouses
|
50
|
+
@warehouses ||= []
|
51
|
+
end
|
23
52
|
end
|
24
53
|
end
|
@@ -7,12 +7,17 @@ module ItemBuilder
|
|
7
7
|
include Modes
|
8
8
|
|
9
9
|
def perform
|
10
|
-
|
10
|
+
base.merge!(
|
11
|
+
warehouse: warehouses
|
12
|
+
)
|
11
13
|
end
|
12
14
|
|
13
|
-
def to_h
|
15
|
+
def to_h(warehouse_space)
|
14
16
|
{
|
15
|
-
active: listing.active
|
17
|
+
active: listing.active,
|
18
|
+
warehouse_id: wh_mapping(
|
19
|
+
warehouse_space.warehouse_id
|
20
|
+
)
|
16
21
|
}
|
17
22
|
end
|
18
23
|
end
|
@@ -7,15 +7,20 @@ module ItemBuilder
|
|
7
7
|
include Modes
|
8
8
|
|
9
9
|
def perform
|
10
|
-
|
10
|
+
base.merge!(
|
11
|
+
warehouse: warehouses
|
12
|
+
)
|
11
13
|
end
|
12
14
|
|
13
|
-
def to_h
|
15
|
+
def to_h(warehouse_space)
|
14
16
|
{
|
15
17
|
price: listing.price,
|
16
18
|
sale_price: listing.sale_price,
|
17
19
|
sale_start_at: listing.sale_start_at,
|
18
|
-
sale_end_at: listing.sale_end_at
|
20
|
+
sale_end_at: listing.sale_end_at,
|
21
|
+
warehouse_id: wh_mapping(
|
22
|
+
warehouse_space.warehouse_id
|
23
|
+
)
|
19
24
|
}
|
20
25
|
end
|
21
26
|
end
|
@@ -8,18 +8,19 @@ module ItemBuilder
|
|
8
8
|
include Modes
|
9
9
|
|
10
10
|
def perform
|
11
|
-
|
11
|
+
base.merge!(
|
12
|
+
warehouse: warehouses
|
13
|
+
)
|
12
14
|
end
|
13
15
|
|
14
|
-
def to_h
|
16
|
+
def to_h(warehouse_space)
|
15
17
|
{
|
16
|
-
quantity:
|
18
|
+
quantity: warehouse_space.quantity,
|
19
|
+
warehouse_id: wh_mapping(
|
20
|
+
warehouse_space.warehouse_id
|
21
|
+
)
|
17
22
|
}
|
18
23
|
end
|
19
|
-
|
20
|
-
def warehouse
|
21
|
-
WarehouseSpace.find_by(item_variant_id: listing.variant_id)
|
22
|
-
end
|
23
24
|
end
|
24
25
|
end
|
25
26
|
end
|
@@ -9,19 +9,22 @@ module ItemBuilder
|
|
9
9
|
include Modes
|
10
10
|
|
11
11
|
def perform
|
12
|
-
|
12
|
+
base.merge!(
|
13
|
+
warehouse: warehouses
|
14
|
+
)
|
13
15
|
end
|
14
16
|
|
15
|
-
def to_h
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
17
|
+
def to_h(warehouse_space)
|
18
|
+
{
|
19
|
+
quantity: warehouse_space.quantity,
|
20
|
+
price: listing.price,
|
21
|
+
sale_price: listing.sale_price,
|
22
|
+
sale_start_at: listing.sale_start_at,
|
23
|
+
sale_end_at: listing.sale_end_at,
|
24
|
+
warehouse_id: wh_mapping(
|
25
|
+
warehouse_space.warehouse_id
|
26
|
+
)
|
27
|
+
}
|
25
28
|
end
|
26
29
|
end
|
27
30
|
end
|
data/lib/item_builder/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: item_builder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- okaaryanata
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-06-
|
11
|
+
date: 2020-06-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|