LogoLogo
timvero.comMaven Repository
  • timveroOS SDK guide
  • timveroOS how-to
  • timveroOS admin-side setup
  • How to use Maven credentials
  • timveroOS SDKs
    • v. 7.11
      • Ubuntu environment setup
      • Data model setup
      • New data source connection, with Bud Financial example
      • Flow customization
      • Decision process execution
      • Participant/ assets dynamic profile setup
      • Documents flow integration setup
      • Application form setup
      • Application API Integration Guide
      • UI/ UX components
        • Collapsing blocks
    • v. 7.10
      • Ubuntu environment setup
      • Data model setup
      • New data source connection, with Bud Financial example
      • Flow customization
      • Participant/ assets dynamic profile setup
      • Documents flow integration setup
      • Application form setup
      • Application API Integration Guide
      • UI/ UX components
        • Collapsing blocks
Powered by GitBook
On this page

Was this helpful?

  1. timveroOS SDKs
  2. v. 7.10

New data source connection, with Bud Financial example

1. The process of creating a client and receiving data from Bud

  • customer_id: A unique client identifier from Bud system.

  • OS: The timveroOS (operating system).

  • public_link: A link to Open Banking which the client uses to grant/deny data access permission.

  • notification_module: An OS module for client and user notifications.

  • callback: A function executed by Bud within OS after client consent.

When a new participant is added, the Operating System (OS) creates a client in the Bud service and saves their customer_id in the data model. Once the client is created, the OS requests a public_link from Bud using the customer_id. The OS then generates and sends a notification to the client via the notification_module. When the client follows the public_link and grants data usage permission, the Bud system executes a callback. Based on the customer_id, the OS requests the client’s data and saves it in the model. Afterwards, the data becomes available for use in the feature store.

2. Connections for integrating timveroOS as a data source

The timveroOS, among other features, provides ready-made interfaces that allow you to connect an unlimited number of data sources at any stage of the system’s implementation and use.

To connect an external data source, you need to extend the DataSource interface by implementing its two main methods:

  • A data retrieval method - getData(Participant) - which encapsulates the logic for connecting to an external data source API.

  • A data parsing method - parseRecord(Content) - which allows transforming the received data of any format into a simple JSON or XML structure.

MappedDataSource interface and implement two main methods:

  • getData(Participant): Logic for API connection to an external data source.

  • parseRecord(Content): Converts data of any format into a simple JSON or XML structure.

DataSource Interface:

public interface DataSource<E extends DataSourceSubject, T> {

    Content getData(E subject) throws Exception;

    T parseRecord(Content data) throws Exception;

    class Content {

        private final byte[] body;
        private final String mime;

        public Content(byte[] body, String mime) {
            this.body = body;
            this.mime = mime;
        }

        public byte[] getBody() {
            return this.body;
        }

        public String getMime() {
            return this.mime;
        }
    }
}

E- a deal entity implementing the DataSourceSubject interface.

Connection of the BudTransactionDataSource data source:

@Service(BudTransactionsDataSource.DATASOURCE_NAME)
public class BudTransactionsDataSource implements DataSource<Participant, TransactionsRoot> {

    public static final String DATASOURCE_NAME = "bud-transactions";

    @Autowired
    private BudService budService;

    private ObjectMapper objectMapper = new ObjectMapper();

    @Override
    public Content getData(Participant subject) throws Exception {
        UUID customerId = subject.getCustomerId();
        TransactionsRoot transactions = budService.getTransactions(customerId);
        return new Content(objectMapper.writeValueAsBytes(transactions),                   MediaType.APPLICATION_JSON_VALUE);
    }

    @Override
    public TransactionsRoot parseRecord(Content data) throws Exception {
        return objectMapper.readValue(data.getBody(), TransactionsRoot.class);
    }

    @Override
    public Class<TransactionsRoot> getType() {
        return TransactionsRoot.class;
    }
}
  • To form and send requests, the standard RestTemplate tool provided by the Spring Web framework is used.

  • For parsing responses, the standard ObjectMapper tool provided by the Jackson library is used.

This example showcases the ease of connecting data sources and the transparency of their implementation. Thanks to the multi-level architecture of Timvero OS, sources are readily available for use immediately and without additional modifications.

3. Implementation of Bud integration

For the implementation of integration, we register a working project in the Bud system and obtain client_id and client_secret. We place the client_id and client_secret values in a configuration file. This allows for the keys to be updated without changing the code.

#BUD
bud.baseUrl=https://api-sandbox.thisisbud.com
bud.clientId=7195a0dc-d158-4cce-8e78-69bbc2e35715
bud.clientSecret=larXySiLtCh6SqU5CbfioVd/mAWmzqTmZsGA/rvhwjg
bud.redirectUrl=http://smb-uk.timvero.xyz/callback/bud
bud.transactionsUrl=/financial/v2/transactions

Getting an access token: The BudService#initAccessToken() method is for initiating an access token used to access client information:

BudService#initAccessToken()

private void initAccessToken() {
    HttpHeaders headers = getTokenHeaders();

    MultiValueMap<String, String> requestBody = new LinkedMultiValueMap<>();
    requestBody.add("grant_type", "client_credentials");

    HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(requestBody, headers);

    String tokenUrl = this.baseUrl + "/v1/oauth/token";
    this.accessToken
        = this.rest.exchange(tokenUrl, HttpMethod.POST, request, BudAccessToken.class).getBody();
}

Creating a client in the Bud system: The BudService#createClient() method is for creating a new client:

public UUID createClient() {
    HttpHeaders headers = getHeaders(null);
    HttpEntity<?> requestEntity = new HttpEntity<>(headers);

    String createUrl = this.baseUrl + "/platform/v3/customers";
    ResponseEntity<Root> response
        = this.rest.exchange(createUrl, HttpMethod.POST, requestEntity, Root.class);
    return Objects.requireNonNull(response.getBody()).getData().getCustomerId();
}

Retrieving the public_link: The BudService#getPublicLink(UUID customerId) method is for obtaining a public link that the client can use to give permissions:

public String getPublicLink(UUID customerId) {
    HttpHeaders headers = getHeaders(customerId);

    String redirectUrl = this.redirectUrl + "?customerId=" + customerId;
    HttpEntity<Map<String, String>> requestEntity
        = new HttpEntity<>(Map.of("redirect_url", redirectUrl), headers);

    String linkUrl = this.baseUrl + "/v2/open-banking/authorisation-gateway-url";

    ResponseEntity<LinkRoot> response
        = this.rest.exchange(linkUrl, HttpMethod.POST, requestEntity, LinkRoot.class);
    return Objects.requireNonNull(response.getBody()).getData().getUrl();
}

Getting client data: The BudService#getTransactions(UUID customerId) method is for retrieving client transaction data:

public TransactionsRoot getTransactions(UUID customerId) {
    HttpHeaders headers = getHeaders(customerId);

    HttpEntity<?> requestEntity = new HttpEntity<>(headers);

    String transactionUrl = this.baseUrl + "/financial/v2/transactions";

    ResponseEntity<TransactionsRoot> response
        = this.rest.exchange(transactionUrl, HttpMethod.GET, requestEntity, TransactionsRoot.class);

    return Objects.requireNonNull(response.getBody());

}

Callback Controller:

@PostMapping(consumes = MediaType.APPLICATION_JSON_VALUE)
public void callback(@RequestBody CallBackRoot root) throws IOException {
    if(SUCCESS_STATUS.equalsIgnoreCase(root.getData().getStatus())){
        UUID customerId = root.getData().getCustomerId();
        Participant participant = participantService.getParticipantByCustomerId(customerId);
        dataSourceManager.getData(participant, BudTransactionsDataSource.DATASOURCE_NAME, LoadingMode.FORCE);
    } else {
        // TODO notifying the system about an exception
    }
}
PreviousData model setupNextFlow customization

Last updated 4 months ago

Was this helpful?