shopify-sinatra-app 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c3e02584eb8e79bcbf60ab18578e11ff839b9c6a
4
- data.tar.gz: deb5585f054df482fc5865ec07934315f1929c8a
3
+ metadata.gz: e1854543c09830d3f60f956339e9c7ad0b022ba9
4
+ data.tar.gz: 4feff63b221008e9d71dbae4117ab485a8c31fb3
5
5
  SHA512:
6
- metadata.gz: 65d064ec39b8b721a76f9b61e95873ed7e6d1e67cd953a3f09f266449edfff8a9a61865971830e8f6feab9605dabb41b6e95922c2d86905234a92fbd1bda1cef
7
- data.tar.gz: 35a7833a1f964b9cefac8445db497243ca55e7d10048416d1e18e83bd858126a848a7b31629a025374e7994e56eb37a585abc835d320e8b4f062134fe0aaca14
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 makes the `webhook_data` available as a hash (note only works for json webhooks, don't use xml). Here is an example that listens to an order creation webhook:
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=<%="https://#{current_shop_name}/admin/products/#{product.id}"%> target="_blank"> <%= product.id %> </a>
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(shop_name, shop.token)
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
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'shopify-sinatra-app'
3
- s.version = '0.0.7'
3
+ s.version = '0.0.8'
4
4
 
5
5
  s.summary = "A classy shopify app"
6
6
  s.description = "A Sinatra extension for building Shopify Apps. Akin to the shopify_app gem but for Sinatra"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shopify-sinatra-app
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Hughes