Sha256: 7d1d01811b1066a732ef334118fa09b45f09b808beb5a43298cb4ab1427f86a4
Contents?: true
Size: 905 Bytes
Versions: 1
Compression:
Stored size: 905 Bytes
Contents
require 'sinatra/shopify-sinatra-app' class SinatraApp < Sinatra::Base register Sinatra::Shopify get '/' do # your app's Home page shopify_session do |shop_name| @shop = Shop.find_by(:name => shop_name) @products = ShopifyAPI::Product.all(limit: 5) erb :home end end private def install # setup any webhooks or services you need when your app is installed shopify_session do |shop_name| params = YAML.load(File.read("config/app.yml")) # create the uninstall webhook uninstall_webhook = ShopifyAPI::Webhook.new(params["uninstall_webhook"]) unless ShopifyAPI::Webhook.find(:all).include?(uninstall_webhook) uninstall_webhook.save end end redirect '/' end def uninstall # remove data for a shop when they uninstall your app webhook_session do |shop, params| shop.destroy end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
shopify-sinatra-app-0.0.1 | lib/generator/lib/app.rb |