Sha256: 69f0c464400d434fb65a5c1cdb03e708974ba02bf07ecd8de6ff6bfe95f479da
Contents?: true
Size: 857 Bytes
Versions: 1
Compression:
Stored size: 857 Bytes
Contents
require 'httparty' module SgDeliverySlotChecker module Stores class Fairprice def initialize(postal_code:) @postal_code = postal_code end def available? if store_id get_availability(store: store_id) else false end end private attr_reader :postal_code def store_id response = HTTParty.get("https://website-api.omni.fairprice.com.sg/api/serviceable-area?city=Singapore&pincode=\"#{postal_code}\"") response.parsed_response&.dig("data", "store", "id") end def get_availability(store:) response = HTTParty.get("https://website-api.omni.fairprice.com.sg/api/slot-availability?address[pincode]=\"#{postal_code}\"&storeId=#{store}") response.parsed_response&.dig("data", "available") end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sg_delivery_slot_checker-0.3.0 | lib/sg_delivery_slot_checker/stores/fairprice.rb |