Roostify Connector | MuleSoft Documentation
# Roostify Connector
Roostify Connector v1.0
Anypoint Connector for Roostify (Roostify Connector) enables customers to convert completed loan applications to an optimized and intuitive digital user experience, tailored to each DBA, branch, or channel. It increases pull-through rates and provides a flexible and scalable framework for growing business requirements. Roostify’s integrated platform enables faster loan closure and allows each loan officer to cultivate and manage more customers at the same time. This improves profitability as well as increases retention and referrals.
Roostify Connector offers simplified access to 46 of Roostify’s APIs to support workflows related to:
  * Access Control
  * Accounts
  * Desktop Underwriter Report
  * Documents
  * Leads (Draft)
  * Loan Applications
  * Messages
  * Offerings (Draft)
  * Reference Ids
  * Service
  * Settings
  * State Changes
  * Status Update
  * Tasks
  * User Management
  * User Settings
  * Webhook events
  * Webhooks


Release Notes: Roostify Connector Release Notes Exchange: Roostify Connector
## Before You Begin
To use this information, you should be familiar with Roostify, Mule concepts, Anypoint connectors, Anypoint Studio, the elements in a Mule flow, and global elements.
The APIs use basic authentication, based on username and password. You need a Roostify account and credentials to use the connector. The username works as your account token and password as a service access token. The username and password are stored within the Authorization header in Base64-encoded string following the word Basic which when decoded follows the format of `account-token:service-access-token`.
For software requirements and compatibility, see the Connector Release Notes.
## POM File Information
```
<dependency>
 <groupId>com.mulesoft.connectors</groupId>
 <artifactId>mule-roostify-connector</artifactId>
 <version>x.x.x</version>
 <classifier>mule-plugin</classifier>
</dependency>
```

Replace `x.x.x` with the version that corresponds to the connector you are using.
To obtain the most up-to-date `pom.xml` file information, access the connector in Anypoint Exchange and click **Dependency Snippets**.
## Add the Connector to a Studio Project
Anypoint Studio provides two ways to add the connector to your Studio project: from the Exchange button in the Studio taskbar or from the Mule Palette view.
### Add the Connector Using Exchange
  1. In Studio, create a Mule project.
  2. Click the Exchange icon **(X)** in the upper-left of the Studio task bar.
  3. In Exchange, click **Login** and supply your Anypoint Platform username and password.
  4. In Exchange, search for "roostify".
  5. Select the connector and click **Add to project**.
  6. Follow the prompts to install the connector.


### Add the Connector in Studio
  1. In Studio, create a Mule project.
  2. In the Mule Palette view, click **(X) Search in Exchange**.
  3. In **Add Modules to Project** , type "roostify" in the search field.
  4. Click this connector’s name in **Available modules**.
  5. Click **Add**.
  6. Click **Finish**.


## Connector Namespace and Schema
When designing your application in the Anypoint Studio, drag the connector from the palette to the canvas. This action automatically populates the XML code with the connector namespace and schema location.
  * Namespace: `http://www.mulesoft.org/schema/mule/roostify`
  * Schema Location: `http://www.mulesoft.org/schema/mule/roostify/current/mule-roostify.xsd`


## Configure Roostify Connector in Anypoint Studio
  1. In Anypoint Studio, create a new Mule project. Ensure that you have **HTTP Listener** configured.
  2. Drag the connector to the Studio Canvas.
  3. Configure the connector’s global element. You can either enter your credentials as global configuration properties or reference a configuration file that contains these values. For simpler maintenance and better reuse of your project, MuleSoft recommends that you use a configuration file.
     * **Address** : URL to access Roostify API
     * **Username** : The user name to access Roostify API
     * **Password** : Password to access Roostify API
     * **Version** : Roostify API version. For example, this property should contain `/v1`, if the API version is `v1`.
An example configuration file for Roostify is available at `src/main/resources/configuration.yaml`. You can add this file in the Configuration Properties of the Global Configuration Elements.   
---  
  4. To ensure that your connection is successful, Click **Test Connection**.
  5. Select a connector operation.


## Use Case: Create a Roostify User and a Loan Application
The following use case demonstrates how you can use the Roostify connector along with Salesforce connector to:
  * Create a user in Roostify for a Salesforce account
  * Create a loan application for the same user in Roostify


In this example, a Mule application queries Salesforce accounts and creates a user in Roostify for this account. Next step in the flow is to create a loan application for this new user in Roostify.
To test this use case:
  1. Create a Mule application and set the connector configuration properties in the configuration file in the `src/main/resources`. For example:
```
rsf:
 address: "<url-to-access-roostify-api>"
 version: "/<roostify-api-version>"
 user: "<username-to-access-roostify-api>"
 password: "<password-to-access-roostify-api>"
```

  2. Add the configuration file for the Roostify connector to the **Configuration Properties** of the **Global Configuration Elements**.


To create the new Mule application flow:
  1. Drag an HTTP Listener to the canvas and configure it.
  2. From the **Palette** , search for the Salesforce connector and drag **Query** operation. To configure Salesforce operation,
    1. Add your query in the **Salesforce query**. For the purpose of this demo, use the following query to get the account from Salesforce.
```
SELECT Id, AccountNumber, Phone, Name FROM Account where Id = ':sfId'
```

    2. In the **Parameters** section, create a parameter with `sfId` as **Name** and `attributes.queryParams.sfcId` as **Value**.
  3. Select and drag Transform Message at the flow on the canvas to prepare the input for the Roostify connector. Here’s an example of the output payload in the transform message.
```
%dw 2.0
output application/json
---
{
	user_role: "borrower",
	home_phone: payload.Phone[0],
	reference_id: "Test-ref-123",
	last_name: "Demo",
	account_id: payload.AccountNumber[0],
	job_title: "ADMIN",
	first_name: payload.Name[0],
	email: payload.Id[0] ++ "@roostify.com"
}
```

  4. From Roostify operations, drag the **Create a User** connector operation after the transform message. In the configuration options:
    1. Select the connector configuration that you created.
    2. Set the **General** section in the connector configuration to `payload`.
    3. Set the **Target Value** in the **Advanced** section to `#[payload]`.
  5. From the **Mule Palette** , search and drag **Set Variable** operation after the Roostify operation, to capture the user ID returned from Roostify into a variable. In the **Settings** section of the **Set Variable** operation, set the following:
    1. **Name** : `userId`
    2. **Value** : `#[payload.id]`
  6. From Roostify operations, drag **Create a Loan Application** operation. In the configuration options,
    1. Use the following example payload in the **Create loan request** of the **General** section:
```
output application/json
---
{
	reference_id: vars.refId,
	application_type: "purchase",
	loan_amount: 20000,
	down_payment: 1000,
	amortization_term: "30"
}
```

    2. Set the **Target Value** in the **Advanced** section to `#[payload]`.
  7. Once again, from the **Mule Palette** , search and drag **Set Variable** operation after the Roostify operation, to capture the loan ID returned from Roostify into a variable. In the **Settings** section of the **Set Variable** operation, set the following:
    1. **Name** : `userId`
    2. **Value** : `#[payload.id]`
  8. Use another Transform Message component to display the response in JSON format. The output payload of the transform message can be set to the following:
```
%dw 2.0
output application/json
---
{
	"RSF Account Id" : payload.account_id,
	"User Id" : vars.userId,
	"Loan Id" : vars.loanId
}
```

  9. Run the application and point your browser to `http://localhost:8081/createLoanApplication`.
2. Set the **Target Value** in the **Advanced** section to `#[payload]`.
  7. Once again, from the **Mule Palette** , search and drag **Set Variable** operation after the Roostify operation, to capture the loan ID returned from Roostify into a variable. In the **Settings** section of the **Set Variable** operation, set the following:
    1. **Name** : `userId`
    2. **Value** : `#[payload.id]`
  8. Use another Transform Message component to display the response in JSON format. The output payload of the transform message can be set to the following:
```
%dw 2.0
output application/json
---
{
	"RSF Account Id" : payload.account_id,
	"User Id" : vars.userId,
	"Loan Id" : vars.loanId
}
```

  9. Run the application and point your browser to `http://localhost:8081/createLoanApplication`.


## Use Cases XML: Create a Roostify User and a Loan Application
```
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:salesforce="http://www.mulesoft.org/schema/mule/salesforce" xmlns:roostify="http://www.mulesoft.org/schema/mule/roostify"
	xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
	xmlns:http="http://www.mulesoft.org/schema/mule/http"
	xmlns="http://www.mulesoft.org/schema/mule/core"
	xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http
http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/core
http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
http://www.mulesoft.org/schema/mule/roostify
http://www.mulesoft.org/schema/mule/roostify/current/mule-roostify.xsd
http://www.mulesoft.org/schema/mule/salesforce
http://www.mulesoft.org/schema/mule/salesforce/current/mule-salesforce.xsd">
	<flow name="CREATE_ROOSTIFY_USER_LOAN_APPLOCATION">
		<http:listener doc:name="8081/createLoanApplication"
		config-ref="HTTP_Listener_config" path="createLoanApplication"/>
		<salesforce:query doc:name="Get Salesforce Account" config-ref="Salesforce_Config">
			<salesforce:salesforce-query>SELECT Id, AccountNumber, Phone, Name FROM Account where Id = ':sfId'</salesforce:salesforce-query>
			<salesforce:parameters><![CDATA[#[output application/java
---
{
	"sfId" : attributes.queryParams.sfcId
}]]]></salesforce:parameters>
		</salesforce:query>
		<ee:transform doc:name="Convert to JSON">
			<ee:message>
				<ee:set-payload><![CDATA[%dw 2.0
output application/json
---
{
	user_role: "borrower",
	home_phone: payload.Phone[0],
	reference_id: "Test-ref-123",
	last_name: "Demo",
	account_id: payload.AccountNumber[0],
	job_title: "ADMIN",
	first_name: payload.Name[0]
}]]></ee:set-payload>
			</ee:message>
			<ee:variables>
				<ee:set-variable variableName="refId"><![CDATA[%dw 2.0
output application/java
---
{
	"refId" : "Test-ref-123"
}]]></ee:set-variable>
			</ee:variables>
		</ee:transform>
		<roostify:create-user doc:name="Create a User in Roostify" config-ref="Roostify_Config" />
		<set-variable value="#[payload.id]" doc:name="Save User ID" variableName="userId" />
		<roostify:creating-loan-application doc:name="Create a Loan Application in Roostify" config-ref="Roostify_Config">
			<roostify:create-loan-request><![CDATA[#[output application/json
---
{
	reference_id: vars.refId,
	application_type: "purchase",
	loan_amount: 20000,
	down_payment: 1000,
	amortization_term: "30"
}]]]></roostify:create-loan-request>
		</roostify:creating-loan-application>
		<set-variable value="#[payload.id]" doc:name="Save Loan ID" variableName="loanId" />
		<ee:transform doc:name="Display Response">
			<ee:message >
				<ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
{
	"RSF Account Id" : payload.account_id,
	"User Id" : vars.userId,
	"Loan Id" : vars.loanId
}
]]></ee:set-payload>
			</ee:message>
		</ee:transform>
	</flow>
</mule>
```

## See Also
  * MuleSoft Help Center