Skip to content

Commit 60e6d10

Browse files
add ticketin server and discount server protos
1 parent be71417 commit 60e6d10

2 files changed

Lines changed: 202 additions & 0 deletions

File tree

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
syntax = "proto3";
2+
3+
package discount;
4+
5+
service Discount {
6+
// Admin APIs
7+
rpc CreateVoucher(CreateVoucherRequest) returns (CreateVoucherResponse); // Creates a new discount voucher
8+
rpc DeleteVoucher(DeleteVoucherRequest) returns (DeleteVoucherResponse); // Deletes a voucher by code
9+
rpc UpdateVoucherRestrictions(UpdateVoucherRestrictionsRequest) returns (UpdateVoucherRestrictionsResponse); // Updates restrictions on a voucher
10+
rpc GetVouchers(GetVouchersRequest) returns (GetVouchersResponse); // Retrieves a list of vouchers with filters and pagination
11+
12+
// User APIs
13+
rpc ValidateVoucher(ValidateVoucherRequest) returns (ValidateVoucherResponse); // Validates if a voucher is applicable
14+
rpc ApplyVoucher(ApplyVoucherRequest) returns (ApplyVoucherResponse); // Applies a voucher to a purchase
15+
}
16+
17+
enum DiscountType {
18+
FIXED = 0; // Fixed amount discount
19+
PERCENTAGE = 1; // Percentage-based discount
20+
}
21+
22+
message Voucher {
23+
string code = 1; // Unique voucher code
24+
DiscountType discount_type = 2; // Type of discount
25+
double discount_value = 3; // Value of the discount
26+
bool is_active = 4; // Indicates if the voucher is active
27+
int32 usage_count = 5; // Number of times the voucher has been used
28+
optional Restrictions restrictions = 6; // Optional restrictions applied to the voucher
29+
}
30+
31+
message Restrictions {
32+
optional bool new_users_only = 1; // Restricts voucher to new users
33+
optional int32 max_uses_per_user = 2; // Maximum times a user can use this voucher
34+
optional double min_purchase_requirement = 3; // Minimum amount required to use the voucher
35+
optional double max_discount_cap = 4; // Max discount amount for percentage-based vouchers
36+
repeated string applicable_services = 5; // List of services/plans the voucher applies to
37+
optional bool has_applicable_services = 9;
38+
optional string start_date = 6; // Start date of voucher validity (ISO 8601 format)
39+
optional string expire_date = 7; // Expiry date of voucher validity (ISO 8601 format)
40+
optional int32 global_usage_limit = 8; // Maximum total usage count across all users
41+
}
42+
43+
// Admin Requests
44+
message CreateVoucherRequest {
45+
string code = 1; // Unique voucher code
46+
DiscountType discount_type = 2; // Type of discount
47+
double discount_value = 3; // Value of the discount
48+
optional Restrictions restrictions = 4;
49+
}
50+
51+
message CreateVoucherResponse {
52+
Voucher voucher = 1; // Response message confirming voucher creation
53+
}
54+
55+
message DeleteVoucherRequest {
56+
string code = 1; // Voucher code to be deleted
57+
}
58+
message DeleteVoucherResponse {
59+
bool success = 1; // Response message confirming deletion
60+
}
61+
62+
message UpdateVoucherRestrictionsRequest {
63+
string code = 1; // Voucher code to update restrictions
64+
optional bool is_active = 2;
65+
Restrictions restrictions = 3; // New restrictions for the voucher
66+
}
67+
message UpdateVoucherRestrictionsResponse {
68+
Voucher voucher = 1; // Response message confirming update
69+
}
70+
71+
message GetVouchersRequest {
72+
optional DiscountType discount_type = 1; // Filter by discount type
73+
optional bool is_active = 2; // Filter by active status
74+
optional string service_name = 3; // Filter by applicable service
75+
optional int32 page_number = 4; // Pagination: page number
76+
optional int32 page_size = 5; // Pagination: number of items per page
77+
}
78+
79+
message GetVouchersResponse {
80+
repeated Voucher vouchers = 1; // List of vouchers
81+
int32 total_count = 2; // Total number of vouchers matching the filters
82+
}
83+
84+
// User Requests
85+
message ValidateVoucherRequest {
86+
string code = 1; // Voucher code to validate
87+
string user_id = 2; // ID of the user trying to use the voucher
88+
double purchase_amount = 3; // Amount of the purchase
89+
string service_name = 4; // Service name where the voucher is applied
90+
}
91+
92+
message ValidateVoucherResponse {
93+
bool is_valid = 1; // Indicates if the voucher is valid for the given purchase
94+
bool success = 2; // Validation message
95+
double discount_amount = 3; // Discount amount applicable
96+
double final_price = 4; // Final price after applying the discount
97+
}
98+
99+
message ApplyVoucherRequest {
100+
string code = 1; // Voucher code to apply
101+
string user_id = 2; // ID of the user using the voucher
102+
double purchase_amount = 3; // Amount of the purchase before discount
103+
string service_name = 4; // Service name where the voucher is applied
104+
}
105+
106+
message ApplyVoucherResponse {
107+
bool success = 1; // Indicates if voucher application was successful
108+
double discount_amount = 2; // Discount amount applicable
109+
double final_price = 3; // Final price after applying the discount
110+
}
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
syntax = "proto3";
2+
3+
package ticketing;
4+
5+
service Ticketing {
6+
// User creates a new ticket
7+
rpc CreateTicket (CreateTicketRequest) returns (CreateTicketResponse);
8+
9+
// User views the status of their tickets with pagination
10+
rpc GetUserTickets (GetUserTicketsRequest) returns (GetUserTicketsResponse);
11+
12+
// User closes a ticket
13+
rpc CloseTicket (CloseTicketRequest) returns (CloseTicketResponse);
14+
15+
// Admin views and searches tickets with pagination
16+
rpc GetTickets (GetTicketsRequest) returns (GetTicketsResponse);
17+
18+
// Admin responds to and closes a ticket
19+
rpc RespondToTicket (RespondToTicketRequest) returns (RespondToTicketResponse);
20+
}
21+
22+
message Ticket {
23+
string id = 1;
24+
string user_id = 2;
25+
string title = 3;
26+
string description = 4;
27+
string category = 5;
28+
TicketStatus status = 6;
29+
optional string admin_response = 7;
30+
optional string admin_id = 8;
31+
string created_at = 9;
32+
}
33+
34+
enum TicketStatus {
35+
OPEN = 0;
36+
CLOSED = 1;
37+
}
38+
39+
message CreateTicketRequest {
40+
string user_id = 1;
41+
string title = 2;
42+
string description = 3;
43+
string category = 4;
44+
}
45+
46+
message CreateTicketResponse {
47+
string ticket_id = 1;
48+
}
49+
50+
message GetUserTicketsRequest {
51+
string user_id = 1;
52+
optional int32 page_number = 2; // The page number for pagination
53+
optional int32 page_size = 3; // Number of tickets per page
54+
}
55+
56+
message GetUserTicketsResponse {
57+
repeated Ticket tickets = 1;
58+
int32 total_count = 2; // Total number of tickets for pagination
59+
}
60+
61+
message CloseTicketRequest {
62+
string user_id = 1;
63+
string ticket_id = 2;
64+
}
65+
66+
message CloseTicketResponse {
67+
bool success = 1;
68+
}
69+
70+
message GetTicketsRequest {
71+
optional string title = 1;
72+
optional string category = 2;
73+
optional TicketStatus status = 3;
74+
optional string user_id = 4;
75+
optional int32 page_number = 5; // The page number for pagination
76+
optional int32 page_size = 6; // Number of tickets per page
77+
}
78+
79+
message GetTicketsResponse {
80+
repeated Ticket tickets = 1;
81+
int32 total_count = 2; // Total number of tickets for pagination
82+
}
83+
84+
message RespondToTicketRequest {
85+
string admin_id = 1;
86+
string ticket_id = 2;
87+
string response_message = 3;
88+
}
89+
90+
message RespondToTicketResponse {
91+
bool success = 1;
92+
}

0 commit comments

Comments
 (0)