summaryrefslogtreecommitdiff
path: root/StoneIsland/www/js/sdk/product.js
blob: 55f1940a0a4875181c54d6184346f752ddfd4b20 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
sdk.product = (function(){
  var product = {}
  
  var default_gallery = 31617

  product.collection = function(opt){
    return $.ajax({
      method: "GET",
      url: sdk.path("Search.API/1.2", "search.json"),
      data: { format: "full", gallery: opt.gallery_id || default_gallery, productsPerPage: 100 },
      success: opt.success,
      error: opt.error,
    })
  }
  
  // https://gist.github.com/fanfare/2d25d1b36944188948ff
  product.item = function(opt){
    return $.ajax({
      method: "GET",
      url: sdk.path("Item.API/1.0", "item/" + opt.code + ".json"),
      success: opt.success,
      error: opt.error,
    })
  }
  
  product.search = function(opt){
    return $.ajax({
      method: "GET",
      url: sdk.path("Search.API/1.2", "search.json"),
      data: { format: "full", gallery: opt.gallery_id || default_gallery, textSearch: opt.query, productsPerPage: 100 },
      success: opt.success,
      error: opt.error,
    })
  }
  
  return product
})()