Send branch to createOrUpdateBranch and update example for Resource Doc / Swagger

This commit is contained in:
Simon Redfern 2017-08-03 16:03:00 +02:00
parent ff04b1a368
commit e14ba467d8
4 changed files with 11 additions and 7 deletions

View File

@ -929,8 +929,8 @@ object SwaggerDefinitionsJSON {
address = address,
location = location,
meta = meta,
lobbyString = null,
driveUpString = null,
lobbyString = None,
driveUpString = None,
lobby = Full(lobby),
driveUp = Full(driveUp),
branchRouting = branchRouting,

View File

@ -422,7 +422,10 @@ object SwaggerJSONFactory {
// name -> Tesobe, --> "name" : {"type":"string"}
// bank -> Bank(gh.29.uk), --> "bank": {"$ref":"#/definitions/Bank"}
// banks -> List(Bank(gh.29.uk) --> "banks": {"type": "array", "items":{"$ref": "#/definitions/Bank"}}
val properties = for ((key, value) <- mapOfFields) yield {
val properties = for {
(key, value) <- mapOfFields
_ = print("\n val properties for comprehension: " + key + " is " + value)
} yield {
value match {
case i: Boolean => "\"" + key + """": {"type":"boolean", "example":"""" +i+"\"}"
case Some(i: Boolean) => "\"" + key + """": {"type":"boolean", "example":"""" +i+"\"}"

View File

@ -719,11 +719,13 @@ trait APIMethods300 {
||
hasEntitlement("", u.userId, CanCreateBranchAtAnyBank)
, createBranchEntitlementsRequiredText)
branchJsonV300 <- tryo {json.extract[Branch]} ?~! ErrorMessages.InvalidJsonFormat
success <- Connector.connector.vend.createOrUpdateBranch(branchJsonV300)
branchJsonV300 <- tryo {json.extract[BranchJsonV300]} ?~! ErrorMessages.InvalidJsonFormat
branch <- transformToBranchFromV300(branchJsonV300)
success <- Connector.connector.vend.createOrUpdateBranch(branch)
} yield {
val json = branchJsonV300 // JSONFactory300.createBranchJson(success)
createdJsonResponse(Extraction.decompose(json))
// TODO remove the shortcut i.e. we should do the conversion back from branch to json rather than just echo the input
}
}
}

View File

@ -678,8 +678,7 @@ object JSONFactory300{
// This goes FROM JSON TO internal representation of a Branch
// This can be overloaded, and each function can accept a different input type
def transformToBranch(branchJsonV300: BranchJsonV300): Box[Branch] = {
def transformToBranchFromV300(branchJsonV300: BranchJsonV300): Box[Branch] = {
val address : Address = transformToAddressFromV300(branchJsonV300.address) // Note the address in V220 is V140