storesapp-rb 0.2.4 → 0.2.5

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.
Files changed (43) hide show
  1. data/app/models/base.rb +5 -0
  2. data/app/models/collection.rb +20 -0
  3. data/app/models/order.rb +21 -0
  4. data/app/models/order_item.rb +9 -0
  5. data/app/models/order_item_property.rb +5 -0
  6. data/app/models/page.rb +2 -0
  7. data/app/models/product.rb +25 -0
  8. data/app/models/product_image.rb +12 -0
  9. data/app/models/product_property.rb +5 -0
  10. data/app/models/shipping_rate.rb +2 -0
  11. data/app/models/store.rb +2 -0
  12. data/app/models/tax_rate.rb +2 -0
  13. data/app/models/user.rb +2 -0
  14. data/app/models/variant.rb +9 -0
  15. data/app/models/variant_property.rb +5 -0
  16. data/lib/storesapp.rb +16 -30
  17. metadata +35 -45
  18. data/.gitignore +0 -1
  19. data/LICENSE +0 -20
  20. data/Manifest.txt +0 -22
  21. data/README.markdown +0 -58
  22. data/lib/storesapp/base.rb +0 -92
  23. data/lib/storesapp/plugins/active_resource_inheritable_headers.rb +0 -32
  24. data/lib/storesapp/plugins/hash_ext.rb +0 -11
  25. data/lib/storesapp/resources/cart.rb +0 -9
  26. data/lib/storesapp/resources/cart_item.rb +0 -13
  27. data/lib/storesapp/resources/cart_item_property.rb +0 -9
  28. data/lib/storesapp/resources/collection.rb +0 -31
  29. data/lib/storesapp/resources/collection_product.rb +0 -13
  30. data/lib/storesapp/resources/order.rb +0 -25
  31. data/lib/storesapp/resources/order_item.rb +0 -13
  32. data/lib/storesapp/resources/order_item_property.rb +0 -9
  33. data/lib/storesapp/resources/page.rb +0 -6
  34. data/lib/storesapp/resources/product.rb +0 -43
  35. data/lib/storesapp/resources/product_image.rb +0 -9
  36. data/lib/storesapp/resources/product_property.rb +0 -9
  37. data/lib/storesapp/resources/store.rb +0 -6
  38. data/lib/storesapp/resources/tax_rate.rb +0 -6
  39. data/lib/storesapp/resources/user.rb +0 -6
  40. data/lib/storesapp/resources/variant.rb +0 -13
  41. data/lib/storesapp/resources/variant_property.rb +0 -9
  42. data/lib/storesapp/stores_app_resource.rb +0 -5
  43. data/storesapp.gemspec +0 -19
@@ -0,0 +1,5 @@
1
+ class Base < ActiveResource::Base
2
+ self.site = ENV['STORESAPP_URL'] || "http://api.storesapp.com/v1"
3
+ self.user = ENV['STORESAPP_SUBDOMAIN']
4
+ self.password = ENV['STORESAPP_KEY']
5
+ end
@@ -0,0 +1,20 @@
1
+ class Collection < Base
2
+ def products
3
+ Product.find(:all, :from => "/v1/collections/#{self.handle}/products.xml")
4
+ end
5
+
6
+ def add_product(options={})
7
+ post(:add_product, :product_id => options[:product_id])
8
+ end
9
+
10
+ def remove_product(options={})
11
+ post(:remove_product, :product_id => options[:product_id])
12
+ end
13
+
14
+ def image
15
+ dragonfly = Dragonfly[:images]
16
+ dragonfly.url_host = 'http://cdn.storesapp.com'
17
+ dragonfly.url_path_prefix = '/images'
18
+ dragonfly.fetch(self.image_uid)
19
+ end
20
+ end
@@ -0,0 +1,21 @@
1
+ class Order < Base
2
+ def items
3
+ OrderItem.find(:all, :from => "/v1/order_items.xml", :params => {'search[order_id]' => self.id})
4
+ end
5
+
6
+ def authorize(credit_card={})
7
+ post(:authorize, :credit_card => credit_card)
8
+ end
9
+
10
+ def capture
11
+ post(:capture)
12
+ end
13
+
14
+ def credit(amount, credit_card_number)
15
+ post(:credit, :amount => amount, :credit_card_number => credit_card_number)
16
+ end
17
+
18
+ def void
19
+ post(:void)
20
+ end
21
+ end
@@ -0,0 +1,9 @@
1
+ class OrderItem < Base
2
+ def order
3
+ Order.find(:first, :from => "/v1/orders/#{self.order_id}.xml")
4
+ end
5
+
6
+ def properties
7
+ OrderItemProperty.find(:all, :from => "/v1/order_item_properties.xml", :params => {'search[order_item_id_equals]' => self.id})
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ class OrderItemProperty < Base
2
+ def item
3
+ OrderItem.find(:first, :from => "/v1/order_items.xml", :params => {'search[order_item_id_equals]' => self.order_item_id})
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ class Page < Base
2
+ end
@@ -0,0 +1,25 @@
1
+ class Product < Base
2
+ def collections
3
+ Collection.find(:all, :from => "/v1/products/#{self.handle}/collections.xml")
4
+ end
5
+
6
+ def images(options={})
7
+ ProductImage.find(:all, :from => "/v1/products/#{self.handle}/images.xml")
8
+ end
9
+
10
+ def properties
11
+ ProductProperty.find(:all, :from => "/v1/products/#{self.handle}/properties.xml")
12
+ end
13
+
14
+ def variants
15
+ Variant.find(:all, :from => "/v1/products/#{self.handle}/variants.xml")
16
+ end
17
+
18
+ def add_collection(options={})
19
+ post(:add_collection, :collection_id => options[:collection_id])
20
+ end
21
+
22
+ def remove_collection(options={})
23
+ post(:remove_collection, :collection_id => options[:collection_id])
24
+ end
25
+ end
@@ -0,0 +1,12 @@
1
+ class ProductImage < Base
2
+ def product
3
+ Product.find(:first, :from => "/v1/products/#{self.product_id}.xml")
4
+ end
5
+
6
+ def image
7
+ dragonfly = Dragonfly[:images]
8
+ dragonfly.url_host = 'http://cdn.storesapp.com'
9
+ dragonfly.url_path_prefix = '/images'
10
+ dragonfly.fetch(self.image_uid)
11
+ end
12
+ end
@@ -0,0 +1,5 @@
1
+ class ProductProperty < Base
2
+ def product
3
+ Product.find(:first, :from => "/v1/products/#{self.product_id}.xml")
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ class ShippingRate < Base
2
+ end
@@ -0,0 +1,2 @@
1
+ class Store < Base
2
+ end
@@ -0,0 +1,2 @@
1
+ class TaxRate < Base
2
+ end
@@ -0,0 +1,2 @@
1
+ class User < Base
2
+ end
@@ -0,0 +1,9 @@
1
+ class Variant < Base
2
+ def product
3
+ Product.find(:first, :from => "/v1/products/#{self.product_id}.xml")
4
+ end
5
+
6
+ def properties
7
+ VariantProperty.find(:all, :from => "/v1/variant_properties.xml?search[product_variant_id_equals]=#{self.id}")
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ class VariantProperty < Base
2
+ def variant
3
+ Variant.find(:first, :from => "/v1/variants/#{self.variant_id}.xml")
4
+ end
5
+ end
data/lib/storesapp.rb CHANGED
@@ -1,31 +1,17 @@
1
- module StoresApp
2
- # Class method to load all ruby files from a given path.
3
- def self.load_all_ruby_files_from_path(path)
4
- Dir.foreach(path) do |file|
5
- require File.join(path, file) if file =~ /\.rb$/
6
- end
7
- end
8
- end
9
-
10
- # Gems
11
- require "rubygems"
12
- require "active_support"
13
- require "active_resource"
14
-
15
- # Plugins
16
- PluginPath = File.join(File.dirname(__FILE__), "storesapp", "plugins")
17
- StoresApp.load_all_ruby_files_from_path(PluginPath)
18
-
19
- # Base
20
- require File.join(File.dirname(__FILE__), "storesapp", "base")
21
- require File.join(File.dirname(__FILE__), "storesapp", "stores_app_resource")
22
-
23
- # Shortcut for StoresApp::Base.new
24
- #
25
- # Example:
26
- # StoresApp(:api_key => "asdf1234",
27
- # :subdomain => "myhostname",
28
- # :headers => {"User-Agent => "Harvest Rubygem"})
29
- def StoresApp(options={})
30
- StoresApp::Base.new(options)
1
+ require 'rails'
2
+ module Storesapp
3
+ class Engine < Rails::Engine
4
+ paths.app = "app"
5
+ paths.app.controllers = "app/controllers"
6
+ paths.app.helpers = "app/helpers"
7
+ paths.app.models = "app/models"
8
+ paths.app.metals = "app/metal"
9
+ paths.app.views = "app/views"
10
+ paths.lib = "lib"
11
+ paths.lib.tasks = "lib/tasks"
12
+ # paths.config = "config"
13
+ # paths.config.initializers = "config/initializers"
14
+ # paths.config.locales = "config/locales"
15
+ # paths.config.routes = "config/routes.rb"
16
+ end
31
17
  end
metadata CHANGED
@@ -1,58 +1,58 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: storesapp-rb
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 4
10
- version: 0.2.4
9
+ - 5
10
+ version: 0.2.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Next Feature
14
+ - Adam Lindsay
14
15
  autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2010-08-16 00:00:00 -04:00
19
+ date: 2010-09-20 00:00:00 -04:00
19
20
  default_executable:
20
21
  dependencies:
21
22
  - !ruby/object:Gem::Dependency
22
- name: activesupport
23
+ name: rails
23
24
  prerelease: false
24
25
  requirement: &id001 !ruby/object:Gem::Requirement
25
26
  none: false
26
27
  requirements:
27
28
  - - ">="
28
29
  - !ruby/object:Gem::Version
29
- hash: 19
30
+ hash: 7
30
31
  segments:
31
- - 2
32
32
  - 3
33
- - 8
34
- version: 2.3.8
33
+ - 0
34
+ - 0
35
+ version: 3.0.0
35
36
  type: :runtime
36
37
  version_requirements: *id001
37
38
  - !ruby/object:Gem::Dependency
38
- name: activeresource
39
+ name: dragonfly
39
40
  prerelease: false
40
41
  requirement: &id002 !ruby/object:Gem::Requirement
41
42
  none: false
42
43
  requirements:
43
44
  - - ">="
44
45
  - !ruby/object:Gem::Version
45
- hash: 19
46
+ hash: 15
46
47
  segments:
47
- - 2
48
- - 3
49
- - 8
50
- version: 2.3.8
48
+ - 0
49
+ - 7
50
+ - 6
51
+ version: 0.7.6
51
52
  type: :runtime
52
53
  version_requirements: *id002
53
- description:
54
- email:
55
- - info@nextfeature.com
54
+ description: A wrapper for the StoresApp API. See http://api.storesapp.com for details.
55
+ email: support@nextfeature.com
56
56
  executables: []
57
57
 
58
58
  extensions: []
@@ -60,33 +60,22 @@ extensions: []
60
60
  extra_rdoc_files: []
61
61
 
62
62
  files:
63
- - .gitignore
64
- - LICENSE
65
- - Manifest.txt
66
- - README.markdown
67
63
  - lib/storesapp.rb
68
- - lib/storesapp/base.rb
69
- - lib/storesapp/plugins/active_resource_inheritable_headers.rb
70
- - lib/storesapp/plugins/hash_ext.rb
71
- - lib/storesapp/resources/cart.rb
72
- - lib/storesapp/resources/cart_item.rb
73
- - lib/storesapp/resources/cart_item_property.rb
74
- - lib/storesapp/resources/collection.rb
75
- - lib/storesapp/resources/collection_product.rb
76
- - lib/storesapp/resources/order.rb
77
- - lib/storesapp/resources/order_item.rb
78
- - lib/storesapp/resources/order_item_property.rb
79
- - lib/storesapp/resources/page.rb
80
- - lib/storesapp/resources/product.rb
81
- - lib/storesapp/resources/product_image.rb
82
- - lib/storesapp/resources/product_property.rb
83
- - lib/storesapp/resources/store.rb
84
- - lib/storesapp/resources/tax_rate.rb
85
- - lib/storesapp/resources/user.rb
86
- - lib/storesapp/resources/variant.rb
87
- - lib/storesapp/resources/variant_property.rb
88
- - lib/storesapp/stores_app_resource.rb
89
- - storesapp.gemspec
64
+ - app/models/base.rb
65
+ - app/models/collection.rb
66
+ - app/models/order.rb
67
+ - app/models/order_item.rb
68
+ - app/models/order_item_property.rb
69
+ - app/models/page.rb
70
+ - app/models/product.rb
71
+ - app/models/product_image.rb
72
+ - app/models/product_property.rb
73
+ - app/models/shipping_rate.rb
74
+ - app/models/store.rb
75
+ - app/models/tax_rate.rb
76
+ - app/models/user.rb
77
+ - app/models/variant.rb
78
+ - app/models/variant_property.rb
90
79
  has_rdoc: true
91
80
  homepage: http://github.com/nextfeature/storesapp-rb
92
81
  licenses: []
@@ -95,6 +84,7 @@ post_install_message:
95
84
  rdoc_options: []
96
85
 
97
86
  require_paths:
87
+ - .
98
88
  - lib
99
89
  required_ruby_version: !ruby/object:Gem::Requirement
100
90
  none: false
@@ -120,6 +110,6 @@ rubyforge_project:
120
110
  rubygems_version: 1.3.7
121
111
  signing_key:
122
112
  specification_version: 3
123
- summary: A wrapper for the StoresApp API. See http://api.storesapp.com for details.
113
+ summary: StoresApp Engine
124
114
  test_files: []
125
115
 
data/.gitignore DELETED
@@ -1 +0,0 @@
1
- .DS_Store
data/LICENSE DELETED
@@ -1,20 +0,0 @@
1
- Copyright (c) 2010, Next Feature
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Manifest.txt DELETED
@@ -1,22 +0,0 @@
1
- lib/storesapp/base.rb
2
- lib/storesapp/stores_app_resource.rb
3
- lib/storesapp/resources/cart.rb
4
- lib/storesapp/resources/cart_item.rb
5
- lib/storesapp/resources/cart_item_property.rb
6
- lib/storesapp/resources/collection.rb
7
- lib/storesapp/resources/collection_product.rb
8
- lib/storesapp/resources/order.rb
9
- lib/storesapp/resources/order_item.rb
10
- lib/storesapp/resources/order_item_property.rb
11
- lib/storesapp/resources/page.rb
12
- lib/storesapp/resources/product.rb
13
- lib/storesapp/resources/product_image.rb
14
- lib/storesapp/resources/product_property.rb
15
- lib/storesapp/resources/user.rb
16
- lib/storesapp/resources/variant.rb
17
- lib/storesapp/resources/variant_property.rb
18
- lib/storesapp/resources/tax_rate.rb
19
- lib/storesapp/resources/store.rb
20
- lib/storesapp.rb
21
- LICENSE
22
- README.markdown
data/README.markdown DELETED
@@ -1,58 +0,0 @@
1
- # storesapp-rb #
2
-
3
- A ruby library wrapping the StoresApp API.
4
-
5
- ## Description ##
6
-
7
- This library uses ActiveResource to provide simple, reliable access to the StoresApp API. Good for building eCommerce websites.
8
-
9
- ## Usage ##
10
-
11
- ### Creating a new StoresApp object: ###
12
-
13
- All calls to the StoresApp API will originate from a StoresApp object. Initialize it like so:
14
-
15
- `@store = StoresApp(:api_key => "12340987asdf12340987qwer", :subdomain => "joeandcompany")`
16
-
17
- ### Collections ###
18
-
19
- Index
20
-
21
- `@store.collections.find(:all)`
22
-
23
- Show
24
-
25
- `@store.collections.find(43235) # ID`
26
-
27
- `@store.collections.find('clothing') # Handle`
28
-
29
- Create
30
-
31
- `@collection = @store.collection.new`
32
-
33
- `@collection.attributes = {:name => "Toys", :description => "lorem ipsum..."}`
34
-
35
- `@collection.save`
36
-
37
- Update
38
-
39
- `@collection.name = "Adult Toys"`
40
-
41
- `@collection.save`
42
-
43
- Destroy
44
-
45
- `@client.destroy`
46
-
47
- ## Features / Problems ##
48
-
49
- Supports most of the StoresApp API (http://api.storesapp.com).
50
-
51
- ## Requirements ##
52
-
53
- Requires active_support >= 2.3.5
54
- Requires active_resource >= 2.3.5
55
-
56
- ## Install ##
57
-
58
- `gem install storesapp-rb`
@@ -1,92 +0,0 @@
1
- module StoresApp
2
- class Base
3
- # Requires a subdomain, and api_key.
4
- # Specifying headers is optional, but useful for setting a user agent.
5
- def initialize(options={})
6
- options.assert_valid_keys(:subdomain, :api_key, :headers)
7
- options.assert_required_keys(:subdomain)
8
- @subdomain = options[:subdomain]
9
- @api_key = options[:api_key]
10
- @headers = options[:headers]
11
- configure_base_resource
12
- end
13
-
14
- def collections(params={})
15
- StoresApp::Resources::Collection.find(:all, :params => params)
16
- end
17
-
18
- def collection(obj)
19
- StoresApp::Resources::Collection.find(obj)
20
- end
21
-
22
- def products(params={})
23
- StoresApp::Resources::Product.find(:all, :params => params)
24
- end
25
-
26
- def product(obj)
27
- StoresApp::Resources::Product.find(obj)
28
- end
29
-
30
- def carts(params={})
31
- StoresApp::Resources::Cart.find(:all, :params => params)
32
- end
33
-
34
- def cart(obj)
35
- StoresApp::Resources::Cart.find(obj)
36
- end
37
-
38
- def orders(params={})
39
- StoresApp::Resources::Order.find(:all, :params => params)
40
- end
41
-
42
- def order(obj)
43
- StoresApp::Resources::Order.find(obj)
44
- end
45
-
46
- def store
47
- StoresApp::Resources::Store.find(:first)
48
- end
49
-
50
- def users(params={})
51
- StoresApp::Resources::User.find(:all, :params => params)
52
- end
53
-
54
- def user(obj)
55
- StoresApp::Resources::User.find(obj)
56
- end
57
-
58
- def pages(params={})
59
- StoresApp::Resources::Page.find(:all, :params => params)
60
- end
61
-
62
- def page(obj)
63
- StoresApp::Resources::Page.find(obj)
64
- end
65
-
66
- def tax_rates(params={})
67
- StoresApp::Resources::TaxRate.find(:all, :params => params)
68
- end
69
-
70
- private
71
- # Configure resource base class so that
72
- # inherited classes can access the api.
73
- def configure_base_resource
74
- if @api_key
75
- StoresAppResource.site = "https://api.storesapp.com/v1"
76
- StoresAppResource.user = @subdomain
77
- StoresAppResource.password = @api_key
78
- else
79
- StoresAppResource.site = "http://api.storesapp-com.local/v1"
80
- StoresAppResource.user = @subdomain
81
- end
82
- StoresAppResource.headers.update(@headers) if @headers.is_a?(Hash)
83
- load_resources
84
- end
85
-
86
- # Load the classes representing the various resources.
87
- def load_resources
88
- resource_path = File.join(File.dirname(__FILE__), "resources")
89
- StoresApp.load_all_ruby_files_from_path(resource_path)
90
- end
91
- end
92
- end
@@ -1,32 +0,0 @@
1
- # Allows headers in an ActiveResource::Base class
2
- # to be inherited by subclasses. Useful for setting
3
- # a User-Agent used by all resources.
4
- module StoresApp
5
- module Plugins
6
- module ActiveResourceInheritableHeaders
7
- module ClassMethods
8
- # If headers are not defined in a
9
- # given subclass, then obtain headers
10
- # from the superclass.
11
- def inheritable_headers
12
- if defined?(@headers)
13
- @headers
14
- elsif superclass != Object && superclass.headers
15
- superclass.headers
16
- else
17
- @headers ||= {}
18
- end
19
- end
20
- end
21
-
22
- def self.included(klass)
23
- klass.instance_eval do
24
- klass.extend ClassMethods
25
- class << self
26
- alias_method :headers, :inheritable_headers
27
- end
28
- end
29
- end
30
- end
31
- end
32
- end
@@ -1,11 +0,0 @@
1
- class Hash
2
- def assert_valid_keys(*valid_keys)
3
- invalid_keys = keys - valid_keys
4
- raise ArgumentError, "Invalid key(s): #{invalid_keys.join(", ")}" unless invalid_keys.empty?
5
- end
6
-
7
- def assert_required_keys(*required_keys)
8
- missing_keys = required_keys.select {|key| !keys.include?(key)}
9
- raise ArgumentError, "Missing required option(s): #{missing_keys.join(", ")}" unless missing_keys.empty?
10
- end
11
- end
@@ -1,9 +0,0 @@
1
- module StoresApp
2
- module Resources
3
- class Cart < StoresApp::StoresAppResource
4
- def items
5
- CartItem.find(:all, :from => "/v1/cart_items.xml", :params => {'search[cart_id]' => self.id})
6
- end
7
- end
8
- end
9
- end
@@ -1,13 +0,0 @@
1
- module StoresApp
2
- module Resources
3
- class CartItem < StoresApp::StoresAppResource
4
- def cart
5
- Cart.find(:first, :from => "/v1/carts/#{self.cart_id}.xml")
6
- end
7
-
8
- def properties
9
- CartItemProperty.find(:all, :from => "/v1/cart_item_properties.xml", :params => {'search[cart_item_id_equals]' => self.id})
10
- end
11
- end
12
- end
13
- end
@@ -1,9 +0,0 @@
1
- module StoresApp
2
- module Resources
3
- class CartItemProperty < StoresApp::StoresAppResource
4
- def item
5
- CartItem.find(:first, :from => "/v1/cart_items.xml", :params => {'search[cart_item_id_equals]' => self.cart_item_id})
6
- end
7
- end
8
- end
9
- end
@@ -1,31 +0,0 @@
1
- module StoresApp
2
- module Resources
3
- class Collection < StoresApp::StoresAppResource
4
- def products
5
- collection_products = CollectionProduct.find(:all, :from => "/v1/collection_products.xml?search[collection_id_equals]=#{self.id}")
6
- product_ids = collection_products.collect {|cp| cp.product_id}
7
- return Product.find(:all).select {|p| product_ids.include?(p.id)}
8
- end
9
-
10
- def add_product(options={})
11
- options.assert_valid_keys(:product_id)
12
- options.assert_required_keys(:product_id)
13
- CollectionProduct.create(:product_id => options[:product_id], :collection_id => self.id)
14
- end
15
-
16
- def remove_product(options={})
17
- options.assert_valid_keys(:product_id)
18
- options.assert_required_keys(:product_id)
19
- CollectionProduct.find(:first, :from => "/v1/collection_products.xml?search[collection_id_equals]=#{self.id}&search[product_id_equals]=#{options[:collection_id]}").destroy
20
- end
21
-
22
- # def enable
23
- # put(:enable)
24
- # end
25
-
26
- # def disable
27
- # put(:disable)
28
- # end
29
- end
30
- end
31
- end
@@ -1,13 +0,0 @@
1
- module StoresApp
2
- module Resources
3
- class CollectionProduct < StoresApp::StoresAppResource
4
- def collection
5
- Collection.find(:first, :from => "/v1/collections/#{self.collection_id}.xml")
6
- end
7
-
8
- def product
9
- Product.find(:first, :from => "/v1/products/#{self.product_id}.xml")
10
- end
11
- end
12
- end
13
- end
@@ -1,25 +0,0 @@
1
- module StoresApp
2
- module Resources
3
- class Order < StoresApp::StoresAppResource
4
- def items
5
- OrderItem.find(:all, :from => "/v1/order_items.xml", :params => {'search[order_id]' => self.id})
6
- end
7
-
8
- def authorize(credit_card={})
9
- post(:authorize, :credit_card => credit_card)
10
- end
11
-
12
- def capture
13
- post(:capture)
14
- end
15
-
16
- def credit(amount, credit_card_number)
17
- post(:credit, :amount => amount, :credit_card_number => credit_card_number)
18
- end
19
-
20
- def void
21
- post(:void)
22
- end
23
- end
24
- end
25
- end
@@ -1,13 +0,0 @@
1
- module StoresApp
2
- module Resources
3
- class OrderItem < StoresApp::StoresAppResource
4
- def order
5
- Order.find(:first, :from => "/v1/orders/#{self.order_id}.xml")
6
- end
7
-
8
- def properties
9
- OrderItemProperty.find(:all, :from => "/v1/order_item_properties.xml", :params => {'search[order_item_id_equals]' => self.id})
10
- end
11
- end
12
- end
13
- end
@@ -1,9 +0,0 @@
1
- module StoresApp
2
- module Resources
3
- class OrderItemProperty < StoresApp::StoresAppResource
4
- def item
5
- OrderItem.find(:first, :from => "/v1/order_items.xml", :params => {'search[order_item_id_equals]' => self.order_item_id})
6
- end
7
- end
8
- end
9
- end
@@ -1,6 +0,0 @@
1
- module StoresApp
2
- module Resources
3
- class Page < StoresApp::StoresAppResource
4
- end
5
- end
6
- end
@@ -1,43 +0,0 @@
1
- module StoresApp
2
- module Resources
3
- class Product < StoresApp::StoresAppResource
4
- def collections
5
- collection_products = CollectionProduct.find(:all, :from => "/v1/collection_products.xml?search[product_id_equals]=#{self.id}")
6
- collection_ids = collection_products.collect {|cp| cp.collection_id}
7
- return Collection.find(:all).select {|c| collection_ids.include?(c.id)}
8
- end
9
-
10
- def images
11
- ProductImage.find(:all, :from => "/v1/product_images.xml?search[product_id_equals]=#{self.id}")
12
- end
13
-
14
- def properties
15
- ProductProperty.find(:all, :from => "/v1/product_properties.xml?search[product_id_equals]=#{self.id}")
16
- end
17
-
18
- def variants
19
- Variant.find(:all, :from => "/v1/variants.xml?search[product_id_equals]=#{self.id}")
20
- end
21
-
22
- def add_collection(options={})
23
- options.assert_valid_keys(:collection_id)
24
- options.assert_required_keys(:collection_id)
25
- CollectionProduct.create(:collection_id => options[:collection_id], :product_id => self.id)
26
- end
27
-
28
- def remove_collection(options={})
29
- options.assert_valid_keys(:collection_id)
30
- options.assert_required_keys(:collection_id)
31
- CollectionProduct.find(:first, :from => "/v1/collection_products.xml?search[product_id_equals]=#{self.id}&search[collection_id_equals]=#{options[:collection_id]}").destroy
32
- end
33
-
34
- # def enable
35
- # put(:enable)
36
- # end
37
- #
38
- # def disable
39
- # put(:disable)
40
- # end
41
- end
42
- end
43
- end
@@ -1,9 +0,0 @@
1
- module StoresApp
2
- module Resources
3
- class ProductImage < StoresApp::StoresAppResource
4
- def product
5
- Product.find(:first, :from => "/v1/products/#{self.product_id}.xml")
6
- end
7
- end
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- module StoresApp
2
- module Resources
3
- class ProductProperty < StoresApp::StoresAppResource
4
- def product
5
- Product.find(:first, :from => "/v1/products/#{self.product_id}.xml")
6
- end
7
- end
8
- end
9
- end
@@ -1,6 +0,0 @@
1
- module StoresApp
2
- module Resources
3
- class Store < StoresApp::StoresAppResource
4
- end
5
- end
6
- end
@@ -1,6 +0,0 @@
1
- module StoresApp
2
- module Resources
3
- class TaxRate < StoresApp::StoresAppResource
4
- end
5
- end
6
- end
@@ -1,6 +0,0 @@
1
- module StoresApp
2
- module Resources
3
- class User < StoresApp::StoresAppResource
4
- end
5
- end
6
- end
@@ -1,13 +0,0 @@
1
- module StoresApp
2
- module Resources
3
- class Variant < StoresApp::StoresAppResource
4
- def product
5
- Product.find(:first, :from => "/v1/products/#{self.product_id}.xml")
6
- end
7
-
8
- def properties
9
- VariantProperty.find(:all, :from => "/v1/variant_properties.xml?search[product_variant_id_equals]=#{self.id}")
10
- end
11
- end
12
- end
13
- end
@@ -1,9 +0,0 @@
1
- module StoresApp
2
- module Resources
3
- class VariantProperty < StoresApp::StoresAppResource
4
- def variant
5
- Variant.find(:first, :from => "/v1/variants/#{self.variant_id}.xml")
6
- end
7
- end
8
- end
9
- end
@@ -1,5 +0,0 @@
1
- module StoresApp
2
- class StoresAppResource < ActiveResource::Base
3
- include StoresApp::Plugins::ActiveResourceInheritableHeaders
4
- end
5
- end
data/storesapp.gemspec DELETED
@@ -1,19 +0,0 @@
1
- #!/usr/bin/env gem build
2
- # encoding: utf-8
3
-
4
- Gem::Specification.new do |s|
5
- s.name = "storesapp-rb"
6
- s.version = "0.2.4"
7
- s.authors = ["Next Feature"]
8
- s.summary = "A wrapper for the StoresApp API. See http://api.storesapp.com for details."
9
- s.date = Date.today.to_s
10
- # s.description = s.summary
11
- s.homepage = "http://github.com/nextfeature/storesapp-rb"
12
- s.email = ["info@nextfeature.com"]
13
- s.files = `git ls-files`.split("\n")
14
- s.require_paths = ["lib"]
15
- # s.test_files = [""]
16
- s.has_rdoc = false
17
- s.add_dependency("activesupport", [">= 2.3.8"])
18
- s.add_dependency("activeresource", [">= 2.3.8"])
19
- end