Hi,
the currentAppInstllation query on the GraphQL API returns the activeSubscriptions
with the the current app subscription if it has any.
This AppSubscription
object always reflects the current state of the current billing period with the respective field currentPeriodEnd
and the line items.
If a app subscription is usage-based, the line items contains a AppSubscriptionLineItem
with AppUsagePricing
which has a cappedAmount
and a balanceUsed
. Again, the balanceUsed
reflects the state of the current billing period.
Now, in contrast, the usageRecords
on the line item contain all records ever created. It is not limited to the current billing period. I think a common use case, at least for me, is to get all usage records for the current period to determine what was already charged.
This is not easily possible, as we have to paginate through all the usage records and check if their creation date is within the current period, which we have to calculate ourselves by using the currentPeriodEnd
and subtracting the interval length (30 or 365 days).
Since there is a dedicated appUsageRecordsCreate
mutation, I’d like to suggest a query counterpart like appUsageRecords($subscriptionLineItemId)
and currentAppUsageRecords($subscriptionLineItemId)
which only returns records for the current period.
This would make working with billing API much easier.