From fffc000bd73b740318762747c07aa39adca1313a Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Wed, 21 Oct 2015 18:58:22 -0400 Subject: stub in proxy --- StoneIsland/platforms/ios/www/js/index.js | 34 +++++++++++++--------- .../ios/www/js/lib/products/CollectionView.js | 4 +-- StoneIsland/platforms/ios/www/js/sdk/_sdk.js | 9 ++++-- StoneIsland/platforms/ios/www/js/sdk/account.js | 9 +++--- StoneIsland/platforms/ios/www/js/sdk/address.js | 6 ++-- StoneIsland/platforms/ios/www/js/sdk/auth.js | 10 +++---- StoneIsland/platforms/ios/www/js/sdk/cart.js | 4 +-- StoneIsland/platforms/ios/www/js/sdk/product.js | 4 +-- 8 files changed, 45 insertions(+), 35 deletions(-) (limited to 'StoneIsland/platforms/ios/www/js') diff --git a/StoneIsland/platforms/ios/www/js/index.js b/StoneIsland/platforms/ios/www/js/index.js index 31e78c92..332e780d 100644 --- a/StoneIsland/platforms/ios/www/js/index.js +++ b/StoneIsland/platforms/ios/www/js/index.js @@ -1,7 +1,26 @@ var app = (function(){ var app = {} - app.init = function(){ + app.init = function(){ + app.bind() + app.build() + + sdk.init({ production: true }) + + if (window.cordova) { + document.addEventListener('deviceready', app.ready, false) + } + else { + app.ready() + } + } + + app.bind = function(){ + document.addEventListener('touchmove', function(e){ e.preventDefault() }) + FastClick.attach(document.body) + } + + app.build = function(){ app.blog = new BlogView () app.archive = new ArchiveView () app.hub = new HubView () @@ -21,17 +40,6 @@ var app = (function(){ app.collection = new CollectionView () app.selector = new Selector () - - app.bind() - } - - app.bind = function(){ - if (window.cordova) { - document.addEventListener('deviceready', app.ready, false) - } - else { - app.ready() - } } app.ready = function(){ @@ -39,8 +47,6 @@ var app = (function(){ // cordova.plugins.Keyboard.disableScroll(true) } - document.addEventListener('touchmove', function(e){ e.preventDefault() }) - app.view = null app.router = new SiteRouter () app.router.route() diff --git a/StoneIsland/platforms/ios/www/js/lib/products/CollectionView.js b/StoneIsland/platforms/ios/www/js/lib/products/CollectionView.js index 71d07723..987804fc 100644 --- a/StoneIsland/platforms/ios/www/js/lib/products/CollectionView.js +++ b/StoneIsland/platforms/ios/www/js/lib/products/CollectionView.js @@ -26,8 +26,8 @@ var CollectionView = View.extend({ fetch: function(){ this.$loader.show() - sdk.product.fetch_collection({ - gallery_id: 31483, // FOCUS ON CAMO + sdk.product.collection({ + gallery_id: 31617, success: this.populate.bind(this) }) }, diff --git a/StoneIsland/platforms/ios/www/js/sdk/_sdk.js b/StoneIsland/platforms/ios/www/js/sdk/_sdk.js index ce68da62..a7ecf6d3 100644 --- a/StoneIsland/platforms/ios/www/js/sdk/_sdk.js +++ b/StoneIsland/platforms/ios/www/js/sdk/_sdk.js @@ -1,9 +1,14 @@ var sdk = (function(){ var sdk = {} - // var endpoint = "https://secure.api.yoox.biz/" var endpoint = "https://sandbox.api.yoox.biz/" - + + sdk.init = function(opt){ + if (opt && opt.production) { + endpoint = "https://secure.api.yoox.biz/" + } + } + sdk.path = function(api, path){ return endpoint + api + "/STONEISLAND_US/" + path } diff --git a/StoneIsland/platforms/ios/www/js/sdk/account.js b/StoneIsland/platforms/ios/www/js/sdk/account.js index a1498e76..3dfe2cfe 100644 --- a/StoneIsland/platforms/ios/www/js/sdk/account.js +++ b/StoneIsland/platforms/ios/www/js/sdk/account.js @@ -14,11 +14,10 @@ sdk.account = (function(){ }, data: opt.data, success: function(data){ - console.log(data) user_id = data['UserAccount']['UserId'] access_token = data['UserAccount']['AccessToken'] - auth.set_user(user_id, access_token, name) + auth.set_user(user_id, access_token) opt.success(data) }, @@ -36,9 +35,9 @@ sdk.account = (function(){ }, data: opt.data, success: function(data){ - console.log(data) - auth.user_id = data['UserAccount']['UserId'] - auth.access_token = data['UserAccount']['AccessToken'] + // console.log(data) + // auth.user_id = data['UserFull']['UserId'] + // auth.access_token = data['UserFull']['AccessToken'] // why bother? // auth.set_user(user_id, access_token, name) diff --git a/StoneIsland/platforms/ios/www/js/sdk/address.js b/StoneIsland/platforms/ios/www/js/sdk/address.js index 16fc2dc4..144589d0 100644 --- a/StoneIsland/platforms/ios/www/js/sdk/address.js +++ b/StoneIsland/platforms/ios/www/js/sdk/address.js @@ -11,7 +11,7 @@ sdk.address = (function(){ }, data: opt.data, success: function(data){ - console.log(data) + // console.log(data) opt.success(data) }, error: opt.error, @@ -28,11 +28,13 @@ sdk.address = (function(){ }, data: opt.data, success: function(data){ - console.log(data) + // console.log(data) opt.success(data) }, error: opt.error, }) } + + return address })() \ No newline at end of file diff --git a/StoneIsland/platforms/ios/www/js/sdk/auth.js b/StoneIsland/platforms/ios/www/js/sdk/auth.js index 911da902..cea0054c 100644 --- a/StoneIsland/platforms/ios/www/js/sdk/auth.js +++ b/StoneIsland/platforms/ios/www/js/sdk/auth.js @@ -10,26 +10,24 @@ var auth = (function(){ var auth = {} - auth.appname = "{API-TEST}" - auth.apikey = "{API-KEY}" + auth.appname = is_iphone ? "native-iphone-stoneisland/1.0.0" : "native-android-stoneisland/1.0.0" + auth.apikey = "U2FsdGVkX18fThqg9bF0/ZgE9Jg948hn8O9EXli4B2729nAESCQaexv//M5+7+za" auth.device = "smartphone" auth.access_token = "" auth.user_id = -1 - auth.name = name // ios: integrate keychain api // android: cordova.file.externalRootDirectory api - auth.set_user = function(user_id, access_token, name){ + auth.set_user = function(user_id, access_token){ // persist user data auth.user_id = user_id auth.access_token = access_token - auth.name = name } auth.get_user = function(cb){ // fetch user data } return auth -})() \ No newline at end of file +})() diff --git a/StoneIsland/platforms/ios/www/js/sdk/cart.js b/StoneIsland/platforms/ios/www/js/sdk/cart.js index 3c16feae..9f9d81f1 100644 --- a/StoneIsland/platforms/ios/www/js/sdk/cart.js +++ b/StoneIsland/platforms/ios/www/js/sdk/cart.js @@ -13,7 +13,7 @@ sdk.cart = (function(){ "x-yoox-appname": auth.appname, "x-yoox-device": auth.device, }, - data: opt.data, + // data: opt.data, success: function(data){ console.log(data) cart.id = data["CartSession"]["CartId"] @@ -27,7 +27,7 @@ sdk.cart = (function(){ cart.set_user = function(opt){ $.ajax({ method: "PUT", - url: sdk.path("Cart.API/1.6", "carts.json"), + url: sdk.path("Cart.API/1.6", "user.json"), headers: { "x-yoox-appname": auth.appname, "x-yoox-cart-token": cart.token, diff --git a/StoneIsland/platforms/ios/www/js/sdk/product.js b/StoneIsland/platforms/ios/www/js/sdk/product.js index c904eb32..a2ba30a1 100644 --- a/StoneIsland/platforms/ios/www/js/sdk/product.js +++ b/StoneIsland/platforms/ios/www/js/sdk/product.js @@ -1,7 +1,7 @@ sdk.product = (function(){ var product = {} - product.fetch_collection = function(opt){ + product.collection = function(opt){ $.ajax({ method: "GET", url: sdk.path("Search.API/1.2", "search.json"), @@ -15,7 +15,7 @@ sdk.product = (function(){ product.item = function(opt){ $.ajax({ method: "GET", - url: sdk.path("Item.API/1.0", "item/" + data.code + ".json"), + url: sdk.path("Item.API/1.0", "item/" + opt.code + ".json"), success: opt.success, error: opt.error, }) -- cgit v1.2.3-70-g09d2