shopify-sinatra-app 0.0.7 → 0.0.8
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 +4 -4
- data/README.md +1 -1
- data/lib/generator/views/home.erb +1 -1
- data/lib/sinatra/shopify-sinatra-app.rb +7 -6
- data/shopify-sinatra-app.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1854543c09830d3f60f956339e9c7ad0b022ba9
|
4
|
+
data.tar.gz: 4feff63b221008e9d71dbae4117ab485a8c31fb3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d1e99622f237fec0c38e265589b561c8a03ed0ad0603aa52810fc559b5a55f9a60827c842f4b83c71441a8676be4a0fd5e9cc6553d0bda7414f5a2b4667d553
|
7
|
+
data.tar.gz: 15c4de8878a15a3e816c05f9862e56f2f2123fbd5c4fce10c2075dc1c67bfa16d623757fd96a1ab6e360baa530efb2b5e5ff88d06c3973a0af3e20879c1302eb
|
data/README.md
CHANGED
@@ -83,7 +83,7 @@ get '/products.json' do
|
|
83
83
|
end
|
84
84
|
```
|
85
85
|
|
86
|
-
**webhook_session** - This method is for an endpoint that recieves a webhook from Shopify. Webhooks are a great way to keep your app in sync with a shop's data without polling. You can read more about webhooks [here](http://docs.shopify.com/api/tutorials/using-webhooks). This method also takes a block of code and
|
86
|
+
**webhook_session** - This method is for an endpoint that recieves a webhook from Shopify. Webhooks are a great way to keep your app in sync with a shop's data without polling. You can read more about webhooks [here](http://docs.shopify.com/api/tutorials/using-webhooks). This method also takes a block of code and yields the `webhook_data` as a hash (note only works for json webhooks, don't use xml). Here is an example that listens to an order creation webhook:
|
87
87
|
|
88
88
|
```ruby
|
89
89
|
post '/order.json' do
|
@@ -9,7 +9,7 @@
|
|
9
9
|
<% @products.each do |product| %>
|
10
10
|
<tr>
|
11
11
|
<td>
|
12
|
-
<a href=<%="
|
12
|
+
<a href=<%="#{current_shop_url}/admin/products/#{product.id}"%> target="_blank"> <%= product.id %> </a>
|
13
13
|
</td>
|
14
14
|
</tr>
|
15
15
|
<% end %>
|
@@ -32,7 +32,8 @@ module Sinatra
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def current_shop_name
|
35
|
-
session[:shopify][:shop] if session.has_key?(:shopify)
|
35
|
+
return session[:shopify][:shop] if session.has_key?(:shopify)
|
36
|
+
return @shop_name if @shop_name
|
36
37
|
end
|
37
38
|
|
38
39
|
def current_shop_url
|
@@ -59,12 +60,12 @@ module Sinatra
|
|
59
60
|
def webhook_session(&blk)
|
60
61
|
return unless verify_shopify_webhook
|
61
62
|
|
62
|
-
shop_name = request.env['HTTP_X_SHOPIFY_SHOP_DOMAIN']
|
63
|
-
shop = Shop.find_by(:name => shop_name)
|
63
|
+
@shop_name = request.env['HTTP_X_SHOPIFY_SHOP_DOMAIN']
|
64
|
+
shop = Shop.find_by(:name => @shop_name)
|
64
65
|
|
65
66
|
if shop.present?
|
66
67
|
params = ActiveSupport::JSON.decode(request.body.read.to_s)
|
67
|
-
api_session = ShopifyAPI::Session.new(
|
68
|
+
api_session = ShopifyAPI::Session.new(shop.name, shop.token)
|
68
69
|
ShopifyAPI::Base.activate_session(api_session)
|
69
70
|
|
70
71
|
yield params
|
@@ -76,8 +77,8 @@ module Sinatra
|
|
76
77
|
def webhook_job(jobKlass)
|
77
78
|
return unless verify_shopify_webhook
|
78
79
|
|
79
|
-
shop_name = request.env['HTTP_X_SHOPIFY_SHOP_DOMAIN']
|
80
|
-
shop = Shop.find_by(:name => shop_name)
|
80
|
+
@shop_name = request.env['HTTP_X_SHOPIFY_SHOP_DOMAIN']
|
81
|
+
shop = Shop.find_by(:name => @shop_name)
|
81
82
|
|
82
83
|
params = ActiveSupport::JSON.decode(request.body.read.to_s)
|
83
84
|
|
data/shopify-sinatra-app.gemspec
CHANGED