popshops 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/popshops.rb +31 -1
  2. metadata +3 -2
data/lib/popshops.rb CHANGED
@@ -6,8 +6,9 @@ class Popshops
6
6
  include HTTParty
7
7
  base_uri 'api.popshops.com/v2'
8
8
 
9
- def initialize(api_key)
9
+ def initialize(api_key, private_api_key = nil)
10
10
  @api_key = api_key
11
+ @private_api_key = private_api_key
11
12
  end
12
13
 
13
14
  def product_search(options={})
@@ -40,4 +41,33 @@ class Popshops
40
41
  Hashie::Mash.new(results['deal_types'])
41
42
  end
42
43
 
44
+ def catalogs
45
+ results = self.class.get("https://www.popshops.com/v2/#{@api_key}/catalogs/list.xml?private_api_key=#{@private_api_key}")
46
+ Hashie::Mash.new(results['results']['catalogs'])
47
+ end
48
+
49
+ # Activates merchants for the given catalog.
50
+ #
51
+ # merchants can be either a string, an integer, or an array of ids.
52
+ def activate_merchants(catalog_key, merchants)
53
+ results = self.class.post(catalog_update_url(catalog_key, merchants), :query => { :active => 1 })
54
+ Hashie::Mash.new(results['response'])
55
+ end
56
+
57
+ # Deactivates merchants for the given catalog.
58
+ #
59
+ # merchants can be either a string, an integer, or an array of ids.
60
+ def deactivate_merchants(catalog_key, merchants)
61
+ results = self.class.post(catalog_update_url(catalog_key, merchants), :query => { :active => 0 })
62
+ Hashie::Mash.new(results['response'])
63
+ end
64
+
65
+ private
66
+ def catalog_update_url(catalog_key, merchants)
67
+ "https://www.popshops.com/v2/#{@api_key}/catalogs/update.xml?catalog_key=#{catalog_key}&private_api_key=#{@private_api_key}&merchant_id=#{normalize_merchants(merchants)}"
68
+ end
69
+
70
+ def normalize_merchants(merchants)
71
+ merchants.is_a?(Array) ? merchants.join(',') : merchants
72
+ end
43
73
  end
metadata CHANGED
@@ -1,15 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: popshops
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Mueller
8
+ - Trey Bean
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
12
 
12
- date: 2010-01-17 00:00:00 -06:00
13
+ date: 2010-07-14 00:00:00 -05:00
13
14
  default_executable:
14
15
  dependencies:
15
16
  - !ruby/object:Gem::Dependency