shopify_api 2.2.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ == Version 2.3.0
2
+
3
+ * Fix double root bug with ActiveSupport 3.2.0
4
+ * Add metafields methods on Customer resource
5
+ * Fix prefix_options on assets returned from Asset.find
6
+
1
7
  == Version 2.2.0
2
8
 
3
9
  * Fix issues with resources that have both direct and namespaced routes
@@ -3,7 +3,7 @@ module ActiveResource
3
3
  def encode(options = {})
4
4
  same = dup
5
5
  same.attributes = {self.class.element_name => same.attributes} if self.class.format.extension == 'json'
6
-
6
+
7
7
  same.send("to_#{self.class.format.extension}", options)
8
8
  end
9
9
  end
@@ -21,3 +21,19 @@ module ActiveResource
21
21
  end
22
22
  end
23
23
  end
24
+
25
+ module ActiveModel
26
+ module Serializers
27
+ module JSON
28
+ def as_json(options = nil)
29
+ root = options[:root] if options.try(:key?, :root)
30
+ if include_root_in_json
31
+ root = self.class.model_name.element if root == true
32
+ { root => serializable_hash(options) }
33
+ else
34
+ serializable_hash(options)
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -55,7 +55,9 @@ module ShopifyAPI
55
55
  params = {:asset => {:key => args[0]}}
56
56
  params = params.merge(args[1][:params]) if args[1] && args[1][:params]
57
57
  path_prefix = params[:theme_id] ? "/admin/themes/#{params[:theme_id]}" : "/admin"
58
- find(:one, :from => "#{path_prefix}/assets.#{format.extension}", :params => params)
58
+ resource = find(:one, :from => "#{path_prefix}/assets.#{format.extension}", :params => params)
59
+ resource.prefix_options[:theme_id] = params[:theme_id] if resource && params[:theme_id]
60
+ resource
59
61
  end
60
62
  end
61
63
 
@@ -1,4 +1,5 @@
1
1
  module ShopifyAPI
2
2
  class Customer < Base
3
+ include Metafields
3
4
  end
4
5
  end
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 = "2.2.0"
5
+ s.version = "2.3.0"
6
6
  s.author = "Shopify"
7
7
 
8
8
  s.summary = %q{The Shopify API gem is a lightweight gem for accessing the Shopify admin REST web services}
data/test/blog_test.rb ADDED
@@ -0,0 +1,8 @@
1
+ require 'test_helper'
2
+ class BlogTest < Test::Unit::TestCase
3
+ test "blog creation" do
4
+ fake "blogs", :method => :post, :status => 202
5
+ ShopifyAPI::Blog.create(:title => "Test Blog")
6
+ assert_equal '{"blog":{"title":"Test Blog"}}', FakeWeb.last_request.body
7
+ end
8
+ end
@@ -27,7 +27,8 @@ class LogSubscriberTest < Test::Unit::TestCase
27
27
  assert_equal "GET http://localhost:80/admin/pages/1.json", @logger.logged(:info)[0]
28
28
  assert_match /\-\-\> 200/, @logger.logged(:info)[1]
29
29
  assert_equal "Headers: {\"Accept\"=>\"application/json\"}", @logger.logged(:info)[2]
30
- assert_equal "Response:\n{\"page\":{\"title\":\"Shopify API\",\"id\":1}}", @logger.logged(:info)[3]
30
+ assert_match /Response:\n\{\"page\"\:\{((\"id\"\:1)|(\"title\"\:\"Shopify API\")),((\"id\"\:1)|(\"title\"\:\"Shopify API\"))\}\}/, @logger.logged(:info)[3]
31
+
31
32
  end
32
33
 
33
34
  test "logging on #find with an error" do
@@ -0,0 +1,13 @@
1
+ {
2
+ "blog": {
3
+ "handle": "test-blog",
4
+ "created_at": "2012-01-10T17:45:19-05:00",
5
+ "title": "Test Blog",
6
+ "template_suffix": null,
7
+ "updated_at": "2012-01-10T17:45:19-05:00",
8
+ "feedburner_location": null,
9
+ "id": 1008414260,
10
+ "feedburner": null,
11
+ "commentable": "no"
12
+ }
13
+ }
data/test/product_test.rb CHANGED
@@ -12,7 +12,7 @@ class ProductTest < Test::Unit::TestCase
12
12
  fake "products/632910392/metafields", :method => :post, :status => 201, :body => load_fixture('metafield')
13
13
 
14
14
  field = @product.add_metafield(ShopifyAPI::Metafield.new(:namespace => "contact", :key => "email", :value => "123@example.com", :value_type => "string"))
15
-
15
+ assert_equal ActiveSupport::JSON.decode('{"metafield":{"namespace":"contact","key":"email","value":"123@example.com","value_type":"string"}}'), ActiveSupport::JSON.decode(FakeWeb.last_request.body)
16
16
  assert !field.new_record?
17
17
  assert_equal "contact", field.namespace
18
18
  assert_equal "email", field.key
data/test/shop_test.rb CHANGED
@@ -29,7 +29,7 @@ class ShopTest < Test::Unit::TestCase
29
29
  fake "metafields", :method => :post, :status => 201, :body =>load_fixture('metafield')
30
30
 
31
31
  field = @shop.add_metafield(ShopifyAPI::Metafield.new(:namespace => "contact", :key => "email", :value => "123@example.com", :value_type => "string"))
32
-
32
+ assert_equal ActiveSupport::JSON.decode('{"metafield":{"namespace":"contact","key":"email","value":"123@example.com","value_type":"string"}}'), ActiveSupport::JSON.decode(FakeWeb.last_request.body)
33
33
  assert !field.new_record?
34
34
  assert_equal "contact", field.namespace
35
35
  assert_equal "email", field.key
metadata CHANGED
@@ -1,95 +1,72 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: shopify_api
3
- version: !ruby/object:Gem::Version
4
- hash: 7
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.3.0
5
5
  prerelease:
6
- segments:
7
- - 2
8
- - 2
9
- - 0
10
- version: 2.2.0
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Shopify
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-11-25 00:00:00 -05:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
12
+ date: 2012-02-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
22
15
  name: activeresource
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &2152625980 !ruby/object:Gem::Requirement
25
17
  none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 7
30
- segments:
31
- - 3
32
- - 0
33
- - 0
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
34
21
  version: 3.0.0
35
22
  type: :runtime
36
- version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
38
- name: thor
39
23
  prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *2152625980
25
+ - !ruby/object:Gem::Dependency
26
+ name: thor
27
+ requirement: &2152625260 !ruby/object:Gem::Requirement
41
28
  none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- hash: 47
46
- segments:
47
- - 0
48
- - 14
49
- - 4
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
50
32
  version: 0.14.4
51
33
  type: :runtime
52
- version_requirements: *id002
53
- - !ruby/object:Gem::Dependency
54
- name: mocha
55
34
  prerelease: false
56
- requirement: &id003 !ruby/object:Gem::Requirement
35
+ version_requirements: *2152625260
36
+ - !ruby/object:Gem::Dependency
37
+ name: mocha
38
+ requirement: &2152624800 !ruby/object:Gem::Requirement
57
39
  none: false
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- hash: 43
62
- segments:
63
- - 0
64
- - 9
65
- - 8
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
66
43
  version: 0.9.8
67
44
  type: :development
68
- version_requirements: *id003
69
- - !ruby/object:Gem::Dependency
70
- name: fakeweb
71
45
  prerelease: false
72
- requirement: &id004 !ruby/object:Gem::Requirement
46
+ version_requirements: *2152624800
47
+ - !ruby/object:Gem::Dependency
48
+ name: fakeweb
49
+ requirement: &2152624420 !ruby/object:Gem::Requirement
73
50
  none: false
74
- requirements:
75
- - - ">="
76
- - !ruby/object:Gem::Version
77
- hash: 3
78
- segments:
79
- - 0
80
- version: "0"
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
81
55
  type: :development
82
- version_requirements: *id004
83
- description: The Shopify API gem allows Ruby developers to programmatically access the admin section of Shopify stores. The API is implemented as JSON or 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.
56
+ prerelease: false
57
+ version_requirements: *2152624420
58
+ description: The Shopify API gem allows Ruby developers to programmatically access
59
+ the admin section of Shopify stores. The API is implemented as JSON or XML over
60
+ HTTP using all four verbs (GET/POST/PUT/DELETE). Each resource, like Order, Product,
61
+ or Collection, has its own URL and is manipulated in isolation.
84
62
  email: developers@jadedpixel.com
85
- executables:
63
+ executables:
86
64
  - shopify
87
65
  extensions: []
88
-
89
- extra_rdoc_files:
66
+ extra_rdoc_files:
90
67
  - LICENSE
91
68
  - README.rdoc
92
- files:
69
+ files:
93
70
  - .document
94
71
  - .gitignore
95
72
  - CHANGELOG
@@ -154,10 +131,12 @@ files:
154
131
  - lib/shopify_api/session.rb
155
132
  - shopify_api.gemspec
156
133
  - test/asset_test.rb
134
+ - test/blog_test.rb
157
135
  - test/cli_test.rb
158
136
  - test/detailed_log_subscriber_test.rb
159
137
  - test/fixtures/asset.json
160
138
  - test/fixtures/assets.json
139
+ - test/fixtures/blogs.json
161
140
  - test/fixtures/events.json
162
141
  - test/fixtures/metafield.json
163
142
  - test/fixtures/metafields.json
@@ -172,39 +151,31 @@ files:
172
151
  - test/shop_test.rb
173
152
  - test/test_helper.rb
174
153
  - test/variant_test.rb
175
- has_rdoc: true
176
154
  homepage: http://www.shopify.com/partners/apps
177
- licenses:
155
+ licenses:
178
156
  - MIT
179
157
  post_install_message:
180
- rdoc_options:
158
+ rdoc_options:
181
159
  - --charset=UTF-8
182
- require_paths:
160
+ require_paths:
183
161
  - lib
184
- required_ruby_version: !ruby/object:Gem::Requirement
162
+ required_ruby_version: !ruby/object:Gem::Requirement
185
163
  none: false
186
- requirements:
187
- - - ">="
188
- - !ruby/object:Gem::Version
189
- hash: 3
190
- segments:
191
- - 0
192
- version: "0"
193
- required_rubygems_version: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - ! '>='
166
+ - !ruby/object:Gem::Version
167
+ version: '0'
168
+ required_rubygems_version: !ruby/object:Gem::Requirement
194
169
  none: false
195
- requirements:
196
- - - ">="
197
- - !ruby/object:Gem::Version
198
- hash: 3
199
- segments:
200
- - 0
201
- version: "0"
170
+ requirements:
171
+ - - ! '>='
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
202
174
  requirements: []
203
-
204
175
  rubyforge_project:
205
- rubygems_version: 1.6.2
176
+ rubygems_version: 1.8.11
206
177
  signing_key:
207
178
  specification_version: 3
208
- summary: ShopifyAPI is a lightweight gem for accessing the Shopify admin REST web services
179
+ summary: ShopifyAPI is a lightweight gem for accessing the Shopify admin REST web
180
+ services
209
181
  test_files: []
210
-