Skip to content

feat(account-tree): add usage attribution types and attributed usage - #427

Open
lovrocolic wants to merge 1 commit into
mainfrom
usage_attribution
Open

lovrocolic wants to merge 1 commit into
mainfrom
usage_attribution

Conversation

@lovrocolic

Copy link
Copy Markdown
Collaborator

Context

The account tree feature lets usage be tracked under custom types, such as teams or users. The API exposes CRUD endpoints for usage attribution types (getlago/lago-api#6415) and an endpoint that reads attributed usage (getlago/lago-api#6566).

Description

Usage attribution types

  • New client.usage_attribution_types client with create, update, find, destroy and find_all. Each one is keyed by code.
  • New UsageAttributionType input model and UsageAttributionTypeResponse response model.
  • find_all accepts page, per_page, role and search_term options.

Attributed usage

  • New client.customers.attributed_usage(external_customer_id, external_subscription_id, group_by=None, filters=None, options=None). It calls GET /customers/:external_customer_id/attributed_usage.
  • In filters, a string value is sent as filters[key]=value and a list value as repeated filters[key][]=value. The other query params (from_datetime, to_datetime, charge_codes[], split_charge_code, search_term, basis, page, per_page) go through options.
  • It returns {"attributed_usage": AttributedUsageResponse, "meta": {...}}. The response includes the rows, the unattributed usage and the totals, and each one is split into charge usage.

Fixtures and tests cover each endpoint.

🤖 Generated with Claude Code

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.

1 participant