-
Notifications
You must be signed in to change notification settings - Fork 1
/
backand.provider.js
101 lines (96 loc) · 3.12 KB
/
backand.provider.js
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*********************************************************
* @backand/angular1-sdk - Backand SDK for Angular 1
* @version v2.0.18
* @link https://github.com/backand/angular1-sdk#readme
* @copyright Copyright (c) 2017 Backand https://www.backand.com/
* @license MIT (http://www.opensource.org/licenses/mit-license.php)
* @Compiled At: 11/5/2017
*********************************************************/
(function() {
'use strict';
angular
.module('backand', [])
.provider('Backand', BackandProvider);
function BackandProvider() {
this.init = backand.init;
var config = { };
this.setAppName = function (appName) {
config.appName = appName;
return this;
};
this.setAnonymousToken = function (anonymousToken) {
config.anonymousToken = anonymousToken;
return this;
};
this.setSignUpToken = function (signUpToken) {
config.signUpToken = signUpToken;
return this;
};
this.setApiUrl = function (newApiUrl) {
config.apiUrl = newApiUrl;
return this;
};
this.manageRefreshToken = function (manageRefreshToken) {
config.manageRefreshToken = manageRefreshToken;
return this;
};
this.runSigninAfterSignup = function (runSigninAfterSignup) {
config.runSigninAfterSignup = runSigninAfterSignup;
return this;
};
this.runSocket = function (runSocket) {
config.runSocket = runSocket;
return this;
};
this.setSocketUrl = function (newSocketUrl) {
config.socketUrl = newSocketUrl;
return this;
};
this.setIsMobile = function(isMobile){
config.isMobile = isMobile;
return this;
};
this.setMobilePlatform = function(mobilePlatform){
config.mobilePlatform = mobilePlatform;
return this;
};
this.$get = ['$timeout', function BackandFactory($timeout) {
backand.init && backand.init(config);
var BKNDANGULAR = (function wrap (obj) {
if(!obj){
return null;
}
var temp = obj.constructor();
Object.keys(obj).forEach(function (key) {
if (typeof obj[key] === 'function') {
temp[key] = function () {
var args = Array.prototype.slice.call(arguments);
return $timeout.apply(undefined, [obj[key], 0, true].concat(args));
}
}
else if(typeof obj[key] !== 'object' || key === 'utils' || key === 'defaults' || key === 'helpers') {
temp[key] = obj[key];
}
else if(key === 'cache' || key === 'queue') {
var desc = Object.getOwnPropertyDescriptor(obj, key);
Object.defineProperty(temp, key, desc);
}
else {
temp[key] = wrap(obj[key]);
}
});
return temp;
})(backand);
BKNDANGULAR.setIsMobile = function(isMobile){
backand.defaults.isMobile = isMobile;
};
BKNDANGULAR.setMobilePlatform = function(mobilePlatform){
backand.defaults.mobilePlatform = mobilePlatform;
};
BKNDANGULAR.getApiUrl = function(){
return backand.defaults.apiUrl;
};
return BKNDANGULAR;
}];
}
})();