Skip to content

Feat: add /fees endpoint support to lago-types and lago-client#44

Merged
vladmarascu merged 2 commits into
mainfrom
list-fees
May 19, 2026
Merged

Feat: add /fees endpoint support to lago-types and lago-client#44
vladmarascu merged 2 commits into
mainfrom
list-fees

Conversation

@vladmarascu
Copy link
Copy Markdown
Contributor

@vladmarascu vladmarascu commented May 11, 2026

Summary

Adds the type definitions needed to consume Lago's /fees endpoint from the Rust SDK: FeeType enum, FeeFilters, request and response shapes. The matching client-side methods (LagoClient::list_fees, LagoClient::get_fee) will follow in a separate PR after this lands and lago-types is published.

What this PR adds

  • models::FeeType — new enum: Charge, AddOn, Subscription, Credit, Commitment. Added in models/invoice.rs next to the existing Fee, FeePaymentStatus, and FeeItem types, which are reused as-is.
  • filters::fee::FeeFilters — composes CustomerFilter, DateRangeFilter, plus scalars: fee_type, payment_status, billable_metric_code, external_subscription_id, currency. Date range maps to created_at_from / created_at_to.
  • requests::fee::ListFeesRequest, requests::fee::GetFeeRequest
  • responses::fee::ListFeesResponse, responses::fee::GetFeeResponse

What this PR does NOT add (intentional)

  • LagoClient::list_fees / LagoClient::get_fee — split into a follow-up PR after this lands. CI here would have required lago-client to build against an unpublished lago-types, which is incompatible with the repo's cargo publish --dry-run policy. The follow-up will bump lago-client's lago-types dep to whatever version this lands as.

Test plan

  • cargo fmt --all -- --check — clean
  • cargo clippy --all-features -- -D warnings — clean
  • cargo test --all-features — passes (no new tests; existing 8 doctests still pass)
  • cargo build --release --all-features — clean
  • cargo publish --dry-run for lago-types — clean
  • cargo publish --dry-run for lago-client — clean (no functional change in lago-client)

Followups

  • Publish lago-types 0.1.22 — needed before the lago-client work can land.
  • lago-client PR — adds list_fees and get_fee methods, plus an example. Will be opened against main once this is merged and the new lago-types version is on crates.io.
  • lago-agent-toolkit PR — adds the MCP tools that consume the new LagoClient methods. Opens after the lago-client PR lands.

## Context

The Lago API exposes a `/fees` endpoint that lets clients enumerate fee
line items across invoices with rich filtering. The SDK previously had
no module for this — `Fee`, `FeePaymentStatus`, and `FeeItem` lived in
`models/invoice.rs` as nested types for the invoice payload, but there
was no `FeeType` enum and no filter struct for the `/fees` list query.

## Description

Adds `FeeType` (Charge, AddOn, Subscription, Credit, Commitment) to
`models/invoice.rs` alongside the existing fee-related types.

Introduces `FeeFilters` in `filters/fee.rs` with the standard builder
pattern, composing `CustomerFilter` and `DateRangeFilter`. Date keys
are remapped to `created_at_from` / `created_at_to`. Enum-to-string
serialization uses explicit matches so multi-word variants like
`AddOn` correctly emit `add_on`.
## Context

Building on the FeeFilters added in the previous commit, the SDK needs
matching request/response shapes for the `/fees` list and detail endpoints.

## Description

Adds `ListFeesRequest` and `GetFeeRequest` in `requests/fee.rs`. The
list request composes `PaginationParams` and `FeeFilters` and exposes
`to_query_params()` for serializing into the URL query string.

Adds `ListFeesResponse` and `GetFeeResponse` in `responses/fee.rs`,
mirroring the existing invoice response shape (`Vec<Fee>` plus
`PaginationMeta` for lists; single `Fee` for detail).

Registers both modules in `requests.rs` and `responses.rs`.
@vladmarascu vladmarascu marked this pull request as ready for review May 14, 2026 17:02
@vladmarascu vladmarascu merged commit eadeee7 into main May 19, 2026
1 check passed
@vladmarascu vladmarascu deleted the list-fees branch May 19, 2026 13:00
@vladmarascu vladmarascu mentioned this pull request May 20, 2026
5 tasks
vladmarascu added a commit that referenced this pull request May 20, 2026
## Context

`lago-types 0.1.23` was published to crates.io with the `/fees` endpoint
types from #44. This commit consumes that release.

## Description

- `lago-client/Cargo.toml`: version 0.1.24 → 0.1.25 (new release for the
  `list_fees` / `get_fee` methods added in this PR)
- `lago-client/Cargo.toml`: dep `lago-types = "0.1.22"` → `"0.1.23"`
- `Cargo.lock`: regenerated; lago-client now resolves lago-types from the
  crates.io registry at 0.1.23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants