var kuwego_cba = pm.environment.get("kuwego-cba");
var scheme_id = pm.environment.get("scheme_id");
var scheme_send_url = kuwego_cba + "/api/v1/ledger-account-schemes/" + scheme_id;
var customer_send_url = kuwego_cba + "/api/v1/customers";
var account_send_url = kuwego_cba + "/api/v1/ledger-accounts";
var token = pm.environment.get("kuwego_admin_token");
var account_number_length = pm.environment.get("scheme_account_length");
var prefix = pm.environment.get("scheme_account_prefix");
const scheme_payload = {
url: scheme_send_url,
method: 'PUT',
header: {
'Authorization': 'bearer ' + token,
'Content-Type': 'application/json'
},
body: {
mode: 'raw',
raw: JSON.stringify({
code: 'anything',
name: pm.environment.get("scheme_name"),
status: 'ACTIVE',
classification: "INCOME",
allowNegativeBalance: true,
allowLien: true,
accountNumberPrefix: prefix,
accountNumberLength: account_number_length,
enableInstantBalanceUpdate: true,
schemeRequirement: {
signature: true,
residentialAddress: true,
employment: true,
nextOfKin: true,
identification: true,
spouse: true
}
})
}
};
pm.sendRequest(scheme_payload, function (err, res) {
// jsonData = res.json();
// if (err) {
// console.log(err);
// } else {
// // account_number_length = jsonData.data.accountNumberLength;
// // pm.environment.set("scheme_id", jsonData.data.id);
// // pm.environment.set("scheme_account_length", account_number_length);
// }
});
var random_gen = pm.variables.replaceIn('{{$randomBankAccount}}{{$timestamp}}');
console.log (random_gen);
var request_length = parseInt(account_number_length) - prefix.length ;
console.log (request_length);
var refined_gen = prefix + random_gen.substring(0, request_length);
console.log (refined_gen);
pm.environment.set("generated_account_no", refined_gen);
const customer_payload = {
url: customer_send_url,
method: 'POST',
header: {
'Authorization': 'bearer ' + token,
'Content-Type': 'application/json'
},
body: {
mode: 'raw',
raw: JSON.stringify({
firstName: pm.variables.replaceIn('{{$randomLastName}}'),
lastName: pm.variables.replaceIn('{{$randomLastName}}'),
gender: "FEMALE",
dateOfBirth: "2020-08-03",
phoneNumber: "07033031209",
emailAddress: "conigbinde"+pm.variables.replaceIn('{{$randomPassword}}')+"@teamapt.com",
passportRef: pm.variables.replaceIn('{{$randomUUID}}'),
bankVerificationNumber: "08" + pm.variables.replaceIn("{{$randomBankAccount}}") + "1",
maritalStatus: "SINGLE",
status: null,
countryCode: null,
nationality: "NG",
title: pm.variables.replaceIn('{{$randomNamePrefix}}'),
middleName: pm.variables.replaceIn('{{$randomFirstName}}'),
signatureRef: pm.variables.replaceIn('{{$randomUUID}}'),
placeOfBirth: "ydzzqmldafdixethb",
stateOfOrigin: "Lagos",
localGovernmentOfOrigin: "Eti-Osa",
motherMaidenName: pm.variables.replaceIn('{{$randomLastName}}'),
religion: "Christianity",
taxIdentificationNumber: pm.variables.replaceIn('{{$timestamp}}'),
residentialAddress: {
addressLineOne: "No" + pm.variables.replaceIn("{{$randomInt}}{{$randomAlphaNumeric}}"),
addressLineTwo: pm.variables.replaceIn("{{$randomStreetName}}"),
city: "Lagos",
localGovernment: "Eti-Osa",
state: "Lagos",
countryCode: "NG",
verificationRef: pm.variables.replaceIn("{{$randomUUID}}")
},
mailingAddress: {
addressLineOne: pm.variables.replaceIn("{{$randomStreetAddress}}"),
addressLineTwo: pm.variables.replaceIn("{{$randomStreetName}}"),
city: pm.variables.replaceIn("{{$randomCity}}"),
localGovernment: "Agege",
state: "Lagos",
countryCode: "NG",
verificationRef: pm.variables.replaceIn("{{$guid}}")
},
employmentInfo: {
employerName: pm.variables.replaceIn("{{$randomFullName}}"),
natureOfBusiness: pm.variables.replaceIn("{{$randomProductName}}"),
annualIncome: 4.00,
employmentDate: "2020-08-03",
employmentStatus: "CURRENT",
officePhoneNumber: "07033031209",
officeFaxNumber: "07033031209",
employmentLetterRef: pm.variables.replaceIn("{{$randomUUID}}"),
employmentIdRef: pm.variables.replaceIn("{{$randomUUID}}")
},
nextOfKin: {
addressLineOne: pm.variables.replaceIn("{{$randomStreetAddress}}"),
addressLineTwo: pm.variables.replaceIn("{{$randomStreetName}}"),
city: pm.variables.replaceIn("{{$randomCity}}"),
localGovernment: "Ikorodu",
state: "Lagos",
countryCode: "NG",
verificationRef: null,
title: pm.variables.replaceIn("{{$randomNamePrefix}}"),
fullName: pm.variables.replaceIn("{{$randomFullName}}"),
dateOfBirth: "2020-08-03",
gender: "MALE",
relationship: "Sibling",
phoneNumber: "08030000007",
emailAddress: "[email protected]"
},
identificationInfo: {
identificationType: "International Passport",
registrationNumber: pm.variables.replaceIn("{{$randomBankAccount}}"),
issueDate: "2020-08-03",
expiryDate: "2022-08-03",
scannedImageRef: pm.variables.replaceIn("{{$randomUUID}}")
},
spousalInfo: {
fullName: pm.variables.replaceIn("{{$randomFullName}}"),
dateOfBirth: "2020-08-03",
occupation: "rooulbazebobzsvtgnjhzmegbrw"
},
location: {
latitude: pm.variables.replaceIn("{{$randomLatitude}}"),
longitude: pm.variables.replaceIn("{{$randomLongitude}}")
}
})
}
};
pm.sendRequest(customer_payload, function (err, res) {
jsonData = res.json();
if (err) {
console.log(err);
} else {
var customer_code = jsonData.data.code;
pm.environment.set("pair_customer_code", customer_code);
// pm.environment.set("scheme_account_length", account_number_length);
}
});
const account_payload = {
url: account_send_url,
method: 'POST',
header: {
'Authorization': 'bearer ' + token,
'Content-Type': 'application/json'
},
body: {
mode: 'raw',
raw: JSON.stringify({
schemeCode: pm.environment.get("scheme_code"),
accountCode: pm.variables.replaceIn("{{$randomBankAccount}}{{$randomAlphaNumeric}}"),
accountNumber: refined_gen,
accountName: "Aptpay" + pm.variables.replaceIn("{{$randomBankAccountName}}"),
parentAccountId:"",
hierarchyNumber:"0",
currencyCode:"566",
allowCredit: true,
allowDebit: true,
allowOwnEntry: true,
status:"active"
})
}
};
pm.sendRequest(account_payload, function (err, res) {
jsonData = res.json();
if (err) {
console.log(err);
} else {
var account_number = jsonData.data.accountNumber;
pm.environment.set("pair_account_number", account_number);
// pm.environment.set("scheme_account_length", account_number_length);
}
});
Here is the snippet of the code in the pre-request