Skip to content

It's a trade project using LWC and Fixer APi to get the latest rate of a currency and convert.

Notifications You must be signed in to change notification settings

brunagirao/trade-lwc

Repository files navigation

Ebury Trading App

My Image

Ebury Requirements Test

  • We want to build a new web application that will allow us to create and store foreign exchange trades.
  • The main view is the Ebury Trading application, which contains a Trade list view, displaying the list of already booked trades and the relevant fields

What I used in this project

  • Apex Class
  • Apex Test Class
  • Apex Mock Class
  • Fixer API
  • Lightning Web Component (LWC)
  • Custom Labels
  • Named Credentials
  • Custom Settings

IMPORTANT! | Ebury Custom Settings

  • After push the components of this project in Salesforce a Custom Setting named Ebury Custom Setting will be created. So, you need fill the fields below with the correct data for the code execute as expected:
  • ApiKey: get your key in Fixer API site. My apiKey is C2NlwIvwyXnRC2smGYyGRc9kDlctJ82O
  • Ebury Queue: TradeReviewers
  • Template Email Notification: NewTrade

REQ1. New Trade View [Done]

  • Sell Currency and Buy Currency: initial value should be empty.
  • App: retrieve latest rate for the selected currency pair and display it.
  • Buy Amount: not be editable and be automatically calculated.
  • Rate: not be editable.
  • Buy Amount formula: Sell Amount x Rate.

What I Made?

  • I created the New Trade View using LWC as imagem below provided in the test.
  • I used the newTrade.js of the NewTrade LWC provided in the test.
  • I added the fields to view and follow the requirements above:

Wireframe

My Image

Screen I created | Initial field values

My Image

Screen after selected currency pairs

My Image

Screen after fill Sell Amount

My Image

REQ2. Send a notification after Trade Creation [Done]

  • Notify all users in a queue named Trade Reviewers.
  • Content of notification:
    “A new trade has been created with the following data:
    Sell Currency: {sell ccy}
    Sell Amount: {sell amount}
    Buy Currency: {buy ccy}
    Buy Amount: {buy amount}
    Rate: {rate}
    Booked Date: {date}
    Link to the trade: {trade link}"

What I Made?

  • I created a Classic Email Template named New Trade and add the Template Content provided in the test.
  • I created a Queue named Trade Reviewers
  • I created a Custom Settings named Ebury Trading Settings to store the main app settings.

Classic Email Template

My Image My Image

Queue

My Image

Custom Settings

My Image My Image

REQ3. Create a connection with a External Service(API) | Fixer.io | Get Latest Rate [Done]

  • Create a connection with a External Service(API) to get Latest Rate
  • Use fixer.io(API) to get Latest Rate.
  • Use the class NewTradeController provided in the test to make the connection to API Fixer.io

What I Made?

  • I created add the link fixer.io to CSP Trusted Sites in Salesforce
  • I created a Named Credentials named GetLatestExchangeRate to add the fixer.io endpoint that I use to make the callouts to get the latest rates.
  • I added the ApiKey provided by fixer.io in the Ebury Trade Settings (Custom Setting)
  • I created a standard class of response named ActionResponse
  • I used the endpoint /latest of the API (returns real-time exchange rate data for all available or a specific set of currencies).

CSP Trusted Sites

My Image

Named Credentials

My Image

Ebury Trade Settings

My Image My Image

REQ4. Test Class Coverage [Done]

  • Create a connection with a External Service(API) to get Latest Rate
  • Use fixer.io(API) to get Latest Rate.
  • Use the class NewTradeController provided in the test to make the connection to API Fixer.io

What I Made?

  • I created a mock class named NewTradeControllerMock to simulate the callouts to fixer.io
  • I created a test class named NewTradeControllerTest.
  • I covered 100% of the classes used in this test.

Test Class Coverage

My Image My Image

REQ5. Salesforce CLI and Salesforce DX [Done]

  • This application will be deployed using Salesforce CLI and Salesforce DX
  • Update the build.sh script to create the scratch org if needed and leave it ready for testing.

What I Made?

  • I worked with the SFDX and CLI developement to push, retrieve, run test and so on.
  • I updated the buil.sh with the command needed to:
    • create scratch org
    • set the scratch org as default
    • push the changes
    • execute tests

How Do You Plan to Deploy Your Changes?

Do you want to deploy a set of changes, or create a self-contained application? Choose a development model.

Configure Your Salesforce DX Project

The sfdx-project.json file contains useful configuration information for your project. See Salesforce DX Project Configuration in the Salesforce DX Developer Guide for details about this file.

Read All About It