Updated docs with a fast intro
This commit is contained in:
@@ -20,16 +20,22 @@ public class FraudDetectionController {
|
||||
private static final String AMOUNT_TOO_HIGH = "Amount too high";
|
||||
private static final BigDecimal MAX_AMOUNT = new BigDecimal("5000");
|
||||
|
||||
// tag::server_api[]
|
||||
@RequestMapping(
|
||||
value = "/fraudcheck",
|
||||
method = PUT,
|
||||
consumes = FRAUD_SERVICE_JSON_VERSION_1,
|
||||
produces = FRAUD_SERVICE_JSON_VERSION_1)
|
||||
public FraudCheckResult fraudCheck(@RequestBody FraudCheck fraudCheck) {
|
||||
// end::server_api[]
|
||||
// tag::new_impl[]
|
||||
if (amountGreaterThanThreshold(fraudCheck)) {
|
||||
return new FraudCheckResult(FraudCheckStatus.FRAUD, AMOUNT_TOO_HIGH);
|
||||
}
|
||||
// end::new_impl[]
|
||||
// tag::initial_impl[]
|
||||
return new FraudCheckResult(FraudCheckStatus.OK, NO_REASON);
|
||||
// end::initial_impl[]
|
||||
}
|
||||
|
||||
private boolean amountGreaterThanThreshold(FraudCheck fraudCheck) {
|
||||
|
||||
@@ -2,8 +2,8 @@ package contracts
|
||||
|
||||
org.springframework.cloud.contract.spec.Contract.make {
|
||||
request {
|
||||
method """PUT"""
|
||||
url """/fraudcheck"""
|
||||
method 'PUT'
|
||||
url '/fraudcheck'
|
||||
body("""
|
||||
{
|
||||
"clientPesel":"${value(client(regex('[0-9]{10}')), server('1234567890'))}",
|
||||
@@ -11,7 +11,7 @@ org.springframework.cloud.contract.spec.Contract.make {
|
||||
"""
|
||||
)
|
||||
headers {
|
||||
header("""Content-Type""", """application/vnd.fraud.v1+json""")
|
||||
header('Content-Type', 'application/vnd.fraud.v1+json')
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user