lib/lita/handlers/onewheel_beer_properpint.rb in lita-onewheel-beer-properpint-0.0.2 vs lib/lita/handlers/onewheel_beer_properpint.rb in lita-onewheel-beer-properpint-0.1.0
- old
+ new
@@ -47,12 +47,13 @@
end
def get_source
# unless (response = redis.get('page_response'))
# Lita.logger.info 'No cached result found, fetching.'
- Lita.logger.info 'Getting https://my-site-109373-104980.square.site'
- response = RestClient.get('https://my-site-109373-104980.square.site')
+ url = 'https://my-site-109373-104980.square.site/dine-in'
+ Lita.logger.info "Getting #{url}"
+ response = RestClient.get(url)
# redis.setex('page_response', 1800, response)
# end
parse_response response
end
@@ -65,10 +66,10 @@
valid_products = {}
products = {}
response.split(/\n/).each do |line|
if matches = line.match(/window.siteData = (.*)/)
site_hash = JSON.parse matches[1].sub /;$/, ''
- valid_products = site_hash['page']['properties']['contentAreas']['userContent']['content']['cells'][0]['content']['properties']['menuItems']
+ valid_products = site_hash['page']['properties']['contentAreas']['userContent']['content']['cells'][0]['content']['properties']['products']
end
if matches = line.match(/window.__BOOTSTRAP_STATE__ = (.*)/)
whatevenintheshitsquarespace = JSON.parse matches[1].sub /;$/, ''
products = whatevenintheshitsquarespace['commerceLinks']['products']
end