storesapp-rb 0.1.5 → 0.1.6
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/lib/storesapp/base.rb +9 -9
- data/lib/storesapp/resources/collection.rb +15 -14
- data/lib/storesapp/resources/collection_product.rb +7 -0
- data/lib/storesapp/resources/product.rb +24 -22
- data/lib/storesapp/resources/product_image.rb +3 -0
- data/lib/storesapp/resources/product_property.rb +3 -3
- data/lib/storesapp/resources/variant.rb +7 -3
- data/lib/storesapp/resources/variant_property.rb +3 -0
- data/lib/storesapp.rb +1 -1
- data/storesapp.gemspec +3 -3
- metadata +10 -10
data/lib/storesapp/base.rb
CHANGED
@@ -12,39 +12,39 @@ module StoresApp
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def collections
|
15
|
-
StoresApp::Resources::Collection
|
15
|
+
StoresApp::Resources::Collection.find(:all)
|
16
16
|
end
|
17
17
|
|
18
18
|
def collection_products
|
19
|
-
StoresApp::Resources::CollectionProduct
|
19
|
+
StoresApp::Resources::CollectionProduct.find(:all)
|
20
20
|
end
|
21
21
|
|
22
22
|
def pages
|
23
|
-
StoresApp::Resources::Page
|
23
|
+
StoresApp::Resources::Page.find(:all)
|
24
24
|
end
|
25
25
|
|
26
26
|
def products
|
27
|
-
StoresApp::Resources::Product
|
27
|
+
StoresApp::Resources::Product.find(:all)
|
28
28
|
end
|
29
29
|
|
30
30
|
def product_images
|
31
|
-
StoresApp::Resources::ProductImage
|
31
|
+
StoresApp::Resources::ProductImage.find(:all)
|
32
32
|
end
|
33
33
|
|
34
34
|
def product_properties
|
35
|
-
StoresApp::Resources::ProductProperty
|
35
|
+
StoresApp::Resources::ProductProperty.find(:all)
|
36
36
|
end
|
37
37
|
|
38
38
|
def users
|
39
|
-
StoresApp::Resources::User
|
39
|
+
StoresApp::Resources::User.find(:all)
|
40
40
|
end
|
41
41
|
|
42
42
|
def variants
|
43
|
-
StoresApp::Resources::Variant
|
43
|
+
StoresApp::Resources::Variant.find(:all)
|
44
44
|
end
|
45
45
|
|
46
46
|
def variant_properties
|
47
|
-
StoresApp::Resources::VariantProperty
|
47
|
+
StoresApp::Resources::VariantProperty.find(:all)
|
48
48
|
end
|
49
49
|
|
50
50
|
private
|
@@ -1,22 +1,23 @@
|
|
1
1
|
module StoresApp
|
2
2
|
module Resources
|
3
3
|
class Collection < StoresApp::StoresAppResource
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
def products
|
5
|
+
collection_products = CollectionProduct.find(:all, :from => "/api/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
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
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
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
def remove_product(options={})
|
17
|
+
options.assert_valid_keys(:product_id)
|
18
|
+
options.assert_required_keys(:product_id)
|
19
|
+
CollectionProduct.find(:first, :from => "/api/v1/collection_products.xml?search[collection_id_equals]=#{self.id}&search[product_id_equals]=#{options[:collection_id]}").destroy
|
20
|
+
end
|
20
21
|
|
21
22
|
# def enable
|
22
23
|
# put(:enable)
|
@@ -1,6 +1,13 @@
|
|
1
1
|
module StoresApp
|
2
2
|
module Resources
|
3
3
|
class CollectionProduct < StoresApp::StoresAppResource
|
4
|
+
def collection
|
5
|
+
return Collection.find(:first, :from => "/api/v1/collections.xml?search[collection_id_equals]=#{self.collection_id}")
|
6
|
+
end
|
7
|
+
|
8
|
+
def products
|
9
|
+
return Product.find(:first, :from => "/api/v1/products.xml?search[product_id_equals]=#{self.product_id}")
|
10
|
+
end
|
4
11
|
end
|
5
12
|
end
|
6
13
|
end
|
@@ -1,33 +1,35 @@
|
|
1
1
|
module StoresApp
|
2
2
|
module Resources
|
3
3
|
class Product < StoresApp::StoresAppResource
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
def collections
|
5
|
+
collection_products = CollectionProduct.find(:all, :from => "/api/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
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
-
|
10
|
+
def images
|
11
|
+
ProductImage.find(:all, :from => "/api/v1/product_images.xml?search[product_id_equals]=#{self.id}")
|
12
|
+
end
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
-
|
14
|
+
def properties
|
15
|
+
ProductProperty.find(:all, :from => "/api/v1/product_properties.xml?search[product_id_equals]=#{self.id}")
|
16
|
+
end
|
15
17
|
|
16
|
-
|
17
|
-
|
18
|
-
|
18
|
+
def variants
|
19
|
+
Variant.find(:all, :from => "/api/v1/variants.xml?search[product_id_equals]=#{self.id}")
|
20
|
+
end
|
19
21
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
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
|
25
27
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
def remove_collection(options={})
|
29
|
+
options.assert_valid_keys(:collection_id)
|
30
|
+
options.assert_required_keys(:collection_id)
|
31
|
+
CollectionProduct.find(:first, :from => "/api/v1/collection_products.xml?search[product_id_equals]=#{self.id}&search[collection_id_equals]=#{options[:collection_id]}").destroy
|
32
|
+
end
|
31
33
|
|
32
34
|
# def enable
|
33
35
|
# put(:enable)
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module StoresApp
|
2
2
|
module Resources
|
3
3
|
class ProductProperty < StoresApp::StoresAppResource
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
def product
|
5
|
+
Product.find(:first, :from => "/api/v1/product.xml?search[product_id_equals]=#{self.product_id}")
|
6
|
+
end
|
7
7
|
end
|
8
8
|
end
|
9
9
|
end
|
@@ -1,9 +1,13 @@
|
|
1
1
|
module StoresApp
|
2
2
|
module Resources
|
3
3
|
class Variant < StoresApp::StoresAppResource
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
def product
|
5
|
+
Product.find(:first, :from => "/api/v1/product.xml?search[product_id_equals]=#{self.product_id}")
|
6
|
+
end
|
7
|
+
|
8
|
+
def properties
|
9
|
+
VariantProperty.find(:all, :from => "/api/v1/variant_properties.xml?search[product_variant_id_equals]=#{self.id}")
|
10
|
+
end
|
7
11
|
end
|
8
12
|
end
|
9
13
|
end
|
data/lib/storesapp.rb
CHANGED
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.1.
|
6
|
+
s.version = "0.1.6"
|
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.
|
18
|
-
s.add_dependency("activeresource", [">= 2.3.
|
17
|
+
s.add_dependency("activesupport", [">= 2.3.8"])
|
18
|
+
s.add_dependency("activeresource", [">= 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:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 6
|
10
|
+
version: 0.1.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Next Feature
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-07-
|
18
|
+
date: 2010-07-29 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -26,12 +26,12 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
hash:
|
29
|
+
hash: 19
|
30
30
|
segments:
|
31
31
|
- 2
|
32
32
|
- 3
|
33
|
-
-
|
34
|
-
version: 2.3.
|
33
|
+
- 8
|
34
|
+
version: 2.3.8
|
35
35
|
type: :runtime
|
36
36
|
version_requirements: *id001
|
37
37
|
- !ruby/object:Gem::Dependency
|
@@ -42,12 +42,12 @@ dependencies:
|
|
42
42
|
requirements:
|
43
43
|
- - ">="
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
hash:
|
45
|
+
hash: 19
|
46
46
|
segments:
|
47
47
|
- 2
|
48
48
|
- 3
|
49
|
-
-
|
50
|
-
version: 2.3.
|
49
|
+
- 8
|
50
|
+
version: 2.3.8
|
51
51
|
type: :runtime
|
52
52
|
version_requirements: *id002
|
53
53
|
description:
|