vylth-flow 0.4.1

Official Rust SDK for Vylth Flow — self-custody crypto payment processing
Documentation
# Vylth Flow Rust SDK


Official Rust SDK for [Vylth Flow](https://flow.vylth.com) — self-custody crypto payment processing.

## Installation


```toml
[dependencies]
vylth-flow = "0.1"
tokio = { version = "1", features = ["full"] }
```

## Quick Start


```rust,no_run
use vylth_flow::Flow;

#[tokio::main]

async fn main() {
    let client = Flow::new("vf_live_...");

    let invoice = client.invoices().create(vylth_flow::CreateInvoiceParams {
        amount: 100.0,
        currency: "USDT".into(),
        network: "tron".into(),
        ..Default::default()
    }).await.unwrap();

    println!("Invoice: {} -> {}", invoice.id, invoice.payment_url);
}
```

## Resources


### Invoices


```rust,no_run
# use vylth_flow::*;
# async fn example(client: &Flow) -> FlowResult<()> {
// Create
let inv = client.invoices().create(CreateInvoiceParams {
    amount: 100.0,
    currency: "USDT".into(),
    network: "tron".into(),
    description: Some("Order #123".into()),
    ..Default::default()
}).await?;

// Get
let inv = client.invoices().get("inv_123").await?;

// List
let list = client.invoices().list(Some(&ListParams {
    page: Some(1), limit: Some(20), ..Default::default()
})).await?;

// Cancel
let inv = client.invoices().cancel("inv_123").await?;
# Ok(())

# }

```

### Payouts


```rust,no_run
# use vylth_flow::*;
# async fn example(client: &Flow) -> FlowResult<()> {
let payout = client.payouts().create(CreatePayoutParams {
    amount: 50.0,
    currency: "USDT".into(),
    network: "tron".into(),
    destination_address: "TXyz...".into(),
    ..Default::default()
}).await?;

// Batch
let payouts = client.payouts().create_batch(&[
    CreatePayoutParams { amount: 50.0, currency: "USDT".into(), network: "tron".into(), destination_address: "TXyz...".into(), ..Default::default() },
]).await?;
# Ok(())

# }

```

### Wallets


```rust,no_run
# use vylth_flow::*;
# async fn example(client: &Flow) -> FlowResult<()> {
let wallet = client.wallets().generate(GenerateWalletParams {
    network: "tron".into(),
    currency: "USDT".into(),
    label: Some("deposits".into()),
}).await?;

let balance = client.wallets().balance("w_123").await?;
# Ok(())

# }

```

### Swaps


```rust,no_run
# use vylth_flow::*;
# async fn example(client: &Flow) -> FlowResult<()> {
let quote = client.swaps().quote(SwapParams {
    from_currency: "USDT".into(),
    to_currency: "BTC".into(),
    amount: 1000.0,
}).await?;
println!("Rate: {}", quote.rate);
# Ok(())
# }
```

### Webhooks

```rust,no_run
# use vylth_flow::*;
let client = Flow::builder("vf_live_...")
    .webhook_secret("whsec_...")
    .build();

if let Some(verifier) = client.webhooks() {
    let event = verifier.verify(payload, signature).unwrap();
    match event.event_type.as_str() {
        "invoice.paid" => { /* handle */ }
        "payout.completed" => { /* handle */ }
        _ => {}
    }
}
```

## Error Handling


```rust,no_run
# use vylth_flow::*;
# async fn example(client: &Flow) {
match client.invoices().get("inv_123").await {
    Ok(inv) => println!("Got invoice: {}", inv.id),
    Err(FlowError::Authentication { .. }) => eprintln!("Invalid API key"),
    Err(FlowError::NotFound { .. }) => eprintln!("Not found"),
    Err(FlowError::Validation { errors, .. }) => eprintln!("Invalid: {:?}", errors),
    Err(FlowError::RateLimit { retry_after, .. }) => eprintln!("Retry after {}s", retry_after),
    Err(FlowError::Server { .. }) => eprintln!("Server error"),
    Err(e) => eprintln!("Error: {}", e),
}
# }
```

## Configuration

```rust,no_run
use vylth_flow::Flow;
use std::time::Duration;

let client = Flow::builder("vf_live_...")
    .base_url("https://custom-api.example.com")
    .timeout(Duration::from_secs(60))
    .webhook_secret("whsec_...")
    .build();
```

## License


MIT