# How to Integrate using Reference Application
source: https://developer.mastercard.com/enhanced-currency-conversion-calculator/documentation/tutorials-and-guides/how-to-integrate-using-reference-application-tutorial/index.md

## Overview {#overview}

In this tutorial, we are building a simple Spring application that uses the Enhanced Currency Conversion Calculator API. We are passing the API a couple of parameters and viewing the response in a simple front-end application that is built using Spring and ThymeLeaf.

## Technologies Used {#technologies-used}

* Java
* Spring

## Pre-requisites {#pre-requisites}

* A development environment set up with your IDE of choice.
* Install Java 8 locally
* Install Maven 3 locally
* Download Spring [Reference Application](https://developer.mastercard.com/enhanced-currency-conversion-calculator/documentation/reference-app/index.md)

## What you will Build {#what-you-will-build}

A simple Spring application that shows how both APIs can be used together.

## What you will Learn {#what-you-will-learn}

* How to sign a request using Mastercard Java OAuth signer library
* How to integrate the Enhanced Currency Conversion Calculator with the OpenAPI Client Generator

## APIs used in this tutorial {#apis-used-in-this-tutorial}

Enhanced Currency Conversion Calculator

## Configuring the Local Server {#configuring-the-local-server}

To make API calls from our application, you must first configure and authenticate with our sandbox credentials.

![reference-app-folder-structure](https://static.developer.mastercard.com/content/enhanced-currency-conversion-calculator/uploads/ref-app/ref-app.PNG)

Properties  

mastercard.consumer.key=consumer.key.here  

mastercard.keystore.alias=key.alias.here  

mastercard.keystore.pass=key.pass.here  

mastercard.p12.path=path-to-your-p12  

The demo project utilizes [Mastercard's OAuth Signer library](https://github.com/Mastercard/oauth1-signer-java) and uses the values in application.properties to create an OAuth1.0a authorization header for our API calls. The request signing can be seen in the EnhancedCurrencyConversionService.java file.

```java
public ApiClient setupAppClient()
      throws org.openapitools.client.ApiException, CertificateException, UnrecoverableKeyException,
      NoSuchAlgorithmException, IOException, KeyStoreException, NoSuchProviderException {
    ApiClient client = new ApiClient();
    Builder builder = client.getHttpClient().newBuilder();
    // Provide absolutePath, keyalias, keystorepassword, consumer key for sanbox
    // before running the tests.
    PrivateKey signingKey = AuthenticationUtils.loadSigningKey(p12Path, keyAlias, keyPass);
    client.setBasePath(basePath);
    client.setHttpClient(builder.addInterceptor(new OkHttpOAuth1Interceptor(consumerKey, signingKey)).build());
    return client;
  }
```

## Building and Executing {#building-and-executing}

Once you've added the correct properties, you can build the demo application. Go to the project's base directory from the terminal and run the following command:

`mvn clean install`

When the project builds and tests pass successfully you can run the following command to start the project:

`mvn spring-boot:run`

## Viewing the Demo Application {#viewing-the-demo-application}

Once you have run the demo application you can navigate to:

<http://localhost:8080>

Our reference application is built as an MVC web application with the Spring Boot framework. Our template is integrated with the Thymeleaf template engine and it includes a simple form as a front-end interface used to populate the Enhanced Currency Conversion Calculator API call.

## How it works {#how-it-works}

List of available API Calls:

|        Endpoint         |                                                                                                     Description                                                                                                      |
|-------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Mastercard-currencies   | Provides a list of Mastercard currencies for which Mastercard publishes a rate.                                                                                                                                      |
| ECB-currencies          | Provides the list of currencies for which the ECB publishes an euro foreign exchange reference rate.                                                                                                                 |
| Conversion-rate-issued  | Helps determine if the present day's Mastercard and ECB conversion rates are available. Refer the Support section for more information on the Mastercard and ECB rate publication schedule.                          |
| Conversion-rate-summary | Provides Mastercard currency conversion rate, calculated cardholder billing amount, the ECB reference rate, and the calculated percentage difference between Mastercard and ECB rate for the provided currency pair. |

Select the endpoint from the dropdown menu at the button Currency Conversion API's

### Mastercard-currencies {#mastercard-currencies}

Once \[GET\] Mastercard Currencies endpoint is selected, you can click Submit to view the JSON returned by the service.

![reference-app-submit-screen](https://static.developer.mastercard.com/content/enhanced-currency-conversion-calculator/uploads/ref-app/ref-app-1.png)

![reference-app-json-response](https://static.developer.mastercard.com/content/enhanced-currency-conversion-calculator/uploads/ref-app/ref-app-2.png)

1. **View Response**: You can click this button to view the raw JSON request returned by the Reference Service API.
2. **Reset**: Restart the project to its initial state

### ECB-currencies {#ecb-currencies}

Once \[GET\] ECB Currencies endpoint is selected, you can click Submit to view the JSON returned by the service.

![reference-app-submit-screen](https://static.developer.mastercard.com/content/enhanced-currency-conversion-calculator/uploads/ref-app/ref-app-3.png)

![reference-app-json-response](https://static.developer.mastercard.com/content/enhanced-currency-conversion-calculator/uploads/ref-app/ref-app-4.png)

1. **View Response**: You can click this button to view the raw JSON request returned by the Reference Service API.
2. **Reset**: Restart the project to its initial state

### Conversion-rate-issued {#conversion-rate-issued}

Once \[GET\] Rate Statuses endpoint is selected, you can enter the below details and click Submit to view the JSON returned by the service.

![reference-app-submit-screen-rate-statuses](https://static.developer.mastercard.com/content/enhanced-currency-conversion-calculator/uploads/ref-app/ref-app-5.png)

![reference-app-json-response-rate-statuses](https://static.developer.mastercard.com/content/enhanced-currency-conversion-calculator/uploads/ref-app/ref-app-6.png)

1. **View Response**: You can click this button to view the raw JSON request returned by the Reference Service API.
2. **Reset**: Restart the project to its initial state

### Conversion-rate-summary {#conversion-rate-summary}

Once \[GET\] Summary Rates endpoint is selected, you can enter the below details and click Submit to view the JSON returned by the service.

![reference-app-submit-screen-currency-conversion-rate](https://static.developer.mastercard.com/content/enhanced-currency-conversion-calculator/uploads/ref-app/ref-app-7.png)

![reference-app-submit-screen-currency-conversion-rate-json-response](https://static.developer.mastercard.com/content/enhanced-currency-conversion-calculator/uploads/ref-app/ref-app-8.png)

1. **View Response**: You can click this button to view the raw JSON request returned by the Reference Service API.
2. **Reset**: Restart the project to its initial state

## Thank you {#thank-you}

You have completed the tutorial!

You are now running an application that utilizes the Enhanced Currency Conversion Calculator API. The next step is converting your sandbox keys to production. Refer to [How to Move to Production](https://developer.mastercard.com/currency-conversion-calculator/documentation/tutorials-and-guides/how-to-move-to-production-tutorial/).

We hope this tutorial was helpful. Please [Contact Us](https://developer.mastercard.com/support) with any questions or feedback you may have.
