Preparing for the client to register. This function is responsible for registering a client.
registerAsClient(){
this.loading =this.loadingCtrl.create({
content:"Setting up Account"
});
this.loading.present();
this.buildClientData();
console.log(this.clientData);
this.auth.store('clients', this.clientData).subscribe((response)=>{
this.clients = response.json();
This section displays the server response on the console after registration.
console.log("Client ID : " + this.clients['clientId']);
console.log("Savings Account ID : " + this.clients['savingsAccountId']);
localStorage.setItem('clientID', this.clients['clientId']);
localStorage.setItem('officeID', this.clients['officeId']);
localStorage.setItem('savingsAccountID', this.clients['savingsAccountId']);
setTimeout(()=>{
this.loading.dismissAll();
this.toastrCtrl.messenger('Successfully Registered');
localStorage.setItem('registered', 'true');
this.navCtrl.push(HomePage);
},5000)
},error=>{
if(error.status === 403){
this.loading.dismissAll();
this.toastrCtrl.messenger("Phone number already exists. Please use another");
}else {
this.loading.dismissAll();
this.toastrCtrl.messenger('Service unavailable. Please try again later');
console.log(error);
}
})
}
This part shows the console response during registration. Client id can be retrieved, but savings account id appears as undefined.
Client ID : 104
Savings Account ID : undefined
Here is the complete json
response when testing with the endpoints.
{
"id": 89,
"accountNo": "000000089",
"status": {
"id": 300,
"code": "clientStatusType.active",
"value": "Active"
},
"subStatus": {
"active": false,
"mandatory": false
},
"active": true,
"activationDate": [
2018,
8,
13
],
"firstname": "Albertina",
"lastname": "Ben-Patterson",
"displayName": "Albertina Ben-Patterson",
"mobileNo": "0201234598",
"gender": {
"active": false,
"mandatory": false
},
"clientType": {
"active": false,
"mandatory": false
},
"clientClassification": {
"active": false,
"mandatory": false
},
"isStaff": false,
"officeId": 10,
"officeName": "Greater Accra Region",
"timeline": {
"submittedOnDate": [
2018,
8,
13
],
"submittedByUsername": "admin",
"submittedByFirstname": "App",
"submittedByLastname": "Administrator",
"activatedOnDate": [
2018,
8,
13
],
"activatedByUsername": "admin",
"activatedByFirstname": "App",
"activatedByLastname": "Administrator"
},
"savingsAccountId": 8,
"groups": [],
"clientNonPersonDetails": {
"constitution": {
"active": false,
"mandatory": false
},
"mainBusinessLine": {
"active": false,
"mandatory": false
}
}
}
Your assistance is greatly appreciated.
Thank you.