From cb6a105b51c52f47fc19990647747c911cb495fc Mon Sep 17 00:00:00 2001 From: Jonathan Lui Date: Thu, 21 Jun 2018 14:40:14 -0700 Subject: [PATCH] PaymentService: use genproto.sh to cp proto to paymentservice --- src/paymentservice/.gitignore | 1 + src/paymentservice/genproto.sh | 6 + src/paymentservice/proto/demo.proto | 227 ---------------------------- 3 files changed, 7 insertions(+), 227 deletions(-) create mode 100755 src/paymentservice/genproto.sh delete mode 100644 src/paymentservice/proto/demo.proto diff --git a/src/paymentservice/.gitignore b/src/paymentservice/.gitignore index fd4f2b0..fd72c53 100644 --- a/src/paymentservice/.gitignore +++ b/src/paymentservice/.gitignore @@ -1,2 +1,3 @@ node_modules +proto .DS_Store diff --git a/src/paymentservice/genproto.sh b/src/paymentservice/genproto.sh new file mode 100755 index 0000000..42c18a1 --- /dev/null +++ b/src/paymentservice/genproto.sh @@ -0,0 +1,6 @@ +#!/bin/bash -e + +# protos are loaded dynamically for node, simply copies over the proto. + +mkdir -p proto && \ +cp ../../pb/demo.proto proto diff --git a/src/paymentservice/proto/demo.proto b/src/paymentservice/proto/demo.proto deleted file mode 100644 index ffd0518..0000000 --- a/src/paymentservice/proto/demo.proto +++ /dev/null @@ -1,227 +0,0 @@ -syntax = "proto3"; - -package hipstershop; - -// -----------------Cart service----------------- - -service CartService { - rpc AddItem(AddItemRequest) returns (Empty) {} - rpc GetCart(GetCartRequest) returns (Cart) {} - rpc EmptyCart(EmptyCartRequest) returns (Empty) {} -} - -message CartItem { - string product_id = 1; - int32 quantity = 2; -} - -message AddItemRequest { - string user_id = 1; - CartItem item = 2; -} - -message EmptyCartRequest { - string user_id = 1; -} - -message GetCartRequest { - string user_id = 1; -} - -message Cart { - string user_id = 1; - repeated CartItem items = 2; -} - -message Empty {} - -// ---------------Recommendation service---------- - -service RecommendationService { - rpc ListRecommendations(ListRecommendationsRequest) returns (ListRecommendationsResponse){} -} - -message ListRecommendationsRequest { - string user_id = 1; - repeated string product_ids = 2; -} - -message ListRecommendationsResponse { - repeated string product_ids = 1; -} - -// ---------------Product Catalog---------------- - -service ProductCatalogService { - rpc ListProducts(Empty) returns (ListProductsResponse) {} - rpc GetProduct(GetProductRequest) returns (Product) {} - rpc SearchProducts(SearchProductsRequest) returns (SearchProductsResponse) {} -} - -message Product { - string id = 1; - string name = 2; - string description = 3; - string picture = 4; - MoneyAmount price_usd = 5; -} - -message ListProductsResponse { - repeated Product products = 1; -} - -message GetProductRequest { - string id = 1; -} - -message SearchProductsRequest { - string query = 1; -} - -message SearchProductsResponse { - repeated Product results = 1; -} - -// ---------------Shipping Service---------- - -service ShippingService { - rpc GetQuote(GetQuoteRequest) returns (GetQuoteResponse) {} - rpc ShipOrder(ShipOrderRequest) returns (ShipOrderResponse) {} -} - -message GetQuoteRequest { - Address address = 1; - repeated CartItem items = 2; -} - -message GetQuoteResponse { - MoneyAmount cost_usd = 1; -} - -message ShipOrderRequest { - Address address = 1; - repeated CartItem items = 2; -} - -message ShipOrderResponse { - string tracking_id = 1; -} - -message Address { - string street_address_1 = 1; - string street_address_2 = 2; - string city= 3; - string country = 4; - int32 zip_code = 5; -} - -// -----------------Currency service----------------- - -service CurrencyService { - rpc GetSupportedCurrencies(Empty) returns (GetSupportedCurrenciesResponse) {} - rpc Convert(CurrencyConversionRequest) returns (Money) {} -} - - -// Describes a money amount without currency. For example, decimal=2 and -// fractional=500 (or fractional=5) makes up 2.5 units. -message MoneyAmount { - uint32 decimal = 1; - uint32 fractional = 2; -} - -message Money { - // The 3-letter currency code defined in ISO 4217. - string currency_code = 1; - MoneyAmount amount = 2; -} - -message GetSupportedCurrenciesResponse { - // The 3-letter currency code defined in ISO 4217. - repeated string currency_codes = 1; -} - -message CurrencyConversionRequest { - Money from = 1; - - // The 3-letter currency code defined in ISO 4217. - string to_code = 2; -} - -// -------------Payment service----------------- - -service PaymentService { - rpc Charge(ChargeRequest) returns (ChargeResponse) {} -} - -message CreditCardInfo { - string credit_card_number = 1; - int32 credit_card_cvv = 2; - int32 credit_card_expiration_year = 3; - int32 credit_card_expiration_month = 4; -} - -message ChargeRequest { - Money amount = 1; - CreditCardInfo credit_card = 2; -} - -message ChargeResponse { - string transaction_id = 1; -} - -// -------------Email service----------------- - -service EmailService { - rpc SendOrderConfirmation(SendOrderConfirmationRequest) returns (Empty) {} -} - -message OrderItem { - CartItem item = 1; - Money cost = 2; -} - -message OrderResult { - string order_id = 1; - string shipping_tracking_id = 2; - Money shipping_cost = 3; - Address shipping_address = 4; - repeated OrderItem items = 5; -} - -message SendOrderConfirmationRequest { - string email = 1; - OrderResult order = 2; -} - - -// -------------Checkout service----------------- - -service CheckoutService { - rpc CreateOrder(CreateOrderRequest) returns (CreateOrderResponse) {} - rpc PlaceOrder(PlaceOrderRequest) returns (PlaceOrderResponse) {} -} - -message CreateOrderRequest { - string user_id = 1; - string user_currency = 2; - Address address = 3; -} - -message CreateOrderResponse { - repeated OrderItem items = 1; - Money shipping_cost = 2; -} - -message PlaceOrderRequest { - string user_id = 1; - string user_currency = 2; - - Address address = 3; - string email = 5; - CreditCardInfo credit_card = 6; -} - -message PlaceOrderResponse { - OrderResult order = 1; -}