Skip to content

Commit

Permalink
wip: cancellation message types and services
Browse files Browse the repository at this point in the history
  • Loading branch information
havan committed Oct 26, 2024
1 parent db76968 commit c1d9741
Show file tree
Hide file tree
Showing 7 changed files with 198 additions and 0 deletions.
27 changes: 27 additions & 0 deletions proto/cmp/services/cancellation/v1/accept.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
syntax = "proto3";

package cmp.services.cancellation.v1;

import "cmp/types/v1/common.proto";
import "cmp/types/v2/price.proto";

// Request for cancellation acceptance
message AcceptCancellationRequest {
// Request header
optional cmp.types.v1.RequestHeader header = 1;

// Cancellation token ID
optional uint64 token_id = 2;

// Refund amount to validate the acceptance on-chain
optional cmp.types.v2.Price refund_amount = 3;
}

// Response for cancellation acceptance
message AcceptCancellationResponse {
// Response header
optional cmp.types.v1.ResponseHeader header = 1;

// Accept cancellation transaction ID
optional string transaction_id = 2;
}
27 changes: 27 additions & 0 deletions proto/cmp/services/cancellation/v1/accept_counter.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
syntax = "proto3";

package cmp.services.cancellation.v1;

import "cmp/types/v1/common.proto";
import "cmp/types/v2/price.proto";

// Request for counter cancellation acceptance
message AcceptCounterCancellationRequest {
// Request header
optional cmp.types.v1.RequestHeader header = 1;

// Cancellation token ID
optional uint64 token_id = 2;

// Refund amount to validate the acceptance on-chain
optional cmp.types.v2.Price refund_amount = 3;
}

// Response for counter cancellation acceptance
message AcceptCounterCancellationResponse {
// Response header
optional cmp.types.v1.ResponseHeader header = 1;

// Accept counter cancellation transaction ID
optional string transaction_id = 2;
}
23 changes: 23 additions & 0 deletions proto/cmp/services/cancellation/v1/cancel_proposal.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
syntax = "proto3";

package cmp.services.cancellation.v1;

import "cmp/types/v1/common.proto";

// Request for cancelling an active cancellation proposal
message CancelCancellationRequest {
// Request header
optional cmp.types.v1.RequestHeader header = 1;

// Cancellation token ID
optional uint64 token_id = 2;
}

// Response for cancelling an active cancellation proposal
message CancelCancellationResponse {
// Response header
optional cmp.types.v1.ResponseHeader header = 1;

// Accept cancellation transaction ID
optional string transaction_id = 2;
}
27 changes: 27 additions & 0 deletions proto/cmp/services/cancellation/v1/counter.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
syntax = "proto3";

package cmp.services.cancellation.v1;

import "cmp/types/v1/common.proto";
import "cmp/types/v2/price.proto";

// Request for countering a cancellation
message CounterCancellationRequest {
// Request header
optional cmp.types.v1.RequestHeader header = 1;

// Cancellation token ID
optional uint64 token_id = 2;

// Refund amount to counter the cancellation proposal with
optional cmp.types.v2.Price refund_amount = 3;
}

// Response for countering a cancellation
message CounterCancellationResponse {
// Response header
optional cmp.types.v1.ResponseHeader header = 1;

// Counter cancellation transaction ID
optional string transaction_id = 2;
}
25 changes: 25 additions & 0 deletions proto/cmp/services/cancellation/v1/initiate.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
syntax = "proto3";

package cmp.services.cancellation.v1;

import "cmp/types/v1/common.proto";
import "cmp/types/v2/price.proto";

message InitiateCancellationRequest {
// The request header
cmp.types.v1.RequestHeader header = 1;

// The token id of the booking to be cancelled
uint64 token_id = 2;

// The amount to be refunded
cmp.types.v2.Price refund_amount = 3;
}

message InitiateCancellationResponse {
// The response header
cmp.types.v1.ResponseHeader header = 1;

// Transaction id for the initiate cancellation request
string transaction_id = 2;
}
39 changes: 39 additions & 0 deletions proto/cmp/services/cancellation/v1/reject.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
syntax = "proto3";

package cmp.services.cancellation.v1;

import "cmp/types/v1/common.proto";

// Request for cancellation rejection
message RejectCancellationRequest {
// Request Header
cmp.types.v1.RequestHeader header = 1;

// Token ID to reject the cancellation for (Booking Token)
uint64 token_id = 2;

// Reason for rejection
cmp.services.cancellation.v1.CancellationRejectionReason reason = 3;
}

// Response for cancellation rejection
message RejectCancellationResponse {
// Response Header
cmp.types.v1.ResponseHeader header = 1;

// Transaction id for the rejected cancellation
string transaction_id = 2;
}

enum CancellationRejectionReason {
CANCELLATION_REJECTION_REASON_UNSPECIFIED = 0;
CANCELLATION_REJECTION_REASON_TECHNICAL_ERROR = 1;
CANCELLATION_REJECTION_REASON_INVALID_SERVICE_OR_BOOKING_REFERENCE = 2;
CANCELLATION_REJECTION_REASON_BOOKING_IS_ALREADY_CANCELLED = 3;
CANCELLATION_REJECTION_REASON_SERVICE_HAS_STARTED_OR_HAS_BEEN_DELIVERED = 4;
CANCELLATION_REJECTION_REASON_CANCELLATION_WINDOW_EXPIRED = 5;
CANCELLATION_REJECTION_REASON_SERVICE_CANNOT_BE_CANCELLED_ONLINE = 6;
CANCELLATION_REJECTION_REASON_RATE_OR_FARE_CANNOT_BE_CANCELLED = 7;
CANCELLATION_REJECTION_REASON_ENTIRE_PACKAGE_MUST_BE_CANCELLED = 8; // Service forms part of a package, the entire package must be cancelled
CANCELLATION_REJECTION_REASON_REFUND_CURRENCY_NOT_SUPPORTED = 9;
}
30 changes: 30 additions & 0 deletions proto/cmp/services/cancellation/v1/services.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
syntax = "proto3";

package cmp.services.cancellation.v1;

import "cmp/services/cancellation/v1/accept.proto";
import "cmp/services/cancellation/v1/accept_counter.proto";
import "cmp/services/cancellation/v1/cancel_proposal.proto";
import "cmp/services/cancellation/v1/counter.proto";
import "cmp/services/cancellation/v1/initiate.proto";
import "cmp/services/cancellation/v1/reject.proto";

service CancellationService {
// Initiate cancellation
rpc InitiateCancellation(InitiateCancellationRequest) returns (InitiateCancellationResponse) {}

// Accept cancellation
rpc AcceptCancellation(AcceptCancellationRequest) returns (AcceptCancellationResponse) {}

// Reject cancellation
rpc RejectCancellation(RejectCancellationRequest) returns (RejectCancellationResponse) {}

// Counter cancellation
rpc CounterCancellation(CounterCancellationRequest) returns (CounterCancellationResponse) {}

// Accept countered cancellation
rpc AcceptCounterCancellation(AcceptCounterCancellationRequest) returns (AcceptCounterCancellationResponse) {}

// Cancel cancellation proposal
rpc CancelCancellation(CancelCancellationRequest) returns (CancelCancellationResponse) {}
}

0 comments on commit c1d9741

Please sign in to comment.