summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/pseudomuto/protokit/fixtures/booking.proto
blob: 38101f65e8b5fc6424a9434e9dcedff0540392d5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
syntax = "proto2";

import "extend.proto";

/**
 * Booking related messages.
 *
 * This file is really just an example. The data model is completely fictional.
 */
package com.pseudomuto.protokit.v1;

option (com.pseudomuto.protokit.v1.extend_file) = true;

/**
 * Service for handling vehicle bookings.
 */
service BookingService {
  option (com.pseudomuto.protokit.v1.extend_service) = true;

  /// Used to book a vehicle. Pass in a Booking and a BookingStatus will be returned.
  rpc BookVehicle (Booking) returns (BookingStatus) {
    option (com.pseudomuto.protokit.v1.extend_method) = true;
  };
}

/**
 * Represents the status of a vehicle booking.
 */
message BookingStatus {
  /**
   * A flag for the status result.
   */
  enum StatusCode {
    OK          = 200; // OK result.
    BAD_REQUEST = 400; // BAD result.
  }

  required int32 id               = 1; /// Unique booking status ID.
  required string description     = 2; /// Booking status description. E.g. "Active".
  optional StatusCode status_code = 3; /// The status of this status?

  extensions 100 to max;
}

// File-level extension
extend BookingStatus {
  /* The country the booking occurred in. */
  optional string country = 100 [default = "china", (com.pseudomuto.protokit.v1.extend_field) = true];
}

/**
 * The type of booking.
 */
enum BookingType {
  option (com.pseudomuto.protokit.v1.extend_enum) = true;

  IMMEDIATE = 100; // Immediate booking.
  FUTURE    = 101 [(com.pseudomuto.protokit.v1.extend_enum_value) = true]; // Future booking.
}

/**
 * Represents the booking of a vehicle.
 *
 * Vehicles are some cool shit. But drive carefully!
 */
message Booking {
  option (com.pseudomuto.protokit.v1.extend_message) = true;

  required int32 vehicle_id     = 1; /// ID of booked vehicle.
  required int32 customer_id    = 2; /// Customer that booked the vehicle.
  required BookingStatus status = 3; /// Status of the booking.

  /** Has booking confirmation been sent? */
  required bool confirmation_sent = 4;

  /** Has payment been received? */
  optional bool payment_received = 5 [default = true, (com.pseudomuto.protokit.v1.extend_field) = true];

  oneof things {
    int32 reference_num  = 6; // the numeric reference number
    string reference_tag = 7; // the reference tag (string)
  }

  // Nested extentions are also a thing.

  extend BookingStatus {
    optional string optional_field_1 = 101; // An optional field to be used however you please.
  }
}