shopify_api 1.2.2 → 1.2.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +14 -0
- data/lib/shopify_api.rb +33 -10
- data/shopify_api.gemspec +2 -2
- metadata +66 -23
data/CHANGELOG
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
== Version 1.2.5
|
2
|
+
|
3
|
+
* Fix for Article#comments
|
4
|
+
|
5
|
+
== Version 1.2.4
|
6
|
+
|
7
|
+
* Added Article#comments
|
8
|
+
* Added Order#cancel
|
9
|
+
* Added Comment#restore, #not_spam
|
10
|
+
|
11
|
+
== Version 1.2.3
|
12
|
+
|
13
|
+
* Added Customer, CustomerGroup support
|
14
|
+
|
1
15
|
== Version 1.2.2
|
2
16
|
|
3
17
|
* Added ScriptTag support
|
data/lib/shopify_api.rb
CHANGED
@@ -252,19 +252,26 @@ module ShopifyAPI
|
|
252
252
|
end
|
253
253
|
|
254
254
|
class Order < Base
|
255
|
-
def close;
|
255
|
+
def close; load_attributes_from_response(post(:close, {}, only_id)); end
|
256
|
+
def open; load_attributes_from_response(post(:open, {}, only_id)); end
|
256
257
|
|
257
|
-
def
|
258
|
+
def cancel(options = {})
|
259
|
+
load_attributes_from_response(post(:cancel, options, only_id))
|
260
|
+
end
|
258
261
|
|
259
262
|
def transactions
|
260
263
|
Transaction.find(:all, :params => { :order_id => id })
|
261
264
|
end
|
262
|
-
|
265
|
+
|
263
266
|
def capture(amount = "")
|
264
267
|
Transaction.create(:amount => amount, :kind => "capture", :order_id => id)
|
265
268
|
end
|
269
|
+
|
270
|
+
def only_id
|
271
|
+
encode(:only => :id, :include => [], :methods => [], :fields => [])
|
272
|
+
end
|
266
273
|
end
|
267
|
-
|
274
|
+
|
268
275
|
class Product < Base
|
269
276
|
|
270
277
|
# Share all items of this store with the
|
@@ -345,6 +352,10 @@ module ShopifyAPI
|
|
345
352
|
|
346
353
|
class Article < Base
|
347
354
|
self.prefix = "/admin/blogs/:blog_id/"
|
355
|
+
|
356
|
+
def comments
|
357
|
+
Comment.find(:all, :params => { :article_id => id })
|
358
|
+
end
|
348
359
|
end
|
349
360
|
|
350
361
|
class Metafield < Base
|
@@ -362,13 +373,19 @@ module ShopifyAPI
|
|
362
373
|
|
363
374
|
end
|
364
375
|
|
365
|
-
class Comment < Base
|
366
|
-
def remove;
|
367
|
-
def ham;
|
368
|
-
def spam;
|
369
|
-
def approve;
|
376
|
+
class Comment < Base
|
377
|
+
def remove; load_attributes_from_response(post(:remove, {}, only_id)); end
|
378
|
+
def ham; load_attributes_from_response(post(:ham, {}, only_id)); end
|
379
|
+
def spam; load_attributes_from_response(post(:spam, {}, only_id)); end
|
380
|
+
def approve; load_attributes_from_response(post(:approve, {}, only_id)); end
|
381
|
+
def restore; load_attributes_from_response(post(:restore, {}, only_id)); end
|
382
|
+
def not_spam; load_attributes_from_response(post(:not_spam, {}, only_id)); end
|
383
|
+
|
384
|
+
def only_id
|
385
|
+
encode(:only => :id)
|
386
|
+
end
|
370
387
|
end
|
371
|
-
|
388
|
+
|
372
389
|
class Province < Base
|
373
390
|
self.prefix = "/admin/countries/:country_id/"
|
374
391
|
end
|
@@ -388,6 +405,12 @@ module ShopifyAPI
|
|
388
405
|
end
|
389
406
|
end
|
390
407
|
|
408
|
+
class Customer < Base
|
409
|
+
end
|
410
|
+
|
411
|
+
class CustomerGroup < Base
|
412
|
+
end
|
413
|
+
|
391
414
|
# Assets represent the files that comprise your theme.
|
392
415
|
# There are different buckets which hold different kinds
|
393
416
|
# of assets, each corresponding to one of the folders
|
data/shopify_api.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{shopify_api}
|
5
|
-
s.version = "1.2.
|
5
|
+
s.version = "1.2.5"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Tobias L\303\274tke", "Cody Fauser", "Dennis Theisen", "Edward Ocampo-Gooding"]
|
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
|
|
11
11
|
|
12
12
|
The Shopify API gem allows Ruby developers to programmatically access the admin section of Shopify stores.
|
13
13
|
|
14
|
-
The API is implemented as XML over HTTP using all four verbs (GET/POST/PUT/DELETE). Each resource, like Order, Product, or Collection, has its own URL and is manipulated in isolation. In other words, we
|
14
|
+
The API is implemented as XML over HTTP using all four verbs (GET/POST/PUT/DELETE). Each resource, like Order, Product, or Collection, has its own URL and is manipulated in isolation. In other words, we've tried to make the API follow the REST principles as much as possible.
|
15
15
|
|
16
16
|
|
17
17
|
== Usage
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
version: 1.2.
|
8
|
+
- 5
|
9
|
+
version: 1.2.5
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- "Tobias L\xC3\xBCtke"
|
@@ -24,6 +24,7 @@ dependencies:
|
|
24
24
|
name: activeresource
|
25
25
|
prerelease: false
|
26
26
|
requirement: &id001 !ruby/object:Gem::Requirement
|
27
|
+
none: false
|
27
28
|
requirements:
|
28
29
|
- - ">="
|
29
30
|
- !ruby/object:Gem::Version
|
@@ -38,6 +39,7 @@ dependencies:
|
|
38
39
|
name: thor
|
39
40
|
prerelease: false
|
40
41
|
requirement: &id002 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
41
43
|
requirements:
|
42
44
|
- - ">="
|
43
45
|
- !ruby/object:Gem::Version
|
@@ -52,6 +54,7 @@ dependencies:
|
|
52
54
|
name: mocha
|
53
55
|
prerelease: false
|
54
56
|
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
55
58
|
requirements:
|
56
59
|
- - ">="
|
57
60
|
- !ruby/object:Gem::Version
|
@@ -62,26 +65,63 @@ dependencies:
|
|
62
65
|
version: 0.9.8
|
63
66
|
type: :development
|
64
67
|
version_requirements: *id003
|
65
|
-
description:
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
68
|
+
description: |
|
69
|
+
= Shopify API
|
70
|
+
|
71
|
+
The Shopify API gem allows Ruby developers to programmatically access the admin section of Shopify stores.
|
72
|
+
|
73
|
+
The API is implemented as XML over HTTP using all four verbs (GET/POST/PUT/DELETE). Each resource, like Order, Product, or Collection, has its own URL and is manipulated in isolation. In other words, we've tried to make the API follow the REST principles as much as possible.
|
74
|
+
|
75
|
+
|
76
|
+
== Usage
|
77
|
+
|
78
|
+
=== Requirements
|
79
|
+
|
80
|
+
All API usage happens through Shopify applications, created by either shop owners for their own shops, or by Shopify Partners for use by other shop owners:
|
81
|
+
|
82
|
+
* Shop owners can create applications for themselves through their own admin (under the Preferences > Applications tab).
|
83
|
+
* Shopify Partners create applications through their admin: http://app.shopify.com/services/partners
|
84
|
+
|
85
|
+
For more information and detailed documentation about the API visit http://api.shopify.com
|
86
|
+
|
87
|
+
=== Getting Started
|
88
|
+
|
89
|
+
ShopifyAPI uses ActiveResource to communicate with the REST web service. ActiveResource has to be configured with a fully authorized URL of a particular store first. To obtain that URL you can follow these steps:
|
90
|
+
|
91
|
+
1. First create a new application in either the partners admin or your store admin and write down your API_KEY and SHARED_SECRET.
|
92
|
+
|
93
|
+
2. You will need to supply two parameters to the Session class before you instantiate it:
|
94
|
+
|
95
|
+
ShopifyAPI::Session.setup({:api_key => API_KEY, :secret => SHARED_SECRET})
|
96
|
+
|
97
|
+
3. Create a new Session for a specific shop. That session is not fully valid yet, but it can be used to create a URL that you will redirect your users to:
|
98
|
+
|
99
|
+
session = ShopifyAPI::Session.new("yourshopname.myshopify.com")
|
100
|
+
session.valid? # returns false
|
101
|
+
|
102
|
+
4. To access the API shop owners need a "token" from that specific shop. In order to get this token they need to authorize with that shop first. The URL to redirect your user to can be generated via:
|
103
|
+
|
104
|
+
url = session.create_permission_url
|
105
|
+
|
106
|
+
5. After visiting this URL, the shop redirects the owner to a custom URL of your application where the "token" gets sent to (it's param name is just "t"). Use that token to instantiate a "valid" session, that is ready to make calls to that particular shop.
|
107
|
+
|
108
|
+
token = params[:t]
|
109
|
+
session = ShopifyAPI::Session.new("yourshopname.myshopify.com", token)
|
110
|
+
session.valid? # returns true
|
111
|
+
|
112
|
+
6. Now you can finally get the fully authorized URL for that shop. Use that URL to configure ActiveResource and you're set:
|
113
|
+
|
114
|
+
ActiveResource::Base.site = session.site
|
115
|
+
|
116
|
+
7. Get data from that shop (returns ActiveResource instances):
|
117
|
+
|
118
|
+
shop = ShopifyAPI::Shop.current
|
119
|
+
latest_orders = ShopifyAPI::Order.find(:all)
|
120
|
+
|
121
|
+
== Copyright
|
122
|
+
|
123
|
+
Copyright (c) 2009 "JadedPixel inc.". See LICENSE for details.
|
124
|
+
|
85
125
|
email: developers@jadedpixel.com
|
86
126
|
executables:
|
87
127
|
- shopify
|
@@ -103,6 +143,7 @@ files:
|
|
103
143
|
- test/order_test.rb
|
104
144
|
- test/shopify_api_test.rb
|
105
145
|
- test/test_helper.rb
|
146
|
+
- bin/shopify
|
106
147
|
has_rdoc: true
|
107
148
|
homepage: http://github.com/Shopify/shopify_api
|
108
149
|
licenses: []
|
@@ -113,6 +154,7 @@ rdoc_options:
|
|
113
154
|
require_paths:
|
114
155
|
- lib
|
115
156
|
required_ruby_version: !ruby/object:Gem::Requirement
|
157
|
+
none: false
|
116
158
|
requirements:
|
117
159
|
- - ">="
|
118
160
|
- !ruby/object:Gem::Version
|
@@ -120,6 +162,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
120
162
|
- 0
|
121
163
|
version: "0"
|
122
164
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
165
|
+
none: false
|
123
166
|
requirements:
|
124
167
|
- - ">="
|
125
168
|
- !ruby/object:Gem::Version
|
@@ -129,7 +172,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
129
172
|
requirements: []
|
130
173
|
|
131
174
|
rubyforge_project: shopify-api
|
132
|
-
rubygems_version: 1.3.
|
175
|
+
rubygems_version: 1.3.7
|
133
176
|
signing_key:
|
134
177
|
specification_version: 3
|
135
178
|
summary: ShopifyAPI is a lightweight gem for accessing the Shopify admin REST web services
|