automizy-js-api
Version:
JavaScript API library for Automizy Marketing Automation software
3 lines • 42.2 kB
JavaScript
(function(a){var b={};(function(){b=new function(){var c=this;c.d={version:"0.1.0",login:false,hasOpenLoginForm:true,lastAjaxData:{},ad:{error:function(c,d,e){if(3===arguments.length)if(a.inArray(c.status,[404,405])>=0)alert(c.status+" ("+e+")");else if(a.inArray(c.status,[403])>=0)b.d.lastAjaxData=this,b.openLoginDialog();else if(a.inArray(c.status,[400,401])>=0)alert(c.status+" ("+e+")"),b.openLoginDialog();else console.error(c.status,d,e);else console.log("<----------- Automizy Api Error"),console.log(c),console.log(d),console.log(e),console.log("Automizy Api Error ----------->"),b.openLoginDialog()}}};var d="https://api.automizy.com";var e="https://app.automizy.com/php/login.php";var f="https://app.automizy.com/php/refresh.php";c.u={base:d,loginPhp:e,refreshPhp:f,oauth:d+"/oauth",segments:d+"/segments",campaigns:d+"/campaigns",splitTests:d+"/split-tests",newsletters:d+"/newsletters",contacts:d+"/contacts",customFields:d+"/custom-fields",users:d+"/users",jobs:d+"/jobs",webhooks:d+"/webhooks",images:d+"/images",templates:d+"/templates",forms:d+"/forms",automations:d+"/automations",account:d+"/account",contactImports:d+"/contact-imports",tags:d+"/tags",clients:d+"/clients",emailPreview:d+"/email-preview"},c.m=[]}})(),function(){b.cookie=function(){function a(){var a=0;var b={};for(;a<arguments.length;a++){var c=arguments[a];for(var d in c)b[d]=c[d]}return b}function b(c){function d(b,e,f){var g;if(arguments.length>1){if(f=a({path:"/"},d.defaults,f),"number"===typeof f.expires){var h=new Date;h.setMilliseconds(h.getMilliseconds()+864e5*f.expires),f.expires=h}try{if(g=JSON.stringify(e),/^[\{\[]/.test(g))e=g}catch(i){}return e=encodeURIComponent(String(e)),e=e.replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),b=encodeURIComponent(String(b)),b=b.replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent),b=b.replace(/[\(\)]/g,escape),document.cookie=[b,"=",e,f.expires&&"; expires="+f.expires.toUTCString(),f.path&&"; path="+f.path,f.domain&&"; domain="+f.domain,f.secure&&"; secure"].join("")}if(!b)g={};var j=document.cookie?document.cookie.split("; "):[];var k=/(%[0-9A-Z]{2})+/g;var l=0;for(;l<j.length;l++){var m=j[l].split("=");var n=m[0].replace(k,decodeURIComponent);var o=m.slice(1).join("=");if('"'===o.charAt(0))o=o.slice(1,-1);if(o=c&&c(o,n)||o.replace(k,decodeURIComponent),this.json)try{o=JSON.parse(o)}catch(i){}if(b===n){g=o;break}if(!b)g[n]=o}return g}return d.get=d.set=d,d.getJSON=function(){return d.apply({json:true},[].slice.call(arguments))},d.defaults={},d.remove=function(b,c){d(b,"",a(c,{expires:-1}))},d.withConverter=b,d}return b()}()}(),function(){b.date={},b.date.now=function(){return(new Date).getTime()},b.date.timestamp=function(){return Math.floor(b.date.now()/1e3)}}(),function(){var c=function(){var a=this;a.d={access_token:b.cookie.get("AutomizyApiAccessToken")||false,refresh_token:b.cookie.get("AutomizyApiRefreshToken")||false,client_id:b.cookie.get("AutomizyApiClientId")||false,username:b.cookie.get("AutomizyApiUsername")||false,expires:parseInt(b.cookie.get("AutomizyApiExpires"))||0,scope:b.cookie.get("AutomizyApiScope")||null,token_type:b.cookie.get("AutomizyApiTokenType")||"Bearer",error:function(){},success:function(){},loginError:function(){},loginAjaxError:function(){},loginAjaxSuccess:function(){},refreshAjaxError:function(){},refreshAjaxSuccess:function(){},refreshLoopTimeout:false}};var d=c.prototype;d.refreshLoop=function(){var a=this;if(b.date.timestamp()>parseInt(b.cookie.get("AutomizyApiExpires"))-120)a.refresh();clearTimeout(a.d.refreshLoopTimeout),a.d.refreshLoopTimeout=setTimeout(function(){a.refreshLoop()},3e4)},d.refreshLoopStop=function(){var a=this;clearTimeout(a.d.refreshLoopTimeout)},d.refreshLoopStart=function(){var a=this;a.refreshLoop()},d.refreshLoopRestart=function(){var a=this;a.refreshLoopStop(),a.refreshLoopStart()},d.loggedIn=function(a){var c=this;if("undefined"!==typeof a)return c.d.loggedIn=b.parseBoolean(a),c;return c.d.loggedIn},d.get=function(){var a=this;if(false!==b.cookie.get("AutomizyApiAccessToken"))a.loggedIn(true),a.refreshLoopRestart();else a.refreshLoopStop(),a.loggedIn(false);return b.cookie.get("AutomizyApiAccessToken")},d.set=function(a){var c=this;if("undefined"!==typeof a.access_token)c.d.access_token=a.access_token,b.cookie.set("AutomizyApiAccessToken",a.access_token,c.cookieAttributes());if("undefined"!==typeof a.expires_in)c.d.expires=b.date.timestamp()+parseInt(a.expires_in)-10,b.cookie.set("AutomizyApiExpires",c.d.expires,c.cookieAttributes());if("undefined"!==typeof a.refresh_token)c.d.refresh_token=a.refresh_token,b.cookie.set("AutomizyApiRefreshToken",a.refresh_token,c.cookieAttributes());if("undefined"!==typeof a.scope)if(c.d.scope=a.scope,false!==c.d.scope)b.cookie.set("AutomizyApiScope",a.scope,c.cookieAttributes());if("undefined"!==typeof a.token_type)c.d.token_type=a.token_type,b.cookie.set("AutomizyApiTokenType",a.token_type,c.cookieAttributes());if("undefined"!==typeof a.client_id)c.d.client_id=a.client_id,b.cookie.set("AutomizyApiClientId",a.client_id,c.cookieAttributes());if("undefined"!==typeof a.username)c.d.username=a.username,b.cookie.set("AutomizyApiUsername",a.username,c.cookieAttributes());return true},d.refresh=function(){var c=this;return a.ajax({type:"POST",url:b.u.refreshPhp,data:{refresh_token:b.cookie.get("AutomizyApiRefreshToken"),username:b.cookie.get("AutomizyApiUsername")},success:function(a,b,d){c.set(a),c.loggedIn(true),c.refreshAjaxSuccess.apply(c,[a,b,d])},error:function(a,b,d){c.refreshAjaxError.apply(c,[a,b,d])}})},d.error=function(a){var b=this;if("function"===typeof a)return b.d.error=a,b;return b.d.error},d.success=function(a){var b=this;if("function"===typeof a)return b.d.success=a,b;return b.d.success},d.loginError=function(a){var b=this;if("function"===typeof a)return b.d.loginError=a,b;return b.d.loginError},d.loginAjaxError=function(a){var b=this;if("function"===typeof a)return b.d.loginAjaxError=a,b;return b.d.loginAjaxError},d.loginAjaxSuccess=function(a){var b=this;if("function"===typeof a)return b.d.loginAjaxSuccess=a,b;return b.d.loginAjaxSuccess},d.refreshAjaxError=function(a){var b=this;if("function"===typeof a)return b.d.refreshAjaxError=a,b;return b.d.refreshAjaxError},d.refreshAjaxSuccess=function(a){var b=this;if("function"===typeof a)return b.d.refreshAjaxSuccess=a,b;return b.d.refreshAjaxSuccess},d.passwordLogin=function(c){var d=this;var c=c||{};if(c.username=c.username||false,c.password=c.password||false,false===c.username||false===c.password)return d.loginError.apply(d,["The username and password must be provide!"]),false;return b.cookie.set("AutomizyApiUsername",c.username,d.cookieAttributes()),a.ajax({type:"POST",url:b.u.loginPhp,data:{username:c.username,password:c.password},success:function(a,b,c){d.set(a),d.loggedIn(true),d.refreshLoopRestart(),d.d.loginAjaxSuccess.apply(d,[a,b,c])},error:function(a,b,c){d.d.loginAjaxError.apply(d,[a,b,c])}})},d.credentialsLogin=function(c){var d=this;var c=c||{};if(c.clientId=c.clientId||false,c.clientSecret=c.clientSecret||false,false===c.clientId||false===c.clientSecret)return d.loginError.apply(d,["The clientId and clientSecret must be provide!"]),false;return a.ajax({type:"POST",url:b.u.oauth,data:{grant_type:"client_credentials",client_id:c.clientId,client_secret:c.clientSecret},success:function(a,b,c){d.set(a),d.loggedIn(true),d.refreshLoopRestart(),d.d.loginAjaxSuccess.apply(d,[a,b,c])},error:function(a,b,c){d.d.loginAjaxError.apply(d,[a,b,c])}})},d.login=function(a){var b=this;var a=a||{};if("undefined"!==typeof a.username&&"undefined"!==typeof a.password)return b.passwordLogin(a);else if("undefined"!==typeof a.clientId&&"undefined"!==typeof a.clientSecret)return b.credentialsLogin(a);else return b.loginError.apply(b,["Missing parameters!"]),false},d.cookieAttributes=function(){var a={};if(location.href.indexOf(".protopmail.com")>=0)a.domain=".protopmail.com";else if(location.href.indexOf(".automizy.com")>=0)a.domain=".automizy.com";return a},d.logout=function(){var a=this;a.loggedIn(false),a.refreshLoopStop(),a.d.access_token=false,a.d.refresh_token=false,a.d.username=false,a.d.client_id=false,a.d.expires=0,b.cookie.remove("AutomizyApiAccessToken",a.cookieAttributes()),b.cookie.remove("AutomizyApiRefreshToken",a.cookieAttributes()),b.cookie.remove("AutomizyApiClientId",a.cookieAttributes()),b.cookie.remove("AutomizyApiExpires",a.cookieAttributes()),b.cookie.remove("AutomizyApiUsername",a.cookieAttributes())},b.m.Token=c,b.d.token=new c,b.token=function(){return b.d.token}}(),function(){b.initBasicFunctions=function(c,d){var c=c||false;if(false===c)return false;var d=d||false;if(false===d)return false;var e=d.toLowerCase();var f=d.charAt(0).toLowerCase()+d.slice(1);var g=c.prototype;g.init=g.init||function(){var a=this;if("undefined"===typeof a.d.urlSuffix)a.d.urlSuffix="";if("undefined"===typeof a.d.itemsDir)a.d.itemsDir=false;if("undefined"===typeof a.d.fields)a.d.fields=false;if("undefined"===typeof a.d.format)a.d.format=false;if("undefined"===typeof a.d.limit)a.d.limit=false;if("undefined"===typeof a.d.page)a.d.page=false;if("undefined"===typeof a.d.order_by)a.d.order_by=false;if("undefined"===typeof a.d.order_dir)a.d.order_dir=false;if("undefined"===typeof a.d.links)a.d.links=false;if("undefined"===typeof a.d.set)a.d.set={}},g.initParameter=g.initParameter||function(a){var b=this;if("undefined"!==typeof a.urlSuffix)b.urlSuffix(a.urlSuffix);if("undefined"!==typeof a.itemsDir)b.itemsDir(a.itemsDir);if("undefined"!==typeof a.format)b.format(a.format);if("undefined"!==typeof a.fields)b.fields(a.fields);if("undefined"!==typeof a.limit)b.limit(a.limit);if("undefined"!==typeof a.page)b.page(a.page);if("undefined"!==typeof a.orderBy||"undefined"!==typeof a.order_by)b.orderBy(a.orderBy||a.order_by);if("undefined"!==typeof a.orderDir||"undefined"!==typeof a.order_dir)b.orderDir(a.orderDir||a.order_dir);if("undefined"!==typeof a.links)b.links(a.links);if("undefined"!==typeof a.url)b.url(a.url)},g.setOptions=g.setOptions||function(a){if("undefined"!==typeof a.fields)t.d.option.fields=a.fields;if("undefined"!==typeof a.format)t.d.option.format=a.format;if("undefined"!==typeof a.limit)t.d.option.limit=a.limit;if("undefined"!==typeof a.page)t.d.option.page=a.page;if("undefined"!==typeof a.where)t.d.option.where=a.where;if("undefined"!==typeof a.order_by)t.d.option.order_by=a.order_by;if("undefined"!==typeof a.order_dir)t.d.option.order_dir=a.order_dir;if("undefined"!==typeof a.order)t.d.option.order=a.order;if("undefined"!==typeof a.links)t.d.option.links=a.links},g.getDataFromParameter=g.getDataFromParameter||function(a){var b={};if(false!==a.fields)b.fields=a.fields;if(false!==a.format)b.format=a.format;if(false!==a.limit)b.limit=a.limit;if(false!==a.page)b.page=a.page;if(false!==a.where)b.where=a.where;if(false!==a.order_dir)b.order_dir=a.order_dir;if(false!==a.order_by)b.order_by=a.order_by;if(false!==a.order)b.order=a.order;if(false!==a.links)b.links=a.links;return b},g.get=g.get||function(c,d,e){var f=this;var d=true;if("undefined"!==typeof e)e=b.parseBoolean(e);else var e=true;if("undefined"!==typeof d)d=b.parseBoolean(d);if(d&&("object"===typeof c||"array"===typeof c))f.setOptions(c);var g={};if("object"===typeof c||"array"===typeof c)g=f.getDataFromParameter(c);else for(var h in f.d.option)if(false!==f.d.option[h])g[h]=f.d.option[h];if("undefined"===typeof g.order&&"undefined"!==typeof g.order_by)g.order=g.order_by+":"+g.order_dir||"asc";var i=a.ajax({url:f.d.url+f.d.urlSuffix,type:"GET",dataType:"json",async:e,data:g,headers:{Authorization:"Bearer "+b.token().get()},error:b.token().error()});if(!e)return i.responseJSON;return i},g.getSync=g.getSync||function(a,b){var a=a||false;var b=b||false;return this.get.apply(this,[a,b,false])},g["export"]=g["export"]||function(c,d,e){var f=this;var d=true;if("undefined"!==typeof e)e=b.parseBoolean(e);else var e=true;if("undefined"!==typeof d)d=b.parseBoolean(d);if(d&&("object"===typeof c||"array"===typeof c))f.setOptions(c);var g={};if("object"===typeof c||"array"===typeof c)g=f.getDataFromParameter(c);else for(var h in f.d.option)if(false!==f.d.option[h])g[h]=f.d.option[h];if("undefined"===typeof g.order&&"undefined"!==typeof g.order_by)g.order=g.order_by+":"+g.order_dir||"asc";g.showContent=false;var i=a.ajax({xhr:function(){var a=new window.XMLHttpRequest;return a.addEventListener("progress",function(a){if(a.lengthComputable){var b=a.loaded/a.total;console.log(parseInt(100*b))}},false),a},url:f.d.url+f.d.urlSuffix,type:"GET",async:e,data:g,headers:{Authorization:"Bearer "+b.token().get(),Accept:"text/csv"},error:b.token().error()});if(!e)return i.responseJSON;return i},g.insert=g.insert||function(c,d){var e=this;if("undefined"!==typeof d)d=b.parseBoolean(d);else var d=true;var f=c;var g=a.ajax({url:e.d.url+e.d.urlSuffix,type:"POST",dataType:"json",async:d,data:f,headers:{Authorization:"Bearer "+b.token().get()},error:b.token().error()});if(!d)return g.responseJSON;return g},g.insertSync=g.insertSync||function(a){var a=a||false;return this.insert.apply(this,[a,false])},g.update=g.update||function(c,d,e){var f=this;if("undefined"!==typeof e)e=b.parseBoolean(e);else var e=true;var g=c;var d=d||c.id||0;delete g.id;var h=a.ajax({url:f.d.url+"/"+d+f.d.urlSuffix,type:"PATCH",dataType:"json",async:e,data:g,headers:{Authorization:"Bearer "+b.token().get()},error:b.token().error()});if(!e)return h.responseJSON;return h},g.updateSync=g.updateSync||function(a,b){var a=a||false;var b=b||false;return this.update.apply(this,[a,b,false])},g["delete"]=g["delete"]||function(c,d){var e=this;if("undefined"!==typeof d)d=b.parseBoolean(d);else var d=true;var f=a.ajax({url:e.d.url+"/"+c+e.d.urlSuffix,type:"DELETE",dataType:"json",async:d,headers:{Authorization:"Bearer "+b.token().get()},error:b.token().error()});if(!d)return f.responseJSON;return f},g.deleteSync=g.deleteSync||function(a){var a=a||false;return this["delete"].apply(this,[a,false])},g.getAll=g.getAll||function(){var c=this;return a.ajax({url:c.d.url+c.d.urlSuffix,type:"GET",dataType:"json",headers:{Authorization:"Bearer "+b.token().get()},error:b.token().error()})},g.getRecordById=g.getRecordById||function(c){var d=this;var e={};for(var f in d.d.option)if(false!==d.d.option[f])e[f]=d.d.option[f];if("undefined"===typeof e.order&&"undefined"!==typeof e.order_by)e.order=e.order_by+":"+e.order_dir||"asc";return a.ajax({url:d.d.url+"/"+c+d.d.urlSuffix,type:"GET",dataType:"json",data:e,headers:{Authorization:"Bearer "+b.token().get()},error:b.token().error()})},g.getFieldById=g.getFieldById||function(c,d){var e=this;var f=d.split(".");return a.ajax({url:e.d.url+"/"+c+e.d.urlSuffix,type:"GET",dataType:"json",data:{fields:f[0],links:""},headers:{Authorization:"Bearer "+b.token().get()},converters:{"text json":function(b){var c=a.parseJSON(b)[f[0]];for(var d=1;d<f.length;d++)c=c[f[d]];return c}},error:b.token().error()})},g.getAllIdNamePair=g.getAllIdNamePair||function(c){var d=this;var e=c.split(".");return a.ajax({url:d.d.url+d.d.urlSuffix,type:"GET",dataType:"json",data:{fields:"id,"+e[0],links:""},headers:{Authorization:"Bearer "+b.token().get()},converters:{"text json":function(b){var c=a.parseJSON(b)._embedded;c=c[Object.keys(c)[0]];var d=[];for(var f in c){var g=c[f][e[0]];for(var h=1;h<e.length;h++)g=g[e[h]];d.push([c[f].id,g])}return d}},error:b.token().error()})},g.urlSuffix=g.urlSuffix||function(a){var b=this;if("undefined"!==typeof a)return b.d.urlSuffix=a,b;return b.d.urlSuffix},g.itemsDir=g.itemsDir||function(a){var b=this;if("undefined"!==typeof a)return b.d.itemsDir=a,b;return b.d.itemsDir},g.fields=g.fields||function(a){var b=this;if("undefined"!==typeof a){if(false!==a&&a.length>0)b.d.option.fields=a;return b}return b.d.option.fields},g.limit=g.limit||function(a){var b=this;if("undefined"!==typeof a)return b.d.option.limit=a,b;return b.d.option.limit},g.format=g.format||function(a){var b=this;if("undefined"!==typeof a)return b.d.option.format=a,b;return b.d.option.format},g.page=g.page||function(a){var b=this;if("undefined"!==typeof a)return b.d.option.page=a,b;return b.d.option.page},g.where=g.where||function(a){var b=this;if("undefined"!==typeof a)return b.d.option.where=a,b;return b.d.option.where},g.orderBy=g.order_by=g.orderBy||g.order_by||function(a){var b=this;if("undefined"!==typeof a){if(false===a)return b;return b.d.option.order_by=a,b}return b.d.option.order_by},g.orderDir=g.order_dir=g.orderDir||g.order_dir||function(a){var b=this;if("undefined"!==typeof a){if(false===a)return b;return b.d.option.order_dir=a,b}return b.d.option.order_dir},g.order=g.order||function(a){var b=this;if("undefined"!==typeof a){if(false===a)return b;return b.d.option.order=a,b}return b.d.option.order},g.links=g.links||function(a){var b=this;if("undefined"!==typeof a)return b.d.option.links=a,b;return b.d.option.links},g.set=g.values=g.set||g.values||function(a,b){var c=this;if("string"===typeof a&&"undefined"!==typeof b)return c.d.option.set[a]=b,c;if("object"===typeof a||"array"===typeof a){for(var d in a)c.d.option.set[d]=a[d];return c}return c.d.option.set},b.m[d]=c,b[f]=function(a){var b=new c(a);return b}}}(),function(){var c=function(a){var c=this;if(c.d={a:3,option:{},url:b.u.segments},c.init(),"undefined"!==typeof a)c.initParameter(a)};var d=c.prototype;d.calculateByArray=function(c){var d=this;return a.ajax({url:d.d.url+"/calculate"+d.d.urlSuffix,type:"GET",data:c,dataType:"json",headers:{Authorization:"Bearer "+b.token().get()},error:b.token().error()})},d.calculateById=function(c){var d=this;return a.ajax({url:d.d.url+"/"+c+"/calculate"+d.d.urlSuffix,type:"GET",data:{waitForResponse:true,saveAfterFinish:false},dataType:"json",headers:{Authorization:"Bearer "+b.token().get()},error:b.token().error()})},d.calculateAndSave=function(c){var d=this;return a.ajax({url:d.d.url+"/"+c+"/calculate"+d.d.urlSuffix,type:"GET",data:{waitForResponse:true,saveAfterFinish:true},dataType:"json",headers:{Authorization:"Bearer "+b.token().get()},error:b.token().error()})},b.initBasicFunctions(c,"Segments")}(),function(){var c=function(a){var c=this;if(c.d={a:3,option:{},url:b.u.campaigns},c.init(),"undefined"!==typeof a)c.initParameter(a)};var d=c.prototype;d.getOpenStatById=function(c,d,e){var f=this;var g={format:"total"};if("undefined"!==typeof d&&false!==d)g.from=d;if("undefined"!==typeof e&&false!==e)g.to=e;return a.ajax({url:f.d.url+"/"+c+"/opens"+f.d.urlSuffix,type:"GET",dataType:"json",data:g,headers:{Authorization:"Bearer "+b.token().get()},error:b.token().error()})},d.getClickStatById=function(c,d,e){var f=this;var g={format:"total"};if("undefined"!==typeof d&&false!==d)g.from=d;if("undefined"!==typeof e&&false!==e)g.to=e;return a.ajax({url:f.d.url+"/"+c+"/clicks"+f.d.urlSuffix,type:"GET",dataType:"json",data:g,headers:{Authorization:"Bearer "+b.token().get()},error:b.token().error()})},d.getShareStatById=function(c,d,e){var f=this;var g={format:"total"};if("undefined"!==typeof d&&false!==d)g.from=d;if("undefined"!==typeof e&&false!==e)g.to=e;return a.ajax({url:f.d.url+"/"+c+"/shares"+f.d.urlSuffix,type:"GET",dataType:"json",data:g,headers:{Authorization:"Bearer "+b.token().get()},error:b.token().error()})},d.getUnsubscribeStatById=function(c,d,e){var f=this;var g={format:"total"};if("undefined"!==typeof d&&false!==d)g.from=d;if("undefined"!==typeof e&&false!==e)g.to=e;return a.ajax({url:f.d.url+"/"+c+"/unsubscribes"+f.d.urlSuffix,type:"GET",dataType:"json",data:g,headers:{Authorization:"Bearer "+b.token().get()},error:b.token().error()})},d.getBounceStatById=function(c,d,e){var f=this;var g={format:"total"};if("undefined"!==typeof d&&false!==d)g.from=d;if("undefined"!==typeof e&&false!==e)g.to=e;return a.ajax({url:f.d.url+"/"+c+"/bounces"+f.d.urlSuffix,type:"GET",dataType:"json",data:g,headers:{Authorization:"Bearer "+b.token().get()},error:b.token().error()})},d.getGeoStatById=function(c,d,e){var f=this;var g={format:"raw"};if("undefined"!==typeof d&&false!==d)g.from=d;if("undefined"!==typeof e&&false!==e)g.to=e;return a.ajax({url:f.d.url+"/"+c+"/geo-locations"+f.d.urlSuffix,type:"GET",dataType:"json",data:g,headers:{Authorization:"Bearer "+b.token().get()},error:b.token().error()})},d.getOpenTimeLineById=function(c,d,e,f){var g=this;var h={format:"timeline"};if("undefined"!==typeof d&&false!==d)h.from=d;if("undefined"!==typeof e&&false!==e)h.to=e;if("undefined"!==typeof f&&false!==f)h.step=f;return a.ajax({url:g.d.url+"/"+c+"/opens"+g.d.urlSuffix,type:"GET",dataType:"json",data:h,headers:{Authorization:"Bearer "+b.token().get()},error:b.token().error()})},d.getClickTimeLineById=function(c,d,e,f){var g=this;var h={format:"timeline"};if("undefined"!==typeof d&&false!==d)h.from=d;if("undefined"!==typeof e&&false!==e)h.to=e;if("undefined"!==typeof f&&false!==f)h.step=f;return a.ajax({url:g.d.url+"/"+c+"/clicks"+g.d.urlSuffix,type:"GET",dataType:"json",data:h,headers:{Authorization:"Bearer "+b.token().get()},error:b.token().error()})},d.getOpenDevicePieById=function(c,d,e){var f=this;var g={format:"aggregate",groupBy:"device"};if("undefined"!==typeof d&&false!==d)g.from=d;if("undefined"!==typeof e&&false!==e)g.to=e;return a.ajax({url:f.d.url+"/"+c+"/opens"+f.d.urlSuffix,type:"GET",dataType:"json",data:g,headers:{Authorization:"Bearer "+b.token().get()},error:b.token().error()})},d.getClickDevicePieById=function(c,d,e){var f=this;var g={format:"aggregate",groupBy:"device"};if("undefined"!==typeof d&&false!==d)g.from=d;if("undefined"!==typeof e&&false!==e)g.to=e;return a.ajax({url:f.d.url+"/"+c+"/clicks"+f.d.urlSuffix,type:"GET",dataType:"json",data:g,headers:{Authorization:"Bearer "+b.token().get()},error:b.token().error()})},d.getOpenDeviceTimeLineById=function(c,d,e,f){var g=this;var h={format:"timeline",groupBy:"device"};if("undefined"!==typeof d&&false!==d)h.from=d;if("undefined"!==typeof e&&false!==e)h.to=e;return a.ajax({url:g.d.url+"/"+c+"/opens"+g.d.urlSuffix,type:"GET",dataType:"json",data:h,headers:{Authorization:"Bearer "+b.token().get()},error:b.token().error()})},d.getClickDeviceTimeLineById=function(c,d,e,f){var g=this;var h={format:"timeline",groupBy:"device"};if("undefined"!==typeof d&&false!==d)h.from=d;if("undefined"!==typeof e&&false!==e)h.to=e;return a.ajax({url:g.d.url+"/"+c+"/clicks"+g.d.urlSuffix,type:"GET",dataType:"json",data:h,headers:{Authorization:"Bearer "+b.token().get()},error:b.token().error()})},d.getOpenOsPieById=function(c,d,e){var f=this;var g={format:"aggregate",groupBy:"os"};if("undefined"!==typeof d&&false!==d)g.from=d;if("undefined"!==typeof e&&false!==e)g.to=e;return a.ajax({url:f.d.url+"/"+c+"/opens"+f.d.urlSuffix,type:"GET",dataType:"json",data:g,headers:{Authorization:"Bearer "+b.token().get()},error:b.token().error()})},d.getClickOsPieById=function(c,d,e){var f=this;var g={format:"aggregate",groupBy:"os"};if("undefined"!==typeof d&&false!==d)g.from=d;if("undefined"!==typeof e&&false!==e)g.to=e;return a.ajax({url:f.d.url+"/"+c+"/clicks"+f.d.urlSuffix,type:"GET",dataType:"json",data:g,headers:{Authorization:"Bearer "+b.token().get()},error:b.token().error()})},d.getOpenOsTimeLineById=function(c,d,e,f){var g=this;var h={format:"timeline",groupBy:"os"};if("undefined"!==typeof d&&false!==d)h.from=d;if("undefined"!==typeof e&&false!==e)h.to=e;return a.ajax({url:g.d.url+"/"+c+"/opens"+g.d.urlSuffix,type:"GET",dataType:"json",data:h,headers:{Authorization:"Bearer "+b.token().get()},error:b.token().error()})},d.getClickOsTimeLineById=function(c,d,e,f){var g=this;var h={format:"timeline",groupBy:"os"};if("undefined"!==typeof d&&false!==d)h.from=d;if("undefined"!==typeof e&&false!==e)h.to=e;return a.ajax({url:g.d.url+"/"+c+"/clicks"+g.d.urlSuffix,type:"GET",dataType:"json",data:h,headers:{Authorization:"Bearer "+b.token().get()},error:b.token().error()})},d.getOpenBrowserPieById=function(c,d,e){var f=this;var g={format:"aggregate",groupBy:"browser"};if("undefined"!==typeof d&&false!==d)g.from=d;if("undefined"!==typeof e&&false!==e)g.to=e;return a.ajax({url:f.d.url+"/"+c+"/opens"+f.d.urlSuffix,type:"GET",dataType:"json",data:g,headers:{Authorization:"Bearer "+b.token().get()},error:b.token().error()})},d.getClickBrowserPieById=function(c,d,e){var f=this;var g={format:"aggregate",groupBy:"browser"};if("undefined"!==typeof d&&false!==d)g.from=d;if("undefined"!==typeof e&&false!==e)g.to=e;return a.ajax({url:f.d.url+"/"+c+"/clicks"+f.d.urlSuffix,type:"GET",dataType:"json",data:g,headers:{Authorization:"Bearer "+b.token().get()},error:b.token().error()})},d.getOpenBrowserTimeLineById=function(c,d,e,f){var g=this;var h={format:"timeline",groupBy:"browser"};if("undefined"!==typeof d&&false!==d)h.from=d;if("undefined"!==typeof e&&false!==e)h.to=e;return a.ajax({url:g.d.url+"/"+c+"/opens"+g.d.urlSuffix,type:"GET",dataType:"json",data:h,headers:{Authorization:"Bearer "+b.token().get()},error:b.token().error()})},d.getClickBrowserTimeLineById=function(c,d,e,f){var g=this;var h={format:"timeline",groupBy:"browser"};if("undefined"!==typeof d&&false!==d)h.from=d;if("undefined"!==typeof e&&false!==e)h.to=e;return a.ajax({url:g.d.url+"/"+c+"/clicks"+g.d.urlSuffix,type:"GET",dataType:"json",data:h,headers:{Authorization:"Bearer "+b.token().get()},error:b.token().error()})},d.getOpenDomainPieById=function(c,d,e){var f=this;var g={format:"aggregate",groupBy:"domain"};if("undefined"!==typeof d&&false!==d)g.from=d;if("undefined"!==typeof e&&false!==e)g.to=e;return a.ajax({url:f.d.url+"/"+c+"/opens"+f.d.urlSuffix,type:"GET",dataType:"json",data:g,headers:{Authorization:"Bearer "+b.token().get()},error:b.token().error()})},d.getClickDomainPieById=function(c,d,e){var f=this;var g={format:"aggregate",groupBy:"domain"};if("undefined"!==typeof d&&false!==d)g.from=d;if("undefined"!==typeof e&&false!==e)g.to=e;return a.ajax({url:f.d.url+"/"+c+"/clicks"+f.d.urlSuffix,type:"GET",dataType:"json",data:g,headers:{Authorization:"Bearer "+b.token().get()},error:b.token().error()})},d.getOpenDomainTimeLineById=function(c,d,e,f){var g=this;var h={format:"timeline",groupBy:"domain"};if("undefined"!==typeof d&&false!==d)h.from=d;if("undefined"!==typeof e&&false!==e)h.to=e;return a.ajax({url:g.d.url+"/"+c+"/opens"+g.d.urlSuffix,type:"GET",dataType:"json",data:h,headers:{Authorization:"Bearer "+b.token().get()},error:b.token().error()})},d.getClickDomainTimeLineById=function(c,d,e,f){var g=this;var h={format:"timeline",groupBy:"domain"};if("undefined"!==typeof d&&false!==d)h.from=d;if("undefined"!==typeof e&&false!==e)h.to=e;return a.ajax({url:g.d.url+"/"+c+"/clicks"+g.d.urlSuffix,type:"GET",dataType:"json",data:h,headers:{Authorization:"Bearer "+b.token().get()},error:b.token().error()})},d.getHeatMapById=function(c,d,e){var f=this;var g={format:"raw"};if("undefined"!==typeof d&&false!==d)g.from=d;if("undefined"!==typeof e&&false!==e)g.to=e;return a.ajax({url:f.d.url+"/"+c+"/heat-map"+f.d.urlSuffix,type:"GET",dataType:"json",data:g,headers:{Authorization:"Bearer "+b.token().get()},error:b.token().error()})},b.initBasicFunctions(c,"Campaigns"),d.send=d.insert}(),function(){var c=function(a){var c=this;if(c.d={a:3,option:{},url:b.u.splitTests},c.init(),"undefined"!==typeof a)c.initParameter(a)};var d=c.prototype;d.getOpenStatById=function(c,d,e){var f=this;var g={format:"total"};if("undefined"!==typeof d&&false!==d)g.from=d;if("undefined"!==typeof e&&false!==e)g.to=e;return a.ajax({url:f.d.url+"/"+c+"/opens"+f.d.urlSuffix,type:"GET",dataType:"json",data:g,headers:{Authorization:"Bearer "+b.token().get()},error:b.token().error()})},d.getClickStatById=function(c,d,e){var f=this;var g={format:"total"};if("undefined"!==typeof d&&false!==d)g.from=d;if("undefined"!==typeof e&&false!==e)g.to=e;return a.ajax({url:f.d.url+"/"+c+"/clicks"+f.d.urlSuffix,type:"GET",dataType:"json",data:g,headers:{Authorization:"Bearer "+b.token().get()},error:b.token().error()})},d.getShareStatById=function(c,d,e){var f=this;var g={format:"total"};if("undefined"!==typeof d&&false!==d)g.from=d;if("undefined"!==typeof e&&false!==e)g.to=e;return a.ajax({url:f.d.url+"/"+c+"/shares"+f.d.urlSuffix,type:"GET",dataType:"json",data:g,headers:{Authorization:"Bearer "+b.token().get()},error:b.token().error()})},d.getUnsubscribeStatById=function(c,d,e){var f=this;var g={format:"total"};if("undefined"!==typeof d&&false!==d)g.from=d;if("undefined"!==typeof e&&false!==e)g.to=e;return a.ajax({url:f.d.url+"/"+c+"/unsubscribes"+f.d.urlSuffix,type:"GET",dataType:"json",data:g,headers:{Authorization:"Bearer "+b.token().get()},error:b.token().error()})},d.getBounceStatById=function(c,d,e){var f=this;var g={format:"total"};if("undefined"!==typeof d&&false!==d)g.from=d;if("undefined"!==typeof e&&false!==e)g.to=e;return a.ajax({url:f.d.url+"/"+c+"/bounces"+f.d.urlSuffix,type:"GET",dataType:"json",data:g,headers:{Authorization:"Bearer "+b.token().get()},error:b.token().error()})},d.getGeoStatById=function(c,d,e){var f=this;var g={format:"raw"};if("undefined"!==typeof d&&false!==d)g.from=d;if("undefined"!==typeof e&&false!==e)g.to=e;return a.ajax({url:f.d.url+"/"+c+"/geo-locations"+f.d.urlSuffix,type:"GET",dataType:"json",data:g,headers:{Authorization:"Bearer "+b.token().get()},error:b.token().error()})},d.getOpenTimeLineById=function(c,d,e,f){var g=this;var h={format:"timeline"};if("undefined"!==typeof d&&false!==d)h.from=d;if("undefined"!==typeof e&&false!==e)h.to=e;if("undefined"!==typeof f&&false!==f)h.step=f;return a.ajax({url:g.d.url+"/"+c+"/opens"+g.d.urlSuffix,type:"GET",dataType:"json",data:h,headers:{Authorization:"Bearer "+b.token().get()},error:b.token().error()})},d.getClickTimeLineById=function(c,d,e,f){var g=this;var h={format:"timeline"};if("undefined"!==typeof d&&false!==d)h.from=d;if("undefined"!==typeof e&&false!==e)h.to=e;if("undefined"!==typeof f&&false!==f)h.step=f;return a.ajax({url:g.d.url+"/"+c+"/clicks"+g.d.urlSuffix,type:"GET",dataType:"json",data:h,headers:{Authorization:"Bearer "+b.token().get()},error:b.token().error()})},d.getOpenDevicePieById=function(c,d,e){var f=this;var g={format:"aggregate",groupBy:"device"};if("undefined"!==typeof d&&false!==d)g.from=d;if("undefined"!==typeof e&&false!==e)g.to=e;return a.ajax({url:f.d.url+"/"+c+"/opens"+f.d.urlSuffix,type:"GET",dataType:"json",data:g,headers:{Authorization:"Bearer "+b.token().get()},error:b.token().error()})},d.getClickDevicePieById=function(c,d,e){var f=this;var g={format:"aggregate",groupBy:"device"};if("undefined"!==typeof d&&false!==d)g.from=d;if("undefined"!==typeof e&&false!==e)g.to=e;return a.ajax({url:f.d.url+"/"+c+"/clicks"+f.d.urlSuffix,type:"GET",dataType:"json",data:g,headers:{Authorization:"Bearer "+b.token().get()},error:b.token().error()})},d.getOpenOsPieById=function(c,d,e){var f=this;var g={format:"aggregate",groupBy:"os"};if("undefined"!==typeof d&&false!==d)g.from=d;if("undefined"!==typeof e&&false!==e)g.to=e;return a.ajax({url:f.d.url+"/"+c+"/opens"+f.d.urlSuffix,type:"GET",dataType:"json",data:g,headers:{Authorization:"Bearer "+b.token().get()},error:b.token().error()})},d.getClickOsPieById=function(c,d,e){var f=this;var g={format:"aggregate",groupBy:"os"};if("undefined"!==typeof d&&false!==d)g.from=d;if("undefined"!==typeof e&&false!==e)g.to=e;return a.ajax({url:f.d.url+"/"+c+"/clicks"+f.d.urlSuffix,type:"GET",dataType:"json",data:g,headers:{Authorization:"Bearer "+b.token().get()},error:b.token().error()})},d.getOpenBrowserPieById=function(c,d,e){var f=this;var g={format:"aggregate",groupBy:"browser"};if("undefined"!==typeof d&&false!==d)g.from=d;if("undefined"!==typeof e&&false!==e)g.to=e;return a.ajax({url:f.d.url+"/"+c+"/opens"+f.d.urlSuffix,type:"GET",dataType:"json",data:g,headers:{Authorization:"Bearer "+b.token().get()},error:b.token().error()})},d.getClickBrowserPieById=function(c,d,e){var f=this;var g={format:"aggregate",groupBy:"browser"};if("undefined"!==typeof d&&false!==d)g.from=d;if("undefined"!==typeof e&&false!==e)g.to=e;return a.ajax({url:f.d.url+"/"+c+"/clicks"+f.d.urlSuffix,type:"GET",dataType:"json",data:g,headers:{Authorization:"Bearer "+b.token().get()},error:b.token().error()})},d.getOpenDomainPieById=function(c,d,e){var f=this;
var g={format:"aggregate",groupBy:"domain"};if("undefined"!==typeof d&&false!==d)g.from=d;if("undefined"!==typeof e&&false!==e)g.to=e;return a.ajax({url:f.d.url+"/"+c+"/opens"+f.d.urlSuffix,type:"GET",dataType:"json",data:g,headers:{Authorization:"Bearer "+b.token().get()},error:b.token().error()})},d.getClickDomainPieById=function(c,d,e){var f=this;var g={format:"aggregate",groupBy:"domain"};if("undefined"!==typeof d&&false!==d)g.from=d;if("undefined"!==typeof e&&false!==e)g.to=e;return a.ajax({url:f.d.url+"/"+c+"/clicks"+f.d.urlSuffix,type:"GET",dataType:"json",data:g,headers:{Authorization:"Bearer "+b.token().get()},error:b.token().error()})},b.initBasicFunctions(c,"SplitTests"),d.send=d.insert}(),function(){var a=function(a){var c=this;if(c.d={a:3,option:{},url:b.u.newsletters},c.init(),"undefined"!==typeof a)c.initParameter(a)};var c=a.prototype;c.copy=function(a,b,c){var d=this;var b=b||{};b.copyData=b.copyData||{};var c=c||function(){};return d.getRecordById(a).done(function(a){var e={name:b.name||(b.copyData.prefix||"")+a.name+(b.copyData.suffix||""),subject:b.subject||a.subject,editorCode:b.editorCode||a.editorCode,htmlCode:b.htmlCode||a.htmlCode,maxWidth:b.maxWidth||a.maxWidth,tags:b.tags||a.tags};return d.insert(e).done(function(a){c.apply(d,[a])})})},b.initBasicFunctions(a,"Newsletters")}(),function(){var c=function(a){var c=this;if(c.d={a:3,option:{},url:b.u.contacts},c.init(),"undefined"!==typeof a)c.initParameter(a)};var d=c.prototype;d.getActivitiesById=function(c){var d=this;return a.ajax({url:d.d.url+"/"+c+"/activities",type:"GET",dataType:"json",headers:{Authorization:"Bearer "+b.token().get()},error:b.token().error()})},b.initBasicFunctions(c,"Contacts")}(),function(){var a=function(a){var c=this;if(c.d={a:3,option:{},url:b.u.customFields},c.init(),"undefined"!==typeof a)c.initParameter(a)};var c=a.prototype;b.initBasicFunctions(a,"CustomFields")}(),function(){var c=function(a){var c=this;if(c.d={a:3,option:{},url:b.u.users},c.init(),"undefined"!==typeof a)c.initParameter(a)};var d=c.prototype;d["switch"]=function(c){return a.ajax({url:b.u.users+"/switch-site",type:"POST",data:{site:c},dataType:"json",headers:{Authorization:"Bearer "+b.token().get()}}).done(function(a){b.token().set(a),b.token().refreshLoopRestart()}).error(function(a){})},b.initBasicFunctions(c,"Users")}(),function(){var a=function(a){var c=this;if(c.d={a:3,option:{},url:b.u.jobs},c.init(),"undefined"!==typeof a)c.initParameter(a)};var c=a.prototype;b.initBasicFunctions(a,"Jobs")}(),function(){var a=function(a){var c=this;if(c.d={a:3,option:{},url:b.u.webhooks},c.init(),"undefined"!==typeof a)c.initParameter(a)};var c=a.prototype;b.initBasicFunctions(a,"Webhooks")}(),function(){var a=function(a){var c=this;if(c.d={a:3,option:{},url:b.u.templates},c.init(),"undefined"!==typeof a)c.initParameter(a)};var c=a.prototype;c.copy=function(a,b,c){var d=this;var b=b||{};b.copyData=b.copyData||{};var c=c||function(){};return d.getRecordById(a).done(function(a){var e={name:b.name||(b.copyData.prefix||"")+a.name+(b.copyData.suffix||""),editorCode:b.editorCode||a.editorCode,htmlCode:b.htmlCode||a.htmlCode,maxWidth:b.maxWidth||a.maxWidth};return d.insert(e).done(function(a){c.apply(d,[a])})})},b.initBasicFunctions(a,"Templates")}(),function(){var c=function(a){var c=this;if(c.d={a:3,option:{},url:b.u.forms},c.init(),"undefined"!==typeof a)c.initParameter(a)};var d=c.prototype;d.getFullTimeLineById=function(c,d,e,f){var g=this;var h={format:"timeline"};if("undefined"!==typeof d&&false!==d)h.from=d;if("undefined"!==typeof e&&false!==e)h.to=e;return a.ajax({url:g.d.url+"/"+c+"/conversion"+g.d.urlSuffix,type:"GET",dataType:"json",data:h,headers:{Authorization:"Bearer "+b.token().get()},error:b.token().error()})},b.initBasicFunctions(c,"Forms")}(),function(){var a=function(a){var c=this;if(c.d={a:3,option:{},url:b.u.automations},c.init(),"undefined"!==typeof a)c.initParameter(a)};var c=a.prototype;b.initBasicFunctions(a,"Automations")}(),function(){var c=function(a){var c=this;if(c.d={a:3,option:{},url:b.u.contactImports},c.init(),"undefined"!==typeof a)c.initParameter(a)};var d=c.prototype;d.getContactsByIdAndType=function(c,d){var e=this;return a.ajax({url:e.d.url+"/"+c+"/"+d,type:"GET",dataType:"json",headers:{Authorization:"Bearer "+b.token().get()},error:b.token().error()})},d.getForbiddenContactsById=function(a){return this.getContactsByIdAndType(a,"creation-forbidden-errors")},d.getAlreadyInDatabaseContactsById=function(a){return this.getContactsByIdAndType(a,"already-in-database-errors")},d.getInvalidContactsById=function(a){return this.getContactsByIdAndType(a,"invalid-email-errors")},d.getUnsubscribedContactsById=function(a){return this.getContactsByIdAndType(a,"unsubscribed-errors")},b.initBasicFunctions(c,"ContactImports")}(),function(){var c=function(a){};var d=c.prototype;d.get=function(){return a.ajax({url:b.u.tags,type:"GET",dataType:"json",headers:{Authorization:"Bearer "+b.token().get()}})},b.m.Tags=c,b.tags=function(a){var b=new c(a);return b}}(),function(){var c=function(a){};var d=c.prototype;d.get=function(){return a.ajax({url:b.u.account,type:"GET",dataType:"json",headers:{Authorization:"Bearer "+b.token().get()}})},d.limits=function(){return a.ajax({url:b.u.account+"/limits",type:"GET",dataType:"json",headers:{Authorization:"Bearer "+b.token().get()}})},d.getPackages=function(){return a.ajax({url:b.u.account+"/limits",type:"GET",dataType:"json",headers:{Authorization:"Bearer "+b.token().get()}})},b.m.Account=c,b.account=function(a){var b=new c(a);return b}}(),function(){var c=function(a){var c=this;if(c.d={a:3,option:{},url:b.u.clients},c.init(),"undefined"!==typeof a)c.initParameter(a)};var d=c.prototype;d.create=function(){return a.ajax({url:b.u.clients,type:"POST",dataType:"json",headers:{Authorization:"Bearer "+b.token().get()}})},b.initBasicFunctions(c,"Clients")}(),function(){b.parseBoolean=function(a,b){if("string"===typeof a)a=a.toLowerCase();switch(a){case true:case"true":case 1:case"1":case"on":case"yes":case"y":case"\u2713":case"\u2714":case"\u2611":case"\u2612":a=true;break;case false:case"false":case 0:case"0":case"off":case"no":case"n":case"x":case"\u2717":case"\u2718":case"\u2610":a=false;break;default:if(b)a=null;else a=false}return a}}(),function(){b.refreshTable=function(c){if("undefined"===typeof c)return false;var d=c.data("apiName");var e=c.data("apiUrlSuffix");var f=c.data("apiItemsDir");var g=c.data("apiFormat");var h=c.data("refreshComplete");var i=c.d.orderBy;var j=c.d.orderDir;var k=c.perPage();var l=c.page();var m=c.data("fields")||false;var n=false;if("undefined"!==typeof c.data("xhr"))c.data("xhr").abort();if("undefined"===typeof e)e="";if("undefined"===typeof f)f=false;if("undefined"===typeof g)g=false;if("function"!==typeof h)h=function(){};if(false===m){m=[];var o=c.cols();for(var p=c.selectable()?1:0;p<o.length;p++)if(o[p].active())m.push(o[p].name());if(a.inArray("id",m)===-1)m.push("id");else n=true;m=m.join()}else m=JSON.stringify(m);var q=[];if(("string"===typeof c.d.searchValue||"number"===typeof c.d.searchValue)&&c.d.searchValue.length>0){var o=c.cols();for(var p=0;p<o.length;p++){console.log(o[p]);var r=c.d.settings.cols;var s={};for(var t=0;t<r.length;t++)s[r[t].name||0]=false===r[t].searchable?false:true;console.log(s,r);var u=o[p].name();if(s[u])q.push([[u,"like","%"+c.d.searchValue+"%"]])}}c.d.$checkboxCheckAll.prop("checked",false).change(),c.loading();var v=b[d]().links("").fields(m).limit(k).page(l).where(q).orderBy(i).orderDir(j).urlSuffix(e).format(g).get().done(function(b){if(c.pageMax(b.page_count),false!==f){var e=f.split("/");var g=b;for(var i=0;i<e.length;i++)g=g[e[i]]}else var g=b._embedded[d];var j=g.length;var k=[];for(var i=0;i<j;i++){var l={recordId:g[i].id||0,values:{}};for(var m in g[i]){if("_"===m.charAt(0)||"id"===m&&!n)continue;if(null!==g[i][m]&&("object"===typeof g[i][m]||"array"===typeof g[i][m]))if(a.isArray(g[i][m]))l.values[m]=g[i][m];else{var o=false;var p=0;var q=false;var r=0;var s=false;for(var t in g[i][m]){if("date"===t||"timezone"===t||"timezone_type"===t)p++;if("code"===t||"value"===t)r++;if(o=false,q=false,s=false,3===p)o=true;else if(2==r)q=true;else if("customFields"===m)s=true}if(o)l.values[m]=g[i][m].date||g[i][m][Object.keys(g[i][m])[0]]||"";else if(q)l.values[m]=g[i][m].value||g[i][m][Object.keys(g[i][m])[0]]||"";else if(s)for(var u in g[i][m])if(null!==g[i][m][u]&&("array"===typeof g[i][m][u]||"object"===typeof g[i][m][u]))if(a.isArray(g[i][m][u])){if(l.values["customFields."+u]=g[i][m][u],g[i][m][u].length>0)l.values["customFields."+u]='<ul style="margin: 0; padding-left: 17px;"><li>'+g[i][m][u].join("</li><li>")+"</li></ul>"}else l.values["customFields."+u]=g[i][m][u].date||g[i][m][u].value||g[i][m][u][Object.keys(g[i][m][u])[0]]||"";else l.values["customFields."+u]=g[i][m][u];else l.values[m]=g[i][m]}else l.values[m]=g[i][m]}k.push(l)}c.deleteRows();var v=c.getColByName("customFields");if(false!==v)v.$cells().css("display","none");c.rows(k),c.d.stepFunction(),setTimeout(function(){h.apply(c,[c,c.d.$widget])},10)});c.data("xhr",v)}}(),function(){b.exportTable=function(a){if("undefined"===typeof a)return false;var c=a.data("apiName");var d=a.data("apiUrlSuffix");var e=a.data("exportFields")||[];if(e.length>0)e=e.join(",");else e=false;var f=a.d.orderBy;var g=a.d.orderDir;if("undefined"===typeof d)d="";var h=b[c]().orderBy(f).orderDir(g).fields(e).urlSuffix(d)["export"]().done(function(a,b,c){window.location.href=c.getResponseHeader("X-Download-Url")})}}(),function(){b.downloadContent=function(b,c){var d="download"in document.createElement("a");if(d){var e=a("<a></a>");e.attr({href:"data:attachment/csv,"+encodeURI(b),target:"_blank",download:c})[0].click(),setTimeout(function(){e.remove()},50)}else if("undefined"!==typeof safari)window.open("data:attachment/csv,"+encodeURI(b));else if(window.navigator.msSaveOrOpenBlob){var f=new Blob([b],{type:"text/plain"});navigator.msSaveBlob(f,c)}else alert($A.translate("Your browser is not supported the csv export."))}}(),function(){console.log("%c AutomizyJsApi module loaded! ","background: #000000; color: #bada55; font-size:14px")}(),window.$AA=b,window.AutomizyJsApi=b})($);
//# sourceMappingURL=automizy.api.min.map