shopify_api 3.1.6 → 3.1.7
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.
- data/CHANGELOG +4 -0
- data/Gemfile.lock +1 -1
- data/lib/active_resource/disable_prefix_check.rb +14 -0
- data/lib/shopify_api/resources/article.rb +9 -5
- data/lib/shopify_api/resources/asset.rb +3 -6
- data/lib/shopify_api/resources/base.rb +8 -0
- data/lib/shopify_api/resources/event.rb +1 -6
- data/lib/shopify_api/resources/fulfillment.rb +1 -1
- data/lib/shopify_api/resources/image.rb +1 -1
- data/lib/shopify_api/resources/metafield.rb +2 -7
- data/lib/shopify_api/resources/province.rb +1 -1
- data/lib/shopify_api/resources/transaction.rb +1 -1
- data/lib/shopify_api/resources/variant.rb +1 -5
- data/lib/shopify_api/version.rb +1 -1
- data/test/article_test.rb +34 -0
- data/test/fixtures/authors.json +1 -0
- data/test/fixtures/tags.json +1 -0
- data/test/fixtures/transaction.json +29 -0
- data/test/transaction_test.rb +16 -0
- metadata +8 -4
data/CHANGELOG
CHANGED
data/Gemfile.lock
CHANGED
@@ -4,5 +4,19 @@ module DisablePrefixCheck
|
|
4
4
|
module ClassMethods
|
5
5
|
def check_prefix_options(options)
|
6
6
|
end
|
7
|
+
|
8
|
+
# `flexible = true` is hack to allow multiple things through the same AR class
|
9
|
+
def conditional_prefix(resource, flexible = false)
|
10
|
+
resource_id = "#{resource}_id".to_sym
|
11
|
+
resource_type = flexible ? ":#{resource}" : resource.to_s.pluralize
|
12
|
+
|
13
|
+
init_prefix_explicit resource_type, resource_id
|
14
|
+
|
15
|
+
define_singleton_method :prefix do |options|
|
16
|
+
resource_type = options[resource] if flexible
|
17
|
+
|
18
|
+
options[resource_id].nil? ? "/admin/" : "/admin/#{resource_type}/#{options[resource_id]}/"
|
19
|
+
end
|
20
|
+
end
|
7
21
|
end
|
8
22
|
end
|
@@ -4,14 +4,18 @@ module ShopifyAPI
|
|
4
4
|
include Metafields
|
5
5
|
include DisablePrefixCheck
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
def self.prefix(options={})
|
10
|
-
options[:blog_id].nil? ? "/admin/" : "/admin/blogs/#{options[:blog_id]}/"
|
11
|
-
end
|
7
|
+
conditional_prefix :blog
|
12
8
|
|
13
9
|
def comments
|
14
10
|
Comment.find(:all, :params => { :article_id => id })
|
15
11
|
end
|
12
|
+
|
13
|
+
def self.authors(options = {})
|
14
|
+
get(:authors, options)
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.tags(options={})
|
18
|
+
get(:tags, options)
|
19
|
+
end
|
16
20
|
end
|
17
21
|
end
|
@@ -35,12 +35,9 @@ module ShopifyAPI
|
|
35
35
|
include DisablePrefixCheck
|
36
36
|
|
37
37
|
self.primary_key = 'key'
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
options[:theme_id].nil? ? "/admin/" : "/admin/themes/#{options[:theme_id]}/"
|
42
|
-
end
|
43
|
-
|
38
|
+
|
39
|
+
conditional_prefix :theme
|
40
|
+
|
44
41
|
def self.element_path(id, prefix_options = {}, query_options = nil) #:nodoc:
|
45
42
|
prefix_options, query_options = split_options(prefix_options) if query_options.nil?
|
46
43
|
"#{prefix(prefix_options)}#{collection_name}.#{format.extension}#{query_string(query_options)}"
|
@@ -45,6 +45,14 @@ module ShopifyAPI
|
|
45
45
|
self.site = nil
|
46
46
|
self.headers.delete('X-Shopify-Access-Token')
|
47
47
|
end
|
48
|
+
|
49
|
+
def init_prefix(resource)
|
50
|
+
init_prefix_explicit(resource.to_s.pluralize, "#{resource}_id")
|
51
|
+
end
|
52
|
+
|
53
|
+
def init_prefix_explicit(resource_type, resource_id)
|
54
|
+
self.prefix = "/admin/#{resource_type}/:#{resource_id}/"
|
55
|
+
end
|
48
56
|
end
|
49
57
|
|
50
58
|
def persisted?
|
@@ -2,11 +2,6 @@ module ShopifyAPI
|
|
2
2
|
class Event < Base
|
3
3
|
include DisablePrefixCheck
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
# Hack to allow both Shop and other Events in through the same AR class
|
8
|
-
def self.prefix(options={})
|
9
|
-
options[:resource].nil? ? "/admin/" : "/admin/#{options[:resource]}/#{options[:resource_id]}/"
|
10
|
-
end
|
5
|
+
conditional_prefix :resource, true
|
11
6
|
end
|
12
7
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module ShopifyAPI
|
2
2
|
class Fulfillment < Base
|
3
|
-
|
3
|
+
init_prefix :order
|
4
4
|
|
5
5
|
def cancel; load_attributes_from_response(post(:cancel, {}, only_id)); end
|
6
6
|
def complete; load_attributes_from_response(post(:complete, {}, only_id)); end
|
@@ -2,13 +2,8 @@ module ShopifyAPI
|
|
2
2
|
class Metafield < Base
|
3
3
|
include DisablePrefixCheck
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
# Hack to allow both Shop and other Metafields in through the same AR class
|
8
|
-
def self.prefix(options={})
|
9
|
-
options[:resource].nil? ? "/admin/" : "/admin/#{options[:resource]}/#{options[:resource_id]}/"
|
10
|
-
end
|
11
|
-
|
5
|
+
conditional_prefix :resource, true
|
6
|
+
|
12
7
|
def value
|
13
8
|
return if attributes["value"].nil?
|
14
9
|
attributes["value_type"] == "integer" ? attributes["value"].to_i : attributes["value"]
|
@@ -3,10 +3,6 @@ module ShopifyAPI
|
|
3
3
|
include Metafields
|
4
4
|
include DisablePrefixCheck
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
def self.prefix(options={})
|
9
|
-
options[:product_id].nil? ? "/admin/" : "/admin/products/#{options[:product_id]}/"
|
10
|
-
end
|
6
|
+
conditional_prefix :product
|
11
7
|
end
|
12
8
|
end
|
data/lib/shopify_api/version.rb
CHANGED
data/test/article_test.rb
CHANGED
@@ -25,4 +25,38 @@ class ArticleTest < Test::Unit::TestCase
|
|
25
25
|
article = ShopifyAPI::Article.find(6242736, :params => {:blog_id => 1008414260})
|
26
26
|
assert_equal "First Post", article.title
|
27
27
|
end
|
28
|
+
|
29
|
+
def test_get_authors
|
30
|
+
fake "articles/authors", :method => :get, :body => load_fixture('authors')
|
31
|
+
authors = ShopifyAPI::Article.authors
|
32
|
+
assert_equal "Shopify", authors.first
|
33
|
+
assert_equal "development shop", authors.last
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_get_authors_for_blog_id
|
37
|
+
fake "blogs/1008414260/articles/authors", :method => :get, :body => load_fixture('authors')
|
38
|
+
authors = ShopifyAPI::Article.authors(:blog_id => 1008414260)
|
39
|
+
assert_equal 3, authors.length
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_get_tags
|
43
|
+
fake "articles/tags", :method => :get, :body => load_fixture('tags')
|
44
|
+
tags = ShopifyAPI::Article.tags
|
45
|
+
assert_equal "consequuntur", tags.first
|
46
|
+
assert_equal "repellendus", tags.last
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_get_tags_for_blog_id
|
50
|
+
fake "blogs/1008414260/articles/tags", :method => :get, :body => load_fixture('tags')
|
51
|
+
tags = ShopifyAPI::Article.tags(:blog_id => 1008414260)
|
52
|
+
assert_equal "consequuntur", tags.first
|
53
|
+
assert_equal "repellendus", tags.last
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_get_popular_tags
|
57
|
+
fake "articles/tags.json?limit=1&popular=1", :extension => false, :method => :get, :body => load_fixture('tags')
|
58
|
+
tags = ShopifyAPI::Article.tags(:popular => 1, :limit => 1)
|
59
|
+
assert_equal 3, tags.length
|
60
|
+
end
|
61
|
+
|
28
62
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
{"authors": ["Shopify", "development shop", "development shop"]}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"tags": ["consequuntur", "cupiditate", "repellendus"]}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
{
|
2
|
+
"transaction": {
|
3
|
+
"amount": "409.94",
|
4
|
+
"authorization": "authorization-key",
|
5
|
+
"created_at": "2005-08-01T11:57:11-04:00",
|
6
|
+
"gateway": "bogus",
|
7
|
+
"id": 389404469,
|
8
|
+
"kind": "authorization",
|
9
|
+
"location_id": null,
|
10
|
+
"message": null,
|
11
|
+
"order_id": 450789469,
|
12
|
+
"parent_id": null,
|
13
|
+
"status": "success",
|
14
|
+
"test": false,
|
15
|
+
"user_id": null,
|
16
|
+
"device_id": null,
|
17
|
+
"receipt": {
|
18
|
+
"testcase": true,
|
19
|
+
"authorization": "123456"
|
20
|
+
},
|
21
|
+
"payment_details": {
|
22
|
+
"avs_result_code": null,
|
23
|
+
"credit_card_bin": null,
|
24
|
+
"cvv_result_code": null,
|
25
|
+
"credit_card_number": "XXXX-XXXX-XXXX-4242",
|
26
|
+
"credit_card_company": "Visa"
|
27
|
+
}
|
28
|
+
}
|
29
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class TransactionTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
fake "orders/450789469/transactions/389404469", :method => :get, :body => load_fixture('transaction')
|
6
|
+
end
|
7
|
+
|
8
|
+
context "Transaction" do
|
9
|
+
context "#find" do
|
10
|
+
should "find a specific transaction" do
|
11
|
+
transaction = ShopifyAPI::Transaction.find(389404469, :params => {:order_id => 450789469})
|
12
|
+
assert_equal "409.94", transaction.amount
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
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.1.
|
4
|
+
version: 3.1.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-11-
|
12
|
+
date: 2013-11-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activeresource
|
@@ -186,6 +186,7 @@ files:
|
|
186
186
|
- test/fixtures/articles.json
|
187
187
|
- test/fixtures/asset.json
|
188
188
|
- test/fixtures/assets.json
|
189
|
+
- test/fixtures/authors.json
|
189
190
|
- test/fixtures/blog.json
|
190
191
|
- test/fixtures/blogs.json
|
191
192
|
- test/fixtures/carts.json
|
@@ -197,6 +198,8 @@ files:
|
|
197
198
|
- test/fixtures/metafields.json
|
198
199
|
- test/fixtures/product.json
|
199
200
|
- test/fixtures/shop.json
|
201
|
+
- test/fixtures/tags.json
|
202
|
+
- test/fixtures/transaction.json
|
200
203
|
- test/fixtures/variant.json
|
201
204
|
- test/fixtures/variants.json
|
202
205
|
- test/fulfillment_test.rb
|
@@ -206,6 +209,7 @@ files:
|
|
206
209
|
- test/session_test.rb
|
207
210
|
- test/shop_test.rb
|
208
211
|
- test/test_helper.rb
|
212
|
+
- test/transaction_test.rb
|
209
213
|
- test/variant_test.rb
|
210
214
|
homepage: http://www.shopify.com/partners/apps
|
211
215
|
licenses:
|
@@ -223,7 +227,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
223
227
|
version: '0'
|
224
228
|
segments:
|
225
229
|
- 0
|
226
|
-
hash:
|
230
|
+
hash: 355511341296706903
|
227
231
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
228
232
|
none: false
|
229
233
|
requirements:
|
@@ -232,7 +236,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
232
236
|
version: '0'
|
233
237
|
segments:
|
234
238
|
- 0
|
235
|
-
hash:
|
239
|
+
hash: 355511341296706903
|
236
240
|
requirements: []
|
237
241
|
rubyforge_project:
|
238
242
|
rubygems_version: 1.8.23
|