storesapp-rb 0.2.7 → 0.2.8

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/app/models/base.rb CHANGED
@@ -1,12 +1,13 @@
1
1
  require 'yaml'
2
2
  class Base < ActiveResource::Base
3
+ BASE_URL = "https://api.storesapp.com/v1"
3
4
  begin
4
- CONFIG = YAML::load(File.open(File.join(Rails.root, 'config', 'storesapp.yml')))[Rails.env]
5
- self.site = CONFIG['url'] || "http://api.storesapp.com/v1"
5
+ CONFIG = YAML::load(File.open(File.join(Rails.root, 'config', 'storesapp.yml')))[Rails.env]
6
+ self.site = CONFIG['url'] || BASE_URL
6
7
  self.user = CONFIG['subdomain']
7
8
  self.password = CONFIG['api_key']
8
9
  rescue Exception => e
9
- self.site = ENV['STORESAPP_URL'] || "http://api.storesapp.com/v1"
10
+ self.site = ENV['STORESAPP_URL'] || BASE_URL
10
11
  self.user = ENV['STORESAPP_SUBDOMAIN']
11
12
  self.password = ENV['STORESAPP_API_KEY']
12
13
  end
@@ -1,14 +1,30 @@
1
1
  class Collection < Base
2
- def products
3
- Product.find(:all, :from => "/v1/collections/#{self.handle}/products.xml")
2
+ def self.roots
3
+ self.find(:all, :from => "/v1/collections/roots.xml")
4
4
  end
5
5
 
6
- def add_product(options={})
7
- # post(:add_product, :product_id => options[:product_id])
6
+ def root?
7
+ self.parent_id.blank?
8
8
  end
9
9
 
10
- def remove_product(options={})
11
- # post(:remove_product, :product_id => options[:product_id])
10
+ def parent
11
+ Collection.find(:one, :from => "/v1/collections/#{self.parent_id}.xml")
12
+ end
13
+
14
+ def ancestors
15
+ Collection.find(:all, :from => "/v1/collections/#{self.handle}/ancestors.xml")
16
+ end
17
+
18
+ def children
19
+ Collection.find(:all, :from => "/v1/collections/#{self.handle}/children.xml")
20
+ end
21
+
22
+ def siblings
23
+ Collection.find(:all, :from => "/v1/collections/#{self.handle}/siblings.xml")
24
+ end
25
+
26
+ def products
27
+ Product.find(:all, :from => "/v1/collections/#{self.handle}/products.xml")
12
28
  end
13
29
 
14
30
  def image
@@ -14,12 +14,4 @@ class Product < Base
14
14
  def variants
15
15
  Variant.find(:all, :from => "/v1/products/#{self.handle}/variants.xml")
16
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
17
  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: 25
4
+ hash: 7
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 7
10
- version: 0.2.7
9
+ - 8
10
+ version: 0.2.8
11
11
  platform: ruby
12
12
  authors:
13
13
  - Next Feature
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-09-21 00:00:00 -04:00
19
+ date: 2010-09-22 00:00:00 -04:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency