Compare commits

...

5 Commits

Author SHA1 Message Date
Chris Diesch
5feee5408c Consistent punctuation 2025-04-23 15:25:50 -06:00
Chris Diesch
dda93b929d Typo fix 2025-04-23 15:24:34 -06:00
Chris Diesch
83ca5f1bb6 Some typo/whitespace fixes 2025-04-11 16:30:25 -06:00
Chris Diesch
dd93b848d1 Add response code documentation 2025-04-10 19:57:02 -06:00
Chris Diesch
b3382bc539 Add 400 return code for invalid ranges 2025-04-10 19:52:13 -06:00

View File

@ -13,27 +13,35 @@ MRE_request_parser = RequestParser()
MRE_request_parser.add_argument('consumer_fico',
required=True,
type=int,
help='The consumer\'s fico score (int between [300, 850])')
help='The consumer\'s fico score (int between [300, 850]).')
MRE_request_parser.add_argument('home_price',
required=True,
type=float,
help='The price of the home the consumer wants to buy (float)')
help='The price of the home the consumer wants to buy (float).')
MRE_request_parser.add_argument('down_payment',
required=True,
type=float,
help='The down payment (as a percentage) for purchasing the home (float between [0, 1]).')
@namespace.route('/compute_mre')
@namespace.route('/from_down_payment')
@namespace.doc(params={
'consumer_fico': 'The consumer\'s fico score (int).',
'home_price': 'The price of the home (float).',
'down_payment': 'The down_payment percentage (float).'
'consumer_fico': 'The consumer\'s fico score (int) range: [620, 850].',
'home_price': 'The price of the home (float) range: [0, inf).',
'down_payment': 'The down_payment percentage (float) range: [0-1].'
})
class ComputeMRE(Resource):
@namespace.doc(description='Computes and returns the MRE.')
class FromDownPayment(Resource):
@namespace.expect(MRE_request_parser)
@namespace.doc(description='Computes and returns the MRE.',
responses={
200: 'Good',
400: 'Validation Error'
})
def get(self):
args = MRE_request_parser.parse_args()
mre = compute_mre(args.home_price, args.down_payment, args.consumer_fico)
try:
mre = compute_mre(args.home_price, args.down_payment, args.consumer_fico)
return {'consumer_mre': mre}
except ValueError as ve:
return {'error': str(ve)}, 400
return {'consumer_mre': mre}