shopify_api 3.0.0 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/CHANGELOG +10 -0
- data/README.rdoc +35 -11
- data/lib/shopify_api/resources/base.rb +5 -1
- data/lib/shopify_api/version.rb +1 -1
- data/test/fixtures/product.json +4 -0
- data/test/product_test.rb +8 -0
- metadata +11 -10
data/CHANGELOG
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
== Version 3.0.1
|
2
|
+
|
3
|
+
* Fix saving nested resources in ActiveResource 3.1+
|
4
|
+
|
5
|
+
== Version 3.0.0
|
6
|
+
|
7
|
+
* Added support for OAuth Authentication
|
8
|
+
* Removal of support for Legacy Authentication
|
9
|
+
* Added Cart resource
|
10
|
+
|
1
11
|
== Version 2.3.0
|
2
12
|
|
3
13
|
* Fix double root bug with ActiveSupport 3.2.0
|
data/README.rdoc
CHANGED
@@ -26,26 +26,39 @@ ShopifyAPI uses ActiveResource to communicate with the REST web service. ActiveR
|
|
26
26
|
|
27
27
|
ShopifyAPI::Session.setup({:api_key => API_KEY, :secret => SHARED_SECRET})
|
28
28
|
|
29
|
-
3.
|
29
|
+
3. To access a shop's data apps need an access token from that specific shop. This is a two-stage process. Before interacting with a shop for the first time an app should redirect the user to the following URL:
|
30
30
|
|
31
|
-
|
32
|
-
session.valid? # returns false
|
31
|
+
GET https://SHOP_NAME.myshopify.com/admin/oauth/authorize
|
33
32
|
|
34
|
-
|
33
|
+
with the following parameters:
|
35
34
|
|
36
|
-
|
35
|
+
* client_id – Required – The API key for your app
|
36
|
+
* scope – Required – The list of required scopes (explained below)
|
37
|
+
* redirect_uri – Optional – The URL that the merchant will be sent to once authentication is complete. Must be the same host as the Return URL specified in the application settings
|
37
38
|
|
38
|
-
|
39
|
+
4. Once authorized, the shop redirects the owner to the return URL of your application with a parameter named 'code'. This is a temporary token the the app can exchange for a permanent access token. Make the following call:
|
39
40
|
|
40
|
-
|
41
|
+
POST https://SHOP_NAME.myshopify.com/admin/oauth/access_token
|
42
|
+
|
43
|
+
with the following parameters:
|
44
|
+
|
45
|
+
* client_id – Required – The API key for your app
|
46
|
+
* client_secret – Required – The shared secret for your app
|
47
|
+
* code – Required – The token you received in step 3
|
48
|
+
|
49
|
+
and you'll get your permanent access token back in the response.
|
50
|
+
|
51
|
+
5. Use that token to instantiate a session that is ready to make calls to the given shop.
|
52
|
+
|
53
|
+
token = params[:code]
|
41
54
|
session = ShopifyAPI::Session.new("yourshopname.myshopify.com", token)
|
42
55
|
session.valid? # returns true
|
43
56
|
|
44
|
-
|
57
|
+
5. Now you can activate the session and you're set:
|
45
58
|
|
46
|
-
|
59
|
+
ShopifyAPI::Base.activate_session(session)
|
47
60
|
|
48
|
-
|
61
|
+
6. Get data from that shop (returns ActiveResource instances):
|
49
62
|
|
50
63
|
shop = ShopifyAPI::Shop.current
|
51
64
|
latest_orders = ShopifyAPI::Order.find(:all)
|
@@ -54,7 +67,18 @@ ShopifyAPI uses ActiveResource to communicate with the REST web service. ActiveR
|
|
54
67
|
|
55
68
|
latest_orders = ShopifyAPI::Session.temp("yourshopname.myshopify.com", token) { ShopifyAPI::Order.find(:all) }
|
56
69
|
|
70
|
+
7. Finally, you can also clear the session (for example if you want to work with another shop):
|
71
|
+
|
72
|
+
ShopifyAPI::Base.clear_session
|
73
|
+
|
74
|
+
== Questions or Problems?
|
75
|
+
|
76
|
+
http://api.shopify.com <= Read the tech docs!
|
77
|
+
|
78
|
+
http://wiki.shopify.com/Developer_Home <= Read the wiki!
|
79
|
+
|
80
|
+
http://stackoverflow.com/questions/tagged/shopify <= Ask questions on Stack Overflow!
|
57
81
|
|
58
82
|
== Copyright
|
59
83
|
|
60
|
-
Copyright (c)
|
84
|
+
Copyright (c) 2012 "Shopify inc.". See LICENSE for details.
|
data/lib/shopify_api/version.rb
CHANGED
data/test/fixtures/product.json
CHANGED
@@ -23,6 +23,7 @@
|
|
23
23
|
{
|
24
24
|
"position": 1,
|
25
25
|
"price": "199.00",
|
26
|
+
"product_id": 632910392,
|
26
27
|
"created_at": "2011-10-20T14:05:13-04:00",
|
27
28
|
"requires_shipping": true,
|
28
29
|
"title": "Pink",
|
@@ -43,6 +44,7 @@
|
|
43
44
|
{
|
44
45
|
"position": 2,
|
45
46
|
"price": "199.00",
|
47
|
+
"product_id": 632910392,
|
46
48
|
"created_at": "2011-10-20T14:05:13-04:00",
|
47
49
|
"requires_shipping": true,
|
48
50
|
"title": "Red",
|
@@ -63,6 +65,7 @@
|
|
63
65
|
{
|
64
66
|
"position": 3,
|
65
67
|
"price": "199.00",
|
68
|
+
"product_id": 632910392,
|
66
69
|
"created_at": "2011-10-20T14:05:13-04:00",
|
67
70
|
"requires_shipping": true,
|
68
71
|
"title": "Green",
|
@@ -83,6 +86,7 @@
|
|
83
86
|
{
|
84
87
|
"position": 4,
|
85
88
|
"price": "199.00",
|
89
|
+
"product_id": 632910392,
|
86
90
|
"created_at": "2011-10-20T14:05:13-04:00",
|
87
91
|
"requires_shipping": true,
|
88
92
|
"title": "Black",
|
data/test/product_test.rb
CHANGED
@@ -27,4 +27,12 @@ class ProductTest < Test::Unit::TestCase
|
|
27
27
|
assert_equal 2, metafields.length
|
28
28
|
assert metafields.all?{|m| m.is_a?(ShopifyAPI::Metafield)}
|
29
29
|
end
|
30
|
+
|
31
|
+
def test_update_loaded_variant
|
32
|
+
fake "products/632910392/variants/808950810", :method => :put, :status => 200, :body => load_fixture('variant')
|
33
|
+
|
34
|
+
variant = @product.variants.first
|
35
|
+
variant.price = "0.50"
|
36
|
+
variant.save
|
37
|
+
end
|
30
38
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shopify_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-06-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activeresource
|
16
|
-
requirement: &
|
16
|
+
requirement: &2168463760 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 3.0.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2168463760
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: thor
|
27
|
-
requirement: &
|
27
|
+
requirement: &2168479620 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 0.14.4
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2168479620
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: mocha
|
38
|
-
requirement: &
|
38
|
+
requirement: &2168479160 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 0.9.8
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2168479160
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: fakeweb
|
49
|
-
requirement: &
|
49
|
+
requirement: &2168478780 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2168478780
|
58
58
|
description: The Shopify API gem allows Ruby developers to programmatically access
|
59
59
|
the admin section of Shopify stores. The API is implemented as JSON or XML over
|
60
60
|
HTTP using all four verbs (GET/POST/PUT/DELETE). Each resource, like Order, Product,
|
@@ -185,3 +185,4 @@ specification_version: 3
|
|
185
185
|
summary: ShopifyAPI is a lightweight gem for accessing the Shopify admin REST web
|
186
186
|
services
|
187
187
|
test_files: []
|
188
|
+
has_rdoc:
|