SY_MB_Mobiliser.js

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 or JSON as a result.
5        *
6        * @name SY_MB_Mobiliser.js
7        * @author SAP AG
8        * @version 1.0
9        */
10      
11      MobiliserClient.prototype.mburl = function() {
12          var url = setting.protocol + setting.ipaddress;
13      
14          if(setting.port)
15              url += ":" + setting.port;
16      
17          if(typeof setting.mbwsname !== 'undefined')
18              url += "/" + setting.mbwsname;
19      
20          return url;
21      };
22      
23      /**
24       * @description Get the exchange rate between two currencies from the server
25       * @param org
26       *            id of the organisation
27       * @param from
28       *            the from currency
29       * @param to
30       *            the to currency
31       */
32      MobiliserClient.prototype.getExchangeRate = function(responseBack, from, to) {
33          var pl = new Object();
34          pl.origin = "android";
35          pl.traceNo = UUIDv4();
36          pl.AuditData = setting.appinfo;
37          pl.bankId = '0000';
38          pl.fromCurrency = from;
39          pl.toCurrency = to;
40          var mbankingService = {};
41          jQuery.extend(mbankingService, smartphoneService);
42          mbankingService.url = mc.mburl();
43          mbankingService.post(pl, "getMBExchangeRate", responseBack);
44      };
45      
46      // Needed to override this as there was no way to get the txn id inside
47      // the txn detail page
48      /**
49       * @description Call to send transaction details as SMS
50       * @param responseBack
51       *            callback handler after the call is successful
52       * @param id
53       *            of the transaction
54       */
55      MobiliserClient.prototype.sendTxnAsSMS = function(responseBack, id) {
56          var pl = new Object();
57          pl.origin = setting.origin;
58          pl.traceNo = UUIDv4();
59          pl.AuditData = setting.appinfo;
60          pl.userId = session.username;
61          pl.userMsisdn = session.msisdn;
62          pl.bankId = session.customer.orgUnitId;
63          pl.txnId = id;
64      //TODO: check if this is available to smartphone endpoint? cannot find it.
65          smartphoneService.post(pl, "sendTxnDetailsAsSMS", responseBack);
66      };
67      
68      /**
69       * @description Web service call to get the list of network providers
70       * @param responseBack
71       *            Indicates which function to be called when a response is received.
72       */
73      MobiliserClient.prototype.getCustomerServicePackageRequest = function(responseBack) {
74          var pl = new Object();
75          pl.origin = setting.origin;
76          pl.traceNo = UUIDv4();
77          pl.AuditData = setting.appinfo;
78          pl.customerId = session.customer.id;
79      //TODO: check if this is available to smartphone endpoint? cannot find it.
80          smartphoneService.post(pl, "getCustomerServicePackage", responseBack);
81      };
82      
83      /**
84       * @description checking MB specific login logic
85       * @param responseBack
86       *                 Indicates which function to be called when a response is received.
87       * @param customerId
88       *                Indicates which customer to add with default package
89       */
90      MobiliserClient.prototype.checkMBLogin = function(responseBack) {
91          var pl = new Object();
92          pl.origin = setting.origin;
93          pl.traceNo = UUIDv4();
94          pl.bankId = session.customer.orgUnitId;
95          pl.userMsisdn = session.msisdn;
96          pl.AuditData = setting.appinfo;
97          var mbankingService = {};
98          jQuery.extend(mbankingService, smartphoneService);
99          mbankingService.url = mc.mburl();
100         mbankingService.post(pl, "mBankingingChecks", responseBack);
101     
102     // TODO: mBankingingChecks seems to be defined in web service ... remove "ing".
103     };
104     
105     /**
106      * @description accepts T&C on behalf of customer
107      * @param responseBack
108      *                 Indicates which function to be called when a response is received.
109      * @param customerId
110      *                Indicates which customer to add with default package
111      */
112     MobiliserClient.prototype.acceptTermsAndCondition = function(responseBack, customerId, optInTermsId) {
113         var pl = new Object();
114         pl.origin = setting.origin;
115         pl.traceNo = UUIDv4();
116         pl.AuditData = setting.appinfo;
117         pl.userMsisdn = session.msisdn;
118         pl.bankId = session.customer.orgUnitId;
119         pl.optInTermsId = optInTermsId;
120         var mbankingService = {};
121         jQuery.extend(mbankingService, smartphoneService);
122         mbankingService.url = mc.mburl();
123         mbankingService.post(pl, "acceptTerms", responseBack);
124     };
125