summaryrefslogtreecommitdiff
path: root/StoneIsland/platforms/ios/www/js/sdk/product.js
blob: 07c0219a5afa918677bd85eb18b5e054dec6d71c (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
sdk.product = (function(){
  var product = {}
  
  var default_gallery = 31617
  var default_department = "NkXStnsl"

  product.all = function(opt){
    return sdk.ajax({
      method: "GET",
      url: sdk.path("Search.API/1.3", "search.json", "US"),
      data: { format: "full", productsPerPage: 100 },
      success: opt.success,
      error: opt.error,
    })
  }

  product.collection = function(opt){
    return sdk.ajax({
      method: "GET",
      url: sdk.path("Search.API/1.3", "search.json", "US"),
      data: { format: "full", department: opt.department_id || default_department, productsPerPage: 100 },
      success: opt.success,
      error: opt.error,
    })
  }

  product.department_codes = function(opt){
    return sdk.ajax({
      method: "GET",
      url: sdk.path("Search.API/1.3", "search/results.json", "US"),
      data: { format: "full", department: opt.department_id || default_department, page: 1 },
      success: opt.success,
      error: opt.error,
    })
  }
  
  product.collection_by_gallery = function(opt){
    return sdk.ajax({
      method: "GET",
      url: sdk.path("Search.API/1.2", "search.json", "US"),
      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 sdk.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 sdk.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
})()