tradly 1.0.3 → 1.0.7

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.
@@ -1,3 +1,7 @@
1
1
 
2
- export var BTOKEN = {token: ''};
2
+ export var APPCONSTANT = {
3
+ TOKEN: '',
4
+ CURRENCY:'USD',
5
+ };
3
6
 
7
+ export const TYPES = {account:'accounts', listing: 'listings', event: 'event'};
@@ -14,8 +14,44 @@ export const FORGOTPASSWORD = 'v1/users/password/recovery';
14
14
  export const USERS = 'v1/users';
15
15
  export const DEVICES = 'v1/devices';
16
16
 
17
+ export const ADDRESS = '/v1/addresses'
18
+ export const CURRENCY = 'v1/currencies';
19
+ export const LANGUAGES = 'v1/languages';
20
+
21
+ export const CATEGORY = 'v1/categories';
22
+ export const ATTRIBUTE= 'v1/attributes';
23
+ export const VALUES= '/values';
24
+
25
+ export const ACCOUNTS = 'v1/accounts';
26
+ export const FOLLOW = '/follow';
27
+ export const BLOCK = '/block';
28
+ export const REPORT = '/report';
29
+
30
+ export const LISTINGS = 'products/v1/listings';
31
+ export const LIKE = '/likes';
32
+
33
+ export const VARIANTTYPES = 'products/v1/variant_types';
34
+ export const VARIANTS = '/variants';
35
+
36
+ export const PAYMENTSMETHODS = '/v1/tenants/payment_methods';
37
+ export const SHIPPINGMETHOD = 'v1/tenants/shipping_methods';
38
+
39
+ export const S3SIGNEDURL = 'v1/utils/S3signedUploadURL';
40
+ export const SEARCHADDRESS = 'v1/addresses/search?key=';
17
41
 
18
42
  export const HOME = 'products/v1/home';
19
- export const CATEGORY = 'v1/categories?parent=0&type=';
20
- export const ATTRIBUTE= 'v1/attributes/?type=';
43
+ export const ORDERS = 'products/v1/orders';
44
+
45
+ export const CART = 'products/v1/cart';
46
+ export const CHECKOUT = '/checkout';
47
+ export const STATUS = '/status';
48
+ export const REVIEW = '/v1/reviews';
49
+
50
+
51
+ export const COLLECTIONS = '/v1/collections';
52
+ export const PROMO = '/v1/promos';
53
+ export const TRANSACTIONS = '/v1/transactions';
54
+ export const EARNINGS = '/v1/earnings';
55
+
56
+
21
57
 
@@ -0,0 +1,24 @@
1
+ import { CONFIG, LOGIN } from "../Constants/PathConstant.js"
2
+
3
+ export var APIS = {
4
+ config:'config',
5
+ login: 'login',
6
+ }
7
+
8
+ export function apiType(type = APIS) {
9
+ switch(type) {
10
+ case APIS.config:return CONFIG;
11
+ case APIS.login:return LOGIN;
12
+ }
13
+ }
14
+ export var UserParameter = {data:''}
15
+ export var Parameter = {
16
+ bodyParam:'',
17
+ data:'',
18
+ id:'',
19
+ listingId:'',
20
+ auth:String,
21
+ isFollowing:Boolean,
22
+ isBlocked:Boolean,
23
+ isLiked:Boolean,
24
+ }
@@ -0,0 +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
+ }
9
+ export default Serialization;
@@ -2,33 +2,65 @@
2
2
 
3
3
  import {to} from 'await-to-js';
4
4
  import axios from 'axios';
5
- import { BTOKEN } from '../Constants/AppConstant.js';
6
- import {BASEURL} from './../Constants/PathConstant.js'
5
+ import { APPCONSTANT} from '../Constants/AppConstant.js';
6
+ import {BASEURL} from '../Constants/PathConstant.js'
7
7
 
8
8
  var header = {
9
9
  'Accept': 'application/json',
10
10
  'Content-Type': 'application/json',
11
11
  'x-agent': 1,
12
12
  }
13
+ export const Method = {
14
+ GET :'GET',
15
+ DELETE:'DELETE',
16
+ POST: 'POST',
17
+ PUT: 'PUT',
18
+ PATCH:'PATCH',
19
+ }
20
+
21
+ export var TradlyConfig = {
22
+ path:'',
23
+ method:Method,
24
+ param:'',
25
+ authKey:'',
26
+ refreshKey:'',
27
+ }
28
+
13
29
  class NetworkManager {
14
- networkCall = async (path,method, params,authkey, refreshKey) => {
30
+ networkCall = async (config = TradlyConfig) => {
15
31
  var BaseURL = BASEURL;
16
- var url = BaseURL + path;
17
- header['Authorization'] = "Bearer " + BTOKEN.token;
18
- if (authkey != undefined) {
19
- header['x-auth-key'] = authkey;
32
+ var url = BaseURL + config.path;
33
+ header['Authorization'] = "Bearer " + APPCONSTANT.TOKEN;
34
+ header['x-currency'] = APPCONSTANT.CURRENCY;
35
+ if (config.authKey != undefined || config.authKey == '') {
36
+ header['x-auth-key'] = config.authKey;
20
37
  }
21
- if (refreshKey != undefined) {
22
- header['X-Refresh-Key'] = refreshKey;
38
+ if (config.refreshKey != undefined || config.refreshKey == '') {
39
+ header['X-Refresh-Key'] = config.refreshKey;
23
40
  }
24
- const [err,response] = await to(axios({url:url,method:method,responseType:'json',headers:header,data:params}))
41
+ console.log('header',header )
42
+ console.log('config',config )
43
+ console.log('param.param',config.param )
44
+
45
+ console.log('config.authkey',config.authKey )
46
+
47
+ const [err,response] = await to(axios({url:url,method:config.method,responseType:'json',headers:header,data:config.param}))
25
48
  if (err) {
26
- let errData = err['response']['data'];
49
+ let errData = err['response']['data'];
27
50
  return [errData, undefined];
28
51
  } else {
29
- return [undefined, response['data']];
52
+ console.log('fddf ===> ',response['data']);
53
+ return [undefined, response['data']];
54
+ }
55
+ }
56
+ async uploadImage(signedUrl, mime, blob_body) {
57
+ const [err, response] = await to(axios({url:signedUrl,method:'put',headers:{'Content-Type': mime},data:blob_body}))
58
+ if (err) {
59
+ return false;
60
+ } else {
61
+ return true;
30
62
  }
31
63
  }
32
64
  }
33
65
  const network = new NetworkManager();
34
- export default network;
66
+ export default network;
package/Roots/App.js CHANGED
@@ -1,29 +1,483 @@
1
1
 
2
- import network from "./../NetworkManager/NetworkManager.js"
3
- import {ATTRIBUTE, CATEGORY, DEVICES, HOME, LOGIN, REGISTER,VERIFY} from './../Constants/PathConstant.js'
2
+ import network, { Method } from "./../NetworkManager/NetworkManager.js"
3
+ import {
4
+ ACCOUNTS, ATTRIBUTE,DEVICES, REPORT,
5
+ CATEGORY, CURRENCY, HOME,USERS, BLOCK,
6
+ LANGUAGES, LIKE, LISTINGS, ORDERS,REVIEW,
7
+ PAYMENTSMETHODS,ADDRESS, FOLLOW, COLLECTIONS, PROMO,
8
+ SHIPPINGMETHOD, VARIANTS,CART, CHECKOUT,
9
+ VALUES, TRANSACTIONS, EARNINGS, VARIANTTYPES,
10
+ } from './../Constants/PathConstant.js'
11
+ import serialization from "../Helper/Serialization.js";
4
12
 
5
13
  class App {
6
- async home() {
7
- try {
8
- const [error,responseJson] = await network.networkCall(HOME, 'GET');
9
- if (error) { return error}
10
- else { return responseJson}
11
- } catch (error) { return error}
14
+ async updateDeviceInfo(param = {data,authKey}) {
15
+ try { const [error,responseJson] = await network.networkCall({path:DEVICES,method:Method.POST,param:param.data,authKey:param.authKey});
16
+ if (error) { return error;
17
+ } else { return responseJson}
18
+ } catch (error) {return error}
12
19
  }
13
- async getCategory(type) {
14
- try {
15
- const [error,responseJson] = await network.networkCall(CATEGORY + type, 'GET');
20
+ async updateUserInfo(param = {data,authKey}) {
21
+ try { const [error,responseJson] = await network.networkCall({path:USERS,method:Method.POST,param:param.data,authKey:param.authKey});
22
+ if (error) { return error;
23
+ } else { return responseJson}
24
+ } catch (error) {return error}
25
+ }
26
+ async home(param = {authKey}) {
27
+ try { const [error, responseJson] = await network.networkCall({path:HOME,method:Method.GET,authKey:param.authKey});
28
+ if (error) { return error }
29
+ else { return responseJson }
30
+ } catch (error) { return error }
31
+ }
32
+ async getLanguages(param = {authKey}) {
33
+ try { const [error, responseJson] = await network.networkCall({path:LANGUAGES,method:Method.GET,authKey:param.authKey});
34
+ if (error) { return error }
35
+ else { return responseJson }
36
+ } catch (error) { return error }
37
+ }
38
+ //MARK:-  ADDRESS APIS 
39
+ async addEditAddress(param = {id,data,authKey}) {
40
+ let path = param.id == undefined || param.id == '' ? ADDRESS : ADDRESS + `/${param.id}`
41
+ let method = param.id == undefined || param.id == '' ? Method.POST : Method.PUT;
42
+ try { const [error, responseJson] = await network.networkCall({path:path,method:method,param:param.data,authKey:param.authKey})
43
+ if (error) { return error }
44
+ else { return responseJson }
45
+ } catch (error) { return error }
46
+ }
47
+ async getAddress(param={bodyParam,authKey}) {
48
+ let url = param.bodyParam == undefined || param.bodyParam == '' ? '' : `?${serialization(param.bodyParam)}`;
49
+ try { const [error, responseJson] = await network.networkCall({path:ADDRESS + url,method:Method.GET,authKey:param.authKey});
50
+ if (error) { return error }
51
+ else { return responseJson }
52
+ } catch (error) { return error }
53
+ }
54
+ async deleteAddress(param={id,authKey}) {
55
+ try { const [error, responseJson] = await network.networkCall({path:ADDRESS + `/${param.id}`,method:Method.DELETE,authKey:param.authKey});
56
+ if (error) { return error }
57
+ else { return responseJson }
58
+ } catch (error) { return error }
59
+ }
60
+ //MARK:-  ACCOUNTS APIS 
61
+ async getAccounts(param={bodyParam,authKey}) {
62
+ let url = `?${serialization(param.bodyParam)}`;
63
+ try { const [error, responseJson] = await network.networkCall({path:ACCOUNTS + `${url}`,method:Method.GET,authKey:param.authKey});
64
+ if (error) { return error }
65
+ else { return responseJson }
66
+ } catch (error) { return error }
67
+ }
68
+ async getAccountDetail(param={id,authKey}) {
69
+ try { const [error, responseJson] = await network.networkCall({path:ACCOUNTS + `${param.id}`,method:Method.GET,authKey:param.authKey});
70
+ if (error) { return error }
71
+ else { return responseJson }
72
+ } catch (error) { return error }
73
+ }
74
+ async postAccounts(param={id,authKey,data}) {
75
+ let method = param.id == undefined || param.id == '' ? Method.POST : Method.PATCH
76
+ let path = param.id == undefined || param.id == '' ? ACCOUNTS : ACCOUNTS + `/${param.id}`
77
+ try { const [error, responseJson] = await network.networkCall({path:path,method:method,authKey:param.authKey,param:param.data});
78
+ if (error) { return error }
79
+ else { return responseJson }
80
+ } catch (error) { return error }
81
+ }
82
+ async followUnfollowAccounts(param={id,authKey,isFollowing:Boolean}) {
83
+ let method = param.isFollowing ? Method.DELETE : Method.POST
84
+ let path = ACCOUNTS + `/${param.id}` + FOLLOW
85
+ try { const [error, responseJson] = await network.networkCall({path:path,method:method,authKey:param.authKey});
86
+ if (error) { return error }
87
+ else { return responseJson }
88
+ } catch (error) { return error }
89
+ }
90
+ async blockAccount(param={id,authKey,isBlocked:Boolean}) {
91
+ let method = param.isBlocked ? Method.DELETE : Method.POST
92
+ let path = ACCOUNTS + `/${param.id}` + BLOCK
93
+ try { const [error, responseJson] = await network.networkCall({path:path,method:method,authKey:param.authKey});
94
+ if (error) { return error }
95
+ else { return responseJson }
96
+ } catch (error) { return error }
97
+ }
98
+ async blockAccount(param={id,authKey,data}) {
99
+ let method = Method.POST
100
+ let path = ACCOUNTS + `/${param.id}` + REPORT
101
+ try { const [error, responseJson] = await network.networkCall({path:path,method:method,authKey:param.authKey,param:param.data});
102
+ if (error) { return error }
103
+ else { return responseJson }
104
+ } catch (error) { return error }
105
+ }
106
+ //MARK:-  LISTINGS API 
107
+ async getListings(param={bodyParam,authKey}) {
108
+ let url = param.bodyParam == undefined || param.bodyParam == '' ? '' : `?${serialization(param.bodyParam)}`;
109
+ try { const [error, responseJson] = await network.networkCall({path:LISTINGS + url,method:Method.GET,authKey:param.authKey});
110
+ if (error) { return error }
111
+ else { return responseJson }
112
+ } catch (error) { return error }
113
+ }
114
+ async getListingDetail(param={id,authKey}) {
115
+ try { const [error, responseJson] = await network.networkCall({path:LISTINGS + `/${param.id}`,method:Method.GET,authKey:param.authKey});
116
+ if (error) { return error }
117
+ else { return responseJson }
118
+ } catch (error) { return error }
119
+ }
120
+ async deleteListing(param={id,authKey}) {
121
+ try { const [error, responseJson] = await network.networkCall({path:LISTINGS + `/${param.id}`,method:Method.DELETE,authKey:param.authKey});
122
+ if (error) { return error }
123
+ else { return responseJson }
124
+ } catch (error) { return error }
125
+ }
126
+ async postListing(param={id,authKey,data}) {
127
+ let method = param.id == undefined || param.id == '' ? Method.POST : Method.PATCH
128
+ let path = param.id == undefined || param.id == '' ? LISTINGS : LISTINGS + `/${param.id}`
129
+ try { const [error, responseJson] = await network.networkCall({path:path,method:method,authKey:param.authKey,param:param.data});
130
+ if (error) { return error }
131
+ else { return responseJson }
132
+ } catch (error) { return error }
133
+ }
134
+ async likeListing(param={id,authKey,isLiked:Boolean}) {
135
+ let method = param.isLiked ? Method.DELETE : Method.POST
136
+ let path = LISTINGS + `/${param.id}` + LIKE
137
+ try { const [error, responseJson] = await network.networkCall({path:path,method:method,authKey:param.authKey});
16
138
  if (error) { return error }
17
139
  else { return responseJson }
18
- } catch (error) { return error}
140
+ } catch (error) { return error }
19
141
  }
20
- async getAttribute(type) {
21
- try {
22
- const [error,responseJson] = await network.networkCall(ATTRIBUTE + type, 'GET');
23
- if (error) { return error}
142
+ async getVariants(param={authKey:''}) {
143
+ try { const [error, responseJson] = await network.networkCall({path:VARIANTS,method:Method.GET,authKey:param.authKey});
144
+ if (error) { return error }
145
+ else { return responseJson }
146
+ } catch (error) { return error }
147
+ }
148
+ async addEditVariants(param={authKey:'',listingId:'',id:'',data:{}}) {
149
+ let method = param.id == undefined || param.id == '' ? Method.POST : Method.PUT
150
+ let path = param.id == undefined || param.id == '' ? LISTINGS + `/${param.listingId}/` + VARIANTS : LISTINGS + `/${param.listingId}/` + VARIANTS + `/${param.id}`
151
+ try { const [error, responseJson] = await network.networkCall({path:path,method:method,param:param.data,authKey:param.authKey});
152
+ if (error) { return error }
153
+ else { return responseJson }
154
+ } catch (error) { return error }
155
+ }
156
+ async deleteVariant(param={id:'',listingId:'',authKey:''}) {
157
+ let url = LISTINGS + `/${param.listingId}/` + VARIANTS + `/${param.id}`
158
+ try { const [error, responseJson] = await network.networkCall({path:url,method:Method.DELETE,authKey:param.authKey});
159
+ if (error) { return error }
160
+ else { return responseJson }
161
+ } catch (error) { return error }
162
+ }
163
+ //MARK:-  Variant Types 
164
+ async getVariantTypes(param={authKey:''}) {
165
+ try { const [error, responseJson] = await network.networkCall({path:VARIANTTYPES,method:Method.GET,authKey:param.authKey});
166
+ if (error) { return error }
167
+ else { return responseJson }
168
+ } catch (error) { return error }
169
+ }
170
+ async addEditVariantsTypes(param={authKey:'',id:'',data:{}}) {
171
+ let method = param.id == undefined || param.id == '' ? Method.POST : Method.PUT
172
+ let path = param.id == undefined || param.id == '' ? VARIANTTYPES : VARIANTTYPES + `/${param.id}/`
173
+ try { const [error, responseJson] = await network.networkCall({path:path,method:method,param:param.data,authKey:param.authKey});
174
+ if (error) { return error }
175
+ else { return responseJson }
176
+ } catch (error) { return error }
177
+ }
178
+ async deleteVariantType(param={id:'',authKey:''}) {
179
+ let url = VARIANTTYPES + `/${param.id}`
180
+ try { const [error, responseJson] = await network.networkCall({path:url,method:Method.DELETE,authKey:param.authKey});
181
+ if (error) { return error }
182
+ else { return responseJson }
183
+ } catch (error) { return error }
184
+ }
185
+ //MARK:-  Variant Types Values 
186
+ async getVariantTypeValues(param = {id:'',authKey:''}) {
187
+ let url = VARIANTTYPES + `/${param.id}` + VALUES;
188
+ try { const [error, responseJson] = await network.networkCall({path:url,method:Method.GET,authKey:param.authKey});
189
+ if (error) { return error }
190
+ else { return responseJson }
191
+ } catch (error) { return error }
192
+ }
193
+ async getVariantTypeValuesDetail(param = { id: '', valueID: '', authKey: '' }) {
194
+ let url = VARIANTTYPES + `/${param.id}` + VALUES + `/${param.valueID}`;
195
+ try { const [error, responseJson] = await network.networkCall({path:url,method:Method.GET,authKey:param.authKey});
196
+ if (error) { return error }
197
+ else { return responseJson }
198
+ } catch (error) { return error }
199
+ }
200
+ async addEditVariantTypeValues(param = { id: '', valueID: '', data: {}, authKey: '' }) {
201
+ let path = param.id == undefined || param.id == '' ? VARIANTTYPES + `/${param.id}` + VALUES : VARIANTTYPES + `/${param.id}` + VALUES + `/${param.valueID}`
202
+ let method = param.id == undefined || param.id == '' ? Method.POST : Method.PUT;
203
+ try { const [error, responseJson] = await network.networkCall({path:path,method:method,param:param.data,authKey:param.authKey});
204
+ if (error) { return error }
205
+ else { return responseJson }
206
+ } catch (error) { return error }
207
+ }
208
+ async deleteVariantTypeValues(param = { id: '', authKey: '', valueID: '' }) {
209
+ let url = VARIANTTYPES + `/${param.id}` + VALUES + `/${param.valueID}`;
210
+ try { const [error, responseJson] = await network.networkCall({path:url,method:Method.DELETE,authKey:param.authKey});
211
+ if (error) { return error }
212
+ else { return responseJson }
213
+ } catch (error) { return error }
214
+ }
215
+ //MARK:-  CATEGORY APIS 
216
+ async getCategory(param = {bodyParam,authKey}) {
217
+ console.log('dsds', param.bodyParam);
218
+ let url = param.bodyParam == undefined || param.bodyParam == '' ? '' : `?${serialization(param.bodyParam)}`;
219
+ try { const [error, responseJson] = await network.networkCall({path:CATEGORY + url, method:Method.GET,authKey:param.authKey});
220
+ if (error) { return error }
221
+ else { return responseJson }
222
+ } catch (error) { return error }
223
+ }
224
+ async addEditCategory(param = {id:'',data:{},authKey:''}) {
225
+ let path = param.id == undefined || param.id == '' ? CATEGORY : CATEGORY + `/${param.id}`
226
+ let method = param.id == undefined || param.id == '' ? Method.POST : Method.PUT
227
+ try { const [error, responseJson] = await network.networkCall({path:path,method:method, param:param.data, authKey:param.authKey});
228
+ if (error) { return error }
229
+ else { return responseJson }
230
+ } catch (error) { return error }
231
+ }
232
+ async deleteCategory(param = {id:'',authKey:''}) {
233
+ try { const [error, responseJson] = await network.networkCall({path:CATEGORY + `/${param.id}`, method:Method.DELETE,authKey:param.authKey})
234
+ if (error) { return error }
235
+ else { return responseJson }
236
+ } catch (error) { return error }
237
+ }
238
+ //MARK:-  Attribute APIS 
239
+
240
+ async getAttribute(param = {bodyParam:{},authKey:''}) {
241
+ let url = param.bodyParam == undefined || param.bodyParam == '' ? '' : `?${serialization(param.bodyParam)}`;
242
+ try { const [error, responseJson] = await network.networkCall({path:ATTRIBUTE + url,method:Method.GET,authKey:param.authKey});
243
+ if (error) { return error }
244
+ else { return responseJson }
245
+ } catch (error) { return error }
246
+ }
247
+ async addEditAttribute(param = {id:'',data:{},authKey:''}) {
248
+ let path = param.id == undefined || param.id == '' ? ATTRIBUTE : ATTRIBUTE + `/${param.id}`
249
+ let method = param.id == undefined || param.id == '' ? Method.POST : Method.PUT;
250
+ try { const [error, responseJson] = await network.networkCall({path:path,method:method,param:param.data,authKey:param.authKey});
251
+ if (error) { return error }
252
+ else { return responseJson }
253
+ } catch (error) { return error }
254
+ }
255
+ async deleteAttribute(param = {id:'',authKey:''}) {
256
+ try { const [error, responseJson] = await network.networkCall({path:ATTRIBUTE + `/${param.id}`,method:Method.DELETE,authKey:param.authKey});
257
+ if (error) { return error }
258
+ else { return responseJson }
259
+ } catch (error) { return error }
260
+ }
261
+ //MARK:-  Values
262
+ async getAttributeValues(param = {id:'',authKey:''}) {
263
+ let url = ATTRIBUTE + `/${param.id}` + VALUES;
264
+ try { const [error, responseJson] = await network.networkCall({path:url,method:Method.GET,authKey:param.authKey});
265
+ if (error) { return error }
24
266
  else { return responseJson }
25
- } catch (error) { return error}
267
+ } catch (error) { return error }
268
+ }
269
+ async getAttributeValuesDetail(param = { id: '', valueID: '', authKey: '' }) {
270
+ let url = ATTRIBUTE + `/${param.id}` + VALUES + `/${param.valueID}`;
271
+ try { const [error, responseJson] = await network.networkCall({path:url,method:Method.GET,authKey:param.authKey});
272
+ if (error) { return error }
273
+ else { return responseJson }
274
+ } catch (error) { return error }
275
+ }
276
+ async addEditAttributeValues(param = { id: '', valueID: '', data: {}, authKey: '' }) {
277
+ let path = param.id == undefined || param.id == '' ? ATTRIBUTE + `/${param.id}` + VALUES : ATTRIBUTE + `/${param.id}` + VALUES + `/${param.valueID}`
278
+ let method = param.id == undefined || param.id == '' ? Method.POST : Method.PUT;
279
+ try { const [error, responseJson] = await network.networkCall({path:path,method:method,param:param.data,authKey:param.authKey});
280
+ if (error) { return error }
281
+ else { return responseJson }
282
+ } catch (error) { return error }
283
+ }
284
+ async deleteAttributeValues(param = { id: '', authKey: '', valueID: '' }) {
285
+ let url = ATTRIBUTE + `/${param.id}` + VALUES + `/${param.valueID}`;
286
+ try { const [error, responseJson] = await network.networkCall({path:url,method:Method.DELETE,authKey:param.authKey});
287
+ if (error) { return error }
288
+ else { return responseJson }
289
+ } catch (error) { return error }
290
+ }
291
+ //MARK:-  CART API 
292
+ async addToCart(param={authKey:'',data:{}}) {
293
+ try { const [error, responseJson] = await network.networkCall({path:CART,method:Method.POST,param:param.data,authKey:param.authKey});
294
+ if (error) { return error }
295
+ else { return responseJson }
296
+ } catch (error) { return error }
297
+ }
298
+ async deleteFromCart(param={authKey:'',data:{}}) {
299
+ try { const [error, responseJson] = await network.networkCall({path:CART,method:Method.PATCH,param:param.data,authKey:param.authKey});
300
+ if (error) { return error }
301
+ else { return responseJson }
302
+ } catch (error) { return error }
303
+ }
304
+ async getCarts(param={authKey:''}) {
305
+ try { const [error, responseJson] = await network.networkCall({path:CART,method:Method.GET,authKey:param.authKey});
306
+ if (error) {
307
+ return error
308
+ }
309
+ else { return responseJson }
310
+ } catch (error) { return error }
311
+ }
312
+ async deleteAllCartDetail(param={authKey}) {
313
+ try { const [error, responseJson] = await network.networkCall({path:CART,method:Method.DELETE,authKey:param.authKey});
314
+ if (error) { return error }
315
+ else { return responseJson }
316
+ } catch (error) { return error }
317
+ }
318
+
319
+ async checkout(param={authKey,data}) {
320
+ try { const [error, responseJson] = await network.networkCall({path:CART + CHECKOUT,method:Method.POST,authKey:param.authKey,param:param.data});
321
+ if (error) { return error }
322
+ else { return responseJson }
323
+ } catch (error) { return error }
324
+ }
325
+ async listingDirectCheckout(param={authKey,data,id}) {
326
+ try { const [error, responseJson] = await network.networkCall({path:LISTINGS + `/${param.id}` + CHECKOUT,method:Method.POST,authKey:param.authKey,param:param.data});
327
+ if (error) { return error }
328
+ else { return responseJson }
329
+ } catch (error) { return error }
330
+ }
331
+ //MARK:-  ORDERS API 
332
+
333
+ async getOrders(param={authKey,bodyParam}) {
334
+ let url = param.bodyParam == undefined || param.bodyParam == '' ? '' : `?${serialization(param.bodyParam)}`;
335
+ try { const [error, responseJson] = await network.networkCall({path:ORDERS + url,method:Method.GET,authKey:param.authKey});
336
+ if (error) { return error }
337
+ else { return responseJson }
338
+ } catch (error) { return error }
339
+ }
340
+ async getOrderDetail(param={authKey,id}) {
341
+ try { const [error, responseJson] = await network.networkCall({path:ORDERS + `/${param.id}`,method:Method.GET,authKey:param.authKey});
342
+ if (error) { return error }
343
+ else { return responseJson }
344
+ } catch (error) { return error }
345
+ }
346
+ async updateOrderStatus(param={authKey,id,data}) {
347
+ try { const [error, responseJson] = await network.networkCall({path:ORDERS + `/${param.id}` + STATUS,method:Method.PATCH,authKey:param.authKey,param:param.data});
348
+ if (error) { return error }
349
+ else { return responseJson }
350
+ } catch (error) { return error }
351
+ }
352
+ async updateOrderDetail(param={authKey,id,data}) {
353
+ try { const [error, responseJson] = await network.networkCall({path:ORDERS + `/${param.id}`,method:Method.PATCH,authKey:param.authKey,param:param.data});
354
+ if (error) { return error }
355
+ else { return responseJson }
356
+ } catch (error) { return error }
357
+ }
358
+ async getReviewList(param={authKey,bodyParam}) {
359
+ let url = param.bodyParam == undefined || param.bodyParam == '' ? '' : `?${serialization(param.bodyParam)}`;
360
+ try { const [error, responseJson] = await network.networkCall({path:REVIEW + url,method:Method.GET,authKey:param.authKey});
361
+ if (error) { return error }
362
+ else { return responseJson }
363
+ } catch (error) { return error }
364
+ }
365
+ async addReview(param={authKey,data}) {
366
+ try { const [error, responseJson] = await network.networkCall({path:REVIEW,method:Method.POST,authKey:param.authKey,param:param.data});
367
+ if (error) { return error }
368
+ else { return responseJson }
369
+ } catch (error) { return error }
370
+ }
371
+ async likeReview(param={authKey,data,id}) {
372
+ try { const [error, responseJson] = await network.networkCall({path:REVIEW + `/${param.id}` ,method:Method.PATCH,authKey:param.authKey,param:param.data});
373
+ if (error) { return error }
374
+ else { return responseJson }
375
+ } catch (error) { return error }
376
+ }
377
+ async getPaymentMethods(param={authKey}) {
378
+ try { const [error, responseJson] = await network.networkCall({path:PAYMENTSMETHODS ,method:Method.GET,authKey:param.authKey});
379
+ if (error) { return error }
380
+ else { return responseJson }
381
+ } catch (error) { return error }
382
+ }
383
+ async getShippingMethods(param={authKey}) {
384
+ try { const [error, responseJson] = await network.networkCall({path:SHIPPINGMETHOD ,method:Method.GET,authKey:param.authKey});
385
+ if (error) { return error }
386
+ else { return responseJson }
387
+ } catch (error) { return error }
388
+ }
389
+ //MARK:-  Currency 
390
+ async getCurrency(param={authKey}) {
391
+ try { const [error, responseJson] = await network.networkCall({path:CURRENCY,method:Method.GET,authKey:param.authKey})
392
+ if (error) { return error }
393
+ else { return responseJson }
394
+ } catch (error) { return error }
395
+ }
396
+ async addEditCurrency(param={id,authKey,data}) {
397
+ let method = param.id == undefined || param.id == '' ? Method.POST : Method.PUT
398
+ let path = param.id == undefined || param.id == '' ? CURRENCY : CURRENCY + `/${param.id}`
399
+ try { const [error, responseJson] = await network.networkCall({path:path,method:method,authKey:param.authKey,param:param.data});
400
+ if (error) { return error }
401
+ else { return responseJson }
402
+ } catch (error) { return error }
403
+ }
404
+ async deleteCurrency(param={id,authKey}) {
405
+ try { const [error, responseJson] = await network.networkCall({path:CURRENCY + `/${param.id}`,method:Method.DELETE,authKey:param.authKey});
406
+ if (error) { return error }
407
+ else { return responseJson }
408
+ } catch (error) { return error }
409
+ }
410
+ //MARK:-  Collections 
411
+ async getCollection(param={authKey}) {
412
+ try { const [error, responseJson] = await network.networkCall({path:COLLECTIONS,method:Method.GET,authKey:param.authKey})
413
+ if (error) { return error }
414
+ else { return responseJson }
415
+ } catch (error) { return error }
416
+ }
417
+ async getCollectionDetail(param={authKey,id}) {
418
+ try { const [error, responseJson] = await network.networkCall({path:COLLECTIONS + `/${param.id}`,method:Method.GET,authKey:param.authKey});
419
+ if (error) { return error }
420
+ else { return responseJson }
421
+ } catch (error) { return error }
422
+ }
423
+ async addEditCollection(param={id,authKey,data}) {
424
+ let method = param.id == undefined || param.id == '' ? Method.POST : Method.PUT
425
+ let path = param.id == undefined || param.id == '' ? COLLECTIONS : COLLECTIONS + `/${param.id}`
426
+ try { const [error, responseJson] = await network.networkCall({path:path,method:method,authKey:param.authKey,param:param.data});
427
+ if (error) { return error }
428
+ else { return responseJson }
429
+ } catch (error) { return error }
430
+ }
431
+ async deleteCollections(param={id,authKey}) {
432
+ try { const [error, responseJson] = await network.networkCall({path:COLLECTIONS + `/${param.id}`,method:Method.DELETE,authKey:param.authKey});
433
+ if (error) { return error }
434
+ else { return responseJson }
435
+ } catch (error) { return error }
436
+ }
437
+ //MARK:-  Promo banner 
438
+ async getPromoBanner(param={authKey,bodyParam}) {
439
+ let url = param.bodyParam == undefined || param.bodyParam == '' ? '' : `?${serialization(param.bodyParam)}`;
440
+ try { const [error, responseJson] = await network.networkCall({path:PROMO + url,method:Method.GET,authKey:param.authKey})
441
+ if (error) { return error }
442
+ else { return responseJson }
443
+ } catch (error) { return error }
444
+ }
445
+ async getPromoBanner(param={authKey,id}) {
446
+ try { const [error, responseJson] = await network.networkCall({path:PROMO + `/${param.id}`,method:Method.GET,authKey:param.authKey});
447
+ if (error) { return error }
448
+ else { return responseJson }
449
+ } catch (error) { return error }
450
+ }
451
+ async addPromoBanner(param={id,authKey,data}) {
452
+ let method = param.id == undefined || param.id == '' ? Method.POST : Method.PUT
453
+ let path = param.id == undefined || param.id == '' ? PROMO : PROMO + `/${param.id}`
454
+ try { const [error, responseJson] = await network.networkCall({path:path,method:method,authKey:param.authKey,param:param.data});
455
+ if (error) { return error }
456
+ else { return responseJson }
457
+ } catch (error) { return error }
458
+ }
459
+ async deletePromoBanner(param={id,authKey}) {
460
+ try { const [error, responseJson] = await network.networkCall({path:PROMO + `/${param.id}`,method:Method.DELETE,authKey:param.authKey});
461
+ if (error) { return error }
462
+ else { return responseJson }
463
+ } catch (error) { return error }
464
+ }
465
+ //MARK:-  Transaction 
466
+ async getTransactions(param={authKey,bodyParam}) {
467
+ let url = param.bodyParam == undefined || param.bodyParam == '' ? '' : `?${serialization(param.bodyParam)}`;
468
+ try { const [error, responseJson] = await network.networkCall({path:TRANSACTIONS + url,method:Method.GET,authKey:param.authKey});
469
+ if (error) { return error }
470
+ else { return responseJson }
471
+ } catch (error) { return error }
472
+ }
473
+ async getEarning(param={authKey,bodyParam}) {
474
+ let url = param.bodyParam == undefined || param.bodyParam == '' ? '' : `?${serialization(param.bodyParam)}`;
475
+ try { const [error, responseJson] = await network.networkCall({path:EARNINGS + url,method:Method.GET,authKey:param.authKey});
476
+ if (error) { return error }
477
+ else { return responseJson }
478
+ } catch (error) { return error }
26
479
  }
27
480
  }
28
481
  const app = new App();
29
- export default app;
482
+ export default app;
483
+
@@ -1,6 +1,6 @@
1
- import { BTOKEN } from "../Constants/AppConstant.js";
1
+ import { APPCONSTANT } from "../Constants/AppConstant.js";
2
2
  import { CONFIG, TENANTS, REFRESH, HOME } from "../Constants/PathConstant.js";
3
- import network from "./../NetworkManager/NetworkManager.js"
3
+ import network, { Method } from "./../NetworkManager/NetworkManager.js"
4
4
  import app from './App.js';
5
5
 
6
6
 
@@ -9,13 +9,13 @@ class InitializeSDK {
9
9
  async config(tenantKey) {
10
10
  let configs = TENANTS + tenantKey + CONFIG
11
11
  try {
12
- const [error,responseJson] = await network.networkCall(configs, 'GET')
12
+ const [error,responseJson] = await network.networkCall({path:configs,method:Method.GET})
13
13
  if (error) {return error
14
14
  }else {
15
15
  let keyD = responseJson['data']['key'];
16
16
  if(keyD['app_key']) {
17
- BTOKEN.token = keyD['app_key'];
18
- console.log('Success!!')
17
+ APPCONSTANT.TOKEN = keyD['app_key'];
18
+ console.log('Success!!')
19
19
  }
20
20
  return responseJson;
21
21
  }
@@ -23,7 +23,7 @@ class InitializeSDK {
23
23
  }
24
24
  async refreshAPI(refreshKey) {
25
25
  try {
26
- const [error,responseJson] = await network.networkCall(REFRESH, 'GET', undefined, undefined, refreshKey)
26
+ const [error,responseJson] = await network.networkCall({path:REFRESH,method:Method.GET,refreshKey:refreshKey})
27
27
  if (error) {
28
28
  return error;
29
29
  }else {
package/Roots/User.js CHANGED
@@ -1,42 +1,32 @@
1
1
 
2
- import network from "./../NetworkManager/NetworkManager.js"
3
- import {DEVICES, LOGIN, REGISTER,VERIFY} from './../Constants/PathConstant.js'
2
+ import network, { Method } from "./../NetworkManager/NetworkManager.js"
3
+ import {LOGIN, REGISTER,VERIFY} from './../Constants/PathConstant.js'
4
+ import { UserParameter } from "../Helper/APIParam.js";
4
5
 
5
6
  class User {
6
- async login(params, authkey) {
7
- try {
8
- const [error,responseJson] = await network.networkCall(LOGIN, 'POST', params, authkey);
7
+ async login(param = UserParameter) {
8
+ try { const [error,responseJson] = await network.networkCall({path:LOGIN,method:Method.POST,param:param.data});
9
9
  if (error) { return error
10
10
  } else { return responseJson}
11
11
  } catch (error) { return error}
12
12
  }
13
- async register(params, authkey) {
14
- try {
15
- const [error,responseJson] = await network.networkCall(REGISTER, 'POST', params, authkey);
13
+ async register(param = UserParameter) {
14
+ try { const [error,responseJson] = await network.networkCall({path:REGISTER,method:Method.POST,param:param.data});
16
15
  if (error) { return error} else { return responseJson }
17
16
  } catch (error) { return error }
18
17
  }
19
- async verify(params, authkey) {
20
- try {
21
- const [error,responseJson] = await network.networkCall(VERIFY, 'POST', params, authkey);
18
+ async verify(param = UserParameter) {
19
+ try { const [error,responseJson] = await network.networkCall({path:VERIFY,method:Method.POST,param:param.data});
22
20
  if (error) {return error
23
21
  } else { return responseJson }
24
22
  } catch (error) { return error}
25
23
  }
26
- async resendOTP(params, authkey) {
27
- try {
28
- const [error,responseJson] = await network.networkCall(REGISTER, 'POST', params, authkey);
24
+ async resendOTP(param = UserParameter) {
25
+ try { const [error,responseJson] = await network.networkCall({path:REGISTER,method:Method.POST,param:param.data});
29
26
  if (error) { return error
30
27
  } else { return responseJson}
31
28
  } catch (error) { return error}
32
29
  }
33
- async updateDeviceInfo(params, authkey) {
34
- try {
35
- const [error,responseJson] = await network.networkCall(DEVICES, 'POST', params, authkey);
36
- if (error) { return error;
37
- } else { return responseJson}
38
- } catch (error) {return error}
39
- }
40
30
  }
41
31
  const user = new User();
42
32
  export default user;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tradly",
3
- "version": "1.0.3",
3
+ "version": "1.0.7",
4
4
  "description": "Tradly JS SDK",
5
5
  "main": "index.js",
6
6
  "type": "module",