# Zuora

## Overview

Zuora's applications automate billing, commerce, and finance operations.

## Exporting documents

Tray's Zuora connector allows the creation of files from ZOQL queries. There are two steps to this process. Step 1 - Create an export request
Use the Create Export operation to run a ZOQL query and generate a file. The connector will execute the query and will output an Export ID:

```json
\{
	"Success": true,
	"Id": "2c92c0f8610dde85016122ed1cf810cd"
\}
```

## Step 2 - Attempt to retrieve the export

The export can take some time. More complex queries will take longer for the export to run. Use the **Attempt Export** operation to send a request to retrieve the file that has been exported. You will need to provide the **Export ID** that was returned when you sent the **Create Export** request.
![export-id](https://tray.ai/documentation/images/connectors/service/zuora/0776917f-ce9bc6ea_export-id.png)
If the export has yet to complete you will get a playload like the one below. Note that the **ready** field is *false*. You can use a [Boolean Connector](https://tray.ai/documentation/connectors/core/boolean-condition/) to check whether the export has completed yet.

```json
{
	"ready": false,
	"file": null,
	"response_data": \{
		"Zip": false,
		"Encrypted": false,
		"Query": "select * from RevenueScheduleItem",
		"UpdatedDate": "2018-01-23T04:10:20.000-08:00",
		"UpdatedById": "2c92c0xxxxxxxxxxxxxxe7d3f01482c",
		"Status": "Processing",
		"CreatedDate": "2018-01-23T04:10:20.000-08:00",
		"Format": "csv",
		"CreatedById": "2c92c0fxxxxxxxxxxxxx1e7d3f01482c",
		"Id": "2c92c0fxxxxxxxxxxxxxxxxxed1cf810cd"
	\}
}
```

Once the export has completed the *ready* field is set to true and a URL for downloading the file is returned:

```json
{
	"ready": true,
	"file": \{
		"name": "2c92c086610ddd8e016122ed25b35ad9.csv",
		"url": "https://workflow-file-uploads.s3-us-west-2.amazonaws.com/3256fbc3-0a68-4xxx-xxxx-xxxxb3c5f0a1?Expires=1516795854&AWSAccessKeyId=AKIxxxxxxxxxxBQ&Signature=EhXxxxxxxxxxxxxxmcui%2BTvI0zyg%3D",
		"mime_type": "text/csv",
		"expires": 1516795854
	\},
	"response_data": \{
		"Size": 422,
		"Zip": false,
		"Encrypted": false,
		"Query": "select * from RevenueScheduleItem",
		"UpdatedDate": "2018-01-23T04:10:22.000-08:00",
		"UpdatedById": "2c92cxxxxxxxxxxxxx1e7d3f01482c",
		"Status": "Completed",
		"CreatedDate": "2018-01-23T04:10:20.000-08:00",
		"Format": "csv",
		"FileId": "2c92c0xxxxxxxxxxxx2ed25b35ad9",
		"CreatedById": "2c92cxxxxxxxxxxxxxx11e7d3f01482c",
		"Id": "2c92c0xxxxxxxxxxed1cf810cd"
	\}
}
```

## Step 3 - Process the file

Use another connector to process the saved file. If you have saved the file as a CSV you can use the CSV Connector to process the results.
