storesapp-rb 0.2.1 → 0.2.3

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/Manifest.txt CHANGED
@@ -15,6 +15,8 @@ lib/storesapp/resources/product_property.rb
15
15
  lib/storesapp/resources/user.rb
16
16
  lib/storesapp/resources/variant.rb
17
17
  lib/storesapp/resources/variant_property.rb
18
+ lib/storesapp/resources/tax_rate.rb
19
+ lib/storesapp/resources/store.rb
18
20
  lib/storesapp.rb
19
21
  LICENSE
20
22
  README.markdown
@@ -11,60 +11,72 @@ module StoresApp
11
11
  configure_base_resource
12
12
  end
13
13
 
14
- def collections
15
- StoresApp::Resources::Collection.find(:all)
14
+ def collections(params={})
15
+ StoresApp::Resources::Collection.find(:all, :params => params)
16
16
  end
17
17
 
18
- def collection_products
19
- StoresApp::Resources::CollectionProduct.find(:all)
18
+ def collection(obj)
19
+ StoresApp::Resources::Collection.find(obj)
20
20
  end
21
21
 
22
- def products
23
- StoresApp::Resources::Product.find(:all)
22
+ def products(params={})
23
+ StoresApp::Resources::Product.find(:all, :params => params)
24
24
  end
25
+
26
+ def product(obj)
27
+ StoresApp::Resources::Product.find(obj)
28
+ end
25
29
 
26
- def product_images
27
- StoresApp::Resources::ProductImage.find(:all)
30
+ def carts(params={})
31
+ StoresApp::Resources::Cart.find(:all, :params => params)
28
32
  end
29
33
 
30
- def product_properties
31
- StoresApp::Resources::ProductProperty.find(:all)
32
- end
33
-
34
- def variants
35
- StoresApp::Resources::Variant.find(:all)
34
+ def cart(obj)
35
+ StoresApp::Resources::Cart.find(obj)
36
36
  end
37
37
 
38
- def variant_properties
39
- StoresApp::Resources::VariantProperty.find(:all)
38
+ def orders(params={})
39
+ StoresApp::Resources::Order.find(:all, :params => params)
40
40
  end
41
41
 
42
- def pages
43
- StoresApp::Resources::Page.find(:all)
42
+ def order(obj)
43
+ StoresApp::Resources::Order.find(obj)
44
+ end
45
+
46
+ def store
47
+ StoresApp::Resources::Store.find(:first)
44
48
  end
45
49
 
46
- def users
47
- StoresApp::Resources::User.find(:all)
50
+ def users(params={})
51
+ StoresApp::Resources::User.find(:all, :params => params)
48
52
  end
49
53
 
50
- def carts
51
- StoresApp::Resources::Cart.find(:all)
54
+ def user(obj)
55
+ StoresApp::Resources::User.find(obj)
52
56
  end
53
57
 
54
- def orders
55
- StoresApp::Resources::Order.find(:all)
56
- end
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
57
69
 
58
70
  private
59
71
  # Configure resource base class so that
60
72
  # inherited classes can access the api.
61
73
  def configure_base_resource
62
74
  if @api_key
63
- StoresAppResource.site = "http://#{StoresApp::ApiDomain}/v1"
75
+ StoresAppResource.site = "https://api.storesapp.com/v1"
64
76
  StoresAppResource.user = @subdomain
65
77
  StoresAppResource.password = @api_key
66
78
  else
67
- StoresAppResource.site = "http://#{StoresApp::DevelopmentApiDomain}/v1"
79
+ StoresAppResource.site = "http://api.storesapp-com.local/v1"
68
80
  StoresAppResource.user = @subdomain
69
81
  end
70
82
  StoresAppResource.headers.update(@headers) if @headers.is_a?(Hash)
@@ -2,7 +2,7 @@ module StoresApp
2
2
  module Resources
3
3
  class Cart < StoresApp::StoresAppResource
4
4
  def items
5
- CartItem.find(:all, :from => "/v1//cart_items.xml", :params => {'search[cart_id]' => self.id})
5
+ CartItem.find(:all, :from => "/v1/cart_items.xml", :params => {'search[cart_id]' => self.id})
6
6
  end
7
7
  end
8
8
  end
@@ -2,7 +2,7 @@ module StoresApp
2
2
  module Resources
3
3
  class CartItem < StoresApp::StoresAppResource
4
4
  def cart
5
- Cart.find(:first, :from => "/v1/cart_items.xml", :params => {'search[cart_id_equals]' => self.cart_id})
5
+ Cart.find(:first, :from => "/v1/carts/#{self.cart_id}.xml")
6
6
  end
7
7
 
8
8
  def properties
@@ -2,11 +2,11 @@ module StoresApp
2
2
  module Resources
3
3
  class CollectionProduct < StoresApp::StoresAppResource
4
4
  def collection
5
- return Collection.find(:first, :from => "/v1/collections.xml?search[collection_id_equals]=#{self.collection_id}")
5
+ Collection.find(:first, :from => "/v1/collections/#{self.collection_id}.xml")
6
6
  end
7
7
 
8
- def products
9
- return Product.find(:first, :from => "/v1/products.xml?search[product_id_equals]=#{self.product_id}")
8
+ def product
9
+ Product.find(:first, :from => "/v1/products/#{self.product_id}.xml")
10
10
  end
11
11
  end
12
12
  end
@@ -4,6 +4,22 @@ module StoresApp
4
4
  def items
5
5
  OrderItem.find(:all, :from => "/v1/order_items.xml", :params => {'search[order_id]' => self.id})
6
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
7
23
  end
8
24
  end
9
25
  end
@@ -2,7 +2,7 @@ module StoresApp
2
2
  module Resources
3
3
  class OrderItem < StoresApp::StoresAppResource
4
4
  def order
5
- Order.find(:first, :from => "/v1/order_items.xml", :params => {'search[order_id_equals]' => self.order_id})
5
+ Order.find(:first, :from => "/v1/orders/#{self.order_id}.xml")
6
6
  end
7
7
 
8
8
  def properties
@@ -2,7 +2,7 @@ module StoresApp
2
2
  module Resources
3
3
  class ProductImage < StoresApp::StoresAppResource
4
4
  def product
5
- Product.find(:first, :from => "/v1/product.xml?search[product_id_equals]=#{self.product_id}")
5
+ Product.find(:first, :from => "/v1/products/#{self.product_id}.xml")
6
6
  end
7
7
  end
8
8
  end
@@ -2,7 +2,7 @@ module StoresApp
2
2
  module Resources
3
3
  class ProductProperty < StoresApp::StoresAppResource
4
4
  def product
5
- Product.find(:first, :from => "/v1/product.xml?search[product_id_equals]=#{self.product_id}")
5
+ Product.find(:first, :from => "/v1/products/#{self.product_id}.xml")
6
6
  end
7
7
  end
8
8
  end
@@ -0,0 +1,6 @@
1
+ module StoresApp
2
+ module Resources
3
+ class Store < StoresApp::StoresAppResource
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module StoresApp
2
+ module Resources
3
+ class TaxRate < StoresApp::StoresAppResource
4
+ end
5
+ end
6
+ end
@@ -2,7 +2,7 @@ module StoresApp
2
2
  module Resources
3
3
  class Variant < StoresApp::StoresAppResource
4
4
  def product
5
- Product.find(:first, :from => "/v1/product.xml?search[product_id_equals]=#{self.product_id}")
5
+ Product.find(:first, :from => "/v1/products/#{self.product_id}.xml")
6
6
  end
7
7
 
8
8
  def properties
@@ -2,7 +2,7 @@ module StoresApp
2
2
  module Resources
3
3
  class VariantProperty < StoresApp::StoresAppResource
4
4
  def variant
5
- Variant.find(:first, :from => "/v1/variants.xml?search[variant_id_equals]=#{self.variant_id}")
5
+ Variant.find(:first, :from => "/v1/variants/#{self.variant_id}.xml")
6
6
  end
7
7
  end
8
8
  end
data/lib/storesapp.rb CHANGED
@@ -1,8 +1,4 @@
1
- module StoresApp
2
- # VERSION = '0.2.0'
3
- ApiDomain = 'api.storesapp.com'
4
- DevelopmentApiDomain = 'api.storesapp-com.local'
5
-
1
+ module StoresApp
6
2
  # Class method to load all ruby files from a given path.
7
3
  def self.load_all_ruby_files_from_path(path)
8
4
  Dir.foreach(path) do |file|
@@ -13,8 +9,8 @@ end
13
9
 
14
10
  # Gems
15
11
  require "rubygems"
16
- require "activesupport"
17
- require "activeresource"
12
+ require "active_support"
13
+ require "active_resource"
18
14
 
19
15
  # Plugins
20
16
  PluginPath = File.join(File.dirname(__FILE__), "storesapp", "plugins")
data/storesapp.gemspec CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "storesapp-rb"
6
- s.version = "0.2.1"
6
+ s.version = "0.2.3"
7
7
  s.authors = ["Next Feature"]
8
8
  s.summary = "A wrapper for the StoresApp API. See http://api.storesapp.com for details."
9
9
  s.date = Date.today.to_s
@@ -14,6 +14,6 @@ Gem::Specification.new do |s|
14
14
  s.require_paths = ["lib"]
15
15
  # s.test_files = [""]
16
16
  s.has_rdoc = false
17
- s.add_dependency("activesupport", [">= 2.3.8"])
18
- s.add_dependency("activeresource", [">= 2.3.8"])
17
+ s.add_dependency("active_support", [">= 2.3.8"])
18
+ s.add_dependency("active_resource", [">= 2.3.8"])
19
19
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: storesapp-rb
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 1
10
- version: 0.2.1
9
+ - 3
10
+ version: 0.2.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Next Feature
@@ -15,11 +15,11 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-08-11 00:00:00 -04:00
18
+ date: 2010-08-16 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- name: activesupport
22
+ name: active_support
23
23
  prerelease: false
24
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
25
  none: false
@@ -35,7 +35,7 @@ dependencies:
35
35
  type: :runtime
36
36
  version_requirements: *id001
37
37
  - !ruby/object:Gem::Dependency
38
- name: activeresource
38
+ name: active_resource
39
39
  prerelease: false
40
40
  requirement: &id002 !ruby/object:Gem::Requirement
41
41
  none: false
@@ -80,6 +80,8 @@ files:
80
80
  - lib/storesapp/resources/product.rb
81
81
  - lib/storesapp/resources/product_image.rb
82
82
  - lib/storesapp/resources/product_property.rb
83
+ - lib/storesapp/resources/store.rb
84
+ - lib/storesapp/resources/tax_rate.rb
83
85
  - lib/storesapp/resources/user.rb
84
86
  - lib/storesapp/resources/variant.rb
85
87
  - lib/storesapp/resources/variant_property.rb