Metadata-Version: 2.4
Name: nocfo-file-downloader
Version: 0.1.0
Summary: CLI tool to download NoCFO attachments and organize them by document number.
Author: NoCFO
License: MIT License
        
        Copyright (c) 2026 NoCFO
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: attachments,cli,download,nocfo
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Financial and Insurance Industry
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.9
Requires-Dist: requests>=2.31.0
Requires-Dist: rich>=13.7.0
Requires-Dist: typer>=0.12.3
Description-Content-Type: text/markdown

# NoCFO File Downloader

CLI tool to download all attachments from a NoCFO business and organize them by document number.

## Features

- Fetches all documents and maps `document_number -> attachment_ids`.
- Downloads every attachment.
- Files linked to a document are saved as:

  `<document_number>/<document_number> <original_filename>`

- Files not linked to any document are saved under:

  `UNCATEGORIZED/<original_filename>`

- Shows a progress bar while downloading.

## Installation

```bash
pip install nocfo-file-downloader
```

## Usage

```bash
nocfo-dl <business_slug> --output-dir ./downloads
```

### Options

- `--output-dir/-o` Output folder (default: `./downloads`)
- `--base-url` API base URL (default: `https://api-prd.nocfo.io`)
- `--page-size` Page size for pagination (default: `200`)
- `--token` PAT token (if omitted, the tool will prompt)
- `--concurrency/-c` Number of concurrent downloads (default: `4`)

## PAT token (Personal Access Token)

The API uses token-based authentication. The token must be passed in the `Authorization` header as:

```
Authorization: Token <your_token_here>
```

You can create and manage tokens in the NoCFO web app under **Account Settings**:

- Production: https://login.nocfo.io/auth/tokens/
- Testing: https://login-tst.nocfo.io/auth/tokens/

The CLI prompts for a token at startup if you do not provide `--token`.

## Examples

Download attachments for business `acme-corp` to `./exports`:

```bash
nocfo-dl acme-corp --output-dir ./exports
```

Use a custom API base URL:

```bash
nocfo-dl acme-corp --base-url https://api-prd.nocfo.io
```

Limit concurrency:

```bash
nocfo-dl acme-corp --concurrency 8
```

## Development

```bash
python -m venv .venv
source .venv/bin/activate
pip install -e .
```

Run locally:

```bash
python -m nocfo_file_downloader <business_slug>
```

## License

MIT
