shopify_app 4.1.1 → 4.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,144 @@
1
+ # Shopify App
2
+
3
+ Shopify application generator for Rails 3.1 and Rails 4.0
4
+
5
+ ## Description
6
+
7
+ This gem makes it easy to get a Rails 3.1 or Rails 4.0 app up and running with the Shopify API.
8
+
9
+ The generator creates a basic SessionsController for authenticating with your shop and a HomeController which displays basic information about your products, orders and articles.
10
+
11
+ *Note: It's recommended to use this on a new Rails project, so that the generator won't overwrite/delete some of your files.*
12
+
13
+ ## Installation
14
+
15
+ ``` sh
16
+ # Create a new rails app
17
+ $ rails new my_shopify_app
18
+ $ cd my_shopify_app
19
+
20
+ # Add the gem shopify_app to your Gemfile
21
+ $ echo "gem 'shopify_app'" >> Gemfile
22
+ $ bundle install
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ ``` sh
28
+ $ rails generate shopify_app your_app_api_key your_app_secret
29
+ ```
30
+
31
+ If you don't have an API key yet, create a Shopify Partner account at http://shopify.com/partners and create an app. You can lso create test shops once you're logged in as a partner.
32
+
33
+ When you create your app in the Shopify Partner Account, set the Application Callback URL to
34
+
35
+ http://localhost:3000
36
+
37
+ You can also create a private application that only works for your shop by visiting https://YOUR-SHOP.myshopify.com/admin/api
38
+
39
+ ### Example
40
+
41
+ ``` sh
42
+ $ rails generate shopify_app edffbb1bb793e2750686e6f4647a384a fed5bb18hde3e2750686e6f4647a781a
43
+ ```
44
+
45
+ This will create a LoginController and a HomeController with their own views.
46
+
47
+ ## Configuring Shopify App
48
+
49
+ It's possible to set your API key and secret key from different sources:
50
+
51
+ * `SHOPIFY_APP_API_KEY` and `SHOPIFY_APP_SECRET` environment variables
52
+ * Configuration in a Rails `<environment>.rb` config file
53
+
54
+ ``` ruby
55
+ config.shopify.api_key = 'your api key'
56
+ config.shopify.secret = 'your secret'
57
+ ```
58
+
59
+ * Configuration loaded from `<environment>` key in `shopify_app.yml`
60
+
61
+ ``` yaml
62
+ development:
63
+ api_key: your api key
64
+ secret: your secret
65
+ ```
66
+
67
+ * Configuration loaded from common key in `shopify_app.yml`
68
+
69
+ ``` yaml
70
+ common:
71
+ api_key: your api key
72
+ secret: your secret
73
+ ```
74
+
75
+ ## Set your required API permissions
76
+
77
+ Before making API requests, your application must state which API permissions it requires from the shop it's installed in. These requested permissions will be listed on the screen the merchant sees when approving your app to be installed in their shop.
78
+
79
+ Start by reviewing the documentation on API permission scopes: http://docs.shopify.com/api/tutorials/oauth
80
+
81
+ When you know which ones your app will need, add a scope line to the `config/initializers/omniauth.rb` file.
82
+
83
+ ### Example
84
+
85
+ Make this change to request write access to products and read access to orders:
86
+
87
+ ``` ruby
88
+ Rails.application.config.middleware.use OmniAuth::Builder do
89
+ provider :shopify,
90
+ ShopifyApp.configuration.api_key,
91
+ ShopifyApp.configuration.secret,
92
+ :scope => "write_products,read_orders",
93
+ :setup => lambda {|env|
94
+ params = Rack::Utils.parse_query(env['QUERY_STRING'])
95
+ site_url = "https://#{params['shop']}"
96
+ env['omniauth.strategy'].options[:client_options][:site] = site_url
97
+ }
98
+ end
99
+ ```
100
+
101
+ *Note that you can change your API permission scopes on the fly, but the merchant will have to approve each change and your computed API password will change.*
102
+
103
+ ## After running the generator
104
+
105
+ First, start your application:
106
+
107
+ ``` sh
108
+ $ rails server
109
+ ```
110
+
111
+ Now visit http://localhost:3000 and install your application in a Shopify store. Even if Rails tells you to visit your app at http://0.0.0.0:3000, go to http://localhost:3000.
112
+
113
+ After your application has been given whatever API permissions you requested by the shop, you're ready to start experimenting with the Shopify API.
114
+
115
+ ## Rails 3.0 (as in before 3.1) Support
116
+
117
+ Rails 3.0 (as in before the big changes in 3.1) is supported on a branch of our github repo: https://github.com/Shopify/shopify_app/tree/rails_3.0_support
118
+
119
+ ## Common problems
120
+
121
+ If you are getting the following error:
122
+
123
+ ```
124
+ Faraday::Error::ConnectionFailed error when accessing app.
125
+ ```
126
+
127
+ It probably means that the CA certificate on your computer is out of date. A simple solution on the Mac is to install XCode.
128
+
129
+ If you are getting the following error:
130
+
131
+ ```
132
+ ActiveResource::ForbiddenAccess in HomeController#index
133
+ Failed. Response code = 403. Response message = Forbidden.
134
+ ```
135
+
136
+ It means that you have not set appropriate permissions in your `config/initializers/omniauth.rb` file for what you are trying to do in your HomeController#index action. Example: you set your permissions to 'write_content' because that's what your app will do, but your HomeController#index still has that default code generated by shopify_app which attempts to read products and orders, neither being covered by the 'write_content' scope.
137
+
138
+ ## Questions or problems?
139
+
140
+ http://api.shopify.com <= Read up on the possible API calls!
141
+
142
+ http://ecommerce.shopify.com/c/shopify-apis-and-technology <= Ask questions!
143
+
144
+ http://wiki.shopify.com/Shopify_App_Development <= Edit the docs!
data/Rakefile CHANGED
@@ -1,2 +1,13 @@
1
- require 'bundler'
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
2
4
  Bundler::GemHelper.install_tasks
5
+
6
+ Rake::TestTask.new do |t|
7
+ t.libs << 'lib/shopify_app'
8
+ t.libs << 'test'
9
+ t.test_files = FileList['test/**/*_test.rb']
10
+ t.verbose = true
11
+ end
12
+
13
+ task :default => :test
@@ -21,21 +21,21 @@ class ShopifyAppGenerator < Rails::Generators::Base
21
21
  end
22
22
 
23
23
  def add_config_variables
24
- api_key_str = api_key.nil? ? "ENV['SHOPIFY_API_KEY']" : api_key.inspect
25
- api_secret_str = secret.nil? ? "ENV['SHOPIFY_API_SECRET']" : secret.inspect
24
+ return if api_key.blank? || secret.blank?
26
25
 
27
26
  inject_into_file 'config/application.rb', <<-DATA, :after => "class Application < Rails::Application\n"
28
27
 
29
28
  # Shopify API connection credentials:
30
- config.shopify.api_key = #{api_key_str}
31
- config.shopify.secret = #{api_secret_str}
32
-
29
+ config.shopify.api_key = '#{api_key}'
30
+ config.shopify.secret = '#{secret}'
33
31
  DATA
34
32
  end
35
33
 
36
34
  def add_bootstrap_gem
37
- insert_into_file "Gemfile", "\ngem 'less-rails-bootstrap'\n\n", :before => '# Gems used only for assets and not required'
38
- insert_into_file "Gemfile", "\ngem 'therubyracer', :platforms => :ruby\n\n", :before => 'end'
35
+ gem_group :development, :test do
36
+ gem "less-rails-bootstrap"
37
+ gem 'therubyracer', :platforms => :ruby
38
+ end
39
39
  end
40
40
 
41
41
  def add_routes
@@ -47,8 +47,8 @@ class ShopifyAppGenerator < Rails::Generators::Base
47
47
  route_without_newline " post 'login' => :create"
48
48
  route_without_newline " get 'login' => :new"
49
49
  route_without_newline "controller :sessions do"
50
- route "match 'design' => 'home#design'"
51
- route_without_newline "match 'welcome' => 'home#welcome'"
50
+ route "get 'design' => 'home#design'"
51
+ route_without_newline "get 'welcome' => 'home#welcome'"
52
52
  end
53
53
  end
54
54
 
@@ -0,0 +1,10 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery
3
+
4
+ # Ask shop to authorize app again if additional permissions are required
5
+ # rescue_from ActiveResource::ForbiddenAccess do
6
+ # session[:shopify] = nil
7
+ # flash[:notice] = "This app requires additional permissions, please log in and authorize it."
8
+ # redirect_to controller: :sessions, action: :create
9
+ # end
10
+ end
@@ -8,7 +8,7 @@ class HomeController < ApplicationController
8
8
  end
9
9
 
10
10
  def index
11
- # get 5 products
11
+ # get 10 products
12
12
  @products = ShopifyAPI::Product.find(:all, :params => {:limit => 10})
13
13
 
14
14
  # get latest 5 orders
@@ -7,7 +7,7 @@
7
7
  <div class="info" style="clear: both">
8
8
  This will send the <strong>API-Key</strong> and <strong>Secret</strong> to a shop, and make sure that you have the rights to
9
9
  access its private admin data.<br/>
10
- After authenticating, you will be redirected to the <code>finalize</code> action of your <code>LoginController</code>, which stores the session, and then redirects you to your example dashboard.<br/>
10
+ After authenticating, you will be redirected to the <code>show</code> action of your <code>SessionsController</code>, which stores the session, and then redirects you to your example dashboard.<br/>
11
11
  Your <code>HomeController</code> will get your recent <code>Orders</code> and <code>Articles</code> through the
12
12
  Shopify <%= link_to 'REST', 'http://www.xfront.com/REST-Web-Services.html', :title => "Get more information about REST web services in general" %> API and list them with all of your <code>Products</code>.
13
13
  You can click on a link of one of your objects and will then be taken to the corresponding admin area of your shop.<br/>
@@ -66,7 +66,7 @@ The callback URL of your app can be changed in the API screen of your Shopify ad
66
66
  <div class="info">
67
67
  This will send the <strong>API-Key</strong> and <strong>Secret</strong> to a shop, and make sure that you have the rights to
68
68
  access its private admin data.<br/>
69
- After authenticating, you will be redirected to the <code>finalize</code> action of your <code>LoginController</code>, which stores the session, and then redirects you to your example dashboard.<br/>
69
+ After authenticating, you will be redirected to the <code>show</code> action of your <code>SessionsController</code>, which stores the session, and then redirects you to your example dashboard.<br/>
70
70
  Your <code>HomeController</code> will get your recent <code>Orders</code> and <code>Articles</code> through the
71
71
  Shopify <%= link_to 'REST', 'http://www.xfront.com/REST-Web-Services.html', :title => "Get more information about REST web services in general" %> API and list them with all of your <code>Products</code>.
72
72
  You can click on a link of one of your objects and will then be taken to the corresponding admin area of your shop.<br/>
@@ -62,6 +62,9 @@
62
62
 
63
63
 
64
64
  <div class="container">
65
+ <% flash.each do |type, message| %>
66
+ <div class="alert"><%= message %></div>
67
+ <% end %>
65
68
 
66
69
  <div class="content">
67
70
  <%= yield %>
@@ -3,7 +3,7 @@ Rails.application.config.middleware.use OmniAuth::Builder do
3
3
  ShopifyApp.configuration.api_key,
4
4
  ShopifyApp.configuration.secret,
5
5
 
6
- # Example permission scopes - see http://api.shopify.com/authentication.html for full listing
6
+ # Example permission scopes - see http://docs.shopify.com/api/tutorials/oauth for full listing
7
7
  :scope => 'read_orders, read_products',
8
8
 
9
9
  :setup => lambda {|env|
@@ -1,3 +1,46 @@
1
- class ShopifyApp::Configuration
2
- attr_accessor :api_key, :secret
1
+ class ShopifyApp::Configuration
2
+ VALID_KEYS = [:api_key, :secret]
3
+ attr_writer *VALID_KEYS
4
+
5
+ def initialize(params={})
6
+ self.params = default_params.merge(params)
7
+ end
8
+
9
+ VALID_KEYS.each do |meth|
10
+ define_method meth do
11
+ meth = meth.to_s
12
+ config_from_env(meth) || config_from_rails(meth) || config_from_file(meth) || ''
13
+ end
14
+ end
15
+
16
+ private
17
+
18
+ attr_accessor :params
19
+
20
+ def config_from_env(meth)
21
+ ENV["SHOPIFY_APP_#{meth.upcase}"]
22
+ end
23
+
24
+ def config_from_rails(meth)
25
+ instance_variable_get("@#{meth}")
26
+ end
27
+
28
+ def config_from_file(meth)
29
+ @config_file ||= load_config
30
+ @config_file[Rails.env].try(:[], meth) || @config_file['common'].try(:[], meth)
31
+ end
32
+
33
+ def load_config
34
+ File.exist?(config_filepath) ? YAML.load_file(config_filepath) : {}
35
+ end
36
+
37
+ def config_filepath
38
+ params[:config_file]
39
+ end
40
+
41
+ def default_params
42
+ {
43
+ config_file: File.join(Rails.root, 'config', 'shopify_app.yml')
44
+ }
45
+ end
3
46
  end
@@ -8,7 +8,7 @@ module ShopifyApp::LoginProtection
8
8
  def shopify_session
9
9
  if session[:shopify]
10
10
  begin
11
- # session[:shopify] set in LoginController#finalize
11
+ # session[:shopify] set in LoginController#show
12
12
  ShopifyAPI::Base.activate_session(session[:shopify])
13
13
  yield
14
14
  ensure
@@ -16,7 +16,7 @@ module ShopifyApp::LoginProtection
16
16
  end
17
17
  else
18
18
  session[:return_to] = request.fullpath if request.get?
19
- redirect_to login_path
19
+ redirect_to login_path(shop: params[:shop])
20
20
  end
21
21
  end
22
22
 
@@ -1,3 +1,3 @@
1
1
  module ShopifyApp
2
- VERSION = "4.1.1"
2
+ VERSION = "4.2.0"
3
3
  end
@@ -14,11 +14,14 @@ Gem::Specification.new do |s|
14
14
 
15
15
  s.rubyforge_project = "shopify-api"
16
16
 
17
- s.add_runtime_dependency('rails', '~> 3.1')
17
+ s.add_runtime_dependency('rails', '>= 3.1', '< 5.0')
18
18
  s.add_runtime_dependency('shopify_api', '~> 3.0.0')
19
19
  s.add_runtime_dependency('omniauth-shopify-oauth2', '1.1.0')
20
+ s.add_runtime_dependency('less-rails-bootstrap', '>0')
20
21
 
21
22
  s.add_development_dependency('rake')
23
+ s.add_development_dependency('minitest')
24
+ s.add_development_dependency('mocha')
22
25
 
23
26
  s.files = `git ls-files`.split("\n")
24
27
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -0,0 +1,7 @@
1
+ common:
2
+ api_key: should never see this api key value
3
+ secret: should never see this secret value
4
+
5
+ development:
6
+ api_key: development key
7
+ secret: development secret
@@ -0,0 +1 @@
1
+ common:
@@ -0,0 +1,3 @@
1
+ common:
2
+ api_key: api key from other file
3
+ secret: secret from other file
@@ -0,0 +1,3 @@
1
+ common:
2
+ api_key: api key from default file
3
+ secret: secret from default file
@@ -0,0 +1,78 @@
1
+ require 'test_helper'
2
+
3
+ class ConfigurationTest < MiniTest::Unit::TestCase
4
+ def setup
5
+ Rails.stubs(:env).returns('development')
6
+ Rails.stubs(:root).returns(File.expand_path('../..', File.dirname(__FILE__)))
7
+ end
8
+
9
+ def config_file(filename)
10
+ filepath = File.expand_path("../../config/#{filename}", File.dirname(__FILE__))
11
+ end
12
+
13
+ def test_define_method_creates_readers
14
+ config = ShopifyApp::Configuration.new
15
+ config.respond_to?(:api_key)
16
+ config.respond_to?(:secret)
17
+ end
18
+
19
+ def test_defaults_to_empty_string
20
+ config = ShopifyApp::Configuration.new(config_file: config_file('empty_config_file.yml'))
21
+
22
+ assert_equal '', config.api_key
23
+ assert_equal '', config.secret
24
+ end
25
+
26
+ def test_environment_has_precedence_over_common
27
+ config = ShopifyApp::Configuration.new(config_file: config_file('development_config_file.yml'))
28
+
29
+ assert_equal 'development key', config.api_key
30
+ assert_equal 'development secret', config.secret
31
+ end
32
+
33
+ def test_rails_has_precedence_over_environment
34
+ config = ShopifyApp::Configuration.new(config_file: config_file('development_config_file.yml'))
35
+
36
+ assert_equal 'development key', config.api_key
37
+ assert_equal 'development secret', config.secret
38
+
39
+ config.api_key = 'rails key'
40
+ config.secret = 'rails secret'
41
+
42
+ assert_equal 'rails key', config.api_key
43
+ assert_equal 'rails secret', config.secret
44
+ end
45
+
46
+ def test_env_has_precedence_over_rails
47
+ config = ShopifyApp::Configuration.new
48
+ config.api_key = 'rails key'
49
+ config.secret = 'rails secret'
50
+
51
+ assert_equal 'rails key', config.api_key
52
+ assert_equal 'rails secret', config.secret
53
+
54
+ ENV.expects(:[]).with('SHOPIFY_APP_API_KEY').returns('env key')
55
+ ENV.expects(:[]).with('SHOPIFY_APP_SECRET').returns('env secret')
56
+
57
+ assert_equal 'env key', config.api_key
58
+ assert_equal 'env secret', config.secret
59
+ end
60
+
61
+ def test_reads_config_from_default_config_file
62
+ config = ShopifyApp::Configuration.new
63
+ assert_equal 'api key from default file', config.api_key
64
+ assert_equal 'secret from default file', config.secret
65
+ end
66
+
67
+ def test_reads_config_from_specified_config_file
68
+ config = ShopifyApp::Configuration.new(config_file: config_file('other_config_file.yml'))
69
+ assert_equal 'api key from other file', config.api_key
70
+ assert_equal 'secret from other file', config.secret
71
+ end
72
+
73
+ def test_handles_missing_config_file
74
+ config = ShopifyApp::Configuration.new(config_file: config_file('missing_config_file.yml'))
75
+ assert_equal '', config.api_key
76
+ assert_equal '', config.secret
77
+ end
78
+ end
@@ -0,0 +1,5 @@
1
+ require 'minitest/autorun'
2
+ require 'minitest/pride'
3
+ require 'mocha/setup'
4
+
5
+ require File.expand_path('../../lib/shopify_app.rb', __FILE__)
metadata CHANGED
@@ -1,60 +1,134 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shopify_app
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.1
5
4
  prerelease:
5
+ version: 4.2.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Shopify
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-27 00:00:00.000000000 Z
12
+ date: 2013-07-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: rails
16
- requirement: &70331226041240 !ruby/object:Gem::Requirement
17
- none: false
15
+ version_requirements: !ruby/object:Gem::Requirement
18
16
  requirements:
19
- - - ~>
17
+ - - ! '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '3.1'
20
+ - - <
21
+ - !ruby/object:Gem::Version
22
+ version: '5.0'
23
+ none: false
24
+ name: rails
22
25
  type: :runtime
23
26
  prerelease: false
24
- version_requirements: *70331226041240
25
- - !ruby/object:Gem::Dependency
26
- name: shopify_api
27
- requirement: &70331226040720 !ruby/object:Gem::Requirement
27
+ requirement: !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ! '>='
30
+ - !ruby/object:Gem::Version
31
+ version: '3.1'
32
+ - - <
33
+ - !ruby/object:Gem::Version
34
+ version: '5.0'
28
35
  none: false
36
+ - !ruby/object:Gem::Dependency
37
+ version_requirements: !ruby/object:Gem::Requirement
29
38
  requirements:
30
39
  - - ~>
31
40
  - !ruby/object:Gem::Version
32
41
  version: 3.0.0
42
+ none: false
43
+ name: shopify_api
33
44
  type: :runtime
34
45
  prerelease: false
35
- version_requirements: *70331226040720
46
+ requirement: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ~>
49
+ - !ruby/object:Gem::Version
50
+ version: 3.0.0
51
+ none: false
36
52
  - !ruby/object:Gem::Dependency
37
- name: omniauth-shopify-oauth2
38
- requirement: &70331226040180 !ruby/object:Gem::Requirement
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - '='
56
+ - !ruby/object:Gem::Version
57
+ version: 1.1.0
39
58
  none: false
59
+ name: omniauth-shopify-oauth2
60
+ type: :runtime
61
+ prerelease: false
62
+ requirement: !ruby/object:Gem::Requirement
40
63
  requirements:
41
- - - =
64
+ - - '='
42
65
  - !ruby/object:Gem::Version
43
66
  version: 1.1.0
67
+ none: false
68
+ - !ruby/object:Gem::Dependency
69
+ version_requirements: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ! '>'
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ none: false
75
+ name: less-rails-bootstrap
44
76
  type: :runtime
45
77
  prerelease: false
46
- version_requirements: *70331226040180
78
+ requirement: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>'
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ none: false
47
84
  - !ruby/object:Gem::Dependency
85
+ version_requirements: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ! '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ none: false
48
91
  name: rake
49
- requirement: &70331226039740 !ruby/object:Gem::Requirement
92
+ type: :development
93
+ prerelease: false
94
+ requirement: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
50
99
  none: false
100
+ - !ruby/object:Gem::Dependency
101
+ version_requirements: !ruby/object:Gem::Requirement
51
102
  requirements:
52
103
  - - ! '>='
53
104
  - !ruby/object:Gem::Version
54
105
  version: '0'
106
+ none: false
107
+ name: minitest
55
108
  type: :development
56
109
  prerelease: false
57
- version_requirements: *70331226039740
110
+ requirement: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ! '>='
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ none: false
116
+ - !ruby/object:Gem::Dependency
117
+ version_requirements: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ! '>='
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ none: false
123
+ name: mocha
124
+ type: :development
125
+ prerelease: false
126
+ requirement: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ! '>='
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ none: false
58
132
  description: Creates a basic sessions controller for authenticating with your Shop
59
133
  and also a product controller which lets your edit your products easily.
60
134
  email:
@@ -68,7 +142,7 @@ files:
68
142
  - .gitignore
69
143
  - CHANGELOG
70
144
  - Gemfile
71
- - README.rdoc
145
+ - README.md
72
146
  - RELEASING
73
147
  - Rakefile
74
148
  - install.rb
@@ -86,6 +160,7 @@ files:
86
160
  - lib/generators/shopify_app/templates/app/assets/stylesheets/imports.css.less
87
161
  - lib/generators/shopify_app/templates/app/assets/stylesheets/shopify_app.css.scss
88
162
  - lib/generators/shopify_app/templates/app/assets/stylesheets/shopify_app_buttons.css.less
163
+ - lib/generators/shopify_app/templates/app/controllers/application_controller.rb
89
164
  - lib/generators/shopify_app/templates/app/controllers/home_controller.rb
90
165
  - lib/generators/shopify_app/templates/app/controllers/sessions_controller.rb
91
166
  - lib/generators/shopify_app/templates/app/helpers/home_helper.rb
@@ -110,6 +185,12 @@ files:
110
185
  - lib/shopify_app/railtie.rb
111
186
  - lib/shopify_app/version.rb
112
187
  - shopify_app.gemspec
188
+ - test/config/development_config_file.yml
189
+ - test/config/empty_config_file.yml
190
+ - test/config/other_config_file.yml
191
+ - test/config/shopify_app.yml
192
+ - test/lib/shopify_app/configuration_test.rb
193
+ - test/test_helper.rb
113
194
  homepage: http://www.shopify.com/developers
114
195
  licenses: []
115
196
  post_install_message:
@@ -117,22 +198,27 @@ rdoc_options: []
117
198
  require_paths:
118
199
  - lib
119
200
  required_ruby_version: !ruby/object:Gem::Requirement
120
- none: false
121
201
  requirements:
122
202
  - - ! '>='
123
203
  - !ruby/object:Gem::Version
124
204
  version: '0'
125
- required_rubygems_version: !ruby/object:Gem::Requirement
126
205
  none: false
206
+ required_rubygems_version: !ruby/object:Gem::Requirement
127
207
  requirements:
128
208
  - - ! '>='
129
209
  - !ruby/object:Gem::Version
130
210
  version: '0'
211
+ none: false
131
212
  requirements: []
132
213
  rubyforge_project: shopify-api
133
- rubygems_version: 1.8.11
214
+ rubygems_version: 1.8.23
134
215
  signing_key:
135
216
  specification_version: 3
136
217
  summary: This gem is used to get quickly started with the Shopify API
137
- test_files: []
138
- has_rdoc:
218
+ test_files:
219
+ - test/config/development_config_file.yml
220
+ - test/config/empty_config_file.yml
221
+ - test/config/other_config_file.yml
222
+ - test/config/shopify_app.yml
223
+ - test/lib/shopify_app/configuration_test.rb
224
+ - test/test_helper.rb
@@ -1,89 +0,0 @@
1
- = Shopify application generator for Rails 3.2
2
-
3
- == Description
4
-
5
- This gem makes it easy to get a Rails 3.2 app up and running with the
6
- Shopify API.
7
-
8
- The generator creates a basic SessionsController for authenticating with your
9
- shop and a HomeController which displays basic information about your
10
- products, orders and articles.
11
-
12
- <i>Note: It's recommended to use this on a new Rails project, so that the
13
- generator won't overwrite/delete some of your files.</i>
14
-
15
- == Installation
16
-
17
- # Add the gem shopify_app to your Gemfile
18
- $ echo "gem 'shopify_app'" >> Gemfile
19
- $ bundle install
20
-
21
- == Usage
22
-
23
- $ rails generate shopify_app your_app_api_key your_app_secret
24
-
25
- If you don't have an API key yet, create a Shopify Partner account at
26
- http://shopify.com/partners and create an app. You can also create test shops
27
- once you're logged in as a partner.
28
-
29
- When you create your app in the Shopify Partner Account, set the Application URL to
30
- <tt>http://localhost:3000/login</tt>
31
-
32
- You can also create a private application that only works for your shop by
33
- visiting https://YOUR-SHOP.myshopify.com/admin/api
34
-
35
- === Example
36
-
37
- $ rails generate shopify_app edffbb1bb793e2750686e6f4647a384a fed5bb18hde3e2750686e6f4647a781a
38
-
39
- This will create a LoginController and a HomeController with their own views.
40
-
41
-
42
- == Set your required API permissions
43
-
44
- Before making API requests, your application must state which API permissions it requires from the shop it's installed in. These requested permissions will be listed on the screen the merchant sees when approving your app to be installed in their shop.
45
-
46
- Start by reviewing the documentation on API permission scopes: http://api.shopify.com/authentication.html
47
-
48
- When you know which ones your app will need, add a scope line to the <tt>config/initializers/omniauth.rb</tt> file.
49
-
50
- === Example
51
-
52
- Make this change to request write access to products and read access to orders:
53
-
54
- Rails.application.config.middleware.use OmniAuth::Builder do
55
- provider :shopify,
56
- ShopifyApp.configuration.api_key,
57
- ShopifyApp.configuration.secret,
58
- :scope => "write_products,read_orders",
59
- :setup => lambda {|env|
60
- params = Rack::Utils.parse_query(env['QUERY_STRING'])
61
- site_url = "https://#{params['shop']}"
62
- env['omniauth.strategy'].options[:client_options][:site] = site_url
63
- }
64
- end
65
-
66
- (Note that you can change your API permission scopes on the fly, but the merchant will have to approve each change and your computed API password will change.)
67
-
68
- == After running the generator
69
-
70
- First, start your application:
71
-
72
- $ rails server
73
-
74
- Now visit http://localhost:3000 and install your application in a Shopify store.
75
-
76
- After your application has been given whatever API permissions you requested by the
77
- shop, you're ready to start experimenting with the Shopify API.
78
-
79
- == Rails 3.0 (as in before 3.1) Support
80
-
81
- Rails 3.0 (as in before the big changes in 3.1) is supported on a branch of our github repo: https://github.com/Shopify/shopify_app/tree/rails_3.0_support
82
-
83
- == Questions or problems?
84
-
85
- http://api.shopify.com <= Read up on the possible API calls!
86
-
87
- http://ecommerce.shopify.com/c/shopify-apis-and-technology <= Ask questions!
88
-
89
- http://wiki.shopify.com/Shopify_App_Development <= Edit the docs!