sg_delivery_slot_checker 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7ed4b1f74e908360b66ac8dbae13e6f650bdf62058cf37631d9bd07bec7ea1e4
4
- data.tar.gz: b751d1c63f5f3b2499744f595a89a547b17b9de03c2866664ecd12ec2ebe3d4b
3
+ metadata.gz: fb75d060692f9b14b0a8022be4d7228e7b3629c5158c48e282e5dfa2429159d2
4
+ data.tar.gz: 30fed5a94bd259e20209e67951fd89c4123fde97540517354dede3849e8aed1b
5
5
  SHA512:
6
- metadata.gz: 64798ce7a4f5519886b7956b7eeee2577a0bf0d80f93d38af1b0011dd5a6592048b634e6ebf8706ea466d78517e48741c7a6cfb2bfdd0285a93688be15a6e0aa
7
- data.tar.gz: 2939220778ee577d49ff0d32fcecf20b9e38fb527bb1e3097e94e18a4ba6716afe46b72a6ea76a30ebd204868e2d22719e4d80f80d001452843141983a504ff2
6
+ metadata.gz: df9b1cc0180f9bee98a09efced54576a4d1c5bf0a5545567039fbf09fc908ccdab102d4a4cd3f08d78baabddab00b8f5369ab8f7cfd7322bb867fa7b70b25b8d
7
+ data.tar.gz: 874e3c4d52ec05497a1ab38e99d2afa26cd581fe017434d7445fecdc33f4623dc84e170114bce937d94c404fe22b76654dfedafa6010552f8856326877195e56
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sg_delivery_slot_checker (0.1.0)
4
+ sg_delivery_slot_checker (0.2.0)
5
5
  hashie (~> 4.1.0)
6
6
  httparty (~> 0.18)
7
7
 
@@ -6,7 +6,7 @@ module SgDeliverySlotChecker
6
6
  class Checker
7
7
 
8
8
  def initialize(postal_code:)
9
- @postal_code = postal_code.to_s
9
+ @postal_code = postal_code
10
10
  end
11
11
 
12
12
  def check_availability
@@ -18,11 +18,8 @@ module SgDeliverySlotChecker
18
18
  attr_reader :postal_code
19
19
 
20
20
  def get_availability
21
- response = HTTParty.post('https://coldstorage.com.sg/checkout/cart/checkdelivery',
22
- body: {
23
- 'postal_code': postal_code
24
- }
25
- )
21
+ response = HTTParty.get("https://coldstorage.com.sg/checkout/cart/checkdelivery?postal_code=#{postal_code}")
22
+
26
23
  slots = response.parsed_response
27
24
  slots.extend Hashie::Extensions::DeepFind
28
25
  slots.deep_find_all("available").any?(true)
@@ -21,12 +21,12 @@ module SgDeliverySlotChecker
21
21
  attr_reader :postal_code
22
22
 
23
23
  def store_id
24
- response = HTTParty.get("https://website-api.omni.fairprice.com.sg/api/serviceable-area?city=Singapore&pincode=#{postal_code}")
24
+ response = HTTParty.get("https://website-api.omni.fairprice.com.sg/api/serviceable-area?city=Singapore&pincode=\"#{postal_code}\"")
25
25
  response.parsed_response&.dig("data", "store", "id")
26
26
  end
27
27
 
28
28
  def get_availability(store:)
29
- response = HTTParty.get("https://website-api.omni.fairprice.com.sg/api/slot-availability?address[pincode]=#{postal_code}&storeId=#{store}")
29
+ response = HTTParty.get("https://website-api.omni.fairprice.com.sg/api/slot-availability?address[pincode]=\"#{postal_code}\"&storeId=#{store}")
30
30
  response.parsed_response&.dig("data", "available")
31
31
  end
32
32
 
@@ -1,3 +1,3 @@
1
1
  module SgDeliverySlotChecker
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sg_delivery_slot_checker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vincent Paca