Class: Popshops

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/popshops.rb

Instance Method Summary collapse

Constructor Details

#initialize(api_key, private_api_key = nil) ⇒ Popshops

Returns a new instance of Popshops.



9
10
11
12
# File 'lib/popshops.rb', line 9

def initialize(api_key, private_api_key = nil)
  @api_key = api_key
  @private_api_key = private_api_key
end

Instance Method Details

#activate_merchants(catalog_key, merchants) ⇒ Object

Activates merchants for the given catalog.

merchants can be either a string, an integer, or an array of ids.



52
53
54
55
# File 'lib/popshops.rb', line 52

def activate_merchants(catalog_key, merchants)
  results = self.class.post(catalog_update_url(catalog_key, merchants), :query => { :active => 1 })
  Hashie::Mash.new(results['response'])
end

#catalogsObject



44
45
46
47
# File 'lib/popshops.rb', line 44

def catalogs
  results = self.class.get("https://www.popshops.com/v2/#{@api_key}/catalogs/list.xml?private_api_key=#{@private_api_key}")
  Hashie::Mash.new(results['results']['catalogs'])
end

#deactivate_merchants(catalog_key, merchants) ⇒ Object

Deactivates merchants for the given catalog.

merchants can be either a string, an integer, or an array of ids.



60
61
62
63
# File 'lib/popshops.rb', line 60

def deactivate_merchants(catalog_key, merchants)
  results = self.class.post(catalog_update_url(catalog_key, merchants), :query => { :active => 0 })
  Hashie::Mash.new(results['response'])
end

#deal_search(options = {}) ⇒ Object



34
35
36
37
# File 'lib/popshops.rb', line 34

def deal_search(options={})
  results = self.class.get("/#{@api_key}/deals.xml", options)
  Hashie::Mash.new(results['search_results'])
end

#deal_typesObject



39
40
41
42
# File 'lib/popshops.rb', line 39

def deal_types
  results = self.class.get("/#{@api_key}/deal_types.xml")
  Hashie::Mash.new(results['deal_types'])
end

#merchant_search(options = {}) ⇒ Object



19
20
21
22
# File 'lib/popshops.rb', line 19

def merchant_search(options={})
  results = self.class.get("/#{@api_key}/merchants.xml", options)
  Hashie::Mash.new(results['merchants'])
end

#merchant_typesObject



24
25
26
27
# File 'lib/popshops.rb', line 24

def merchant_types
  results = self.class.get("/#{@api_key}/merchant_types.xml")
  Hashie::Mash.new(results['merchant_types'])
end

#networksObject



29
30
31
32
# File 'lib/popshops.rb', line 29

def networks
  results = self.class.get("/#{@api_key}/networks.xml")
  Hashie::Mash.new(results['networks'])
end

#product_search(options = {}) ⇒ Object



14
15
16
17
# File 'lib/popshops.rb', line 14

def product_search(options={})
  results = self.class.get("/#{@api_key}/products.xml", options)
  Hashie::Mash.new(results['search_results'])
end