Latest Posts

Introduction to OFS

OFS (Open Financial Service) is a standard module within T24, with a module code OF.

Open Financial Service, OFS simply, is the only standard gateway to Temenos T24. Every single interaction with T24 is driven through OFS.

OFS is message driven, i.e. it works in a request-response based system. The OFS syntax or message structure is proprietary to Temenos T24. It is the native way to represent request to execute T24 transaction, enquiries or routines.

Introduction to Go - Getting started with Golang

Golang is an open-source programming language developed by Google. It is incredibly fast and easy to learn. This is our first lesson in our introductory tutorial in which we are going to write a few small programs that will help us understand the key concepts of the Go language.

Photo by XPS on Unsplash

Getting starting with Golang

To be able to follow along, you can either use a playground or install Golang on your computer. The installation package and instructions can be found here.

We are going to start with a simple program that prints "Hello World".

Create a file called hello-world.go or use the playground link above and add the following lines of code:

package main

import "fmt"

func main() {
    fmt.Println("Hello World")
}

We can run our program from the command line as follows:

$ go run hello-world.go
Hello world

 

We can also build an executable and run it as follows:

$ go build hello-world.go

$ ./hello-world
Hello world

Now let's try to understand the lines of code we wrote:

  1. We started by declaring our package: package main
  2. Imported a package called "fmt" : import "fmt"
  3. Declared the main function: func main()
  4. Then in the function block, we used fmt.Println to print our "Hello World"

Congratulations!  You just wrote your first program in Go.

In our upcoming posts, we will discuss some key basic concepts of Go languages such as variables, loops, conditional statements, functions, structs, arrays, slices, maps, pointers, and concurrency. 

We will conclude our tutorial with a CRUD RESTful API. So, stay tuned.

The source codes for the API that we will be building can be found on GitHub page

How to consume Restful API with Vanilla JavaScript

In this tutorial, we are going to look at how to use JavaScript to consume a Restful API. For better illustration of the concept, we are going to have a bit of HTML and CSS. We will use fetch API and async .. await

women-standing-beside-whiteboard-3861952

Photo by ThisIsEngineering from Pexels

1. Create index.html

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Fetch API</title>
    <link rel="stylesheet" href="./main.css">
</head>

<body>
    <h2>List of courses</h2>
    <table id="course-table">
    </table>
    <script src="./app.js"></script>
</body>

</html>

2. Create app.js 

const courseTable = document.getElementById('course-table');
const baseLink = 'https://www.smart-investment.club/ercapi';
//Get token from local storage
const token = localStorage.getItem('accessToken');
let myHeaders = new Headers();

myHeaders.append('Application-Key', 'YOUR-APP-KEY'); //replace YOUR-APP-KEY with the real key
myHeaders.append('Authorization', 'Bearer ' + token);
myHeaders.append('Content-Type', 'application/json');

let requestOptions = {
  headers: myHeaders,
};

//Add table headers
courseTable.innerHTML = `<tr>
            <th>Id</th>
            <th>Name</th>
            <th>#participants</th>
        </tr>`;

//Get a list of courses
const getCourses = async () => {
  if (!token) {
    console.log('Login first');
  }

  requestOptions.method = 'GET';
  const response = await fetch(baseLink + '/api/courses', requestOptions);
  if (response.status === 200) {
    const data = await response.json();
    const courses = data.content;
    
    //Add courses to the table
    courses.forEach((course) => {
      const tr = document.createElement('tr');
      tr.innerHTML = `<td>${course.id}</td> 
                     <td>${course.name}</td>
                     <td>${course.numParticipants}</td>`;
      courseTable.appendChild(tr);
    });
  } else {
    const div = document.createElement('div');
    const message = `Something went wrong with your request (${response.status})`;
    div.innerHTML = message;
    document.body.appendChild(div);
  }
};

getCourses();

3. Add Basic style: main.css

h2 {
    font-weight: 500;
}

table {
    font-family: arial, sans-serif;
    border-collapse: collapse;
    width: 50%;
}

th {
    background-color: dodgerblue;
    color: #f5f3f3;
}

td,
th {
    border: 1px dotted #f5f3f3;
    text-align: left;
    padding: 8px;
}

tr:nth-child(even) {
    background-color: #f5f3f3;
}

td:nth-child(3) {
    text-align: center;
}

 

1