class SgDeliverySlotChecker::Stores::ColdStorage

Attributes

postal_code[R]

Public Class Methods

new(postal_code:) click to toggle source
# File lib/sg_delivery_slot_checker/stores/cold_storage.rb, line 8
def initialize(postal_code:)
  @postal_code = postal_code
end

Public Instance Methods

available?() click to toggle source
# File lib/sg_delivery_slot_checker/stores/cold_storage.rb, line 12
def available?
  get_availability
end

Private Instance Methods

get_availability() click to toggle source
# File lib/sg_delivery_slot_checker/stores/cold_storage.rb, line 20
def get_availability
  response = HTTParty.get("https://coldstorage.com.sg/checkout/cart/checkdelivery?postal_code=#{postal_code}")

  slots = response.parsed_response
  slots.extend Hashie::Extensions::DeepFind
  slots.deep_find_all("available").any?(true)
end