Updated docs with a fast intro

This commit is contained in:
Marcin Grzejszczak
2016-07-15 14:27:03 +02:00
parent bc22227fe3
commit a8a1bc1f2e
16 changed files with 253 additions and 106 deletions

View File

@@ -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) {

View File

@@ -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')
}
}