item_builder 0.1.19 → 0.1.20
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05a5aaf51ca610c9a2ea38268de98a9c610205fae9ecbaf2fdc111799264437f
|
4
|
+
data.tar.gz: a8a1de4a22e3002203db71564da0c88ed2f0440b5ef3d3c43faf7b419d912727
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 105786a98ff16a0531fa9d82078d70ddeae34c0b3516b44f84760a415e8bd22195bc8771905580df71dd8e6d3788dbf65a64b16741bc69b56674b4c9e4013bd8
|
7
|
+
data.tar.gz: c00f310744876ea11269848eac6dcdef46887a43fc855f92337bb5b1cc90deca4f169cfd20cfc3f1defe751aac53fb03b39edb7a733c42bf6c85e476da0b5b5a
|
@@ -31,34 +31,6 @@ class ItemBuilder
|
|
31
31
|
def apigateway_get
|
32
32
|
RestClient.get("#{host}?#{params}")
|
33
33
|
end
|
34
|
-
|
35
|
-
def headers
|
36
|
-
{
|
37
|
-
content_type: :json,
|
38
|
-
accept: :json
|
39
|
-
}
|
40
|
-
end
|
41
|
-
|
42
|
-
def credential
|
43
|
-
account_id = listing.profile_channel_association_id
|
44
|
-
host = ENV['CREDENTIAL_URL'] || 'user.forstok.com'
|
45
|
-
RestClient.get("#{host}/credential?account_id=#{account_id}")
|
46
|
-
end
|
47
|
-
|
48
|
-
def data
|
49
|
-
{
|
50
|
-
"credential": JSON.parse(credential)['credential'],
|
51
|
-
"data": request
|
52
|
-
}
|
53
|
-
end
|
54
|
-
|
55
|
-
def api_data
|
56
|
-
data.to_json
|
57
|
-
end
|
58
|
-
|
59
|
-
def apigateway_post
|
60
|
-
RestClient.post(url, api_data, headers)
|
61
|
-
end
|
62
34
|
end
|
63
35
|
end
|
64
36
|
end
|
@@ -5,7 +5,6 @@ require 'item_builder/modes.rb'
|
|
5
5
|
require 'item_builder/get_quantity_service'
|
6
6
|
require 'item_builder/modes/quantity/base'
|
7
7
|
require 'item_builder/modes/quantity/lazada_service'
|
8
|
-
require 'item_builder/modes/quantity/blibli_service'
|
9
8
|
require 'item_builder/modes/quantity/zalora_service'
|
10
9
|
class ItemBuilder
|
11
10
|
module Modes
|
@@ -14,7 +13,6 @@ class ItemBuilder
|
|
14
13
|
|
15
14
|
QUANTITY_CHANNEL = {}.tap do |hash|
|
16
15
|
hash[3] = :Lazada
|
17
|
-
hash[9] = :Blibli
|
18
16
|
hash[13] = :Zalora
|
19
17
|
end.freeze
|
20
18
|
|
data/lib/item_builder/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- okaaryanata
|
@@ -129,7 +129,6 @@ files:
|
|
129
129
|
- lib/item_builder/modes/price/zalora_service.rb
|
130
130
|
- lib/item_builder/modes/price_service.rb
|
131
131
|
- lib/item_builder/modes/quantity/base.rb
|
132
|
-
- lib/item_builder/modes/quantity/blibli_service.rb
|
133
132
|
- lib/item_builder/modes/quantity/lazada_service.rb
|
134
133
|
- lib/item_builder/modes/quantity/zalora_service.rb
|
135
134
|
- lib/item_builder/modes/quantity_service.rb
|
@@ -1,51 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'item_builder/modes/quantity/base'
|
4
|
-
class ItemBuilder
|
5
|
-
module Modes
|
6
|
-
module Quantity
|
7
|
-
class BlibliService < Base
|
8
|
-
def perform
|
9
|
-
local_variant
|
10
|
-
end
|
11
|
-
|
12
|
-
def local_variant
|
13
|
-
qty = 0
|
14
|
-
local_product['value']['items'].each do |item|
|
15
|
-
qty = total_quantity(item) if item['itemSku'] == listing.local_id
|
16
|
-
end
|
17
|
-
qty
|
18
|
-
end
|
19
|
-
|
20
|
-
def total_quantity(item)
|
21
|
-
# Make stock 0
|
22
|
-
# if local reserved quantity is bigger than available quantity
|
23
|
-
if item['reservedStockLevel2'] > available_quantity
|
24
|
-
0
|
25
|
-
else
|
26
|
-
available_quantity
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
# Find local product based on id
|
31
|
-
# @return [Hash] Local Blibli product
|
32
|
-
def local_product
|
33
|
-
@local_product ||= JSON.parse(apigateway_post)
|
34
|
-
end
|
35
|
-
|
36
|
-
private
|
37
|
-
|
38
|
-
def request
|
39
|
-
{
|
40
|
-
"gdnSku": listing.local_id
|
41
|
-
}
|
42
|
-
end
|
43
|
-
|
44
|
-
def url
|
45
|
-
url = ENV['API_GATEWAY_URL'] || 'apigateway.forstok.com'
|
46
|
-
url + '/blibli/item'
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|