Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pitzzahh/automated-teller-machine-api
API used for making atm applications (none-web-app)
https://github.com/pitzzahh/automated-teller-machine-api
automated-teller-machine database postgresql-database spring-jdbc spring-jdbctemplate
Last synced: 17 days ago
JSON representation
API used for making atm applications (none-web-app)
- Host: GitHub
- URL: https://github.com/pitzzahh/automated-teller-machine-api
- Owner: pitzzahh
- License: mit
- Created: 2022-07-23T13:18:12.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-05-15T07:59:30.000Z (over 1 year ago)
- Last Synced: 2024-10-11T12:45:18.560Z (about 1 month ago)
- Topics: automated-teller-machine, database, postgresql-database, spring-jdbc, spring-jdbctemplate
- Language: Java
- Homepage:
- Size: 809 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# automated-teller-machine-API
API used for making atm applications (none-web-app)![GitHub Issues](https://img.shields.io/github/issues/pitzzahh/automated-teller-machine-console)
![Forks](https://img.shields.io/github/forks/pitzzahh/automated-teller-machine-console)
![Stars](https://img.shields.io/github/stars/pitzzahh/automated-teller-machine-console)
![License](https://img.shields.io/github/license/pitzzahh/automated-teller-machine-console)
________________________________________
## Quickstart
### How to use the API
* With Database (can use any DBMS)```java
import io.github.pitzzahh.atm.database.DatabaseConnection;
import io.github.pitzzahh.atm.dao.InDatabase;
import io.github.pitzzahh.atm.service.AtmService;
import io.github.pitzzahh.atm.dao.AtmDAO;public class App {
private static final AtmDAO ATM_DAO = new InDatabase();
private static final DatabaseConnection DATABASE_CONNECTION = new DatabaseConnection();public static void main(String[] args) {
AtmService atmService = new AtmService(ATM_DAO);
atmService.setDataSource().accept(
DATABASE_CONNECTION
.setDriverClassName("org.postgresql.Driver")
.setUrl("jdbc:postgresql://localhost/{database_name}")
.setUsername("{username}")
.setPassword("{password}")
.getDataSource()
);
}
}
```---
* Without Database (in-memory)
```java
import io.github.pitzzahh.atm.service.AtmService;
import io.github.pitzzahh.atm.dao.InMemory;public class App {
public static void main(String[] args) {
AtmService atmService = new AtmService(new InMemory());
}
}
```## Saving clients
To save a client object, a method called `saveClient()` in `AtmService` is used. It is a Function that accepts a Client Object.
```java
atmService.saveClient().apply(
new Client(
"123123123",
"123123",
new Person(
"Mark",
"Silent",
Gender.PREFER_NOT_TO_SAY,
"Earth",
LocalDate.of(2018, Month.AUGUST, 10)
),
5555,
false
)
);
// getting the client, returns a Client object, throws IllegalArgumentException if account number does not belong to any client.
Client client = atmService.getClientByAccountNumber().apply("123123123");
// prints the client (using Print class from util-classes-API)
println(client);
// removes the client by account number
atmService.removeClientByAccountNumber().apply("123123123");```
To get the client from the database, there are two methods that can be used, first is `getClientByAccountNumber()` a method that accepts a
`String` containing an account number, second is `getAllClients()` a method that get all the client
as a `Supplier>`.
Below shows the two ways on how to get a client/clients.
```java
// getting client by account number
Client client = atmService.getClientByAccountNumber().apply("123123123");
```
```java
// getting all the clients.
Supplier > clients = atmService.getAllClients();
```
To remove a client, there are also two methods that can be used, first is removing client by account number,
second is removing all the clients.
Below shows the two ways on how to remove a client/clients.
```java
// removes the client by account number
atmService.removeClientByAccountNumber().apply("123123123");
```
```java
// removes all the clients
atmService.removeAllClients();
```
### Add Maven Dependency
![maven-central](https://img.shields.io/maven-central/v/io.github.pitzzahh/automated-teller-machine-API?color=blue)If you use Maven, add the following configuration to your project's `pom.xml`
Be sure to replace the **VERSION** key below with the one of the versions shown above
```maven
io.github.pitzzahh
automated-teller-machine-API
VERSION
```
### Others
Dependencies
- [util-classes](https://github.com/pitzzahh/util-classes)