Skip to content

Commit

Permalink
Validate and Mint messages (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
havan authored Apr 15, 2024
1 parent 3db62ed commit 549aa25
Show file tree
Hide file tree
Showing 7 changed files with 158 additions and 4 deletions.
70 changes: 70 additions & 0 deletions proto/cmp/services/book/v1alpha/mint.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
syntax = "proto3";

package cmp.services.book.v1alpha;

import "cmp/types/v1alpha/common.proto";
import "cmp/types/v1alpha/language.proto";
import "cmp/types/v1alpha/payment.proto";
import "cmp/types/v1alpha/pubkey.proto";
import "cmp/types/v1alpha/token.proto";
import "cmp/types/v1alpha/traveller.proto";
import "google/protobuf/timestamp.proto";

message MintRequest {
// Message header
cmp.types.v1alpha.Header header = 1;

string validation_id = 2;

string external_session_id = 3;

cmp.types.v1alpha.Language language = 4;

string market = 5;

string booking_reference = 6;

repeated cmp.types.v1alpha.ExtensiveTraveller travellers = 7;

// The comments field is meant to pass noncommittal remarks entered by the
// end-consumer about the service reservation, like "non-smoking room please",
// "top floor room please".
string comment = 8;

// Public keys that will be used to encrypt the private booking data
repeated cmp.types.v1alpha.PublicKey public_keys = 9;

// This field is only relevant for off chain virtual credit card payments.
cmp.types.v1alpha.AdditionalPaymentInfo additional_payment_info = 10;
}

message MintResponse {
// Message header
cmp.types.v1alpha.Header header = 1;

// This must be a UUID according to RFC 4122
string mint_id = 2;

// This must be a UUID according to RFC 4122
string validation_id = 3;

string provider_booking_reference = 4;

// The token that represents the booking of the service
cmp.types.v1alpha.BookingToken booking_token = 5;

string mint_transaction_id = 6;

google.protobuf.Timestamp booking_timestamp = 7;

// Transaction ID of the buy operation. This field is populated by the distributor
// (buyer) bot after the buy operation and passed to the distributor middleware
// (partner plugin) in the mint response.
string buy_transaction_id = 8;
}

// ![Diagram](https://storage.googleapis.com/docs-cmp-files/diagrams/proto/cmp/services/book/v1alpha/mint.proto.dot.xs.svg)
// [Open Message Diagram](https://storage.googleapis.com/docs-cmp-files/diagrams/proto/cmp/services/book/v1alpha/mint.proto.dot.svg)
service MintService {
rpc Mint(MintRequest) returns (MintResponse);
}
45 changes: 45 additions & 0 deletions proto/cmp/services/book/v1alpha/validate.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
syntax = "proto3";

package cmp.services.book.v1alpha;

import "cmp/types/v1alpha/common.proto";
import "cmp/types/v1alpha/price.proto";

message ValidationRequest {
// Message header
cmp.types.v1alpha.Header header = 1;

// Search ID that is returned in the search response message in the `metadata``
// (`SearchResponseMetadata`) field.
string search_id = 2;

// Result ID that is that is returned by `result_id` field of the search result
// messages, for example: `AccommodationSearchResult`.
int32 result_id = 3;
}

message ValidationResponse {
// Message header
cmp.types.v1alpha.Header header = 1;

// Unique validation ID. This must be a UUID according to RFC 4122
string validation_id = 2;

// Validation object
ValidationObject validation_object = 3;
}

// Validation message that represents a single `result_id` from the search results
// message.
//
// TODO: Better name?
message ValidationObject {
int32 result_id = 1;
cmp.types.v1alpha.PriceDetail price_detail = 2;
}

// ![Diagram](https://storage.googleapis.com/docs-cmp-files/diagrams/proto/cmp/services/book/v1alpha/validate.proto.dot.xs.svg)
// [Open Message Diagram](https://storage.googleapis.com/docs-cmp-files/diagrams/proto/cmp/services/book/v1alpha/validate.proto.dot.svg)
service ValidationService {
rpc Validation(ValidationRequest) returns (ValidationResponse);
}
12 changes: 12 additions & 0 deletions proto/cmp/types/v1alpha/credit_card.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
syntax = "proto3";

package cmp.types.v1alpha;

import "cmp/types/v1alpha/date.proto";

message CreditCard {
// FIXME: Can we use an int64 to represent a credit card number?
string number = 1;
Date expiration_date = 2;
int32 cvc = 3;
}
11 changes: 11 additions & 0 deletions proto/cmp/types/v1alpha/payment.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
syntax = "proto3";

package cmp.types.v1alpha;

import "cmp/types/v1alpha/credit_card.proto";

// Additional payment info message with currently only a single field of
// `CreditCard` message type.
message AdditionalPaymentInfo {
CreditCard credit_card = 1;
}
7 changes: 7 additions & 0 deletions proto/cmp/types/v1alpha/pubkey.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
syntax = "proto3";

package cmp.types.v1alpha;

message PublicKey {
string key = 1;
}
10 changes: 10 additions & 0 deletions proto/cmp/types/v1alpha/token.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,13 @@ package cmp.types.v1alpha;
message TokenCurrency {
string contract_address = 1;
}

// Booking token that represents to access to the service
message BookingToken {
// Contract address of the smart contract or the address of natively implemented
// asset on-chain.
string contract = 1;

// Token ID
int32 token_id = 2;
}
7 changes: 3 additions & 4 deletions proto/cmp/types/v1alpha/traveller.proto
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import "cmp/types/v1alpha/document.proto";
//
// ![Diagram](https://storage.googleapis.com/docs-cmp-files/diagrams/proto/cmp/types/v1alpha/traveller.proto.dot.xs.svg)
// [Open Message Diagram](https://storage.googleapis.com/docs-cmp-files/diagrams/proto/cmp/types/v1alpha/traveller.proto.dot.svg)

message BasicTraveller {
// Guest number, the lowest number is the lead-pax. This ID is also used for
// referencing services linked to specific participants, like baggage.
Expand Down Expand Up @@ -64,9 +63,9 @@ message ExtensiveTraveller {
// into first_name: John, first_name: Roger, surname: Stephens, surname: Legend.
repeated string first_names = 3;
repeated string surnames = 4;
string phone_number = 6;
string email = 7;
repeated cmp.types.v1alpha.Document documents = 8;
string phone_number = 5;
string email = 6;
repeated cmp.types.v1alpha.Document documents = 7;
}

// Gender Type
Expand Down

0 comments on commit 549aa25

Please sign in to comment.