Sample Codes

JavaScript Code Example

<script> 
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", "Bearer test");

var raw = JSON.stringify({
  "loanAccountNumber": "423456789",
  "loanAmount": "50000",
  "email": "daveomo@gmail.com",
  "isNewLoan": false,
  "customer": {
    "fullname": "Dave Omo",
    "BVN": "2323232322",
    "phoneNumber": "08055309113,08055623778"
  },
  "address": {
    "address": "2a stong iron steet surulere",
    "state": "lagos",
    "lga": "lagos mainland"
  },
  "nok": {
    "nokFullname": "Jane Omo",
    "nokBVN": "2390857192",
    "nokPhoneNumber": "0987768899",
    "nokAddress": "15 maryland avenue, off thomson street.",
    "nokState": "lagos",
    "nokLga": "ikeja"
  },
  "schedule": [
    {
      "dueDate": "2023-08-01",
      "amount": "15000",
      "status": "pending"
    },
    {
      "dueDate": "2023-09-01",
      "amount": "15000",
      "status": "pending"
    },
    {
      "dueDate": "2023-10-01",
      "amount": "15000",
      "status": "pending"
    },
    {
      "dueDate": "2023-11-01",
      "amount": "15000",
      "status": "pending"
    }
  ]
});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://fetch-api-staging.up.railway.app/external/loan", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
</script>

Python Code Example

import http.client
import json

conn = http.client.HTTPSConnection("fetch-api-staging.up.railway.app")
payload = json.dumps({
  "loanAccountNumber": "423456789",
  "loanAmount": "50000",
  "email": "daveomo@gmail.com",
  "isNewLoan": false,
  "customer": {
    "fullname": "Dave Omo",
    "BVN": "2323232322",
    "phoneNumber": "08055309113,08055623778"
  },
  "address": {
    "address": "2a stong iron steet surulere",
    "state": "lagos",
    "lga": "lagos mainland"
  },
  "nok": {
    "nokFullname": "Jane Omo",
    "nokBVN": "2390857192",
    "nokPhoneNumber": "0987768899",
    "nokAddress": "15 maryland avenue, off thomson street.",
    "nokState": "lagos",
    "nokLga": "ikeja"
  },
  "schedule": [
    {
      "dueDate": "2023-08-01",
      "amount": "15000",
      "status": "pending"
    },
    {
      "dueDate": "2023-09-01",
      "amount": "15000",
      "status": "pending"
    },
    {
      "dueDate": "2023-10-01",
      "amount": "15000",
      "status": "pending"
    },
    {
      "dueDate": "2023-11-01",
      "amount": "15000",
      "status": "pending"
    }
  ]
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer test'
}
conn.request("POST", "/external/loan", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

PHP Code Example

<?php 
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://fetch-api-staging.up.railway.app/external/loan',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "loanAccountNumber":"423456789",
    "loanAmount": "50000",
    "email": "daveomo@gmail.com",
    "customer":{
        "fullname": "Dave Omo",
        "BVN": "2323232322",
        "phoneNumber": "08055309113,08055623778"
    }, 
    "address": {
        "address" : "2a stong iron steet surulere",
        "state" : "lagos",
        "lga" : "lagos mainland"
    },
    "nok": {
        "nokFullname" : "Jane Omo",
        "nokBVN" : "2390857192",
        "nokPhoneNumber" : "0987768899",
        "nokAddress" : "15 maryland avenue, off thomson street.",
        "nokState" : "lagos",
        "nokLga" : "ikeja"
    },
    "schedule":[
        {
            "dueDate": "2023-08-01",
            "amount": "15000",
            "status": "pending"
        },{
            "dueDate": "2023-09-01",
            "amount": "15000",
            "status": "pending"
        },{
            "dueDate": "2023-10-01",
            "amount": "15000",
            "status": "pending"
        },{
            "dueDate": "2023-11-01",
            "amount": "15000",
            "status": "pending"
        }
    ]
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: Bearer test'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
?>

Last updated