sg_delivery_slot_checker 0.1.0 → 0.2.0
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: 7ed4b1f74e908360b66ac8dbae13e6f650bdf62058cf37631d9bd07bec7ea1e4
|
4
|
+
data.tar.gz: b751d1c63f5f3b2499744f595a89a547b17b9de03c2866664ecd12ec2ebe3d4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64798ce7a4f5519886b7956b7eeee2577a0bf0d80f93d38af1b0011dd5a6592048b634e6ebf8706ea466d78517e48741c7a6cfb2bfdd0285a93688be15a6e0aa
|
7
|
+
data.tar.gz: 2939220778ee577d49ff0d32fcecf20b9e38fb527bb1e3097e94e18a4ba6716afe46b72a6ea76a30ebd204868e2d22719e4d80f80d001452843141983a504ff2
|
data/README.md
CHANGED
@@ -29,7 +29,7 @@ SgDeliverySlotChecker::Checker.new(postal_code: 149555).check_availability
|
|
29
29
|
```
|
30
30
|
Returns the following `Hash`
|
31
31
|
```
|
32
|
-
|
32
|
+
{ fairprice: true, giant: false }
|
33
33
|
```
|
34
34
|
|
35
35
|
## Development
|
@@ -40,7 +40,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
40
40
|
|
41
41
|
## Contributing
|
42
42
|
|
43
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
43
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/vincentpaca/sg_delivery_slot_checker.
|
44
44
|
|
45
45
|
|
46
46
|
## License
|
@@ -1,11 +1,12 @@
|
|
1
1
|
require "sg_delivery_slot_checker/stores/fairprice"
|
2
2
|
require "sg_delivery_slot_checker/stores/giant"
|
3
|
+
require "sg_delivery_slot_checker/stores/cold_storage"
|
3
4
|
|
4
5
|
module SgDeliverySlotChecker
|
5
6
|
class Checker
|
6
7
|
|
7
8
|
def initialize(postal_code:)
|
8
|
-
@postal_code = postal_code
|
9
|
+
@postal_code = postal_code.to_s
|
9
10
|
end
|
10
11
|
|
11
12
|
def check_availability
|
@@ -23,7 +24,8 @@ module SgDeliverySlotChecker
|
|
23
24
|
def stores
|
24
25
|
{
|
25
26
|
fairprice: SgDeliverySlotChecker::Stores::Fairprice,
|
26
|
-
giant: SgDeliverySlotChecker::Stores::Giant
|
27
|
+
giant: SgDeliverySlotChecker::Stores::Giant,
|
28
|
+
cold_storage: SgDeliverySlotChecker::Stores::ColdStorage
|
27
29
|
}
|
28
30
|
end
|
29
31
|
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
require 'hashie'
|
3
|
+
|
4
|
+
module SgDeliverySlotChecker
|
5
|
+
module Stores
|
6
|
+
class ColdStorage
|
7
|
+
|
8
|
+
def initialize(postal_code:)
|
9
|
+
@postal_code = postal_code
|
10
|
+
end
|
11
|
+
|
12
|
+
def available?
|
13
|
+
get_availability
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
attr_reader :postal_code
|
19
|
+
|
20
|
+
def get_availability
|
21
|
+
response = HTTParty.post('https://coldstorage.com.sg/checkout/cart/checkdelivery',
|
22
|
+
body: {
|
23
|
+
'postal_code': postal_code
|
24
|
+
}
|
25
|
+
)
|
26
|
+
slots = response.parsed_response
|
27
|
+
slots.extend Hashie::Extensions::DeepFind
|
28
|
+
slots.deep_find_all("available").any?(true)
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sg_delivery_slot_checker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vincent Paca
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-05-
|
11
|
+
date: 2020-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -139,6 +139,7 @@ files:
|
|
139
139
|
- bin/setup
|
140
140
|
- lib/sg_delivery_slot_checker.rb
|
141
141
|
- lib/sg_delivery_slot_checker/checker.rb
|
142
|
+
- lib/sg_delivery_slot_checker/stores/cold_storage.rb
|
142
143
|
- lib/sg_delivery_slot_checker/stores/fairprice.rb
|
143
144
|
- lib/sg_delivery_slot_checker/stores/giant.rb
|
144
145
|
- lib/sg_delivery_slot_checker/version.rb
|