|
| 1 | +syntax = "proto3"; |
| 2 | + |
| 3 | +package hipstershop; |
| 4 | + |
| 5 | +// -----------------Cart service----------------- |
| 6 | + |
| 7 | +service CartService { |
| 8 | + rpc AddItem(AddItemRequest) returns (Empty) {} |
| 9 | + rpc GetCart(GetCartRequest) returns (Cart) {} |
| 10 | + rpc EmptyCart(EmptyCartRequest) returns (Empty) {} |
| 11 | +} |
| 12 | + |
| 13 | +message CartItem { |
| 14 | + string product_id = 1; |
| 15 | + int32 quantity = 2; |
| 16 | +} |
| 17 | + |
| 18 | +message AddItemRequest { |
| 19 | + string user_id = 1; |
| 20 | + CartItem item = 2; |
| 21 | +} |
| 22 | + |
| 23 | +message EmptyCartRequest { |
| 24 | + string user_id = 1; |
| 25 | +} |
| 26 | + |
| 27 | +message GetCartRequest { |
| 28 | + string user_id = 1; |
| 29 | +} |
| 30 | + |
| 31 | +message Cart { |
| 32 | + string user_id = 1; |
| 33 | + repeated CartItem items = 2; |
| 34 | +} |
| 35 | + |
| 36 | +message Empty {} |
| 37 | + |
| 38 | +// ---------------Recommendation service---------- |
| 39 | + |
| 40 | +service RecommendationService { |
| 41 | + rpc ListRecommendations(ListRecommendationsRequest) returns (ListRecommendationsResponse){} |
| 42 | +} |
| 43 | + |
| 44 | +message ListRecommendationsRequest { |
| 45 | + string user_id = 1; |
| 46 | + repeated string product_ids = 2; |
| 47 | +} |
| 48 | + |
| 49 | +message ListRecommendationsResponse { |
| 50 | + repeated string product_ids = 1; |
| 51 | +} |
| 52 | + |
| 53 | +// ---------------Product Catalog---------------- |
| 54 | + |
| 55 | +service ProductCatalogService { |
| 56 | + rpc ListProducts(Empty) returns (ListProductsResponse) {} |
| 57 | + rpc GetProduct(GetProductRequest) returns (Product) {} |
| 58 | + rpc SearchProducts(SearchProductsRequest) returns (SearchProductsResponse) {} |
| 59 | +} |
| 60 | + |
| 61 | +message Product { |
| 62 | + string id = 1; |
| 63 | + string name = 2; |
| 64 | + string description = 3; |
| 65 | + string picture = 4; |
| 66 | + MoneyAmount price_usd = 5; |
| 67 | +} |
| 68 | + |
| 69 | +message ListProductsResponse { |
| 70 | + repeated Product products = 1; |
| 71 | +} |
| 72 | + |
| 73 | +message GetProductRequest { |
| 74 | + string id = 1; |
| 75 | +} |
| 76 | + |
| 77 | +message SearchProductsRequest { |
| 78 | + string query = 1; |
| 79 | +} |
| 80 | + |
| 81 | +message SearchProductsResponse { |
| 82 | + repeated Product results = 1; |
| 83 | +} |
| 84 | + |
| 85 | +// ---------------Shipping Service---------- |
| 86 | + |
| 87 | +service ShippingService { |
| 88 | + rpc GetQuote(GetQuoteRequest) returns (GetQuoteResponse) {} |
| 89 | + rpc ShipOrder(ShipOrderRequest) returns (ShipOrderResponse) {} |
| 90 | +} |
| 91 | + |
| 92 | +message GetQuoteRequest { |
| 93 | + Address address = 1; |
| 94 | + repeated CartItem items = 2; |
| 95 | +} |
| 96 | + |
| 97 | +message GetQuoteResponse { |
| 98 | + MoneyAmount cost_usd = 1; |
| 99 | +} |
| 100 | + |
| 101 | +message ShipOrderRequest { |
| 102 | + Address address = 1; |
| 103 | + repeated CartItem items = 2; |
| 104 | +} |
| 105 | + |
| 106 | +message ShipOrderResponse { |
| 107 | + string tracking_id = 1; |
| 108 | +} |
| 109 | + |
| 110 | +message Address { |
| 111 | + string street_address_1 = 1; |
| 112 | + string street_address_2 = 2; |
| 113 | + string city= 3; |
| 114 | + string country = 4; |
| 115 | + int32 zip_code = 5; |
| 116 | +} |
| 117 | + |
| 118 | +// -----------------Currency service----------------- |
| 119 | + |
| 120 | +service CurrencyService { |
| 121 | + rpc GetSupportedCurrencies(Empty) returns (GetSupportedCurrenciesResponse) {} |
| 122 | + rpc Convert(CurrencyConversionRequest) returns (Money) {} |
| 123 | +} |
| 124 | + |
| 125 | + |
| 126 | +// Describes a money amount without currency. For example, decimal=2 and |
| 127 | +// fractional=500 (or fractional=5) makes up 2.5 units. |
| 128 | +message MoneyAmount { |
| 129 | + uint32 decimal = 1; |
| 130 | + uint32 fractional = 2; |
| 131 | +} |
| 132 | + |
| 133 | +message Money { |
| 134 | + // The 3-letter currency code defined in ISO 4217. |
| 135 | + string currency_code = 1; |
| 136 | + MoneyAmount amount = 2; |
| 137 | +} |
| 138 | + |
| 139 | +message GetSupportedCurrenciesResponse { |
| 140 | + // The 3-letter currency code defined in ISO 4217. |
| 141 | + repeated string currency_codes = 1; |
| 142 | +} |
| 143 | + |
| 144 | +message CurrencyConversionRequest { |
| 145 | + Money from = 1; |
| 146 | + |
| 147 | + // The 3-letter currency code defined in ISO 4217. |
| 148 | + string to_code = 2; |
| 149 | +} |
| 150 | + |
| 151 | +// -------------Payment service----------------- |
| 152 | + |
| 153 | +service PaymentService { |
| 154 | + rpc Charge(ChargeRequest) returns (ChargeResponse) {} |
| 155 | +} |
| 156 | + |
| 157 | +message CreditCardInfo { |
| 158 | + string credit_card_number = 1; |
| 159 | + int32 credit_card_cvv = 2; |
| 160 | + int32 credit_card_expiration_year = 3; |
| 161 | + int32 credit_card_expiration_month = 4; |
| 162 | +} |
| 163 | + |
| 164 | +message ChargeRequest { |
| 165 | + Money amount = 1; |
| 166 | + CreditCardInfo credit_card = 2; |
| 167 | +} |
| 168 | + |
| 169 | +message ChargeResponse { |
| 170 | + string transaction_id = 1; |
| 171 | +} |
| 172 | + |
| 173 | +// -------------Email service----------------- |
| 174 | + |
| 175 | +service EmailService { |
| 176 | + rpc SendOrderConfirmation(SendOrderConfirmationRequest) returns (Empty) {} |
| 177 | +} |
| 178 | + |
| 179 | +message OrderItem { |
| 180 | + CartItem item = 1; |
| 181 | + Money cost = 2; |
| 182 | +} |
| 183 | + |
| 184 | +message OrderResult { |
| 185 | + string order_id = 1; |
| 186 | + string shipping_tracking_id = 2; |
| 187 | + Money shipping_cost = 3; |
| 188 | + Address shipping_address = 4; |
| 189 | + repeated OrderItem items = 5; |
| 190 | +} |
| 191 | + |
| 192 | +message SendOrderConfirmationRequest { |
| 193 | + string email = 1; |
| 194 | + OrderResult order = 2; |
| 195 | +} |
| 196 | + |
| 197 | + |
| 198 | +// -------------Checkout service----------------- |
| 199 | + |
| 200 | +service CheckoutService { |
| 201 | + rpc CreateOrder(CreateOrderRequest) returns (CreateOrderResponse) {} |
| 202 | + rpc PlaceOrder(PlaceOrderRequest) returns (PlaceOrderResponse) {} |
| 203 | +} |
| 204 | + |
| 205 | +message CreateOrderRequest { |
| 206 | + string user_id = 1; |
| 207 | + string user_currency = 2; |
| 208 | + Address address = 3; |
| 209 | +} |
| 210 | + |
| 211 | +message CreateOrderResponse { |
| 212 | + repeated OrderItem items = 1; |
| 213 | + Money shipping_cost = 2; |
| 214 | +} |
| 215 | + |
| 216 | +message PlaceOrderRequest { |
| 217 | + string user_id = 1; |
| 218 | + string user_currency = 2; |
| 219 | + |
| 220 | + Address address = 3; |
| 221 | + string email = 5; |
| 222 | + CreditCardInfo credit_card = 6; |
| 223 | +} |
| 224 | + |
| 225 | +message PlaceOrderResponse { |
| 226 | + OrderResult order = 1; |
| 227 | +} |
0 commit comments