Skip to content

Commit

Permalink
feat(ProgressiveBilling): Expose lifetime usage GET and PUT (#266)
Browse files Browse the repository at this point in the history
  • Loading branch information
vincent-pochet authored Sep 20, 2024
1 parent 12d5567 commit 8cfd743
Show file tree
Hide file tree
Showing 8 changed files with 303 additions and 0 deletions.
149 changes: 149 additions & 0 deletions openapi.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/openapi.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 53 additions & 0 deletions src/resources/subscription_lifetime_usage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
parameters:
- name: external_id
in: path
description: External ID of the existing subscription
required: true
schema:
type: string
example: "5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba"
get:
tags:
- subscriptions
summary: Retrive subscription lifetime usage
description: This endpoint enables the retrieval of the lifetime usage of a subscription.
operationId: getSubscriptionLifetimeUsage
responses:
"200":
description: Subscription lifetime usage
content:
application/json:
schema:
$ref: "../schemas/LifetimeUsage.yaml"
"401":
$ref: "../responses/Unauthorized.yaml"
"404":
$ref: "../responses/NotFound.yaml"
put:
tags:
- subscriptions
summary: Update a subscription lifetime usage
description: This endpoint allows you to update the lifetime usage of a subscription.
operationId: updateSubscriptionLifetimeUsage
requestBody:
description: Update the lifetime usage of a subscription
content:
application/json:
schema:
$ref: "../schemas/LifetimeUsageInput.yaml"
required: true
responses:
"200":
description: Subscription lifetime usage updated
content:
application/json:
schema:
$ref: "../schemas/LifetimeUsage.yaml"
"400":
$ref: "../responses/BadRequest.yaml"
"401":
$ref: "../responses/Unauthorized.yaml"
"404":
$ref: "../responses/NotFound.yaml"
"422":
$ref: "../responses/UnprocessableEntity.yaml"
6 changes: 6 additions & 0 deletions src/schemas/LifetimeUsage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
type: object
required:
- lifetime_usage
properties:
lifetime_usage:
$ref: "./LifetimeUsageObject.yaml"
13 changes: 13 additions & 0 deletions src/schemas/LifetimeUsageInput.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
type: object
required:
- lifetime_usage
properties:
lifetime_usage:
type: object
required:
- external_historical_usage_amount_cents
properties:
external_historical_usage_amount_cents:
type: integer
example: 100
description: The historical usage amount in cents for the subscription (provided by your own application).
52 changes: 52 additions & 0 deletions src/schemas/LifetimeUsageObject.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
type: object
required:
- lago_id
- lago_subscription_id
- external_subscription_id
- external_historical_usage_amount_cents
- invoiced_usage_amount_cents
- current_usage_amount_cents
- from_datetime
- to_datetime
properties:
lago_id:
type: string
format: "uuid"
example: "1a901a90-1a90-1a90-1a90-1a901a901a90"
description: Unique identifier assigned to the lifetime usage record within the Lago application. This ID is exclusively created by Lago and serves as a unique identifier for the lifetime usage record within the Lago system
lago_subscription_id:
type: string
format: "uuid"
example: "1a901a90-1a90-1a90-1a90-1a901a901a90"
description: Unique identifier assigned to the subscription record within the Lago application. This ID is exclusively created by Lago and serves as a unique identifier for the subscription record within the Lago system
external_subscription_id:
type: string
example: "5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba"
description: The subscription external unique identifier (provided by your own application).
external_historical_usage_amount_cents:
type: integer
example: 100
description: The historical usage amount in cents for the subscription (provided by your own application).
invoiced_usage_amount_cents:
type: integer
example: 100
description: The total invoiced usage amount in cents for the subscription.
current_usage_amount_cents:
type: integer
example: 100
description: The current usage amount in cents for the subscription on the current billing period.
from_datetime:
type: string
format: date-time
example: "2024-01-01T00:00:00Z"
description: The recording start date and time of the subscription lifetime usage. The date and time must be in ISO 8601 format.
to_datetime:
type: string
format: date-time
example: "2024-12-31T23:59:59Z"
description: The recording end date and time of the subscription lifetime usage. The date and time must be in ISO 8601 format.
usage_thresholds:
type: array
description: Array of usage thresholds attached to the subscription's plan.
items:
$ref: "./LifetimeUsageThresholdObject.yaml"
20 changes: 20 additions & 0 deletions src/schemas/LifetimeUsageThresholdObject.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
type: object
required:
- amount_cents
- completion_ratio
- reached_at
properties:
amount_cents:
type: integer
description: The usage threshold amount in cents.
example: 100
completion_ratio:
type: number
description: The completion ratio of the usage threshold.
example: 0.5
reached_at:
type: string
format: date-time
description: The date and time when the usage threshold was reached. The date and time must be in ISO 8601 format.
example: "2024-01-01T00:00:00Z"
nullable: true
8 changes: 8 additions & 0 deletions src/schemas/_index.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,14 @@ GrossRevenueObject:
$ref: "./GrossRevenueObject.yaml"
GrossRevenues:
$ref: "./GrossRevenues.yaml"
LifetimeUsage:
$ref: "./LifetimeUsage.yaml"
LifetimeUsageInput:
$ref: "./LifetimeUsageInput.yaml"
LifetimeUsageObject:
$ref: "./LifetimeUsageObject.yaml"
LifetimeUsageThresholdObject:
$ref: "./LifetimeUsageThresholdObject.yaml"
MinimumCommitmentInput:
$ref: "./MinimumCommitmentInput.yaml"
MinimumCommitmentObject:
Expand Down

0 comments on commit 8cfd743

Please sign in to comment.