Skip to content

Commit

Permalink
feat(frontier): plan discounts
Browse files Browse the repository at this point in the history
Signed-off-by: Kush Sharma <[email protected]>
  • Loading branch information
kushsharma committed Feb 7, 2024
1 parent 4edd109 commit 59adfe3
Show file tree
Hide file tree
Showing 2 changed files with 142 additions and 0 deletions.
118 changes: 118 additions & 0 deletions raystack/frontier/v1beta1/frontier.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1646,6 +1646,67 @@ service FrontierService {
description: "Get the upcoming invoice of a billing account.";
};
}

// Coupon
rpc CreateCoupon(CreateCouponRequest) returns (CreateCouponResponse) {
option (google.api.http) = {
post: "/v1beta1/billing/coupons",
body: "*"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
tags: "Coupon";
summary: "Create coupon";
description: "Create a new coupon.";
};
}

rpc ListCoupons(ListCouponsRequest) returns (ListCouponsResponse) {
option (google.api.http) = {get: "/v1beta1/billing/coupons"};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
tags: "Coupon";
summary: "List coupons";
description: "List all coupons.";
};
}

rpc GetCoupon(GetCouponRequest) returns (GetCouponResponse) {
option (google.api.http) = {get: "/v1beta1/billing/coupons/{id}"};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
tags: "Coupon";
summary: "Get coupon";
description: "Get a coupon by ID.";
};
}

rpc DeleteCoupon(DeleteCouponRequest) returns (DeleteCouponResponse) {
option (google.api.http) = {delete: "/v1beta1/billing/coupons/{id}"};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
tags: "Coupon";
summary: "Delete coupon";
description: "Delete a coupon by ID.";
};
}

rpc CreateCouponCode(CreateCouponCodeRequest) returns (CreateCouponCodeResponse) {
option (google.api.http) = {
post: "/v1beta1/billing/coupons/{coupon_id}/codes",
body: "*"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
tags: "Coupon";
summary: "Create coupon code";
description: "Create a new coupon code for a coupon.";
};
}

rpc ListCouponCodes(ListCouponCodesRequest) returns (ListCouponCodesResponse) {
option (google.api.http) = {get: "/v1beta1/billing/coupons/{coupon_id}/codes"};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
tags: "Coupon";
summary: "List coupon codes";
description: "List all coupon codes of a coupon.";
};
}
}

// Billing
Expand Down Expand Up @@ -2002,6 +2063,63 @@ message GetUpcomingInvoiceResponse {
Invoice invoice = 1;
}

message CreateCouponRequest {
// Coupon to create
Coupon coupon = 1;
}

message CreateCouponResponse {
// Created coupon
Coupon coupon = 1;
}

message ListCouponsRequest {}

message ListCouponsResponse {
// List of coupons
repeated Coupon coupons = 1;
}

message GetCouponRequest {
// ID of the coupon to get
string id = 1 [(validate.rules).string.min_len = 1];
}

message GetCouponResponse {
// Coupon
Coupon coupon = 1;
}

message DeleteCouponRequest {
// ID of the coupon to delete
string id = 1 [(validate.rules).string.min_len = 1];
}

message DeleteCouponResponse {}

message CreateCouponCodeRequest {
string coupon_id = 1 [(validate.rules).string.min_len = 1];
string code = 2 [(validate.rules).string.min_len = 3];

// ID of the billing account to create the coupon code for, if not provided
// it will be applicable to all billing accounts
string billing_id = 3;
}

message CreateCouponCodeResponse {
// Created coupon code
CouponCode coupon_code = 1;
}

message ListCouponCodesRequest {
string coupon_id = 1 [(validate.rules).string.min_len = 1];
}

message ListCouponCodesResponse {
// List of coupon codes
repeated CouponCode coupon_codes = 1;
}

// Authentication

message GetJWKsRequest {}
Expand Down
24 changes: 24 additions & 0 deletions raystack/frontier/v1beta1/models.proto
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,7 @@ message Product {
string behavior = 9;
repeated Feature features = 10;
BehaviorConfig behavior_config = 11;
string provider_id = 12;

google.protobuf.Struct metadata = 20;
google.protobuf.Timestamp created_at = 21;
Expand Down Expand Up @@ -757,6 +758,29 @@ message PaymentMethod {
google.protobuf.Timestamp created_at = 21;
}

message Coupon {
string id = 1;
string provider_id = 2;
string name = 3;
string duration = 4;
// percent_off is a number between 1 and 100
int64 percent_off = 5;
int64 max_redemptions = 6;

google.protobuf.Struct metadata = 20;
google.protobuf.Timestamp created_at = 21;
google.protobuf.Timestamp expire_at = 22;
}

message CouponCode {
string code = 1;
string coupon_id = 2;

// ID of the billing account to create the coupon code for, if not provided
// it will be applicable to all billing accounts
string billing_id = 3;
}

// Model crud body

message RoleRequestBody {
Expand Down

0 comments on commit 59adfe3

Please sign in to comment.