From 6fc811d60a5c00550dab00fc31c913a6ae4c33ae Mon Sep 17 00:00:00 2001 From: Kush Sharma Date: Sun, 21 Jan 2024 22:25:08 +0530 Subject: [PATCH] feat(frontier): change subscribed plan of a billing customer Signed-off-by: Kush Sharma --- raystack/frontier/v1beta1/frontier.proto | 32 ++++++++++++++++++++++++ raystack/frontier/v1beta1/models.proto | 3 +++ 2 files changed, 35 insertions(+) diff --git a/raystack/frontier/v1beta1/frontier.proto b/raystack/frontier/v1beta1/frontier.proto index 0431232e..cfa08b51 100644 --- a/raystack/frontier/v1beta1/frontier.proto +++ b/raystack/frontier/v1beta1/frontier.proto @@ -1461,6 +1461,18 @@ service FrontierService { }; } + rpc ChangeSubscription(ChangeSubscriptionRequest) returns (ChangeSubscriptionResponse) { + option (google.api.http) = { + post: "/v1beta1/organizations/{org_id}/billing/{billing_id}/subscriptions/{id}/change", + body: "*" + }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + tags: "Subscription"; + summary: "Change subscription plan"; + description: "Change a subscription plan by ID."; + }; + } + rpc UpdateSubscription(UpdateSubscriptionRequest) returns (UpdateSubscriptionResponse) { option (google.api.http) = { put: "/v1beta1/organizations/{org_id}/billing/{billing_id}/subscriptions/{id}", @@ -1766,6 +1778,7 @@ message ListSubscriptionsRequest { // Filter subscriptions by state string state = 3; + string plan = 4; } message ListSubscriptionsResponse { @@ -1788,6 +1801,25 @@ message UpdateSubscriptionResponse { Subscription subscription = 1; } +message ChangeSubscriptionRequest { + string org_id = 1 [(validate.rules).string.min_len = 3]; + // ID of the billing account to update the subscription for + string billing_id = 2 [(validate.rules).string.min_len = 1]; + // ID of the subscription to update + string id = 3 [(validate.rules).string.min_len = 1]; + + // plan to change to + string plan = 4; + bool immediate = 5; +} + +message ChangeSubscriptionResponse { + // time at which current plan will end + google.protobuf.Timestamp current_end_at = 1; + // time at which new plan will start + google.protobuf.Timestamp new_start_at = 2; +} + message CancelSubscriptionRequest { string org_id = 1 [(validate.rules).string.min_len = 3]; // ID of the billing account to update the subscription for diff --git a/raystack/frontier/v1beta1/models.proto b/raystack/frontier/v1beta1/models.proto index 336f553f..8a0434bb 100644 --- a/raystack/frontier/v1beta1/models.proto +++ b/raystack/frontier/v1beta1/models.proto @@ -608,6 +608,9 @@ message CheckoutSession { string cancel_url = 4; string state = 5; + string plan = 6; + string product = 7; + google.protobuf.Struct metadata = 10; google.protobuf.Timestamp created_at = 11; google.protobuf.Timestamp updated_at = 12;