tradly 1.0.39 → 1.0.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Constants/AppConstant.js +8 -8
- package/Constants/PathConstant.js +79 -79
- package/Helper/APIParam.js +21 -21
- package/Helper/Serialization.js +8 -8
- package/NetworkManager/ErrorHandler.js +16 -16
- package/NetworkManager/NetworkManager.js +63 -63
- package/README.md +152 -152
- package/Roots/App.js +1600 -591
- package/Roots/Initialize.js +29 -29
- package/Roots/Roots.js +6 -6
- package/Roots/User.js +43 -43
- package/index.js +1 -1
- package/package.json +31 -31
package/Constants/AppConstant.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
export var APPCONSTANT = {
|
|
3
|
-
TOKEN: '',
|
|
4
|
-
CURRENCY:'',
|
|
5
|
-
ENVIRONMENT:'',
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
|
|
2
|
+
export var APPCONSTANT = {
|
|
3
|
+
TOKEN: '',
|
|
4
|
+
CURRENCY:'',
|
|
5
|
+
ENVIRONMENT:'',
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
|
|
9
9
|
export const TYPES = {account:'accounts', listing: 'listings', event: 'event'};
|
|
@@ -1,79 +1,79 @@
|
|
|
1
|
-
import Environment from "../Helper/APIParam.js";
|
|
2
|
-
import { APPCONSTANT } from "./AppConstant.js";
|
|
3
|
-
|
|
4
|
-
var AppName = 'Traldy SDK';
|
|
5
|
-
export default AppName;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
//User module paths
|
|
9
|
-
export var DEV = 'https://api.dev.tradly.app/';
|
|
10
|
-
export var PRO = 'https://api.tradly.app/';
|
|
11
|
-
export var SANDBOX = 'https://api.sandbox.tradly.app/';
|
|
12
|
-
// export var BASEURL = Environment(APPCONSTANT.ENVIRONMENT);
|
|
13
|
-
export const REFRESH = 'v1/users/token/refresh';
|
|
14
|
-
export const TENANTS = 'v1/tenants/';
|
|
15
|
-
export const CONFIG = '/configs';
|
|
16
|
-
export const CONFIGLIST = 'v1/configs?key_group=';
|
|
17
|
-
|
|
18
|
-
export const LOGIN = 'v1/users/login';
|
|
19
|
-
export const REGISTER = 'v1/users/register';
|
|
20
|
-
export const VERIFY = 'v1/users/verify';
|
|
21
|
-
export const FORGOTPASSWORD = 'v1/users/password/recovery';
|
|
22
|
-
export const SETPASSWORD = 'v1/users/password/set';
|
|
23
|
-
|
|
24
|
-
export const USERS = 'v1/users';
|
|
25
|
-
export const DEVICES = 'v1/devices';
|
|
26
|
-
|
|
27
|
-
export const ADDRESS = '/v1/addresses'
|
|
28
|
-
export const CURRENCY = 'v1/currencies';
|
|
29
|
-
export const LANGUAGES = 'v1/languages';
|
|
30
|
-
export const COUNTRIES = 'v1/countries';
|
|
31
|
-
export const TENANTSCOUNTRIES = 'v1/tenants/countries';
|
|
32
|
-
|
|
33
|
-
export const CATEGORY = 'v1/categories';
|
|
34
|
-
export const ATTRIBUTE= 'v1/attributes';
|
|
35
|
-
export const VALUES= '/values';
|
|
36
|
-
|
|
37
|
-
export const ACCOUNTS = 'v1/accounts';
|
|
38
|
-
export const FOLLOW = '/follow';
|
|
39
|
-
export const BLOCK = '/block';
|
|
40
|
-
export const REPORT = '/report';
|
|
41
|
-
|
|
42
|
-
export const LISTINGS = 'products/v1/listings';
|
|
43
|
-
export const LIKE = '/likes';
|
|
44
|
-
export const SCHEDULE = '/schedules';
|
|
45
|
-
export const SCHEDULEPERDAY = '/schedules_per_day?';
|
|
46
|
-
|
|
47
|
-
export const VARIANTTYPES = 'products/v1/variant_types';
|
|
48
|
-
export const VARIANTS = '/variants';
|
|
49
|
-
|
|
50
|
-
export const PAYMENTSMETHODS = '/v1/tenants/payment_methods';
|
|
51
|
-
export const SHIPPINGMETHOD = 'v1/tenants/shipping_methods';
|
|
52
|
-
|
|
53
|
-
export const S3SIGNEDURL = 'v1/utils/S3signedUploadURL';
|
|
54
|
-
export const SEARCHADDRESS = 'v1/addresses/search?key=';
|
|
55
|
-
|
|
56
|
-
export const HOME = 'products/v1/home';
|
|
57
|
-
export const ORDERS = 'products/v1/orders';
|
|
58
|
-
|
|
59
|
-
export const CART = 'products/v1/cart';
|
|
60
|
-
export const CHECKOUT = '/checkout';
|
|
61
|
-
export const EPHERMERALKEY = 'v1/payments/stripe/ephemeralKey';
|
|
62
|
-
export const PAYMENTINTENT = 'v1/payments/stripe/paymentIntent';
|
|
63
|
-
|
|
64
|
-
export const STRIPECONNECTACCOUNT = 'v1/payments/stripe/connect/account?account_id=';
|
|
65
|
-
export const CREATEACCOUNTLINK = 'v1/payments/stripe/connect/account_links';
|
|
66
|
-
export const CREATEEXPRESSLOGINLINK = 'v1/payments/stripe/connect/login_links';
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
export const STATUS = '/status';
|
|
70
|
-
export const REVIEW = '/v1/reviews';
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
export const COLLECTIONS = '/v1/collections';
|
|
74
|
-
export const PROMO = '/v1/promos';
|
|
75
|
-
export const TRANSACTIONS = '/v1/transactions';
|
|
76
|
-
export const EARNINGS = '/v1/earnings';
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
1
|
+
import Environment from "../Helper/APIParam.js";
|
|
2
|
+
import { APPCONSTANT } from "./AppConstant.js";
|
|
3
|
+
|
|
4
|
+
var AppName = 'Traldy SDK';
|
|
5
|
+
export default AppName;
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
//User module paths
|
|
9
|
+
export var DEV = 'https://api.dev.tradly.app/';
|
|
10
|
+
export var PRO = 'https://api.tradly.app/';
|
|
11
|
+
export var SANDBOX = 'https://api.sandbox.tradly.app/';
|
|
12
|
+
// export var BASEURL = Environment(APPCONSTANT.ENVIRONMENT);
|
|
13
|
+
export const REFRESH = 'v1/users/token/refresh';
|
|
14
|
+
export const TENANTS = 'v1/tenants/';
|
|
15
|
+
export const CONFIG = '/configs';
|
|
16
|
+
export const CONFIGLIST = 'v1/configs?key_group=';
|
|
17
|
+
|
|
18
|
+
export const LOGIN = 'v1/users/login';
|
|
19
|
+
export const REGISTER = 'v1/users/register';
|
|
20
|
+
export const VERIFY = 'v1/users/verify';
|
|
21
|
+
export const FORGOTPASSWORD = 'v1/users/password/recovery';
|
|
22
|
+
export const SETPASSWORD = 'v1/users/password/set';
|
|
23
|
+
|
|
24
|
+
export const USERS = 'v1/users';
|
|
25
|
+
export const DEVICES = 'v1/devices';
|
|
26
|
+
|
|
27
|
+
export const ADDRESS = '/v1/addresses'
|
|
28
|
+
export const CURRENCY = 'v1/currencies';
|
|
29
|
+
export const LANGUAGES = 'v1/languages';
|
|
30
|
+
export const COUNTRIES = 'v1/countries';
|
|
31
|
+
export const TENANTSCOUNTRIES = 'v1/tenants/countries';
|
|
32
|
+
|
|
33
|
+
export const CATEGORY = 'v1/categories';
|
|
34
|
+
export const ATTRIBUTE= 'v1/attributes';
|
|
35
|
+
export const VALUES= '/values';
|
|
36
|
+
|
|
37
|
+
export const ACCOUNTS = 'v1/accounts';
|
|
38
|
+
export const FOLLOW = '/follow';
|
|
39
|
+
export const BLOCK = '/block';
|
|
40
|
+
export const REPORT = '/report';
|
|
41
|
+
|
|
42
|
+
export const LISTINGS = 'products/v1/listings';
|
|
43
|
+
export const LIKE = '/likes';
|
|
44
|
+
export const SCHEDULE = '/schedules';
|
|
45
|
+
export const SCHEDULEPERDAY = '/schedules_per_day?';
|
|
46
|
+
|
|
47
|
+
export const VARIANTTYPES = 'products/v1/variant_types';
|
|
48
|
+
export const VARIANTS = '/variants';
|
|
49
|
+
|
|
50
|
+
export const PAYMENTSMETHODS = '/v1/tenants/payment_methods';
|
|
51
|
+
export const SHIPPINGMETHOD = 'v1/tenants/shipping_methods';
|
|
52
|
+
|
|
53
|
+
export const S3SIGNEDURL = 'v1/utils/S3signedUploadURL';
|
|
54
|
+
export const SEARCHADDRESS = 'v1/addresses/search?key=';
|
|
55
|
+
|
|
56
|
+
export const HOME = 'products/v1/home';
|
|
57
|
+
export const ORDERS = 'products/v1/orders';
|
|
58
|
+
|
|
59
|
+
export const CART = 'products/v1/cart';
|
|
60
|
+
export const CHECKOUT = '/checkout';
|
|
61
|
+
export const EPHERMERALKEY = 'v1/payments/stripe/ephemeralKey';
|
|
62
|
+
export const PAYMENTINTENT = 'v1/payments/stripe/paymentIntent';
|
|
63
|
+
|
|
64
|
+
export const STRIPECONNECTACCOUNT = 'v1/payments/stripe/connect/account?account_id=';
|
|
65
|
+
export const CREATEACCOUNTLINK = 'v1/payments/stripe/connect/account_links';
|
|
66
|
+
export const CREATEEXPRESSLOGINLINK = 'v1/payments/stripe/connect/login_links';
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
export const STATUS = '/status';
|
|
70
|
+
export const REVIEW = '/v1/reviews';
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
export const COLLECTIONS = '/v1/collections';
|
|
74
|
+
export const PROMO = '/v1/promos';
|
|
75
|
+
export const TRANSACTIONS = '/v1/transactions';
|
|
76
|
+
export const EARNINGS = '/v1/earnings';
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
package/Helper/APIParam.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import {DEV, PRO, SANDBOX } from "../Constants/PathConstant.js"
|
|
2
|
-
|
|
3
|
-
export var EVN = {
|
|
4
|
-
DEV:'development',
|
|
5
|
-
PRO: 'production',
|
|
6
|
-
SANDBOX: 'sandbox',
|
|
7
|
-
}
|
|
8
|
-
export var UserParameter = {data:{}}
|
|
9
|
-
export default function Environment(evn) {
|
|
10
|
-
switch(evn) {
|
|
11
|
-
case EVN.DEV : return DEV
|
|
12
|
-
case EVN.SANDBOX : return SANDBOX
|
|
13
|
-
case EVN.PRO : return PRO
|
|
14
|
-
default : return DEV
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export var ImageConfig = {
|
|
19
|
-
signedUrl:'',
|
|
20
|
-
mime:'',
|
|
21
|
-
blob_body:''
|
|
1
|
+
import {DEV, PRO, SANDBOX } from "../Constants/PathConstant.js"
|
|
2
|
+
|
|
3
|
+
export var EVN = {
|
|
4
|
+
DEV:'development',
|
|
5
|
+
PRO: 'production',
|
|
6
|
+
SANDBOX: 'sandbox',
|
|
7
|
+
}
|
|
8
|
+
export var UserParameter = {data:{}}
|
|
9
|
+
export default function Environment(evn) {
|
|
10
|
+
switch(evn) {
|
|
11
|
+
case EVN.DEV : return DEV
|
|
12
|
+
case EVN.SANDBOX : return SANDBOX
|
|
13
|
+
case EVN.PRO : return PRO
|
|
14
|
+
default : return DEV
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export var ImageConfig = {
|
|
19
|
+
signedUrl:'',
|
|
20
|
+
mime:'',
|
|
21
|
+
blob_body:''
|
|
22
22
|
}
|
package/Helper/Serialization.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
function Serialization(param) {
|
|
3
|
-
var str = [];
|
|
4
|
-
for (var p in param)
|
|
5
|
-
str.push(encodeURIComponent(p) + "=" + encodeURIComponent(param[p]));
|
|
6
|
-
return str.join("&");
|
|
7
|
-
|
|
8
|
-
}
|
|
1
|
+
|
|
2
|
+
function Serialization(param) {
|
|
3
|
+
var str = [];
|
|
4
|
+
for (var p in param)
|
|
5
|
+
str.push(encodeURIComponent(p) + "=" + encodeURIComponent(param[p]));
|
|
6
|
+
return str.join("&");
|
|
7
|
+
|
|
8
|
+
}
|
|
9
9
|
export default Serialization;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
export default class ErrorHandler {
|
|
2
|
-
static errorHandle(errorCode) {
|
|
3
|
-
switch(errorCode) {
|
|
4
|
-
case 101: return 'User already exist'
|
|
5
|
-
case 102: return 'User not register'
|
|
6
|
-
case 103: return 'invalid credentials'
|
|
7
|
-
case 104: return 'Verification code is invalid'
|
|
8
|
-
case 105: return 'INVALID CREDENTIALS'
|
|
9
|
-
case 301: return 'User already exist'
|
|
10
|
-
case 401: return 'Unauthorized'
|
|
11
|
-
case 402: return 'Technical issue'
|
|
12
|
-
case 753: return 'Action not allowed'
|
|
13
|
-
default: return 'invalid or missing parameters' ;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
1
|
+
export default class ErrorHandler {
|
|
2
|
+
static errorHandle(errorCode) {
|
|
3
|
+
switch(errorCode) {
|
|
4
|
+
case 101: return 'User already exist'
|
|
5
|
+
case 102: return 'User not register'
|
|
6
|
+
case 103: return 'invalid credentials'
|
|
7
|
+
case 104: return 'Verification code is invalid'
|
|
8
|
+
case 105: return 'INVALID CREDENTIALS'
|
|
9
|
+
case 301: return 'User already exist'
|
|
10
|
+
case 401: return 'Unauthorized'
|
|
11
|
+
case 402: return 'Technical issue'
|
|
12
|
+
case 753: return 'Action not allowed'
|
|
13
|
+
default: return 'invalid or missing parameters' ;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import {to} from 'await-to-js';
|
|
4
|
-
import axios from 'axios';
|
|
5
|
-
import { APPCONSTANT} from '../Constants/AppConstant.js';
|
|
6
|
-
import { REFRESH } from '../Constants/PathConstant.js';
|
|
7
|
-
import Environment, { ImageConfig } from '../Helper/APIParam.js';
|
|
8
|
-
|
|
9
|
-
var header = {
|
|
10
|
-
'Accept': 'application/json',
|
|
11
|
-
'Content-Type': 'application/json',
|
|
12
|
-
'x-agent': 1,
|
|
13
|
-
}
|
|
14
|
-
export const Method = {
|
|
15
|
-
GET :'GET',
|
|
16
|
-
DELETE:'DELETE',
|
|
17
|
-
POST: 'POST',
|
|
18
|
-
PUT: 'PUT',
|
|
19
|
-
PATCH:'PATCH',
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export var TradlyConfig = {
|
|
23
|
-
path:'',
|
|
24
|
-
method:Method,
|
|
25
|
-
param:'',
|
|
26
|
-
authKey:'',
|
|
27
|
-
refreshKey:'',
|
|
28
|
-
currency:'',
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
class NetworkManager {
|
|
32
|
-
networkCall = async (config = TradlyConfig) => {
|
|
33
|
-
var BaseURL = Environment(APPCONSTANT.ENVIRONMENT);
|
|
34
|
-
var url = BaseURL + config.path;
|
|
35
|
-
header['Authorization'] = "Bearer " + APPCONSTANT.TOKEN;
|
|
36
|
-
if (config.authKey != undefined || config.authKey == '') {
|
|
37
|
-
header['x-auth-key'] = config.authKey;
|
|
38
|
-
}
|
|
39
|
-
if (config.currency != undefined || config.currency == '') {
|
|
40
|
-
header['x-currency'] = config.currency;
|
|
41
|
-
}
|
|
42
|
-
if (config.refreshKey != undefined || config.refreshKey == '') {
|
|
43
|
-
header['X-Refresh-Key'] = config.refreshKey;
|
|
44
|
-
}
|
|
45
|
-
const [err,response] = await to(axios({url:url,method:config.method,responseType:'json',headers:header,data:config.param}))
|
|
46
|
-
if (err) {
|
|
47
|
-
let errData = err['response']['data'];
|
|
48
|
-
return [errData, undefined];
|
|
49
|
-
} else {
|
|
50
|
-
return [undefined, response['data']];
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
uploadImage = async (param = ImageConfig) => {
|
|
54
|
-
const [err, response] = await to(axios({url:param.signedUrl,method:'put',headers:{'Content-Type':param.mime},data:param.blob_body}))
|
|
55
|
-
if (err) {
|
|
56
|
-
return false;
|
|
57
|
-
} else {
|
|
58
|
-
return true;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
const network = new NetworkManager();
|
|
63
|
-
export default network;
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import {to} from 'await-to-js';
|
|
4
|
+
import axios from 'axios';
|
|
5
|
+
import { APPCONSTANT} from '../Constants/AppConstant.js';
|
|
6
|
+
import { REFRESH } from '../Constants/PathConstant.js';
|
|
7
|
+
import Environment, { ImageConfig } from '../Helper/APIParam.js';
|
|
8
|
+
|
|
9
|
+
var header = {
|
|
10
|
+
'Accept': 'application/json',
|
|
11
|
+
'Content-Type': 'application/json',
|
|
12
|
+
'x-agent': 1,
|
|
13
|
+
}
|
|
14
|
+
export const Method = {
|
|
15
|
+
GET :'GET',
|
|
16
|
+
DELETE:'DELETE',
|
|
17
|
+
POST: 'POST',
|
|
18
|
+
PUT: 'PUT',
|
|
19
|
+
PATCH:'PATCH',
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export var TradlyConfig = {
|
|
23
|
+
path:'',
|
|
24
|
+
method:Method,
|
|
25
|
+
param:'',
|
|
26
|
+
authKey:'',
|
|
27
|
+
refreshKey:'',
|
|
28
|
+
currency:'',
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
class NetworkManager {
|
|
32
|
+
networkCall = async (config = TradlyConfig) => {
|
|
33
|
+
var BaseURL = Environment(APPCONSTANT.ENVIRONMENT);
|
|
34
|
+
var url = BaseURL + config.path;
|
|
35
|
+
header['Authorization'] = "Bearer " + APPCONSTANT.TOKEN;
|
|
36
|
+
if (config.authKey != undefined || config.authKey == '') {
|
|
37
|
+
header['x-auth-key'] = config.authKey;
|
|
38
|
+
}
|
|
39
|
+
if (config.currency != undefined || config.currency == '') {
|
|
40
|
+
header['x-currency'] = config.currency;
|
|
41
|
+
}
|
|
42
|
+
if (config.refreshKey != undefined || config.refreshKey == '') {
|
|
43
|
+
header['X-Refresh-Key'] = config.refreshKey;
|
|
44
|
+
}
|
|
45
|
+
const [err,response] = await to(axios({url:url,method:config.method,responseType:'json',headers:header,data:config.param}))
|
|
46
|
+
if (err) {
|
|
47
|
+
let errData = err['response']['data'];
|
|
48
|
+
return [errData, undefined];
|
|
49
|
+
} else {
|
|
50
|
+
return [undefined, response['data']];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
uploadImage = async (param = ImageConfig) => {
|
|
54
|
+
const [err, response] = await to(axios({url:param.signedUrl,method:'put',headers:{'Content-Type':param.mime},data:param.blob_body}))
|
|
55
|
+
if (err) {
|
|
56
|
+
return false;
|
|
57
|
+
} else {
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const network = new NetworkManager();
|
|
63
|
+
export default network;
|