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: dea667fd969ce159a690f79ab45f3dd0ebe0994bb88364d43ec37a9b2a18a40d
4
- data.tar.gz: 13aa7b1c835273396ab747def854d80cba132133b6af0846204d076a8083a343
3
+ metadata.gz: 05a5aaf51ca610c9a2ea38268de98a9c610205fae9ecbaf2fdc111799264437f
4
+ data.tar.gz: a8a1de4a22e3002203db71564da0c88ed2f0440b5ef3d3c43faf7b419d912727
5
5
  SHA512:
6
- metadata.gz: 982f5e5de1f4183151b0d1daada4c9fc3cc905f98db69195853fe16f59d65740f146446eec243aba23a2035362ed49ab029218e5ed5d2b0539c212fa8b97a433
7
- data.tar.gz: d4a60767cff226b0403d2c645b10cf1857bdf5d5e65b9b59e30a6379d3a6e3ea9f6f243095c7dcbf779a7c5fe68ffbf469f60e35362d2855818c04f71c5da31f
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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class ItemBuilder
4
- VERSION = '0.1.19'
4
+ VERSION = '0.1.20'
5
5
  end
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.19
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