shopify_api 1.0.6 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,5 +1,14 @@
1
- - Add metafields
2
- - Add latest changes from Shopify including asset support, token validation and a common base class
1
+ == Version 1.1.0 (September 24, 2010)
3
2
 
4
- 1.0.0
5
- - extracting ShopifyAPI from Shopify into Gem
3
+ * Add new Events API for Shop, Order, Product, CustomCollection, SmartCollection, Page, Blog and Article
4
+ * Add new 'compact' product image size variant
5
+ * Rails 3 fix: attribute_accessors has to be explicitly included since activesupport 3.0.0
6
+
7
+ == Version 1.0.6
8
+
9
+ * Add metafields
10
+ * Add latest changes from Shopify including asset support, token validation and a common base class
11
+
12
+ == Version 1.0.0
13
+
14
+ * extracting ShopifyAPI from Shopify into Gem
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.6
1
+ 1.1.0
data/lib/shopify_api.rb CHANGED
@@ -1,9 +1,11 @@
1
1
  require 'active_resource'
2
+ require 'active_support/core_ext/class/attribute_accessors'
2
3
  require 'digest/md5'
3
4
 
4
5
  module ShopifyAPI
5
6
  METAFIELD_ENABLED_CLASSES = %w( Order Product CustomCollection SmartCollection Page Blog Article Variant)
6
-
7
+ EVENT_ENABLED_CLASSES = %w( Order Product CustomCollection SmartCollection Page Blog Article )
8
+
7
9
  module Countable
8
10
  def count(options = {})
9
11
  Integer(get(:count, options))
@@ -26,7 +28,13 @@ module ShopifyAPI
26
28
  metafield
27
29
  end
28
30
  end
29
-
31
+
32
+ module Events
33
+ def events
34
+ Event.find(:all, :params => {:resource => self.class.collection_name, :resource_id => id})
35
+ end
36
+ end
37
+
30
38
  #
31
39
  # The Shopify API authenticates each call via HTTP Authentication, using
32
40
  # * the application's API key as the username, and
@@ -194,6 +202,10 @@ module ShopifyAPI
194
202
  metafield.save
195
203
  metafield
196
204
  end
205
+
206
+ def events
207
+ Event.find(:all)
208
+ end
197
209
  end
198
210
 
199
211
  # Custom collection
@@ -295,7 +307,7 @@ module ShopifyAPI
295
307
  self.prefix = "/admin/products/:product_id/"
296
308
 
297
309
  # generate a method for each possible image variant
298
- [:pico, :icon, :thumb, :small, :medium, :large, :original].each do |m|
310
+ [:pico, :icon, :thumb, :small, :compact, :medium, :large, :original].each do |m|
299
311
  reg_exp_match = "/\\1_#{m}.\\2"
300
312
  define_method(m) { src.gsub(/\/(.*)\.(\w{2,4})/, reg_exp_match) }
301
313
  end
@@ -362,6 +374,15 @@ module ShopifyAPI
362
374
  class Webhook < Base
363
375
  end
364
376
 
377
+ class Event < Base
378
+ self.prefix = "/admin/:resource/:resource_id/"
379
+
380
+ # Hack to allow both Shop and other Events in through the same AR class
381
+ def self.prefix(options={})
382
+ options[:resource].nil? ? "/admin/" : "/admin/#{options[:resource]}/#{options[:resource_id]}/"
383
+ end
384
+ end
385
+
365
386
  # Assets represent the files that comprise your theme.
366
387
  # There are different buckets which hold different kinds
367
388
  # of assets, each corresponding to one of the folders
@@ -471,4 +492,9 @@ module ShopifyAPI
471
492
  METAFIELD_ENABLED_CLASSES.each do |klass|
472
493
  "ShopifyAPI::#{klass}".constantize.send(:include, Metafields)
473
494
  end
495
+
496
+ # Include Events module in all enabled classes
497
+ EVENT_ENABLED_CLASSES.each do |klass|
498
+ "ShopifyAPI::#{klass}".constantize.send(:include, Events)
499
+ end
474
500
  end
data/shopify_api.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{shopify_api}
8
- s.version = "1.0.6"
8
+ s.version = "1.1.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Tobias L\303\274tke", "Cody Fauser", "Dennis Theisen"]
12
- s.date = %q{2010-09-07}
12
+ s.date = %q{2010-09-24}
13
13
  s.description = %q{= Shopify API
14
14
 
15
15
  The Shopify API gem allows Ruby developers to programmatically access the admin section of Shopify stores.
@@ -29,5 +29,15 @@ class ShopifyApiTest < Test::Unit::TestCase
29
29
  session = ShopifyAPI::Session.new("testshop.myshopify.com", "any-token", {'foo' => 'bar'})
30
30
  end
31
31
  end
32
+
33
+ should "setup api_key and secret for all sessions" do
34
+ ShopifyAPI::Session.setup(:api_key => "My test key", :secret => "My test secret")
35
+ assert_equal "My test key", ShopifyAPI::Session.api_key
36
+ assert_equal "My test secret", ShopifyAPI::Session.secret
37
+ end
38
+
39
+ should "use 'https' protocol by default for all sessions" do
40
+ assert_equal 'https', ShopifyAPI::Session.protocol
41
+ end
32
42
  end
33
43
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shopify_api
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
+ - 1
8
9
  - 0
9
- - 6
10
- version: 1.0.6
10
+ version: 1.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - "Tobias L\xC3\xBCtke"
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2010-09-07 00:00:00 -04:00
20
+ date: 2010-09-24 00:00:00 -04:00
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency