Repository navigation
feat(account-tree): Add usage attribution types and attributed usage - #379
lovrocolic wants to merge 3 commits into
Conversation
vincent-pochet
left a comment
There was a problem hiding this comment.
Checked against the API (main) and the spec in getlago/lago-openapi#665. The first 3 block the merge: create can never succeed against the real API.
- Whitelist `attribution_keys` (array) and `description` instead of the singular `attribution_key`, matching the API strong params - Use `hierarchical` role and the current serializer shape in fixtures - `attributed_usage`: skip nil options, send empty `filters`/`charge_codes` arrays as empty selections, escape the customer external id and build the query through `connection.get_all` Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| description: params[:description], | ||
| attribution_keys: params[:attribution_keys], | ||
| role: params[:role], | ||
| }.compact |
There was a problem hiding this comment.
.compact drops an explicit description: nil, so update({ description: nil }, 'team') sends an empty payload and the old description stays (200, no error). The API clears it when the key is present (UpdateService uses params.key?(:description)). Could description follow the same key? pattern as parent_code?
result[:description] = params[:description] if params.key?(:description)| if filter_value.is_a?(Array) | ||
| query_params.concat(array_query_param("filters[#{filter_key}][]", filter_value)) | ||
| else | ||
| query_params << ["filters[#{filter_key}]", filter_value] |
There was a problem hiding this comment.
With filters: { team: nil } this sends a valueless filters[team], so the API filters on a blank value instead of ignoring the key. Maybe skip nil inner values here (next if filter_value.nil?).
Context
Account tree MVP adds API endpoints for usage attribution types (getlago/lago-api#6415) and attributed usage (getlago/lago-api#6566).
Description
client.usage_attribution_typeswithcreate,get,update,destroyandget_all, keyed bycode. An explicitparent_code: nilis sent so a type can be detached from its parent.client.customers.attributed_usage(external_customer_id, external_subscription_id, options), which encodesfiltersandcharge_codesas bracketed query params.🤖 Generated with Claude Code