Skip to content

ivanovmd/Slyce-Web-SDK

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Getting started

ui version

Loading

Standart method

<script type="text/javascript" src="https://cdnw.slycecloud.com/websdk/1.2.0/slyce.ui.sdk.js"></script>
<link rel="stylesheet" href="https://cdnw.slycecloud.com/websdk/1.2.0/slyce.sdk.css">
 var sdk = new window.slyceSDK();

AMD, CommonJS2, etc...

For using the Web SDK as AMD or CommonJS2 module, the SDK has to be downloaded and used as a normal module, add it to the local project and use it as normal module.

js - https://cdnw.slycecloud.com/websdk/1.2.0/slyce.ui.sdk.js

css - https://cdnw.slycecloud.com/websdk/1.2.0/slyce.sdk.css

Example code -

 var slyceSDK = require('./slycesdk/slyce.sdk');
 var sdk = new slyceSDK();

Change enviroment

For debug purposes

    var sdk = new slyceSDK('staging');

Envs:

  1. production - default value, all production servers
  2. staging - stagingenvironment
  3. dev - development environment

methods

init(clientId)

call to server uid endpoint and init providers. resolving the list of services allowed.

Params

  1. clientId - unified id

Result

Method return native promise object

  • on resolve - object with result information like this { recognition : false, similar: false }
  • on reject - Error object with text message

Example

var id = 'superidididid';
sdk.init(id).then(function(data) {
    console.log(data);  // { recognition : true, similar: true }
}, function(error) {
    console.log(error); // Error('Incorrect client id')
});

recognitionByUrl(url, callbackProgress, isUI = true)

call to exact match as well as 3D search (sent simultaneously)

Params

  1. url - image url
  2. callbackProgress - function which called when status changed

Result

Method return native promise object

  • on resolve - return array with products list from fastest provider
  • on reject - Error object with text message

Example

var url = 'http://imageurl.com/image.jpg';
sdk.recognitionByUrl(url,  function(data) {
    console.log(data); // progress event, {"code":8000,"message":"Processing started","progress":20,"token":"d1fL0USvp_ZotmfhmH4Vcw"}
}).then(function(data) {
    console.log(data); // success, product list, [{"itemId":"0024984171","productDescription":"Popover fit, Drawstring hood, Long sleeves, Front kangaroo pocket","productImageURL":"https://pics.ae.com/is/image/aeo/0195_9585_604_f?$pdp-main_small$","productImages":["https://pics.ae.com/is/image/aeo/0195_9585_604_f?$pdp-main_small$"],"productName":"AEO Men's Baja Hooded Sweater (Deep Burgundy)","productPrice":"69.95","productURL":""}]
}, function(data) {
    console.log(data); // Error('Image not found')
});

recognitionByFile(file, callbackProgress, isUI = true)

Rotate, resize and upload image to amazon s3 and then run recognitionByUrl method

Params

  1. file - File, received by
  2. canvas - canvas DOM element. If you do not need rotate and resize use null
  3. callbackProgress - function which called when status changed

Result

Same with recognitionByUrl

Example

$('input[type="file"]').on('change', function(e) {
    sdk.recognitionByFile(e.target.files[0], document.getElementById('canvas'),  function(data) { }).then(function(data) {}, function(data) {});
})

similar(keyword, isUI = true)

Call to Find Similar service

Params

  1. keyword - file url or product pid

Result

Native promise object

  • on resolve - return array with products list from the Find Similar
  • on reject - Error object with text message

Example

sdk.similar(url).then(function(data) {
   console.log(data); // [{},{}]
}, function(data) {
   console.log(data); // Error('Products not found')
});

getSimilar(pid, url, isUI = true)

Call to Find Similar service

Params

  1. pid - product pid
  2. url - file url

Result

Native promise object

  • on resolve - return array with products list from Find Similar
  • on reject - Error object with text message

Example

sdk.getSimilar(pid, url).then(function(data) {
   console.log(data); // [{},{}]
}, function(data) {
   console.log(data); // Error('Products not found')
});

progressClose()

Close ui view

track(eventName, params)

Call to statistic service

Params

  1. eventName - name of event
  2. params - object of properties

Result

Native promise object

  • on resolve - return array with products list from Find Similar service
  • on reject - Error object with text message

Example

sdk.track('modalOpen',{ product: 4832 }).then(function(data) {
   console.log('success');
}, function(data) {
   console.log('error');
});

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published