currencyservice: [WIP] money proto migration
Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
This commit is contained in:
parent
a128ab02ef
commit
98d9c87e72
3 changed files with 17 additions and 15 deletions
|
@ -29,10 +29,8 @@ const client = new shopProto.CurrencyService(`localhost:${PORT}`,
|
||||||
const request = {
|
const request = {
|
||||||
from: {
|
from: {
|
||||||
currency_code: 'USD',
|
currency_code: 'USD',
|
||||||
amount: {
|
units: 300,
|
||||||
decimal: 300,
|
nanos: 500000000
|
||||||
fractional: 0
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
to_code: 'CHF'
|
to_code: 'CHF'
|
||||||
};
|
};
|
||||||
|
|
0
src/currencyservice/genproto.sh
Normal file → Executable file
0
src/currencyservice/genproto.sh
Normal file → Executable file
|
@ -63,7 +63,7 @@ message Product {
|
||||||
string name = 2;
|
string name = 2;
|
||||||
string description = 3;
|
string description = 3;
|
||||||
string picture = 4;
|
string picture = 4;
|
||||||
MoneyAmount price_usd = 5;
|
Money price_usd = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
message ListProductsResponse {
|
message ListProductsResponse {
|
||||||
|
@ -95,7 +95,7 @@ message GetQuoteRequest {
|
||||||
}
|
}
|
||||||
|
|
||||||
message GetQuoteResponse {
|
message GetQuoteResponse {
|
||||||
MoneyAmount cost_usd = 1;
|
Money cost_usd = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message ShipOrderRequest {
|
message ShipOrderRequest {
|
||||||
|
@ -122,18 +122,22 @@ service CurrencyService {
|
||||||
rpc Convert(CurrencyConversionRequest) returns (Money) {}
|
rpc Convert(CurrencyConversionRequest) returns (Money) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Represents an amount of money with its currency type.
|
||||||
// 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 {
|
message Money {
|
||||||
// The 3-letter currency code defined in ISO 4217.
|
// The 3-letter currency code defined in ISO 4217.
|
||||||
string currency_code = 1;
|
string currency_code = 1;
|
||||||
MoneyAmount amount = 2;
|
|
||||||
|
// The whole units of the amount.
|
||||||
|
// For example if `currencyCode` is `"USD"`, then 1 unit is one US dollar.
|
||||||
|
int64 units = 2;
|
||||||
|
|
||||||
|
// Number of nano (10^-9) units of the amount.
|
||||||
|
// The value must be between -999,999,999 and +999,999,999 inclusive.
|
||||||
|
// If `units` is positive, `nanos` must be positive or zero.
|
||||||
|
// If `units` is zero, `nanos` can be positive, zero, or negative.
|
||||||
|
// If `units` is negative, `nanos` must be negative or zero.
|
||||||
|
// For example $-1.75 is represented as `units`=-1 and `nanos`=-750,000,000.
|
||||||
|
int32 nanos = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
message GetSupportedCurrenciesResponse {
|
message GetSupportedCurrenciesResponse {
|
||||||
|
|
Loading…
Reference in a new issue