A thin JavaScript web service client that accesses the Mobiliser platform.
1 /**
2 * @fileOverview A thin JavaScript web service client that accesses the Mobiliser platform.
3 * It provides an abstraction layer to communicate with the system and returns
4 * XML documents as a result.
5 *
6 * @name SY_Mobiliser.js
7 * @author SAP AG
8 * @version 1.0
9 *
10 */
11
12 /**
13 @class A thin JavaScript web service client that accesses the Mobiliser platform. It provides an abstraction layer to communicate with the system and returns XML documents as a result.
14
15 @constructor
16
17 */
18 function MobiliserClient() {
19 this.url = setting.protocol + setting.ipaddress;
20
21 if(setting.port)
22 this.url += ":" + setting.port;
23
24 // it's used by file upload/download
25 smartphoneService.urlWithoutWS = this.url;
26
27 if(typeof setting.wsname !== 'undefined')
28 this.url += "/" + setting.wsname;
29
30 smartphoneService.url = this.url;
31 this.network_access = true;
32 }
33
34 /* web service calls */
35
36 /**
37 @description Agent login function
38 @param responseBack Indicates which function to be called when a response is received.
39 @param username The username should normally be the msisdn in addition to its country code i.e. +18881234567
40 @param password The user password
41 @example
42 var loginBack = function(r, xmlResponse) { ... // handle response };
43 mc.login(loginBack, "user1", "pass2");
44 */
45 MobiliserClient.prototype.login = function(responseBack, username, password, authtype) {
46 //TODO : optimize and reuse for each call ?
47 var pl = new Object();
48 pl.origin = setting.origin;
49 pl.traceNo = UUIDv4();
50 pl.AuditData = setting.appinfo;
51
52 pl.identification = username;
53 pl.credential = password;
54 if (authtype == '0') {
55 pl.identificationType = 5;
56 pl.credentialType = 1;
57 } else {
58 pl.identificationType = 0;
59 pl.credentialType = 0;
60 }
61
62 smartphoneService.post(pl, "loginCustomer", responseBack);
63 };
64
65 /**
66 @description Agent security login function
67 @param responseBack Indicates which function to be called when a response is received.
68 */
69 MobiliserClient.prototype.fbssoLogin = function(responseBack, accessToken) {
70 var pl = new Object();
71 pl.origin = setting.origin;
72 pl.traceNo = UUIDv4();
73 pl.AuditData = setting.appinfo;
74
75 smartphoneService.post(pl, "whoami" + "?create_mobiliser_remember_me=yes&facebook_code="+accessToken, responseBack);
76 };
77
78 /**
79 @description Agent request RSA public key from end point
80 @param responseBack Indicates which function to be called when a response is received.
81 @param type Specifies account type ("bank" or "card")
82 */
83 MobiliserClient.prototype.getRsaPublicKey = function(responseBack, type) {
84 var pl = new Object();
85
86 pl.origin = setting.origin;
87 pl.traceNo = UUIDv4();
88 pl.AuditData = setting.appinfo;
89 type = (!type || "card" !== type ? "bank" : "card");
90 session.keyType = type;
91 pl.keyName = ("bank" === type ? "mobiliser_bank" : "mobiliser_card");
92
93 smartphoneService.post(pl, "getRsaPublicKey", responseBack);
94 };
95
96 /**
97 @description Agent logout function
98 @param responseBack Indicates which function to be called when a response is received.
99 */
100 MobiliserClient.prototype.logout = function(responseBack) {
101 var pl = new Object();
102 pl.origin = setting.origin;
103 pl.traceNo = UUIDv4();
104 pl.AuditData = setting.appinfo;
105 pl.sessionId = session.sessionId;
106
107 smartphoneService.post(pl, "logout", responseBack);
108 };
109
110 /**
111 @description Agent create sms token function
112 @param responseBack Indicates which function to be called when a response is received.
113 */
114 MobiliserClient.prototype.createSmsToken = function(responseBack, phoneno) {
115 var pl = new Object();
116 pl.origin = setting.origin;
117 pl.traceNo = UUIDv4();
118 pl.AuditData = setting.appinfo;
119 pl.msisdn = phoneno;
120 pl.language = "en";
121
122 smartphoneService.user = null;
123 smartphoneService.pass = null;
124 smartphoneService.post(pl, "createSmsToken", responseBack);
125 };
126
127 /**
128 @description Agent create full customer function
129 @param responseBack Indicates which function to be called when a response is received.
130 */
131 MobiliserClient.prototype.createFullCustomer = function(responseBack, reginfo, token) {
132 var pl_customer = new Object();
133 pl_customer.orgUnitId = "0000";
134 pl_customer.blackListReason = "0";
135 pl_customer.active = "true";
136 pl_customer.test = "false";
137 pl_customer.displayName = reginfo.FirstName + " " + reginfo.LastName;
138 pl_customer.riskCategoryId = "0";
139 pl_customer.customerTypeId = reginfo.CustomerType;
140 pl_customer.cancellationReasonId = "0";
141 pl_customer.txnReceiptModeId = "3";
142 pl_customer.language = "en";
143 pl_customer.country = "US";
144
145 var pl_ident1 = new Object();
146 pl_ident1.type = "0";
147 pl_ident1.identification = reginfo.Phoneno;
148 if (reginfo.CustomerType == "102")
149 pl_ident1.provider = reginfo.Provider;
150
151 var pl_ident2 = new Object();
152 pl_ident2.type = "5";
153 pl_ident2.identification = reginfo.usrname;
154
155 var pl_cred1 = new Object();
156 pl_cred1.type = "0";
157 pl_cred1.credential = reginfo.Pin;
158
159 var pl_cred2 = new Object();
160 pl_cred2.type = "1";
161 pl_cred2.credential = reginfo.Password;
162
163 var pl_addr = new Object();
164 pl_addr.addressType = "0";
165 pl_addr.addressStatus = "0";
166 pl_addr.firstName = reginfo.FirstName;
167 pl_addr.lastName = reginfo.LastName;
168 pl_addr.email = reginfo.Email;
169
170 var pl = new Object();
171 pl.origin = setting.origin;
172 pl.traceNo = UUIDv4();
173 pl.AuditData = setting.appinfo;
174 pl.customer = pl_customer;
175 pl.identifications = [ pl_ident1, pl_ident2 ];
176 pl.credentials = [ pl_cred1, pl_cred2 ];
177 pl.addresses = [ pl_addr ];
178 pl.smsToken = token;
179 pl.acceptedTncVersionIds = reginfo.acceptedTncVersionIds;
180
181 if (reginfo.CustomerType == "102") {
182 var mbankingService = {};
183 jQuery.extend(mbankingService, smartphoneService);
184 mbankingService.url = mc.mburl();
185 mbankingService.post(pl, "createFullCustomer", responseBack);
186 } else
187 smartphoneService.post(pl, "createFullCustomer", responseBack);
188 };
189
190 /**
191 @description Agent update customer function
192 @param responseBack Indicates which function to be called when a response is received.
193 */
194 MobiliserClient.prototype.updateCustomerNotification = function(responseBack, mode) {
195 var pl_customer = new Object();
196 pl_customer.id = session.customer.id;
197 pl_customer.orgUnitId = session.customer.orgUnitId;
198 pl_customer.blackListReason = session.customer.blackListReason;
199 pl_customer.active = session.customer.active;
200 pl_customer.test = session.customer.test;
201 pl_customer.displayName = session.customer.displayName;
202 pl_customer.riskCategoryId = session.customer.riskCategoryId;
203 pl_customer.customerTypeId = session.customer.customerTypeId;
204 pl_customer.cancellationReasonId = session.customer.cancellationReasonId;
205 pl_customer.txnReceiptModeId = mode;
206
207 var pl = new Object();
208 pl.origin = setting.origin;
209 pl.traceNo = UUIDv4();
210 pl.AuditData = setting.appinfo;
211 pl.customer = pl_customer;
212
213 smartphoneService.post(pl, "updateCustomer", responseBack);
214 };
215
216 /**
217 @description Agent update customer function
218 @param responseBack Indicates which function to be called when a response is received.
219 */
220 MobiliserClient.prototype.updateCustomerBlockAccount = function(responseBack) {
221 var pl_customer = new Object();
222 pl_customer.id = session.customer.id;
223 pl_customer.orgUnitId = session.customer.orgUnitId;
224 pl_customer.blackListReason = "2";
225 pl_customer.active = session.customer.active;
226 pl_customer.test = session.customer.test;
227 pl_customer.displayName = session.customer.displayName;
228 pl_customer.riskCategoryId = session.customer.riskCategoryId;
229 pl_customer.customerTypeId = session.customer.customerTypeId;
230 pl_customer.cancellationReasonId = session.customer.cancellationReasonId;
231 pl_customer.txnReceiptModeId = session.customer.txnReceiptModeId;
232
233 var pl = new Object();
234 pl.origin = setting.origin;
235 pl.traceNo = UUIDv4();
236 pl.AuditData = setting.appinfo;
237 pl.customer = pl_customer;
238
239 smartphoneService.post(pl, "updateCustomer", responseBack);
240 };
241
242 /**
243 @description Agent create identification function
244 @param responseBack Indicates which function to be called when a response is received.
245 */
246 MobiliserClient.prototype.createIdentification = function(responseBack, customerId, type, identification) {
247 var pl_ident = new Object();
248 pl_ident.customerId = customerId;
249 pl_ident.type = type;
250 pl_ident.identification = identification;
251
252 var pl = new Object();
253 pl.origin = setting.origin;
254 pl.traceNo = UUIDv4();
255 pl.AuditData = setting.appinfo;
256 pl.identification = pl_ident;
257
258 smartphoneService.post(pl, "createIdentification", responseBack);
259 };
260
261 /**
262 @description Agent get identifications function
263 @param responseBack Indicates which function to be called when a response is received.
264 */
265 MobiliserClient.prototype.getIdentifications = function(responseBack, customerId, type) {
266 var pl = new Object();
267 pl.origin = setting.origin;
268 pl.traceNo = UUIDv4();
269 pl.AuditData = setting.appinfo;
270 pl.customerId = customerId;
271 pl.identificationTypeId = type;
272
273 smartphoneService.post(pl, "getIdentifications", responseBack);
274 };
275
276 /**
277 @description setCredential function
278 @param responseBack Indicates which function to be called when a response is received.
279 @param customerId The customer id of the user
280 @param Credential The PIN or Password to set
281 @param type The type of Credential
282 */
283 MobiliserClient.prototype.setCredential = function(responseBack, Credential, type) {
284 var pl = new Object();
285 pl.origin = setting.origin;
286 pl.traceNo = UUIDv4();
287 pl.AuditData = setting.appinfo;
288 pl.customerId = session.customer.id;
289 pl.credential = Credential;
290 pl.credentialType = type;
291
292 smartphoneService.post(pl, "setCredential", responseBack);
293 };
294
295 /**
296 @description Change Credential function
297 @param responseBack Indicates which function to be called when a response is received.
298 @param customerId The customer id of the user
299 @param oldCredential The old Credential
300 @param newCredential The new Credential chosen by the user
301 */
302 MobiliserClient.prototype.changeCredential = function(responseBack, oldCredential, newCredential, type) {
303 var pl = new Object();
304 pl.origin = setting.origin;
305 pl.traceNo = UUIDv4();
306 pl.AuditData = setting.appinfo;
307 pl.customerId = session.customer.id;
308 pl.oldCredential = oldCredential;
309 pl.newCredential = newCredential;
310 pl.credentialType = type;
311
312 smartphoneService.post(pl, "changeCredential", responseBack);
313 };
314
315 /**
316 @description checkCredential function
317 @param responseBack Indicates which function to be called when a response is received.
318 @param Credential The PIN or Password to set
319 @param type The type of Credential
320 */
321 MobiliserClient.prototype.checkCredential = function(responseBack, Credential, type) {
322 var pl = new Object();
323 pl.origin = setting.origin;
324 pl.traceNo = UUIDv4();
325 pl.AuditData = setting.appinfo;
326 pl.customerId = session.customer.id;
327 pl.credential = Credential;
328 pl.credentialType = type;
329
330 smartphoneService.post(pl, "checkCredential", responseBack);
331 };
332
333 /**
334 @description A function to query all of the payment instruments in the customer's mobile wallet
335 @param responseBack Indicates which function to be called when a response is received.
336 @param customerId The customer id of the user
337 */
338 MobiliserClient.prototype.getWallet = function(responseBack, customerId) {
339 var pl = new Object();
340 pl.origin = setting.origin;
341 pl.traceNo = UUIDv4();
342 pl.AuditData = setting.appinfo;
343 pl.customerId = customerId;
344
345 smartphoneService.post(pl, "getWalletEntriesByCustomer", responseBack);
346 };
347
348 /**
349 @description A function to get balance of SVA
350 @param responseBack Indicates which function to be called when a response is received.
351 */
352 MobiliserClient.prototype.balanceInquiry = function(responseBack, piid) {
353 var pl = new Object();
354 pl.origin = setting.origin;
355 pl.traceNo = UUIDv4();
356 pl.AuditData = setting.appinfo;
357 pl.paymentInstrumentId = piid;
358
359 smartphoneService.post(pl, "getPaymentInstrumentBalance", responseBack);
360 };
361
362 /**
363 @description A function to create a wallet entry with paymentInstrument in the customer's mobile wallet
364 @param responseBack Indicates which function to be called when a response is received.
365 */
366 MobiliserClient.prototype.createWalletEntry = function(responseBack, paymentInstrument,
367 paymentInstrumentType, nickname) {
368 var pl_pI = new Object();
369 pl_pI.pseudo_type = paymentInstrumentType == "bankAccount" ? "BankAccount" : "CreditCard";
370 pl_pI.customerId = session.customer.id;
371 pl_pI.active = "true";
372 pl_pI.status = "0";
373 pl_pI.currency = "EUR";
374 pl_pI.multiCurrency = "false";
375 for(var p in paymentInstrument)
376 pl_pI[p] = paymentInstrument[p];
377
378 var pl_entry = new Object();
379 pl_entry.customerId = session.customer.id;
380 pl_entry.debitPriority = "1";
381 pl_entry.creditPriority = "1";
382 pl_entry.alias = nickname;
383 pl_entry[paymentInstrumentType] = pl_pI;
384
385 var pl = new Object();
386 pl.origin = setting.origin;
387 pl.traceNo = UUIDv4();
388 pl.AuditData = setting.appinfo;
389 pl.walletEntry = pl_entry;
390 pl.primaryDebit = "true";
391 pl.primaryCredit = "true";
392
393 smartphoneService.post(pl, "createWalletEntry", responseBack);
394 };
395
396 /**
397 @description A function to update a wallet entry in the customer's mobile wallet
398 @param responseBack Indicates which function to be called when a response is received.
399 */
400 MobiliserClient.prototype.updateWalletEntry = function(responseBack, nickname, acctid) {
401 var pl_entry = new Object();
402 pl_entry.id = session.accounts[acctid].walletId;
403 pl_entry.customerId = session.customer.id;
404 pl_entry.paymentInstrumentId = session.accounts[acctid].pIId;
405 pl_entry.alias = nickname;
406
407 var pl = new Object();
408 pl.origin = setting.origin;
409 pl.traceNo = UUIDv4();
410 pl.AuditData = setting.appinfo;
411 pl.walletEntry = pl_entry;
412
413 smartphoneService.post(pl, "updateWalletEntry", responseBack);
414 };
415
416 /**
417 @description A function to set primary wallet in the customer's mobile wallet
418 @param responseBack Indicates which function to be called when a response is received.
419 */
420 MobiliserClient.prototype.setPrimary = function(responseBack, acctid) {
421 var pl_entry = new Object();
422 pl_entry.id = session.accounts[acctid].walletId;
423 pl_entry.customerId = session.customer.id;
424 pl_entry.paymentInstrumentId = session.accounts[acctid].pIId;
425 pl_entry.alias = session.accounts[acctid].info;
426
427 var pl = new Object();
428 pl.origin = setting.origin;
429 pl.traceNo = UUIDv4();
430 pl.AuditData = setting.appinfo;
431 pl.walletEntry = pl_entry;
432 pl.primaryDebit = "true";
433 pl.primaryCredit = "true";
434
435 smartphoneService.post(pl, "updateWalletEntry", responseBack);
436 };
437
438 /**
439 @description A function to update a paymentInstrument of a wallet entry in the customer's mobile wallet
440 @param responseBack Indicates which function to be called when a response is received.
441 */
442 MobiliserClient.prototype.updatePaymentInstrument = function(responseBack, paymentInstrument,
443 paymentInstrumentType, acctid) {
444 var pl_pI = new Object();
445 pl_pI.pseudo_type = paymentInstrumentType;
446 pl_pI.id = session.accounts[acctid].pIId;
447 pl_pI.customerId = session.customer.id;
448 pl_pI.active = "true";
449 pl_pI.status = "0";
450 pl_pI.currency = "EUR";
451 pl_pI.multiCurrency = "false";
452 for(var p in paymentInstrument)
453 pl_pI[p] = paymentInstrument[p];
454
455 var pl = new Object();
456 pl.origin = setting.origin;
457 pl.traceNo = UUIDv4();
458 pl.AuditData = setting.appinfo;
459 pl.PaymentInstrument = pl_pI;
460
461 smartphoneService.post(pl, "updatePaymentInstrument", responseBack);
462 };
463
464 /**
465 @description A function to create a wallet entry with paymentInstrument in the customer's mobile wallet
466 @param responseBack Indicates which function to be called when a response is received.
467 */
468 MobiliserClient.prototype.deleteWalletEntry = function(responseBack, acctid) {
469 var pl = new Object();
470 pl.origin = setting.origin;
471 pl.traceNo = UUIDv4();
472 pl.AuditData = setting.appinfo;
473 pl.walletEntryId = session.accounts[acctid].walletId;
474
475 session.accountPiIdForDeletion = session.accounts[acctid].pIId;
476 smartphoneService.post(pl, "deleteWalletEntry", responseBack);
477 };
478
479 /**
480 @description Get transaction history for a customer
481 @param responseBack Indicates which function to be called when a response is received.
482 @param customerId The customer id of the user
483 @param maxRecords The max number of transactions to return
484 @param paymentInstrumentId The id of the payment instrument
485 */
486 MobiliserClient.prototype.findTransactions = function(responseBack, customerId, maxRecords) {
487 var pl = new Object();
488 pl.origin = setting.origin;
489 pl.traceNo = UUIDv4();
490 pl.AuditData = setting.appinfo;
491 pl.customerId = customerId;
492 pl.statusFilter = "30";
493 pl.maxRecords = maxRecords;
494
495 smartphoneService.post(pl, "findTransactions", responseBack);
496 };
497
498 /**
499 @description Get details of a transaction
500 @param responseBack Indicates which function to be called when a response is received.
501 @param customerId The customer id of the user
502 @param maxRecords The max number of transactions to return
503 @param paymentInstrumentId The id of the payment instrument
504 */
505 MobiliserClient.prototype.getTxnDetails = function(responseBack, id) {
506 var pl = new Object();
507 pl.origin = setting.origin;
508 pl.traceNo = UUIDv4();
509 pl.AuditData = setting.appinfo;
510 pl.txnId = id;
511
512 smartphoneService.post(pl, "getTransactionDetails", responseBack);
513 };
514
515 /**
516 @description Get types of invoices by group in the system
517 @param responseBack Indicates which function to be called when a response is received.
518 */
519 MobiliserClient.prototype.getInvoiceTypesByGroup = function(responseBack) {
520 var pl = new Object();
521 pl.origin = setting.origin;
522 pl.traceNo = UUIDv4();
523 pl.AuditData = setting.appinfo;
524 pl.groupId = "2";
525 pl.onlyActive = "true";
526
527 smartphoneService.post(pl, "getInvoiceTypesByGroup", responseBack);
528 };
529
530 /**
531 @description Get types of invoices by group in the system
532 @param responseBack Indicates which function to be called when a response is received.
533 */
534 MobiliserClient.prototype.createInvoiceForInvoiceType = function(responseBack, invoiceTypeId,
535 reference, amount ) {
536 var pl = new Object();
537 pl.origin = setting.origin;
538 pl.traceNo = UUIDv4();
539 pl.AuditData = setting.appinfo;
540 pl.invoiceTypeId = invoiceTypeId;
541 pl.customerId = session.customer.id;
542 pl.reference = reference;
543 pl.amount = amount;
544 pl.currency = "EUR";
545
546 smartphoneService.post(pl, "createInvoiceForInvoiceType", responseBack);
547 };
548
549 /**
550 @description Get all types of invoices in the system
551 @param responseBack Indicates which function to be called when a response is received.
552 */
553 MobiliserClient.prototype.getBillTypes = function(responseBack) {
554 var pl = new Object();
555 pl.origin = setting.origin;
556 pl.traceNo = UUIDv4();
557 pl.AuditData = setting.appinfo;
558 pl.onlyActive = "true";
559
560 smartphoneService.post(pl, "getAllInvoiceTypes", responseBack);
561 };
562
563 /**
564 @description Get all configured invoices for a customer
565 @param responseBack Indicates which function to be called when a response is received.
566 @param customerId The customer id of the user
567 */
568 MobiliserClient.prototype.getRegisteredBills = function(responseBack, customerId) {
569 var pl = new Object();
570 pl.origin = setting.origin;
571 pl.traceNo = UUIDv4();
572 pl.AuditData = setting.appinfo;
573 pl.customerId = customerId;
574 pl.onlyActive = "true";
575
576 smartphoneService.post(pl, "getInvoiceConfigurationsByCustomer", responseBack);
577 };
578
579 /**
580 @description Configure an invoice for some merchant bill type for a customer
581 @param responseBack Indicates which function to be called when a response is received.
582 @param customerId The customer id of the user
583 @param alias The name the customer gives for this invoice configuration
584 @param typeId The id of the invoice type
585 */
586 MobiliserClient.prototype.registerSimpleBill = function(responseBack, customerId, typeId, ref, alias) {
587 var pl_invconfig = new Object();
588 pl_invconfig.invoiceTypeId = typeId;
589 pl_invconfig.customerId = customerId;
590 pl_invconfig.reference = ref;
591 pl_invconfig.status = "0";
592 pl_invconfig.active = "true";
593 pl_invconfig.alias = alias;
594
595
596 var pl = new Object();
597 pl.origin = setting.origin;
598 pl.traceNo = UUIDv4();
599 pl.AuditData = setting.appinfo;
600 pl.invoiceConfiguration = pl_invconfig;
601
602 smartphoneService.post(pl, "createInvoiceConfiguration", responseBack);
603 };
604
605 /**
606 @description Remove a configured invoice for a customer
607 @param responseBack Indicates which function to be called when a response is received.
608 @param invoiceConfigurationId The id of an invoice configuration for a customer
609 */
610 MobiliserClient.prototype.unregisterBill = function(responseBack, invoiceConfigurationId) {
611 var pl = new Object();
612 pl.origin = setting.origin;
613 pl.traceNo = UUIDv4();
614 pl.AuditData = setting.appinfo;
615 pl.invoiceConfigurationId = invoiceConfigurationId;
616
617 smartphoneService.post(pl, "deleteInvoiceConfiguration", responseBack);
618 };
619
620 /**
621 @description Get all active invoices for a customer
622 @param responseBack Indicates which function to be called when a response is received.
623 @param customerId The customer id of the user
624 */
625 MobiliserClient.prototype.getOpenInvoices = function(responseBack, customerId) {
626 var pl = new Object();
627 pl.origin = setting.origin;
628 pl.traceNo = UUIDv4();
629 pl.AuditData = setting.appinfo;
630 pl.customerId = customerId;
631 pl.invoiceStatus = "1";
632
633 smartphoneService.post(pl, "getInvoicesByCustomer", responseBack);
634 };
635
636 /**
637 @description Create an invoice for a customer for a specific type of merchant bill
638 @param responseBack Indicates which function to be called when a response is received.
639 @param invoiceConfigurationId The id of an invoice configuration for a customer
640 @param ref The reference number of an invoice
641 @param amount The amount of money to pay in cents
642 @param date
643 */
644 MobiliserClient.prototype.createInvoice = function(responseBack, invoiceConfigurationId, amount, date) {
645 var inv = new Object();
646 inv.invoiceConfigurationId = invoiceConfigurationId;
647 inv.status = "1";
648 inv.amount = amount;
649 inv.currency = "EUR";
650 inv.date = date+"T00:00:00.000Z";
651
652 var pl = new Object();
653 pl.origin = setting.origin;
654 pl.traceNo = UUIDv4();
655 pl.AuditData = setting.appinfo;;
656 pl.invoice = inv;
657
658 smartphoneService.post(pl, "createInvoice", responseBack);
659 };
660
661 /**
662 @description transfer function
663 @param responseBack Indicates which function to be called when a response is received.
664 @param payercustomerId The customerId of payer
665 @param payerpI The paymentInstrumentId of payer
666 @param payeemsisdn The msisdn of payee receiving the payment
667 @param txn The TxnData object that contains txn details
668 */
669 MobiliserClient.prototype.transfer = function(responseBack, payercustomerId, payeemsisdn, txn) {
670 var payerident = new Object();
671 payerident.type = "1";
672 payerident.value = payercustomerId;
673
674 var pl_payer = new Object();
675 pl_payer.identifier = payerident;
676
677 var payeeident = new Object();
678 payeeident.type = "0";
679 payeeident.value = payeemsisdn;
680
681 var pl_payee = new Object();
682 pl_payee.identifier = payeeident;
683
684 var pl_amount = new Object();
685 pl_amount.currency = "EUR";
686 pl_amount.vat = "0";
687 pl_amount.value = txn.amount;
688
689 var pl = new Object();
690 pl.origin = setting.origin;
691 pl.traceNo = UUIDv4();
692 pl.AuditData = setting.appinfo;
693 pl.autoCapture = "true";
694 pl.orderChannel = "0";
695 pl.usecase = txn.usecase;
696 pl.Payer = pl_payer;
697 pl.Payee = pl_payee;
698 pl.Amount = pl_amount;
699 pl.Text = txn.text;
700
701 smartphoneService.post(pl, "preAuthorisation", responseBack);
702 };
703
704 /**
705 @description preAuthorisationContinue function
706 @param responseBack Indicates which function to be called when a response is received.
707 @param id The systemId of previous PreAuthorisation
708 @param ref The Reference of previous PreAuthorisation
709 */
710 MobiliserClient.prototype.preAuthorisationContinue = function(responseBack, id) {
711 var pl_ref = new Object();
712 pl_ref.systemId = id;
713
714 var pl = new Object();
715 pl.origin = setting.origin;
716 pl.traceNo = UUIDv4();
717 pl.AuditData = setting.appinfo;
718 pl.ReferenceTransaction = pl_ref;
719
720 smartphoneService.post(pl, "preAuthorisationContinue", responseBack);
721 };
722
723 /**
724 @description request function
725 @param responseBack Indicates which function to be called when a response is received.
726 @param payermsisdn The Customer msisdn that will receive the request
727 @param txn The TxnData object that contains txn details
728 */
729 MobiliserClient.prototype.request = function(responseBack, payermsisdn, txn) {
730 var payerident = new Object();
731 payerident.type = "0";
732 payerident.value = payermsisdn;
733
734 var pl_payer = new Object();
735 pl_payer.identifier = payerident;
736
737 var payeeident = new Object();
738 payeeident.type = "1";
739 payeeident.value = session.customer.id;
740
741 var pl_payee = new Object();
742 pl_payee.identifier = payeeident;
743
744 var pl_amount = new Object();
745 pl_amount.currency = "EUR";
746 pl_amount.vat = "0";
747 pl_amount.value = txn.amount;
748
749 var pl = new Object();
750 pl.origin = setting.origin;
751 pl.traceNo = UUIDv4();
752 pl.AuditData = setting.appinfo;
753 pl.autoCapture = "true";
754 pl.orderChannel = "0";
755 pl.usecase = txn.usecase;
756 pl.Payer = pl_payer;
757 pl.Payee = pl_payee;
758 pl.Amount = pl_amount;
759 pl.Text = txn.text;
760
761 smartphoneService.post(pl, "preAuthorisation", responseBack);
762 };
763
764 /**
765 @description startVoucher function
766 @param responseBack Indicates which function to be called when a response is received.
767 @param payercustomerId The Customer customerId which will make the payment
768 @param payerpI The paymentInstrument Id of the Customer which will use to make the payment
769 @param payeemsisdn The Customer msisdn that will receive the payment
770 @param txn The TxnData object that contains txn details
771 */
772 MobiliserClient.prototype.startVoucher = function(responseBack, payercustomerId, payeemsisdn, txn) {
773 var payerident = new Object();
774 payerident.type = "1";
775 payerident.value = payercustomerId;
776
777 var pl_payer = new Object();
778 pl_payer.identifier = payerident;
779
780 var payeeident = new Object();
781 payeeident.type = "0";
782 payeeident.value = payeemsisdn;
783
784 var pl_payee = new Object();
785 pl_payee.identifier = payeeident;
786
787 var pl_amount = new Object();
788 pl_amount.currency = "EUR";
789 pl_amount.vat = "0";
790 pl_amount.value = txn.amount;
791
792 var pl = new Object();
793 pl.origin = setting.origin;
794 pl.traceNo = UUIDv4();
795 pl.AuditData = setting.appinfo;
796 pl.autoCapture = "true";
797 pl.orderChannel = "0";
798 pl.usecase = txn.usecase;
799 pl.Payer = pl_payer;
800 pl.Payee = pl_payee;
801 pl.Amount = pl_amount;
802 pl.Text = txn.text;
803
804 smartphoneService.post(pl, "startVoucher", responseBack);
805 };
806
807 /**
808 @description confirmVoucher function
809 @param responseBack Indicates which function to be called when a response is received.
810 @param id The systemId of previous StartVoucher
811 @param ref The Reference of previous StartVoucher
812 */
813 MobiliserClient.prototype.confirmVoucher = function(responseBack, id, ref) {
814 var pl_ref = new Object();
815 pl_ref.systemId = id;
816 pl_ref.value = ref;
817
818 var pl = new Object();
819 pl.origin = setting.origin;
820 pl.traceNo = UUIDv4();
821 pl.AuditData = setting.appinfo;
822 pl.ReferenceTransaction = pl_ref;
823
824 smartphoneService.post(pl, "confirmvoucher", responseBack);
825 };
826
827 /**
828 @description DemandOnPayment function
829 @param responseBack Indicates which function to be called when a response is received.
830 @param username The username should normally be the msisdn in addition to its country code i.e. +18881234567
831 @param password The user password
832 @param payer The Customer object which will be making the payment
833 @param payee The Customer object that will be receiving the payment
834 @param txn The TxnData object that contains txn details
835 */
836 MobiliserClient.prototype.demandForPayment = function(responseBack, payermsisdn, payeecustomerId, amount, msg) {
837 var payerident = new Object();
838 payerident.type = "0";
839 payerident.value = payermsisdn;
840
841 var pl_payer = new Object();
842 pl_payer.identifier = payerident;
843
844 var payeeident = new Object();
845 payeeident.type = "1";
846 payeeident.value = payeecustomerId;
847
848 var pl_payee = new Object();
849 pl_payee.identifier = payeeident;
850
851 var pl_amount = new Object();
852 pl_amount.currency = "EUR";
853 pl_amount.vat = "0";
854 pl_amount.value = amount;
855
856 var pl = new Object();
857 pl.origin = setting.origin;
858 pl.traceNo = UUIDv4();
859 pl.AuditData = setting.appinfo;
860 pl.Payer = pl_payer;
861 pl.Payee = pl_payee;
862 pl.Amount = pl_amount;
863 pl.Text = msg;
864
865 smartphoneService.post(pl, "demandForPayment", responseBack);
866 };
867
868 /**
869 @description load function
870 @param responseBack Indicates which function to be called when a response is received.
871 @param payerpI The paymentInstrument Id of the Customer which will use to load fund to SVA
872 @param txn The TxnData object that contains txn details
873 */
874 MobiliserClient.prototype.load = function(responseBack, payer, payee, txn) {
875 var pl_amount = new Object();
876 pl_amount.currency = "EUR";
877 pl_amount.vat = "0";
878 pl_amount.value = txn.amount;
879
880 var pl = new Object();
881 pl.origin = setting.origin;
882 pl.traceNo = UUIDv4();
883 pl.AuditData = setting.appinfo;
884 pl.autoCapture = "true";
885 pl.orderChannel = "0";
886 pl.usecase = txn.usecase;
887 pl.Payer = payer;
888 pl.Payee = payee;
889 pl.Amount = pl_amount;
890 pl.Text = txn.text;
891
892 smartphoneService.post(pl, "preAuthorisation", responseBack);
893 };
894
895 /**
896 @description unload function
897 @param responseBack Indicates which function to be called when a response is received.
898 @param payeepI The paymentInstrument Id of the Customer which will use to receive fund from SVA
899 @param txn The TxnData object that contains txn details
900 */
901 MobiliserClient.prototype.unload = function(responseBack, payer, payee, txn, autocap) {
902 var pl_amount = new Object();
903 pl_amount.currency = "EUR";
904 pl_amount.vat = "0";
905 pl_amount.value = txn.amount;
906
907 var pl = new Object();
908 pl.origin = setting.origin;
909 pl.traceNo = UUIDv4();
910 pl.AuditData = setting.appinfo;
911 pl.autoCapture = autocap;
912 pl.orderChannel = "0";
913 pl.usecase = txn.usecase;
914 pl.Payer = payer;
915 pl.Payee = payee;
916 pl.Amount = pl_amount;
917 pl.Text = txn.text;
918
919 smartphoneService.post(pl, "preAuthorisation", responseBack);
920 };
921
922 /**
923 @description createBalanceAlert function
924 @param responseBack Indicates which function to be called when a response is received.
925 */
926 MobiliserClient.prototype.createBalanceAlert = function(responseBack, threshold, onlyTransition) {
927 var pl_alert = new Object();
928 pl_alert.paymentInstrumentId = session.accounts[0].pIId;
929 pl_alert.threshold = threshold;
930 pl_alert.active = "true";
931 pl_alert.onlyTransition = onlyTransition;
932 pl_alert.templateName = "sva balance alert";
933
934 var pl = new Object();
935 pl.origin = setting.origin;
936 pl.traceNo = UUIDv4();
937 pl.AuditData = setting.appinfo;
938 pl.BalanceAlert = pl_alert;
939
940 smartphoneService.post(pl, "createBalanceAlert", responseBack);
941 };
942
943 /**
944 @description getBalanceAlert function
945 @param responseBack Indicates which function to be called when a response is received.
946 */
947 MobiliserClient.prototype.getBalanceAlert = function(responseBack) {
948 var pl = new Object();
949 pl.origin = setting.origin;
950 pl.traceNo = UUIDv4();
951 pl.AuditData = setting.appinfo;
952 pl.paymentInstrumentId = session.accounts[0].pIId;
953 pl.includeInactive = "false";
954
955 smartphoneService.post(pl, "getBalanceAlertByPaymentInstrument", responseBack);
956 };
957
958 /**
959 @description updateBalanceAlert function
960 @param responseBack Indicates which function to be called when a response is received.
961 */
962 MobiliserClient.prototype.updateBalanceAlert = function(responseBack, threshold, onlyTransition, alertid) {
963 var pl_alert = new Object();
964 pl_alert.id = session.svaalert[alertid].id;
965 pl_alert.paymentInstrumentId = session.accounts[0].pIId;
966 pl_alert.threshold = threshold;
967 pl_alert.active = "true";
968 pl_alert.onlyTransition = onlyTransition;
969 pl_alert.templateName = "sva balance alert";
970
971 var pl = new Object();
972 pl.origin = setting.origin;
973 pl.traceNo = UUIDv4();
974 pl.AuditData = setting.appinfo;
975 pl.BalanceAlert = pl_alert;
976
977 smartphoneService.post(pl, "updateBalanceAlert", responseBack);
978 };
979
980 /**
981 @description deleteBalanceAlert function
982 @param responseBack Indicates which function to be called when a response is received.
983 */
984 MobiliserClient.prototype.deleteBalanceAlert = function(responseBack, alertid) {
985 var pl = new Object();
986 pl.origin = setting.origin;
987 pl.traceNo = UUIDv4();
988 pl.AuditData = setting.appinfo;
989 pl.balanceAlertId = session.svaalert[alertid].id;
990
991 smartphoneService.post(pl, "deleteBalanceAlert", responseBack);
992 };
993
994 /**
995 @description Top up function
996 @param responseBack Indicates which function to be called when a response is received.
997 @param invoiceId The id of an invoice
998 @param payerPaymentInstrumentId The payment instrument id for the payer
999 */
1000 MobiliserClient.prototype.topUp = function(responseBack, invoiceId) {
1001 var pl = new Object();
1002 pl.origin = setting.origin;
1003 pl.traceNo = UUIDv4();
1004 pl.AuditData = setting.appinfo;
1005 pl.invoiceId = invoiceId;
1006
1007 smartphoneService.post(pl, "checkInvoice", responseBack);
1008 };
1009
1010 /**
1011 @description Pay bill function
1012 @param responseBack Indicates which function to be called when a response is received.
1013 @param invoiceId The id of an invoice
1014 @param payerPaymentInstrumentId The payment instrument id for the payer
1015 */
1016 MobiliserClient.prototype.payBill = function(responseBack, invoiceId, payerPaymentInstrumentId) {
1017 var pl = new Object();
1018 pl.origin = setting.origin;
1019 pl.traceNo = UUIDv4();
1020 pl.AuditData = setting.appinfo;
1021 pl.invoiceId = invoiceId;
1022 pl.payerPaymentInstrumentId = payerPaymentInstrumentId;
1023
1024 smartphoneService.post(pl, "checkInvoice", responseBack);
1025 };
1026
1027 /**
1028 @description ContinuePayInvoice function
1029 @param responseBack Indicates which function to be called when a response is received.
1030 @param id The system id of checkPayInvoice transaction
1031 @param ref The reference of checkPayInvoice transaction
1032 */
1033 MobiliserClient.prototype.continuePayBill = function(responseBack, id, ref) {
1034 var pl_ref = new Object();
1035 pl_ref.systemId = id;
1036 pl_ref.value = ref;
1037
1038 var pl = new Object();
1039 pl.origin = setting.origin;
1040 pl.traceNo = UUIDv4();
1041 pl.AuditData = setting.appinfo;
1042 pl.ReferenceTransaction = pl_ref;
1043
1044 smartphoneService.post(pl, "continueInvoice", responseBack);
1045 };
1046
1047 /**
1048 @description Cancel bill function
1049 @param responseBack Indicates which function to be called when a response is received.
1050 @param invoiceId The id of an invoice
1051 */
1052 MobiliserClient.prototype.cancelBill = function(responseBack, invoiceId) {
1053 var pl = new Object();
1054 pl.origin = setting.origin;
1055 pl.traceNo = UUIDv4();
1056 pl.AuditData = setting.appinfo;
1057 pl.invoiceId = invoiceId;
1058 pl.cancelByCustomer = "false";
1059
1060 smartphoneService.post(pl, "cancelInvoice", responseBack);
1061 };
1062
1063
1064 //Coupon Feature
1065
1066 //Assign Coupon
1067 /**
1068 @description AssignCoupon function
1069 @param responseBack Indicates which function to be called when a response is received.
1070 @param couponTypeId The id of an coupon
1071 */
1072 MobiliserClient.prototype.assignCoupon = function(responseBack, couponTypeId) {
1073 var pl = new Object();
1074 pl.origin = setting.origin;
1075 pl.traceNo = UUIDv4();
1076 pl.AuditData = setting.appinfo;
1077 pl.couponTypeId = couponTypeId;
1078
1079 smartphoneService.post(pl, "assignCoupon", responseBack);
1080 };
1081
1082 //Find Coupon Types By Tags
1083 /**
1084 @description FindCouponTypesByTags function
1085 @param responseBack Indicates which function to be called when a response is received.
1086 @param tag The tag of the coupon
1087 @param locale The location of the coupon
1088 @param mimeType The mimetype of the coupon
1089 */
1090 MobiliserClient.prototype.findCouponTypesByTags = function(responseBack, tags) {
1091 var tagarray = tags.split(" ");
1092 var pl = new Object();
1093 pl.origin = setting.origin;
1094 pl.traceNo = UUIDv4();
1095 pl.AuditData = setting.appinfo;
1096 pl.tag = tagarray;
1097 pl.locale = locale;
1098 pl.mimeType = mimeType;
1099 if (geoLocation != null) {
1100 pl.location = new Object();
1101 pl.location.latitude = geoLocation.latitude;
1102 pl.location.longitude = geoLocation.longitude;
1103 }
1104
1105 smartphoneService.post(pl, "findCouponTypesByTags", responseBack);
1106 };
1107
1108 //Get Child Categories
1109 /**
1110 @description GetChildCategories function
1111 @param responseBack Indicates which function to be called when a response is received.
1112 @param parentCategoryId The parent id of the coupon
1113 @param locale The location of the coupon
1114 */
1115 MobiliserClient.prototype.getChildCategories = function(responseBack, parentCategoryId) {
1116 var pl = new Object();
1117 pl.origin = setting.origin;
1118 pl.traceNo = UUIDv4();
1119 pl.AuditData = setting.appinfo;
1120 pl.locale = locale;
1121 pl.parentCategoryId = parentCategoryId;
1122
1123 smartphoneService.post(pl, "getChildCategories", responseBack);
1124 };
1125
1126 //Get Coupon Types For Category
1127 /**
1128 @description getCouponTypesForCategory function
1129 @param responseBack Indicates which function to be called when a response is received.
1130 @param categoryId The category of the coupon
1131 @param locale The location of the coupon
1132 @param mimeType The mimetype of the coupon
1133 */
1134 MobiliserClient.prototype.getCouponTypesForCategory = function(responseBack, categoryId) {
1135 var pl = new Object();
1136 pl.origin = setting.origin;
1137 pl.traceNo = UUIDv4();
1138 pl.AuditData = setting.appinfo;
1139 pl.categoryId = categoryId;
1140 pl.locale = locale;
1141 pl.mimeType = mimeType;
1142 if (geoLocation != null) {
1143 pl.location = new Object();
1144 pl.location.latitude = geoLocation.latitude;
1145 pl.location.longitude = geoLocation.longitude;
1146 }
1147
1148 smartphoneService.post(pl, "getCouponTypesForCategory", responseBack);
1149 };
1150
1151 //Get My Coupons
1152 /**
1153 @description GetMyCoupons function
1154 @param responseBack Indicates which function to be called when a response is received.
1155 @param locale The location of the coupon
1156 @param mimeType The mimetype of the coupon
1157 */
1158 MobiliserClient.prototype.getMyCoupons = function(responseBack) {
1159 var pl = new Object();
1160 pl.origin = setting.origin;
1161 pl.traceNo = UUIDv4();
1162 pl.AuditData = setting.appinfo;
1163 pl.locale = locale;
1164 pl.mimeType = mimeType;
1165
1166 smartphoneService.post(pl, "getMyCoupons", responseBack);
1167 };
1168
1169 //Get Root Categories
1170 /**
1171 @description GetRootCategories function
1172 @param responseBack Indicates which function to be called when a response is received.
1173 @param locale The location of the coupon
1174 @param groupId The group id of the coupon
1175 */
1176 MobiliserClient.prototype.getRootCategories = function(responseBack, groupId) {
1177 var pl = new Object();
1178 pl.origin = setting.origin;
1179 pl.traceNo = UUIDv4();
1180 pl.AuditData = setting.appinfo;
1181 pl.groupId = groupId;
1182 pl.locale = locale;
1183
1184 smartphoneService.post(pl, "getRootCategories", responseBack);
1185 };
1186
1187 /**
1188 @description GetCategoryTree function
1189 @param responseBack Indicates which function to be called when a response is received.
1190 @param locale The location of the coupon
1191 @param groupId The group id of the coupon
1192 */
1193 MobiliserClient.prototype.getCategoryTree = function(responseBack, groupId) {
1194 var pl = new Object();
1195 pl.origin = setting.origin;
1196 pl.traceNo = UUIDv4();
1197 pl.AuditData = setting.appinfo;
1198 pl.groupId = groupId;
1199 pl.locale = locale;
1200
1201 smartphoneService.post(pl, "getCategoryTree", responseBack);
1202 };
1203
1204 /**
1205 @description PurchaseCoupon function
1206 @param responseBack Indicates which function to be called when a response is received.
1207 @param paymentInstrumentId The instrument id of an coupon
1208 */
1209 MobiliserClient.prototype.purchaseCoupon = function(responseBack, couponInstanceId, paymentInstrumentId) {
1210 var pl = new Object();
1211 pl.origin = setting.origin;
1212 pl.traceNo = UUIDv4();
1213 pl.AuditData = setting.appinfo;
1214 pl.couponInstanceId = couponInstanceId;
1215 pl.paymentInstrumentId = paymentInstrumentId;
1216
1217 smartphoneService.post(pl, "purchaseCoupon", responseBack);
1218 };
1219
1220 /**
1221 @description DeleteCoupon function
1222 @param responseBack Indicates which function to be called when a response is received.
1223 @param couponId The id of an coupon
1224 */
1225 MobiliserClient.prototype.deleteCoupon = function(responseBack, couponId) {
1226 var pl = new Object();
1227 pl.origin = setting.origin;
1228 pl.traceNo = UUIDv4();
1229 pl.AuditData = setting.appinfo;
1230 pl.couponInstanceId = couponId;
1231
1232 smartphoneService.post(pl, "deleteCoupon", responseBack);
1233 };
1234
1235 /**
1236 @description get Existing Alerts function
1237 @param responseBack Indicate which function to be called when a response is received.
1238 */
1239 MobiliserClient.prototype.getExistingAlerts = function(responseBack) {
1240 var pl = new Object();
1241 pl.origin = setting.origin;
1242 pl.customerId = session.customer.id;
1243 pl.traceNo = UUIDv4();
1244 pl.AuditData = setting.appinfo;
1245 smartphoneService.post(pl, "findCustomerAlertByCustomer", responseBack);
1246 };
1247
1248 /**
1249 * @description create a new alert for customer
1250 * @param responseBack Indicates which function to be called when a successful response is received.
1251 * @param alertTypeId Type of alert to be created
1252 * @param alertDataListItems alert data item objects list
1253 * @param contactPointsItems contact point objects list
1254 * @param frequencyVal Value of frequency Everytime or First time
1255 * @param alertNotificationMsgId text or conv
1256 */
1257 MobiliserClient.prototype.createNewAlert = function(responseBack, alertTypeId, alertDataListItems, contactPointsItems, frequencyVal, alertNotificationMsdId) {
1258 var alertDataListArray = [];
1259 for(var i = 0;i < alertDataListItems.length;i++) {
1260 var ad = new Object();
1261 ad.key = alertDataListItems[i].key;
1262 ad.value = alertDataListItems[i].value;
1263 alertDataListArray.push(ad);
1264 }
1265
1266 var contactPointsArray = [];
1267 for(var i = 0;i < contactPointsItems.length;i++) {
1268 var oi = new Object();
1269 oi.id = contactPointsItems[i].id;
1270 oi.customerId = contactPointsItems[i].customerId;
1271 oi.type = contactPointsItems[i].type;
1272 oi.identification = contactPointsItems[i].identification;
1273 var cp = new Object();
1274 if(contactPointsItems[i] instanceof Identification) {
1275 cp.identification = oi;
1276 } else {
1277 oi.nickname = contactPointsItems[i].nickname;
1278 cp.otherIdentification = oi;
1279 }
1280 contactPointsArray.push(cp);
1281 }
1282
1283 var pl = new Object();
1284 pl.origin = setting.origin;
1285 var customerAlert = new Object();
1286 customerAlert.customerId = session.customer.id;
1287 customerAlert.alertTypeId = alertTypeId;
1288
1289 //Only add frequency if this alert type supports it else do not add this parameter
1290 if(frequencyVal.notifMax > -1) {
1291 customerAlert.notifMaxCnt = frequencyVal.notifMax;
1292 if(frequencyVal.notifMax != 0) {
1293 customerAlert.notifMaxRecur = frequencyVal.maxRecur;
1294 }
1295 }
1296
1297 customerAlert.alertNotificationMsgId = alertNotificationMsdId;
1298
1299 if(alertDataListItems != null && alertDataListItems.length > 0) {
1300 customerAlert.alertDataList = new Object();
1301 customerAlert.alertDataList.alertData = alertDataListArray;
1302 } else {
1303 delete customerAlert.alertDataList;
1304 }
1305
1306 if(contactPointsArray != null && contactPointsArray.length > 0) {
1307 customerAlert.contactPointList = new Object();
1308 customerAlert.contactPointList.contactPoint = contactPointsArray;
1309 }
1310
1311 pl.customerAlert = customerAlert;
1312 pl.traceNo = UUIDv4();
1313 pl.AuditData = setting.appinfo;
1314
1315 smartphoneService.post(pl, "createCustomerAlert", responseBack);
1316 };
1317
1318 /**
1319 @description delete an existing alert
1320 @param alert_id id of an alert which needs to be deleted
1321 @param responseBack Indicate which function to be called when a response is received.
1322 */
1323 MobiliserClient.prototype.deleteCustomerAlert = function(alertId, responseBack) {
1324 var pl = new Object();
1325 pl.origin = setting.origin;
1326 pl.customerAlertId = alertId;
1327 pl.traceNo = UUIDv4();
1328 pl.AuditData = setting.appinfo;
1329
1330 smartphoneService.post(pl, "deleteCustomerAlert", responseBack);
1331 };
1332
1333 /**
1334 * @description delete an alert if the account itself is deleted
1335 * @param responseBack function to be called in case of success
1336 * @param pIId payment instrument id of the existing alert data key record
1337 */
1338 MobiliserClient.prototype.deleteCustomerAlertByCustomerAndData = function(responseBack, pIId) {
1339 var pl = new Object();
1340 pl.origin = setting.origin;
1341 pl.traceNo = UUIDv4();
1342 pl.AuditData = setting.appinfo;
1343 pl.customerId = session.customer.id;
1344 pl.key = "customerPiId";
1345 pl.data = session.accountPiIdForDeletion;
1346
1347 smartphoneService.post(pl, "deleteCustomerAlertByCustomerAndData", responseBack);
1348 };
1349
1350 /**
1351 * @description get alert details for an existing alert
1352 * @param responseBack function to be called in case of success
1353 * @param alert_id id of the existing alert record
1354 */
1355 MobiliserClient.prototype.getAlertDetailsForEdit = function(responseBack, alertId) {
1356 var pl = new Object();
1357 pl.origin = setting.origin;
1358 pl.customerAlertId = alertId;
1359 pl.traceNo = UUIDv4();
1360 pl.AuditData = setting.appinfo;
1361
1362 smartphoneService.post(pl, "getCustomerAlert", responseBack);
1363 };
1364
1365 /**
1366 * @description Updates an existing alert
1367 * @param responseBack Response Handler
1368 * @param alertId Id of customer alert
1369 * @param alertTypeId alert type id
1370 * @param alertDataList alert data list
1371 */
1372 MobiliserClient.prototype.updateExistingAlert = function(responseBack, customerAlert) {
1373 // var alertData = customerAlert.alertDataList;
1374 // var alertDataListArray = [];
1375 // for(var i = 0;i < alertData.length;i++) {
1376 // var ad = new Object();
1377 // ad.id = alertData[i].id;
1378 // ad.customerAlertId = alertData[i].customerAlertId;
1379 // ad.key = alertData[i].key;
1380 // ad.value = alertData[i].value;
1381 // alertDataListArray.push(ad);
1382 // }
1383 //
1384 // var contactPoint = customerAlert.contactPointList;
1385 // var contactPointsArray = [];
1386 // for(var i = 0;i < contactPoint.length;i++) {
1387 // var cp = new Object();
1388 // if(contactPoint[i].id) // It may be a new addition and hence may not have an id
1389 // cp.id = contactPoint[i].id;
1390 //
1391 // if(contactPoint[i].customerAlertId) // It may be a new addition and hence may not have an id
1392 // cp.customerAlertId = contactPoint[i].customerAlertId;
1393 //
1394 // var oi = new Object();
1395 // var tmpObj = contactPoint[i].otherIdentification
1396 // if(!tmpObj) {
1397 // tmpObj = contactPoint[i].identification;
1398 // }
1399 //
1400 // oi.id = tmpObj.id;
1401 // oi.customerId = tmpObj.customerId;
1402 // oi.type = tmpObj.type;
1403 // oi.identification = tmpObj.identification;
1404 //
1405 // if(contactPoint[i].otherIdentification) {
1406 // oi.nickname = contactPoint[i].otherIdentification.nickname;
1407 // cp.otherIdentification = oi
1408 // } else {
1409 // cp.identification = oi;
1410 // }
1411 //
1412 // contactPointsArray.push(cp);
1413 // }
1414
1415 var pl = new Object();
1416 pl.origin = setting.origin;
1417 pl.traceNo = UUIDv4();
1418 pl.AuditData = setting.appinfo;
1419 pl.customerAlert = customerAlert;
1420
1421 //Restructure Alert Data
1422 var alertData = pl.customerAlert.alertDataList;
1423 pl.customerAlert.alertDataList = new Object();
1424 if(alertData != null && alertData.length > 0) {
1425 pl.customerAlert.alertDataList.alertData = alertData;
1426 } else {
1427 delete pl.customerAlert.alertDataList;
1428 }
1429
1430 //Restructure Contact Point
1431 var contactPoint = pl.customerAlert.contactPointList;
1432 pl.customerAlert.contactPointList = new Object();
1433 if(contactPoint != null && contactPoint.length > 0) {
1434 pl.customerAlert.contactPointList.contactPoint = contactPoint;
1435 } else {
1436 delete pl.customerAlert.contactPointList.contactPoint;
1437 }
1438
1439 smartphoneService.post(pl, "updateCustomerAlert", responseBack);
1440 };
1441
1442 /**
1443 * @description Service call to fetch the alert notification msg type id based of alert type id and notification msg id
1444 * @param alertTypeId alert type
1445 * @param notification type
1446 */
1447 MobiliserClient.prototype.getAlertNotificationMsgId = function(responseBack, alertTypeId, notificationMsgTypeId) {
1448 var pl = new Object();
1449 pl.origin = setting.origin;
1450 pl.traceNo = UUIDv4();
1451 pl.AuditData = setting.appinfo;
1452 pl.alertTypeId = alertTypeId;
1453 pl.notificationMsgTypeId = notificationMsgTypeId;
1454 smartphoneService.post(pl, "getActiveAlertNotifMsgByAlertTypeAndNotifMsgType", responseBack);
1455 };
1456
1457
1458 /**
1459 * @description Service call to fetch the active alert notification message mapping, to be used in
1460 * creating and updating alerts
1461 * @param responseBack callback handler when the results returned.
1462 */
1463 MobiliserClient.prototype.getActiveAlertNotificationMessages = function(responseBack) {
1464 var pl = new Object();
1465 pl.origin = setting.origin;
1466 pl.traceNo = UUIDv4();
1467 pl.AuditData = setting.appinfo;
1468
1469 smartphoneService.post(pl, "getActiveAlertNotificationMessages", responseBack);
1470 };
1471
1472 /**
1473 * @description Function to fetch list of supported look up items like currencies
1474 * networkproviders etc
1475 * @param responseBack the callback handler
1476 * @param entity to be looked up on the server
1477 */
1478 MobiliserClient.prototype.getLookups = function(responseBack, entity) {
1479 var pl = new Object();
1480 pl.origin = setting.origin;
1481 pl.traceNo = UUIDv4();
1482 pl.AuditData = setting.appinfo;
1483 pl.entityName = entity;
1484
1485 smartphoneService.post(pl, "getLookups", responseBack);
1486 };
1487
1488
1489 /**
1490 * @description get Customer's other identifications
1491 * @param responseBack Indicate which function to be called when a response is received.
1492 */
1493 MobiliserClient.prototype.getOtherIdentifications = function(responseBack) {
1494 var pl = new Object();
1495 pl.origin = setting.origin;
1496 pl.customerId = session.customer.id;
1497 pl.traceNo = UUIDv4();
1498 pl.AuditData = setting.appinfo;
1499
1500 smartphoneService.post(pl, "getCustomerOtherIdentificationByCustomer", responseBack);
1501 };
1502
1503 /**
1504 * @description get picture upload URL
1505 * @param responseBack Indicate which function to be called when a response is received.
1506 */
1507 MobiliserClient.prototype.getUploadPictureURL = function(responseBack) {
1508 var pl = {};
1509 pl.origin = setting.origin;
1510 pl.traceNo = UUIDv4();
1511 pl.AuditData = setting.appinfo;
1512
1513 smartphoneService.post(pl, "uploadPicture", responseBack);
1514 };
1515
1516 /**
1517 * @description get picture download URL
1518 * @param responseBack Indicate which function to be called when a response is received.
1519 */
1520 MobiliserClient.prototype.getDownloadPictureURL = function(responseBack) {
1521 var pl = {};
1522 pl.origin = setting.origin;
1523 pl.traceNo = UUIDv4();
1524 pl.AuditData = setting.appinfo;
1525
1526 smartphoneService.post(pl, "getMyPictures", responseBack);
1527 };
1528
1529 /**
1530 * @description find next address with location
1531 * @param responseBack Indicate which function to be called when a response is received.
1532 * @param lat The latitude of current geolocation.
1533 * @param lng The longitude of current geolocation.
1534 */
1535 MobiliserClient.prototype.findNextAddresses = function(responseBack, lat, lng) {
1536 var pl_loc = {};
1537 pl_loc.latitude = lat;
1538 pl_loc.longitude = lng;
1539 pl_loc.radius = "300000";
1540
1541 var pl = {};
1542 pl.origin = setting.origin;
1543 pl.traceNo = UUIDv4();
1544 pl.AuditData = setting.appinfo;
1545 pl.location = pl_loc;
1546
1547 smartphoneService.post(pl, "findNextAddresses", responseBack);
1548 };
1549
1550 /**
1551 * @description get default Terms and Conditions information
1552 * @param responseBack Indicate which function to be called when a response is received.
1553 */
1554 MobiliserClient.prototype.getDefaultTermAndConditions = function(responseBack, customerTypeId) {
1555 var pl = {};
1556 pl.origin = setting.origin;
1557 pl.traceNo = UUIDv4();
1558 pl.AuditData = setting.appinfo;
1559 pl.customerTypeId = customerTypeId;
1560 pl.orgunitId = "0000";
1561
1562 smartphoneService.post(pl, "getDefaultTermAndConditions", responseBack);
1563 };
1564
1565 /**
1566 * @description get open Terms and Conditions information
1567 * @param responseBack Indicate which function to be called when a response is received.
1568 */
1569 MobiliserClient.prototype.getOpenTermAndConditions = function(responseBack) {
1570 var pl = {};
1571 pl.origin = setting.origin;
1572 pl.traceNo = UUIDv4();
1573 pl.AuditData = setting.appinfo;
1574 pl.customerId = session.customer.id;
1575
1576 smartphoneService.post(pl, "getOpenTermAndConditions", responseBack);
1577 };
1578
1579 /**
1580 * @description accept Terms and Conditions information
1581 * @param responseBack Indicate which function to be called when a response is received.
1582 */
1583 MobiliserClient.prototype.acceptTermAndConditions = function(responseBack, tncs) {
1584 var pl = {};
1585 pl.origin = setting.origin;
1586 pl.traceNo = UUIDv4();
1587 pl.AuditData = setting.appinfo;
1588 pl.tncVersionId = tncs;
1589
1590 smartphoneService.post(pl, "acceptTermAndConditions", responseBack);
1591 };
1592
1593 /**
1594 @description FindNextCouponTypesByTags function
1595 @param responseBack Indicates which function to be called when a response is received.
1596 @param tag The tag of the coupon
1597 @param locale The location of the coupon
1598 @param mimeType The mimetype of the coupon
1599 */
1600 MobiliserClient.prototype.findNextCouponTypesByTags = function(responseBack, tags) {
1601 var tagarray = tags.split(" ");
1602 var pl = new Object();
1603 pl.origin = setting.origin;
1604 pl.traceNo = UUIDv4();
1605 pl.AuditData = setting.appinfo;
1606 pl.tag = tagarray;
1607 pl.locale = locale;
1608 pl.mimeType = mimeType;
1609 pl.location = new Object();
1610 pl.location.latitude = geoLocation.latitude;
1611 pl.location.longitude = geoLocation.longitude;
1612 pl.location.radius = "3000";
1613
1614 smartphoneService.post(pl, "findNextCouponTypes", responseBack);
1615 };
1616
1617 /**
1618 @description findNextCouponTypesForCategory function
1619 @param responseBack Indicates which function to be called when a response is received.
1620 @param categoryId The category of the coupon
1621 @param locale The location of the coupon
1622 @param mimeType The mimetype of the coupon
1623 */
1624 MobiliserClient.prototype.findNextCouponTypesForCategory = function(responseBack, categoryId) {
1625 var pl = new Object();
1626 pl.origin = setting.origin;
1627 pl.traceNo = UUIDv4();
1628 pl.AuditData = setting.appinfo;
1629 pl.categoryId = categoryId;
1630 pl.locale = locale;
1631 pl.mimeType = mimeType;
1632 pl.location = new Object();
1633 pl.location.latitude = geoLocation.latitude;
1634 pl.location.longitude = geoLocation.longitude;
1635 pl.location.radius = "3000";
1636
1637 smartphoneService.post(pl, "findNextCouponTypes", responseBack);
1638 };