# Fetch Passport List

Fetch, filter, and paginate through passports onboarded by your dApp.

## Parameters

<table><thead><tr><th width="237">Name</th><th width="231">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>apiAccessToken</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>Access token<br>See <a href="create-access-token">createAccessToken</a></td></tr><tr><td><code>filters</code></td><td>object</td><td>Filter Options</td></tr><tr><td><code>limit</code></td><td>number</td><td>Per page limit</td></tr><tr><td><code>offset</code></td><td>number</td><td>Query / page offset</td></tr><tr><td><code>sortBy</code></td><td>[string, string]</td><td>Sort by options<br><em>["sortByName", "ASC or "DESC"]</em></td></tr><tr><td><code>options</code></td><td>object</td><td>Fetch Options</td></tr></tbody></table>

### Filter Options

<table><thead><tr><th width="223">Name</th><th width="231">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>association</code></td><td>string</td><td><code>"wallets"</code> or <code>"entities"</code><br><br>entities = Business Passports<br>wallets = Individual Passports<br><br>Defaults to "wallets"</td></tr><tr><td><code>attributeName</code></td><td>string<br><em>or</em><br>string[]</td><td>Attribute Name(s)</td></tr><tr><td><code>attributeStatus</code></td><td>QuadrataAttribute<br><em>or</em><br>QuadrataAttribute[]</td><td>Attribute Status(es)</td></tr><tr><td><code>walletAddress</code></td><td>string<br><em>or</em><br>string[]</td><td>Wallet Address(es)</td></tr><tr><td><code>isApproved</code></td><td>boolean</td><td><code>true</code> for approved passports<br><code>false</code> for not approved passports</td></tr><tr><td><code>isOnboardComplete</code></td><td>boolean</td><td><code>true</code> for completed applications<br><code>false</code> for incomplete applications</td></tr><tr><td><code>isProcessed</code></td><td>boolean</td><td><code>true</code> for processed applications<br><code>false</code> for unprocessed</td></tr><tr><td><code>isRejected</code></td><td>boolean</td><td><code>true</code> for rejected applications<br><code>false</code> for not-rejected</td></tr><tr><td><code>dateFrom</code></td><td>mm-dd-yyyy</td><td>Start date to filter by</td></tr><tr><td><code>dateTo</code></td><td>mm-dd-yyyy</td><td>End date to filter by</td></tr></tbody></table>

### Sort By Options

<table><thead><tr><th width="362">Name</th><th>Description</th></tr></thead><tbody><tr><td><code>createdAt</code></td><td>Sort by the wallet's created at date</td></tr><tr><td><code>association</code></td><td>Sort by the association type<br><em>The association type is wallets or entities</em></td></tr><tr><td><code>emailVerifiedAt</code></td><td>Sort by the date a passport's email address was verified at</td></tr><tr><td><code>walletAddress</code></td><td>Sort by wallet address</td></tr></tbody></table>

## SDK Configuration

<table><thead><tr><th width="183">Name</th><th width="233">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>environment</code><mark style="color:red;"><code>*</code></mark></td><td>QuadrataEnvironment</td><td>Access token<br>See <a href="create-access-token">createAccessToken</a></td></tr></tbody></table>

## Example

```typescript
import type { API } from '@quadrata/sdk/types';
import { fetchPassportList, QuadrataEnvironment } from '@quadrata/sdk/api';

type ResponseType = API.Service.FetchPassportList.Response;
type ParsedResponseType = API.Service.FetchPassportList.ParsedResponse;

const response: ResponseType = await fetchPassportList(
    // params
    {
        // required
        apiAccessToken: 'jwt token from createAccessToken',
        
        // all filters are optional
        filters: {
            // to filter only business wallets provide 'entities'
            // wallets is used by default
            association: 'wallets' || 'entities',
            
            // accepts a single attribute name or array of attribute names
            attributeName: QuadrataAttribute.AML || [QuadrataAttribute.AML, QuadrataAttribute.DID],
            
            // accepts a single attribute status or array of attribute statuses
            attributeStatus: QuadrataAttributeStatus.IN_REVIEW || [QuadrataAttributeStatus.READY, QuadrataAttributeStatus.IN_REVIEW],
            
            // date range
            dateFrom: 'mm-dd-yyyy',
            dateTo: 'mm-dd-yyyy',
            
            // accepts a single wallet address or array of wallet addresses
            walletAddress: '0x123' || ['0x123', '0x456'],
            
            // is the application approved
            isApproved: true || false,
            
            // is onboarding application completed (might be in review)
            isOnboardCompleted: true || false,
            
            // is the application processed by Quadrata (might be denied or approved)
            isProcessed: true || false,
            
            // is the application rejected by Quadrata
            isRejected: true || false,
        },
        
        // optional limit for each page of data returned
        limit: 20,
        
        // optional offset to fetch data at
        offset: 0,
        
        // optional page to fetch data for
        page: 1,
        
        // optional sort by
        // fields to sort by are:
        // - createdAt
        // - association
        // - emailVerifiedAt
        // - walletAddress
        sortBy: ['createdAt', 'desc'],
        
        // optional fetch options
        options: {
            cache: 'no-cache'
        }
    },
    // sdk config
    { environment: QuadrataEnvironment.PRODUCTION }
);

const limit = response.data.response.limit;
const totalNumRows = response.data.response.numRows;
const numPages = response.data.resposne.numPages;
const currentPage = response.data.response.page;
const currentOffset = response.data.response.offset;
const sortBy = response.data.response.sortBy;

const walletsForCurrentPage: ParsedResponseType = response.data.response.rows;
```

## Example Response Data

```json
{
    "data": {
        "response": {
            "limit": 100,
            "numPages": 1,
            "numRows": 1,
            "offset": 0,
            "page": 1,
            "rows": [
                {
                    "attributes": [
                        {
                            "name": "AML",
                            "status": "READY",
                            "verifiedAt": 1717618007
                        },
                        {
                            "name": "INVESTOR_STATUS",
                            "status": "READY",
                            "verifiedAt": 1717618249
                        },
                        {
                            "name": "DID",
                            "status": "READY",
                            "verifiedAt": 1717617309
                        },
                        {
                            "name": "COUNTRY",
                            "status": "READY",
                            "verifiedAt": 1717617309
                        }
                    ],
                    "createdAt": "2024-06-05T19:54:46.143226Z",
                    "emailVerifiedAt": "2024-06-05T19:55:08.532956+00:00",
                    "inquiries": [
                        {
                            "createdAt": "2024-06-05T20:10:49.140345",
                            "inquiryRef": "f2b58882-c498-42b1-b430-b05f20846317",
                            "status": "APPROVED",
                            "type": "ACCREDITATION"
                        },
                        {
                            "createdAt": "2024-06-05T19:55:08.541967",
                            "inquiryRef": "a90d5d91-4732-4e3e-93db-547865c1259d",
                            "status": "APPROVED",
                            "type": "EMAIL_VERIFICATION"
                        },
                        {
                            "createdAt": "2024-06-05T19:55:08.616694",
                            "inquiryRef": "a90d5d91-4732-4e3e-93db-547865c1259d",
                            "status": "INITIALIZED",
                            "type": "KYC"
                        },
                        {
                            "createdAt": "2024-06-05T19:56:22.79224",
                            "inquiryRef": "a90d5d91-4732-4e3e-93db-547865c1259d",
                            "status": "APPROVED",
                            "type": "KYC"
                        },
                        {
                            "createdAt": "2024-06-05T20:06:47.58897",
                            "inquiryRef": "17241695-6813-4168-9180-d235e8f2645f",
                            "status": "APPROVED",
                            "type": "AML"
                        }
                    ],
                    "onboardStartedAt": "2024-06-05T19:54:46.151151+00:00",
                    "walletAddress": "0x9f91Dbe7fBb3D12D449D9f1b804fe478aabEE107"
                }
            ],
            "sortBy": [
                "createdAt",
                "DESC"
            ]
        },
        "type": "list.wallets"
    }
}
```
