# Ramp Card

Fetch card transactions from Ramp.

## Setup

Create an OAuth application in Ramp and obtain an access token with `transactions:read` scope.

```bash
export RAMP_ACCESS_TOKEN=ramp_...
```

## Usage

```bash
vgrid fetch ramp-card --from 2026-01-01 --to 2026-02-01 --out ramp-card.csv
```

Filter by card or entity:

```bash
vgrid fetch ramp-card --card card_123 --from 2026-01-01 --to 2026-02-01 --out ramp-card.csv
```

## Options

| Flag | Description | Default |
|------|-------------|---------|
| `--from` | Start date inclusive (YYYY-MM-DD) | required |
| `--to` | End date exclusive (YYYY-MM-DD) | required |
| `--api-key` | Ramp access token | `RAMP_ACCESS_TOKEN` env |
| `--state` | Transaction state filter | `CLEARED` |
| `--card` | Filter by card ID | — |
| `--entity` | Filter by entity ID | — |
| `--out` | Output CSV path | stdout |
| `-q` / `--quiet` | Suppress progress messages | off |

## Type mapping

| Amount sign | Canonical type | Output sign |
|-------------|----------------|-------------|
| Positive (purchase) | `purchase` | negative (outflow) |
| Negative (refund) | `refund` | positive (inflow) |

## Date handling

- **`effective_date`** — `user_transaction_time` truncated to YYYY-MM-DD
- **`posted_date`** — `settlement_date` truncated to YYYY-MM-DD; falls back to `effective_date`

## Notes

**State filter.** Defaults to `CLEARED`. Pass `--state` to change (e.g. `PENDING`).

**Amount parsing.** Ramp sends amounts as decimal dollars or as `{ "amount": cents, "currency_code": "USD" }`. Both formats are handled automatically.

**Description priority.** `merchant_name` > `merchant_descriptor` > `memo`.

**`group_id`.** Set to the `card_id`, grouping transactions by card.

**`source` field.** `ramp_card`.

**Pagination.** Cursor-based (`page.next`). Results are fetched in ascending date order.

**Sort order.** `effective_date` ascending, then `source_id` ascending.