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

## Overview {#overview}

In this tutorial, we are building a simple Spring application that uses the Standard 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
* The Spring reference application that can be downloaded from [here](https://developer.mastercard.com/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 Standard Currency Conversion Calculator with the OpenAPI Client Generator

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

* Standard Currency Conversion Calculator

## 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

## 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.


       currency-conversion-reference-app
       └── src
           └── main
               └── resources
                   └── application.properties

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 utilises [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 **CurrencyConversionService.java** file.
* Java

```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;
  }
```

### Step 3 - Thank you {#step-3---thank-you}

**You have completed the tutorial!**

You are now running an application that utilizes the Standard 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/index.md).  

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

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

**List of available API Calls**

|        Endpoint        |                                                                                                       Description                                                                                                        |
|------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Conversion Rate        | Provides transaction details including date, transaction currency and amount, cardholder billing currency and issuer specific mark up to determine the applicable currency conversion rate and cardholder billing amount |
| Currencies             | Provides a list of currencies for which Mastercard publishes currency conversion rates                                                                                                                                   |
| Conversion Rate Issued | Provides status update if the present day Mastercard currency conversion rates are issued. Mastercard rates are published daily and effective for 24 hours                                                               |

### Select the endpoint from dropdown menu at the button Currency Conversion API's {#select-the-endpoint-from-dropdown-menu-at-the-button-currency-conversion-apis}

#### Conversion Rate {#conversion-rate}

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

![](https://static.developer.mastercard.com/content/currency-conversion-calculator/uploads/getConversionRate.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

#### Currencies {#currencies}

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

![](https://static.developer.mastercard.com/content/currency-conversion-calculator/uploads/getCurrencies.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}

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

![](https://static.developer.mastercard.com/content/currency-conversion-calculator/uploads/getRateIssued.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

## 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 integreated with the Thymeleaf template engine and it includes a simple form as a front-end interface used to populate the Standard Currency Conversion Calculator API call.
