#511 Get rid of JValue from case class ResourceDoc -- 10 added Error body for V220

This commit is contained in:
hongwei1 2017-04-27 19:11:31 +02:00
parent 40775c8f12
commit e1d4dce294
8 changed files with 376 additions and 308 deletions

View File

@ -309,18 +309,32 @@ object SwaggerJSONFactory {
OperationParameterBodyJson(schema=ResponseObjectSchemaJson(s"#/definitions/${caseClassName}")) :: pathParameters
},
responses =
if (rd.requestVerb.toLowerCase == "get" ){
val errorResponseBodies = for (e <- rd.errorResponseBodies if e!= null) yield
"400"-> ResponseObjectJson(Some("Error"), Some(ResponseObjectSchemaJson(s"#/definitions/Error${getFildNameByValue(e)}")))
Map("200" -> ResponseObjectJson(Some("Success"), setReferenceObject(rd)))++errorResponseBodies.toMap
} else if (rd.requestVerb.toLowerCase == "delete"){
val errorResponseBodies = for (e <- rd.errorResponseBodies if e!= null) yield
"400" -> ResponseObjectJson(Some("Error"), Some(ResponseObjectSchemaJson(s"#/definitions/Error${getFildNameByValue(e)}")))
Map("204" -> ResponseNoContentObjectJson(Some("No Content")))++errorResponseBodies.toMap
} else{
val errorResponseBodies = for (e <- rd.errorResponseBodies if e!= null) yield
"400" -> ResponseObjectJson(Some("Error"), Some(ResponseObjectSchemaJson(s"#/definitions/Error${getFildNameByValue(e)}")))
Map( "201" -> ResponseObjectJson(Some("Success"), setReferenceObject(rd)))++errorResponseBodies.toMap
rd.requestVerb.toLowerCase match {
case "get" =>
Map(
"200" -> ResponseObjectJson(Some("Success"), setReferenceObject(rd)),
"400"-> ResponseObjectJson(Some("Error"), Some(ResponseObjectSchemaJson(s"#/definitions/Error${getFildNameByValue(rd.errorResponseBodies.head)}")))
)
case "post" =>
Map(
"201" -> ResponseObjectJson(Some("Success"), setReferenceObject(rd)),
"400"-> ResponseObjectJson(Some("Error"), Some(ResponseObjectSchemaJson(s"#/definitions/Error${getFildNameByValue(rd.errorResponseBodies.head)}")))
)
case "put" =>
Map(
"200" -> ResponseObjectJson(Some("Success"), setReferenceObject(rd)),
"400"-> ResponseObjectJson(Some("Error"), Some(ResponseObjectSchemaJson(s"#/definitions/Error${getFildNameByValue(rd.errorResponseBodies.head)}")))
)
case "delete" =>
Map(
"204" -> ResponseObjectJson(Some("Success"), setReferenceObject(rd)),
"400"-> ResponseObjectJson(Some("Error"), Some(ResponseObjectSchemaJson(s"#/definitions/Error${getFildNameByValue(rd.errorResponseBodies.head)}")))
)
case _ =>
Map(
"200" -> ResponseObjectJson(Some("Success"), setReferenceObject(rd)),
"400"-> ResponseObjectJson(Some("Error"), Some(ResponseObjectSchemaJson(s"#/definitions/Error${getFildNameByValue(rd.errorResponseBodies.head)}")))
)
}
)
)

View File

@ -104,7 +104,7 @@ object ErrorMessages {
val UnexpectedErrorDuringLogin = "OBP-20016: An unexpected login error occurred. Please try again."
val ViewAccessNoPermission = "OBP-20017: Current user does not have access to the view. Please specify a valid value for VIEW_ID."
val UserNoPermissionAccessView = "OBP-20017: Current user does not have access to the view. Please specify a valid value for VIEW_ID."
val InvalidInternalRedirectUrl = "OBP-20018: Login failed, invalid internal redirectUrl."
@ -141,6 +141,7 @@ object ErrorMessages {
val CreateBankInsertError = "OBP-30020: Could not create the Bank"
val CreateBankUpdateError = "OBP-30021: Could not update the Bank"
val ViewNoPermission = "OBP-30022: The current view does not have the permission: "
val MeetingsNotSupported = "OBP-30101: Meetings are not supported on this server."
@ -171,7 +172,7 @@ object ErrorMessages {
val InvalidStrongPasswordFormat = "OBP-30207: Invalid Password Format. Your password should EITHER be at least 10 characters long and contain mixed numbers and both upper and lower case letters and at least one special character, OR be longer than 16 characters."
val AccountIdHasExsited = "OBP-30208: Account_ID already exists at the Bank."
// Transaction related messages:
val InvalidTransactionRequestType = "OBP-40001: Invalid value for TRANSACTION_REQUEST_TYPE"
@ -190,6 +191,8 @@ object ErrorMessages {
val allowedAttemptsUsedUp = "OBP-40014: Sorry, you've used up your allowed attempts. "
val InvalidChallengeType = "OBP-40015: Invalid Challenge Type. Please specify a valid value for CHALLENGE_TYPE, when you create the transaction request."
val UnKnownError = "OBP-50000: Unknown Error."
//For Swagger, used reflect to list all the varible names and values.
// eg : val InvalidUserId = "OBP-30107: Invalid User Id."
// -->(InvalidUserId, "OBP-30107: Invalid User Id.")

View File

@ -108,7 +108,7 @@ trait APIMethods121 {
|* Git Commit""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(Core, notPSD2, OBWG),
apiTagApiInfo :: Nil)
@ -134,7 +134,7 @@ trait APIMethods121 {
|* Website""",
emptyObjectJson,
BanksJSON(List(BankJSON("gh.29.uk", "EFG", "Eurobank", "None", "www.eurobank.rs",BankRoutingJSON("obp","gh.29.uk")))),
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(Core, notPSD2, OBWG),
apiTagBank :: Nil)
@ -170,7 +170,7 @@ trait APIMethods121 {
|* Website""",
emptyObjectJson,
BankJSON("gh.29.uk", "EFG", "Eurobank", "None", "www.eurobank.rs",BankRoutingJSON("obp","gh.29.uk")),
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(Core, notPSD2, OBWG),
apiTagBank :: Nil)
@ -209,7 +209,7 @@ trait APIMethods121 {
|""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(Core, PSD2, OBWG),
apiTagAccount :: Nil)
@ -234,7 +234,7 @@ trait APIMethods121 {
|Authentication via OAuth is required.""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(Core, PSD2, OBWG),
apiTagAccount :: Nil)
@ -262,7 +262,7 @@ trait APIMethods121 {
|For each account the API returns the ID and the available views. Authentication via OAuth is required.""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
apiTagAccount :: Nil)
@ -293,7 +293,7 @@ trait APIMethods121 {
""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
apiTagAccount :: Nil)
@ -323,7 +323,7 @@ trait APIMethods121 {
|Authentication via OAuth is required.""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(Core, PSD2, OBWG),
apiTagAccount :: Nil)
@ -353,7 +353,7 @@ trait APIMethods121 {
|Authentication via OAuth is not required.""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
apiTagAccount :: apiTagPublicData :: Nil)
@ -393,7 +393,7 @@ trait APIMethods121 {
|Authentication is required if the 'is_public' field in view (VIEW_ID) is not set to `true`.""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
apiTagAccount :: Nil)
@ -428,7 +428,7 @@ trait APIMethods121 {
"BANK_ID"
),
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagAccount, apiTagMetaData)
)
@ -482,7 +482,7 @@ trait APIMethods121 {
|OAuth authentication is required and the user needs to have access to the owner view.""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagAccount, apiTagView))
@ -534,7 +534,7 @@ trait APIMethods121 {
)
),
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagAccount, apiTagView)
)
@ -576,7 +576,7 @@ trait APIMethods121 {
List("can_see_transaction_start_date", "can_see_bank_account_label")
),
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagAccount, apiTagView)
)
@ -590,7 +590,7 @@ trait APIMethods121 {
account <- BankAccount(bankId, accountId)
u <- user ?~ "user not found"
updateJson <- tryo
{ json.extract[UpdateViewJSON] } ?~ "wrong JSON format"
{ json.extract[UpdateViewJSON] } ?~ InvalidJsonFormat
updatedView <- account.updateView(u, viewId, updateJson)
} yield {
val viewJSON = JSONFactory.createViewJSON(updatedView)
@ -609,7 +609,7 @@ trait APIMethods121 {
"Deletes the view specified by VIEW_ID on the bank account specified by ACCOUNT_ID at bank BANK_ID.",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagAccount, apiTagView)
)
@ -639,7 +639,7 @@ trait APIMethods121 {
|OAuth authentication is required and the user needs to have access to the owner view.""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagAccount, apiTagView, apiTagEntitlement)
)
@ -672,11 +672,12 @@ trait APIMethods121 {
|OAuth authentication is required and the user needs to have access to the owner view.""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagAccount, apiTagView, apiTagEntitlement)
)
lazy val getPermissionForUserForBankAccount: PartialFunction[Req, Box[User] => Box[JsonResponse]] = {
//get access for specific user
case "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: "permissions" :: providerId :: userId :: Nil JsonGet json => {
@ -706,7 +707,7 @@ trait APIMethods121 {
|OAuth authentication is required and the user needs to have access to the owner view.""",
ViewIdsJson(List("owner", "auditor", "investor")),
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagPerson, apiTagUser, apiTagAccount, apiTagView, apiTagEntitlement, apiTagOwnerRequired))
@ -740,7 +741,7 @@ trait APIMethods121 {
|Granting access to a public view will return an error message, as the user already has access.""",
emptyObjectJson, // No Json body required
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagPerson, apiTagUser, apiTagAccount, apiTagView, apiTagEntitlement, apiTagOwnerRequired))
@ -774,7 +775,7 @@ trait APIMethods121 {
|OAuth authentication is required and the user needs to have access to the owner view.""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagPerson, apiTagUser, apiTagAccount, apiTagView, apiTagEntitlement, apiTagOwnerRequired))
@ -803,7 +804,7 @@ trait APIMethods121 {
|OAuth authentication is required and the user needs to have access to the owner view.""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagPerson, apiTagUser, apiTagAccount, apiTagView, apiTagEntitlement, apiTagOwnerRequired))
@ -832,7 +833,7 @@ trait APIMethods121 {
|Authentication is required if the view VIEW_ID is not public.""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, PSD2, OBWG),
List(apiTagPerson, apiTagUser, apiTagAccount, apiTagCounterparty))
@ -863,7 +864,7 @@ trait APIMethods121 {
|Authentication is required if the view is not public.""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, PSD2, OBWG),
List(apiTagAccount, apiTagCounterparty))
@ -895,7 +896,7 @@ trait APIMethods121 {
|Authentication via OAuth is required if the view is not public.""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagMetaData, apiTagCounterparty))
@ -927,7 +928,7 @@ trait APIMethods121 {
|OAuth authentication is required if the view is not public.""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagMetaData, apiTagCounterparty))
@ -966,7 +967,7 @@ trait APIMethods121 {
|The VIEW_ID parameter should be a view the caller is permitted to access to and that has permission to create public aliases.""",
AliasJSON("An Alias"),
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagMetaData, apiTagCounterparty))
@ -980,7 +981,7 @@ trait APIMethods121 {
otherBankAccount <- account.moderatedOtherBankAccount(other_account_id, view, user)
metadata <- Box(otherBankAccount.metadata) ?~ {"the view " + viewId + "does not allow metadata access"}
addAlias <- Box(metadata.addPublicAlias) ?~ {"the view " + viewId + "does not allow adding a public alias"}
aliasJson <- tryo{(json.extract[AliasJSON])} ?~ {"wrong JSON format"}
aliasJson <- tryo{(json.extract[AliasJSON])} ?~ {InvalidJsonFormat}
added <- Counterparties.counterparties.vend.addPublicAlias(other_account_id, aliasJson.alias) ?~ {"Alias cannot be added"}
if(added)
} yield {
@ -1002,7 +1003,7 @@ trait APIMethods121 {
|Authentication is required if the view is not public.""",
AliasJSON("An Alias"),
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagMetaData, apiTagCounterparty))
@ -1016,7 +1017,7 @@ trait APIMethods121 {
otherBankAccount <- account.moderatedOtherBankAccount(other_account_id, view, user)
metadata <- Box(otherBankAccount.metadata) ?~ {"the view " + viewId + "does not allow metadata access"}
addAlias <- Box(metadata.addPublicAlias) ?~ {"the view " + viewId + "does not allow updating the public alias"}
aliasJson <- tryo{(json.extract[AliasJSON])} ?~ {"wrong JSON format"}
aliasJson <- tryo{(json.extract[AliasJSON])} ?~ {InvalidJsonFormat}
added <- Counterparties.counterparties.vend.addPublicAlias(other_account_id, aliasJson.alias) ?~ {"Alias cannot be updated"}
if(added)
} yield {
@ -1038,7 +1039,7 @@ trait APIMethods121 {
|Authentication is required if the view is not public.""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagMetaData, apiTagCounterparty))
@ -1071,7 +1072,7 @@ trait APIMethods121 {
|Authentication is required if the view is not public.""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagMetaData, apiTagCounterparty))
@ -1105,7 +1106,7 @@ trait APIMethods121 {
|Authentication is required if the view is not public.""",
AliasJSON("An Alias"),
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagMetaData, apiTagCounterparty))
@ -1119,7 +1120,7 @@ trait APIMethods121 {
otherBankAccount <- account.moderatedOtherBankAccount(other_account_id, view, user)
metadata <- Box(otherBankAccount.metadata) ?~ {"the view " + viewId + "does not allow metadata access"}
addAlias <- Box(metadata.addPrivateAlias) ?~ {"the view " + viewId + "does not allow adding a private alias"}
aliasJson <- tryo{(json.extract[AliasJSON])} ?~ {"wrong JSON format"}
aliasJson <- tryo{(json.extract[AliasJSON])} ?~ {InvalidJsonFormat}
added <- Counterparties.counterparties.vend.addPrivateAlias(other_account_id, aliasJson.alias) ?~ {"Alias cannot be added"}
if(added)
} yield {
@ -1142,7 +1143,7 @@ trait APIMethods121 {
|Authentication is required if the view is not public.""",
AliasJSON("An Alias"),
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagMetaData, apiTagCounterparty))
@ -1156,7 +1157,7 @@ trait APIMethods121 {
otherBankAccount <- account.moderatedOtherBankAccount(other_account_id, view, user)
metadata <- Box(otherBankAccount.metadata) ?~ {"the view " + viewId + "does not allow metadata access"}
addAlias <- Box(metadata.addPrivateAlias) ?~ {"the view " + viewId + "does not allow updating the private alias"}
aliasJson <- tryo{(json.extract[AliasJSON])} ?~ {"wrong JSON format"}
aliasJson <- tryo{(json.extract[AliasJSON])} ?~ {InvalidJsonFormat}
updated <- Counterparties.counterparties.vend.addPrivateAlias(other_account_id, aliasJson.alias) ?~ {"Alias cannot be updated"}
if(updated)
} yield {
@ -1179,7 +1180,7 @@ trait APIMethods121 {
|Authentication is required if the view is not public.""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagMetaData, apiTagCounterparty))
@ -1211,7 +1212,7 @@ trait APIMethods121 {
"Add a description of the counter party from the perpestive of the account e.g. My dentist.",
MoreInfoJSON("More info"),
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagMetaData, apiTagCounterparty))
@ -1225,7 +1226,7 @@ trait APIMethods121 {
otherBankAccount <- account.moderatedOtherBankAccount(other_account_id, view, user)
metadata <- Box(otherBankAccount.metadata) ?~ {"the view " + viewId + "does not allow metadata access"}
addMoreInfo <- Box(metadata.addMoreInfo) ?~ {"the view " + viewId + "does not allow adding more info"}
moreInfoJson <- tryo{(json.extract[MoreInfoJSON])} ?~ {"wrong JSON format"}
moreInfoJson <- tryo{(json.extract[MoreInfoJSON])} ?~ {InvalidJsonFormat}
added <- Counterparties.counterparties.vend.addMoreInfo(other_account_id, moreInfoJson.more_info) ?~ {"More Info cannot be added"}
if(added)
} yield {
@ -1245,7 +1246,7 @@ trait APIMethods121 {
"Update the more info description of the counter party from the perpestive of the account e.g. My dentist.",
MoreInfoJSON("More info"),
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagMetaData, apiTagCounterparty))
@ -1259,7 +1260,7 @@ trait APIMethods121 {
otherBankAccount <- account.moderatedOtherBankAccount(other_account_id, view, user)
metadata <- Box(otherBankAccount.metadata) ?~ {"the view " + viewId + "does not allow metadata access"}
addMoreInfo <- Box(metadata.addMoreInfo) ?~ {"the view " + viewId + "does not allow updating more info"}
moreInfoJson <- tryo{(json.extract[MoreInfoJSON])} ?~ {"wrong JSON format"}
moreInfoJson <- tryo{(json.extract[MoreInfoJSON])} ?~ {InvalidJsonFormat}
updated <- Counterparties.counterparties.vend.addMoreInfo(other_account_id, moreInfoJson.more_info) ?~ {"More Info cannot be updated"}
if(updated)
} yield {
@ -1279,7 +1280,7 @@ trait APIMethods121 {
"",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagMetaData, apiTagCounterparty))
@ -1311,7 +1312,7 @@ trait APIMethods121 {
"A url which represents the counterparty (home page url etc.)",
UrlJSON("www.example.com"),
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagMetaData, apiTagCounterparty))
@ -1326,7 +1327,7 @@ trait APIMethods121 {
otherBankAccount <- account.moderatedOtherBankAccount(other_account_id, view, user)
metadata <- Box(otherBankAccount.metadata) ?~ {"the view " + viewId + "does not allow metadata access"}
addUrl <- Box(metadata.addURL) ?~ {"the view " + viewId + "does not allow adding a url"}
urlJson <- tryo{(json.extract[UrlJSON])} ?~ {"wrong JSON format"}
urlJson <- tryo{(json.extract[UrlJSON])} ?~ {InvalidJsonFormat}
added <- Counterparties.counterparties.vend.addURL(other_account_id, urlJson.URL) ?~ {"URL cannot be added"}
if(added)
} yield {
@ -1346,7 +1347,7 @@ trait APIMethods121 {
"A url which represents the counterparty (home page url etc.)",
UrlJSON("www.example.com"),
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagMetaData, apiTagCounterparty))
@ -1360,7 +1361,7 @@ trait APIMethods121 {
otherBankAccount <- account.moderatedOtherBankAccount(other_account_id, view, user)
metadata <- Box(otherBankAccount.metadata) ?~ {"the view " + viewId + "does not allow metadata access"}
addUrl <- Box(metadata.addURL) ?~ {"the view " + viewId + "does not allow updating a url"}
urlJson <- tryo{(json.extract[UrlJSON])} ?~ {"wrong JSON format"}
urlJson <- tryo{(json.extract[UrlJSON])} ?~ {InvalidJsonFormat}
added <- Counterparties.counterparties.vend.addURL(other_account_id, urlJson.URL) ?~ {"URL cannot be updated"}
if(added)
} yield {
@ -1380,7 +1381,7 @@ trait APIMethods121 {
"",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagMetaData, apiTagCounterparty))
@ -1412,7 +1413,7 @@ trait APIMethods121 {
"Add a url that points to the logo of the counterparty",
ImageUrlJSON("www.example.com/logo.png"),
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagMetaData, apiTagCounterparty))
@ -1426,7 +1427,7 @@ trait APIMethods121 {
otherBankAccount <- account.moderatedOtherBankAccount(other_account_id, view, user)
metadata <- Box(otherBankAccount.metadata) ?~ {"the view " + viewId + "does not allow metadata access"}
addImageUrl <- Box(metadata.addImageURL) ?~ {"the view " + viewId + "does not allow adding an image url"}
imageUrlJson <- tryo{(json.extract[ImageUrlJSON])} ?~ {"wrong JSON format"}
imageUrlJson <- tryo{(json.extract[ImageUrlJSON])} ?~ {InvalidJsonFormat}
added <- Counterparties.counterparties.vend.addImageURL(other_account_id, imageUrlJson.image_URL) ?~ {"URL cannot be added"}
if(added)
} yield {
@ -1446,7 +1447,7 @@ trait APIMethods121 {
"Update the url that points to the logo of the counterparty",
ImageUrlJSON("www.example.com/logo.png"),
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagMetaData, apiTagCounterparty))
@ -1460,7 +1461,7 @@ trait APIMethods121 {
otherBankAccount <- account.moderatedOtherBankAccount(other_account_id, view, user)
metadata <- Box(otherBankAccount.metadata) ?~ {"the view " + viewId + "does not allow metadata access"}
addImageUrl <- Box(metadata.addImageURL) ?~ {"the view " + viewId + "does not allow updating an image url"}
imageUrlJson <- tryo{(json.extract[ImageUrlJSON])} ?~ {"wrong JSON format"}
imageUrlJson <- tryo{(json.extract[ImageUrlJSON])} ?~ {InvalidJsonFormat}
updated <- Counterparties.counterparties.vend.addImageURL(other_account_id, imageUrlJson.image_URL) ?~ {"URL cannot be updated"}
if(updated)
} yield {
@ -1480,7 +1481,7 @@ trait APIMethods121 {
"Delete image url of other bank account.",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagMetaData, apiTagCounterparty)) // Tag general then specific for consistent sorting
@ -1512,7 +1513,7 @@ trait APIMethods121 {
"Add open corporates url to other bank account.",
OpenCorporateUrlJSON("https://opencorporates.com/companies/gb/04351490"),
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagMetaData, apiTagCounterparty))
@ -1526,7 +1527,7 @@ trait APIMethods121 {
otherBankAccount <- account.moderatedOtherBankAccount(other_account_id, view, user)
metadata <- Box(otherBankAccount.metadata) ?~ {"the view " + viewId + "does not allow metadata access"}
addOpenCorpUrl <- Box(metadata.addOpenCorporatesURL) ?~ {"the view " + viewId + "does not allow adding an open corporate url"}
openCorpUrl <- tryo{(json.extract[OpenCorporateUrlJSON])} ?~ {"wrong JSON format"}
openCorpUrl <- tryo{(json.extract[OpenCorporateUrlJSON])} ?~ {InvalidJsonFormat}
added <- Counterparties.counterparties.vend.addOpenCorporatesURL(other_account_id, openCorpUrl.open_corporates_URL) ?~ {"URL cannot be added"}
if(added)
} yield {
@ -1546,7 +1547,7 @@ trait APIMethods121 {
"Update open corporate url of other bank account.",
OpenCorporateUrlJSON("https://opencorporates.com/companies/gb/04351490"),
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagMetaData, apiTagCounterparty))
@ -1560,7 +1561,7 @@ trait APIMethods121 {
otherBankAccount <- account.moderatedOtherBankAccount(other_account_id, view, user)
metadata <- Box(otherBankAccount.metadata) ?~ {"the view " + viewId + "does not allow metadata access"}
addOpenCorpUrl <- Box(metadata.addOpenCorporatesURL) ?~ {"the view " + viewId + "does not allow updating an open corporate url"}
openCorpUrl <- tryo{(json.extract[OpenCorporateUrlJSON])} ?~ {"wrong JSON format"}
openCorpUrl <- tryo{(json.extract[OpenCorporateUrlJSON])} ?~ {InvalidJsonFormat}
updated <- Counterparties.counterparties.vend.addOpenCorporatesURL(other_account_id, openCorpUrl.open_corporates_URL) ?~ {"URL cannot be updated"}
if(updated)
} yield {
@ -1580,7 +1581,7 @@ trait APIMethods121 {
"Delete open corporate url of other bank account.",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagMetaData, apiTagCounterparty))
@ -1612,7 +1613,7 @@ trait APIMethods121 {
"Add the geolocation of the counterparty's registered address",
CorporateLocationJSON(JSONFactory.createLocationPlainJSON(52.5571573,13.3728025)),
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagMetaData, apiTagCounterparty))
@ -1627,7 +1628,7 @@ trait APIMethods121 {
otherBankAccount <- account.moderatedOtherBankAccount(other_account_id, view, user)
metadata <- Box(otherBankAccount.metadata) ?~ {"the view " + viewId + "does not allow metadata access"}
addCorpLocation <- Box(metadata.addCorporateLocation) ?~ {"the view " + viewId + "does not allow adding a corporate location"}
corpLocationJson <- tryo{(json.extract[CorporateLocationJSON])} ?~ {"wrong JSON format"}
corpLocationJson <- tryo{(json.extract[CorporateLocationJSON])} ?~ {InvalidJsonFormat}
correctCoordinates <- checkIfLocationPossible(corpLocationJson.corporate_location.latitude, corpLocationJson.corporate_location.longitude)
added <- Counterparties.counterparties.vend.addCorporateLocation(other_account_id, u.resourceUserId, (now:TimeSpan), corpLocationJson.corporate_location.longitude, corpLocationJson.corporate_location.latitude) ?~ {"Corporate Location cannot be deleted"}
if(added)
@ -1648,7 +1649,7 @@ trait APIMethods121 {
"Update the geolocation of the counterparty's registered address",
CorporateLocationJSON(JSONFactory.createLocationPlainJSON(52.5571573,13.3728025)),
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagMetaData, apiTagCounterparty))
@ -1663,7 +1664,7 @@ trait APIMethods121 {
otherBankAccount <- account.moderatedOtherBankAccount(other_account_id, view, user)
metadata <- Box(otherBankAccount.metadata) ?~ {"the view " + viewId + "does not allow metadata access"}
addCorpLocation <- Box(metadata.addCorporateLocation) ?~ {"the view " + viewId + "does not allow updating a corporate location"}
corpLocationJson <- tryo{(json.extract[CorporateLocationJSON])} ?~ {"wrong JSON format"}
corpLocationJson <- tryo{(json.extract[CorporateLocationJSON])} ?~ {InvalidJsonFormat}
correctCoordinates <- checkIfLocationPossible(corpLocationJson.corporate_location.latitude, corpLocationJson.corporate_location.longitude)
updated <- Counterparties.counterparties.vend.addCorporateLocation(other_account_id, u.resourceUserId, (now:TimeSpan), corpLocationJson.corporate_location.longitude, corpLocationJson.corporate_location.latitude) ?~ {"Corporate Location cannot be updated"}
if(updated)
@ -1684,7 +1685,7 @@ trait APIMethods121 {
"Delete corporate location of other bank account. Delete the geolocation of the counterparty's registered address",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagMetaData, apiTagCounterparty))
@ -1720,7 +1721,7 @@ trait APIMethods121 {
"Add geocoordinates of the counterparty's main location",
PhysicalLocationJSON(JSONFactory.createLocationPlainJSON(52.5571573,13.3728025)),
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagMetaData, apiTagCounterparty))
@ -1735,7 +1736,7 @@ trait APIMethods121 {
otherBankAccount <- account.moderatedOtherBankAccount(other_account_id, view, user)
metadata <- Box(otherBankAccount.metadata) ?~ {"the view " + viewId + "does not allow metadata access"}
addPhysicalLocation <- Box(metadata.addPhysicalLocation) ?~ {"the view " + viewId + "does not allow adding a physical location"}
physicalLocationJson <- tryo{(json.extract[PhysicalLocationJSON])} ?~ {"wrong JSON format"}
physicalLocationJson <- tryo{(json.extract[PhysicalLocationJSON])} ?~ {InvalidJsonFormat}
correctCoordinates <- checkIfLocationPossible(physicalLocationJson.physical_location.latitude, physicalLocationJson.physical_location.longitude)
correctCoordinates <- checkIfLocationPossible(physicalLocationJson.physical_location.latitude, physicalLocationJson.physical_location.longitude)
added <- Counterparties.counterparties.vend.addPhysicalLocation(other_account_id, u.resourceUserId, (now:TimeSpan), physicalLocationJson.physical_location.longitude, physicalLocationJson.physical_location.latitude) ?~ {"Physical Location cannot be added"}
@ -1757,7 +1758,7 @@ trait APIMethods121 {
"Update geocoordinates of the counterparty's main location",
PhysicalLocationJSON(JSONFactory.createLocationPlainJSON(52.5571573,13.3728025)),
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagMetaData, apiTagCounterparty))
@ -1772,7 +1773,7 @@ trait APIMethods121 {
otherBankAccount <- account.moderatedOtherBankAccount(other_account_id, view, user)
metadata <- Box(otherBankAccount.metadata) ?~ {"the view " + viewId + "does not allow metadata access"}
addPhysicalLocation <- Box(metadata.addPhysicalLocation) ?~ {"the view " + viewId + "does not allow updating a physical location"}
physicalLocationJson <- tryo{(json.extract[PhysicalLocationJSON])} ?~ {"wrong JSON format"}
physicalLocationJson <- tryo{(json.extract[PhysicalLocationJSON])} ?~ {InvalidJsonFormat}
correctCoordinates <- checkIfLocationPossible(physicalLocationJson.physical_location.latitude, physicalLocationJson.physical_location.longitude)
correctCoordinates <- checkIfLocationPossible(physicalLocationJson.physical_location.latitude, physicalLocationJson.physical_location.longitude)
updated <- Counterparties.counterparties.vend.addPhysicalLocation(other_account_id, u.resourceUserId, (now:TimeSpan), physicalLocationJson.physical_location.longitude, physicalLocationJson.physical_location.latitude) ?~ {"Physical Location cannot be updated"}
@ -1794,7 +1795,7 @@ trait APIMethods121 {
"Delete physical location of other bank account.",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagMetaData, apiTagCounterparty))
@ -1841,7 +1842,7 @@ trait APIMethods121 {
|**Date format parameter**: "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" (2014-07-01T00:00:00.000Z) ==> time zone is UTC.""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagAccount, apiTagTransaction))
@ -1878,7 +1879,7 @@ trait APIMethods121 {
|""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagAccount, apiTagTransaction))
@ -1909,7 +1910,7 @@ trait APIMethods121 {
|Authentication via OAuth is required if the view is not public.""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagMetaData, apiTagTransaction))
@ -1944,7 +1945,7 @@ trait APIMethods121 {
|""",
TransactionNarrativeJSON("My new (old!) piano"),
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagMetaData, apiTagTransaction))
@ -1954,7 +1955,7 @@ trait APIMethods121 {
user =>
for {
u <- user
narrativeJson <- tryo{json.extract[TransactionNarrativeJSON]} ?~ {"wrong json format"}
narrativeJson <- tryo{json.extract[TransactionNarrativeJSON]} ?~ {InvalidJsonFormat}
metadata <- moderatedTransactionMetadata(bankId, accountId, viewId, transactionId, Full(u))
addNarrative <- Box(metadata.addOwnerComment) ?~ {"view " + viewId + " does not allow adding a narrative"}
} yield {
@ -1977,7 +1978,7 @@ trait APIMethods121 {
|Authentication via OAuth is required if the view is not public.""",
TransactionNarrativeJSON("My new (old!) piano"),
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagMetaData, apiTagTransaction))
@ -1987,7 +1988,7 @@ trait APIMethods121 {
user =>
for {
u <- user
narrativeJson <- tryo{json.extract[TransactionNarrativeJSON]} ?~ {"wrong json format"}
narrativeJson <- tryo{json.extract[TransactionNarrativeJSON]} ?~ {InvalidJsonFormat}
metadata <- moderatedTransactionMetadata(bankId, accountId, viewId, transactionId, Full(u))
addNarrative <- Box(metadata.addOwnerComment) ?~ {"view " + viewId + " does not allow updating a narrative"}
} yield {
@ -2010,7 +2011,7 @@ trait APIMethods121 {
|Authentication via OAuth is required if the view is not public.""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagMetaData, apiTagTransaction))
@ -2040,7 +2041,7 @@ trait APIMethods121 {
|Authentication via OAuth is required if the view is not public.""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagMetaData, apiTagTransaction))
@ -2072,7 +2073,7 @@ trait APIMethods121 {
|Authentication is required since the comment is linked with the user.""",
PostTransactionCommentJSON("Why did we spend money on this again?"),
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagMetaData, apiTagTransaction))
@ -2082,7 +2083,7 @@ trait APIMethods121 {
user =>
for {
u <- user
commentJson <- tryo{json.extract[PostTransactionCommentJSON]} ?~ {"wrong json format"}
commentJson <- tryo{json.extract[PostTransactionCommentJSON]} ?~ {InvalidJsonFormat}
metadata <- moderatedTransactionMetadata(bankId, accountId, viewId, transactionId, Full(u))
addCommentFunc <- Box(metadata.addComment) ?~ {"view " + viewId + " does not authorize adding comments"}
postedComment <- addCommentFunc(u.resourceUserId, viewId, commentJson.value, now)
@ -2106,7 +2107,7 @@ trait APIMethods121 {
|Authentication via OAuth is required. The user must either have owner privileges for this account, or must be the user that posted the comment.""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagMetaData, apiTagTransaction))
@ -2136,7 +2137,7 @@ trait APIMethods121 {
Authentication via OAuth is required if the view is not public.""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagMetaData, apiTagTransaction))
@ -2168,7 +2169,7 @@ Authentication via OAuth is required if the view is not public.""",
|Authentication is required as the tag is linked with the user.""",
PostTransactionTagJSON("holiday"),
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagMetaData, apiTagTransaction))
@ -2203,7 +2204,7 @@ Authentication via OAuth is required if the view is not public.""",
Authentication via OAuth is required. The user must either have owner privileges for this account, or must be the user that posted the tag.""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagMetaData, apiTagTransaction))
@ -2234,7 +2235,7 @@ Authentication via OAuth is required. The user must either have owner privileges
Authentication via OAuth is required if the view is not public.""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagMetaData, apiTagTransaction))
@ -2269,7 +2270,7 @@ Authentication via OAuth is required if the view is not public.""",
"www.example.com/images/printer.png"
),
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagMetaData, apiTagTransaction)
)
@ -2303,7 +2304,7 @@ Authentication via OAuth is required if the view is not public.""",
|Authentication via OAuth is required. The user must either have owner privileges for this account, or must be the user that posted the image.""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagMetaData, apiTagTransaction))
@ -2334,7 +2335,7 @@ Authentication via OAuth is required if the view is not public.""",
|Authentication via OAuth is required if the view is not public.""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagMetaData, apiTagTransaction))
@ -2367,7 +2368,7 @@ Authentication via OAuth is required if the view is not public.""",
|The geo tag is linked with the user.""",
PostTransactionWhereJSON(JSONFactory.createLocationPlainJSON(52.5571573,13.3728025)),
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagMetaData, apiTagTransaction))
@ -2380,7 +2381,7 @@ Authentication via OAuth is required if the view is not public.""",
view <- View.fromUrl(viewId, accountId, bankId)
metadata <- moderatedTransactionMetadata(bankId, accountId, viewId, transactionId, user)
addWhereTag <- Box(metadata.addWhereTag) ?~ {"the view " + viewId + "does not allow adding a where tag"}
whereJson <- tryo{(json.extract[PostTransactionWhereJSON])} ?~ {"wrong JSON format"}
whereJson <- tryo{(json.extract[PostTransactionWhereJSON])} ?~ {InvalidJsonFormat}
correctCoordinates <- checkIfLocationPossible(whereJson.where.latitude, whereJson.where.longitude)
if(addWhereTag(u.resourceUserId, viewId, now, whereJson.where.longitude, whereJson.where.latitude))
} yield {
@ -2404,7 +2405,7 @@ Authentication via OAuth is required if the view is not public.""",
|The geo tag is linked with the user.""",
PostTransactionWhereJSON(JSONFactory.createLocationPlainJSON(52.5571573,13.3728025)),
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagMetaData, apiTagTransaction))
@ -2417,7 +2418,7 @@ Authentication via OAuth is required if the view is not public.""",
view <- View.fromUrl(viewId, accountId, bankId)
metadata <- moderatedTransactionMetadata(bankId, accountId, viewId, transactionId, user)
addWhereTag <- Box(metadata.addWhereTag) ?~ {"the view " + viewId + "does not allow updating a where tag"}
whereJson <- tryo{(json.extract[PostTransactionWhereJSON])} ?~ {"wrong JSON format"}
whereJson <- tryo{(json.extract[PostTransactionWhereJSON])} ?~ {InvalidJsonFormat}
correctCoordinates <- checkIfLocationPossible(whereJson.where.latitude, whereJson.where.longitude)
if(addWhereTag(u.resourceUserId, viewId, now, whereJson.where.longitude, whereJson.where.latitude))
} yield {
@ -2441,7 +2442,7 @@ Authentication via OAuth is required if the view is not public.""",
|The user must either have owner privileges for this account, or must be the user that posted the geo tag.""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagMetaData, apiTagTransaction))
@ -2476,7 +2477,7 @@ Authentication via OAuth is required if the view is not public.""",
Authentication via OAuth is required if the view is not public.""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagTransaction, apiTagCounterparty))
@ -2514,7 +2515,7 @@ Authentication via OAuth is required if the view is not public.""",
|There are no checks for 'sufficient funds' at the moment, so it is possible to go into unlimited overdraft.""",
MakePaymentJson("To BANK_ID", "To ACCOUNT_ID", "12.45"),
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagTransactionRequest))
@ -2524,7 +2525,7 @@ Authentication via OAuth is required if the view is not public.""",
if (Props.getBool("payments_enabled", false)) {
for {
u <- user ?~ "User not found"
makeTransJson <- tryo{json.extract[MakePaymentJson]} ?~ {"wrong json format"}
makeTransJson <- tryo{json.extract[MakePaymentJson]} ?~ {InvalidJsonFormat}
rawAmt <- tryo {BigDecimal(makeTransJson.amount)} ?~! s"amount ${makeTransJson.amount} not convertible to number"
toAccountUID = BankAccountUID(BankId(makeTransJson.bank_id), AccountId(makeTransJson.account_id))
createdPaymentId <- Connector.connector.vend.makePayment(u, BankAccountUID(bankId, accountId), toAccountUID, rawAmt, "")

View File

@ -34,7 +34,7 @@ trait APIMethods130 {
"Returns data about all the physical cards a user has been issued. These could be debit cards, credit cards, etc.",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagCustomer))
@ -69,7 +69,7 @@ trait APIMethods130 {
"",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagCustomer))

View File

@ -78,7 +78,7 @@ trait APIMethods140 extends MdcLoggable with APIMethods130 with APIMethods121{
|Authentication via OAuth is required.""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagCustomer))
@ -114,7 +114,7 @@ trait APIMethods140 extends MdcLoggable with APIMethods130 with APIMethods121{
|Authentication via OAuth is required.""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagPerson, apiTagCustomer))
@ -146,7 +146,7 @@ trait APIMethods140 extends MdcLoggable with APIMethods130 with APIMethods121{
// We use Extraction.decompose to convert to json
AddCustomerMessageJson("message to send", "from department", "from person"),
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagPerson, apiTagCustomer)
)
@ -191,7 +191,7 @@ trait APIMethods140 extends MdcLoggable with APIMethods130 with APIMethods121{
|${authenticationRequiredMessage(!getBranchesIsPublic)}""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(Core, notPSD2, OBWG),
List(apiTagBank)
)
@ -235,7 +235,7 @@ trait APIMethods140 extends MdcLoggable with APIMethods130 with APIMethods121{
|${authenticationRequiredMessage(!getAtmsIsPublic)}""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(Core, notPSD2, OBWG),
List(apiTagBank)
)
@ -287,7 +287,7 @@ trait APIMethods140 extends MdcLoggable with APIMethods130 with APIMethods121{
|${authenticationRequiredMessage(!getProductsIsPublic)}""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(Core, notPSD2, OBWG),
List(apiTagBank)
)
@ -324,7 +324,7 @@ trait APIMethods140 extends MdcLoggable with APIMethods130 with APIMethods121{
"",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagCustomer)
)
@ -375,7 +375,7 @@ trait APIMethods140 extends MdcLoggable with APIMethods130 with APIMethods121{
""".stripMargin,
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(Core, PSD2, OBWG),
List(apiTagTransactionRequest))
@ -412,7 +412,7 @@ trait APIMethods140 extends MdcLoggable with APIMethods130 with APIMethods121{
"",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(Core, PSD2, OBWG),
List(apiTagTransactionRequest))
@ -467,7 +467,7 @@ trait APIMethods140 extends MdcLoggable with APIMethods130 with APIMethods121{
"one of the transaction types possible for the account"
),
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(Core, PSD2, OBWG),
List(apiTagTransactionRequest))
@ -515,7 +515,7 @@ trait APIMethods140 extends MdcLoggable with APIMethods130 with APIMethods121{
"In Sandbox mode, any string that can be converted to a possitive integer will be accepted as an answer.",
ChallengeAnswerJSON("89123812", "123345"),
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(Core, PSD2, OBWG),
List(apiTagTransactionRequest))
@ -580,7 +580,7 @@ trait APIMethods140 extends MdcLoggable with APIMethods130 with APIMethods121{
exampleDate
),
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagCustomer))
@ -660,7 +660,7 @@ trait APIMethods140 extends MdcLoggable with APIMethods130 with APIMethods121{
|_etc_...""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
Nil)
}

View File

@ -161,7 +161,7 @@ trait APIMethods200 {
bank_id = "gh.29.uk",
views_available = List(basicViewJSON)
),
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagAccount, apiTagPrivateData, apiTagPublicData))
@ -189,7 +189,7 @@ trait APIMethods200 {
|""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(Core, PSD2, OBWG),
List(apiTagAccount, apiTagPrivateData))
@ -205,7 +205,7 @@ trait APIMethods200 {
user =>
for {
u <- user ?~ ErrorMessages.UserNotLoggedIn
u <- user ?~! ErrorMessages.UserNotLoggedIn
} yield {
val availableAccounts = BankAccount.nonPublicAccounts(u)
val coreBankAccountListJson = coreBankAccountListToJson(CallerContext(corePrivateAccountsAllBanks), codeContext, availableAccounts, Full(u))
@ -232,7 +232,7 @@ trait APIMethods200 {
|""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagAccount, apiTagPublicData))
@ -246,7 +246,7 @@ trait APIMethods200 {
case "accounts" :: "public" :: Nil JsonGet json => {
user =>
for {
publicAccountsJson <- tryo{bankAccountBasicListToJson(BankAccount.publicAccounts, Empty)} ?~ "Could not get accounts."
publicAccountsJson <- tryo{bankAccountBasicListToJson(BankAccount.publicAccounts, Empty)} ?~! "Could not get accounts."
} yield {
Full(successJsonResponse(publicAccountsJson))
}
@ -272,7 +272,7 @@ trait APIMethods200 {
""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagAccount, apiTagPrivateData, apiTagPublicData)
)
@ -320,7 +320,7 @@ trait APIMethods200 {
|${authenticationRequiredMessage(true)}""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(Core, PSD2, OBWG),
List(apiTagAccount, apiTagPrivateData))
@ -335,7 +335,7 @@ trait APIMethods200 {
case "my" :: "banks" :: BankId(bankId) :: "accounts" :: Nil JsonGet json => {
user =>
for {
u <- user ?~ ErrorMessages.UserNotLoggedIn
u <- user ?~! ErrorMessages.UserNotLoggedIn
bank <- Bank(bankId)
} yield {
@ -346,7 +346,7 @@ trait APIMethods200 {
case "my" :: "banks" :: BankId(bankId) :: "accounts" :: "private" :: Nil JsonGet json => {
user =>
for {
u <- user ?~ ErrorMessages.UserNotLoggedIn
u <- user ?~! ErrorMessages.UserNotLoggedIn
bank <- Bank(bankId)
} yield {
@ -358,7 +358,7 @@ trait APIMethods200 {
println("in accounts")
user =>
for {
u <- user ?~ ErrorMessages.UserNotLoggedIn
u <- user ?~! ErrorMessages.UserNotLoggedIn
bank <- Bank(BankId(defaultBankId))
} yield {
corePrivateAccountsAtOneBankResult(CallerContext(corePrivateAccountsAtOneBank), codeContext, bank, u)
@ -385,7 +385,7 @@ trait APIMethods200 {
|${authenticationRequiredMessage(true)}""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(Core, PSD2, OBWG),
apiTagAccount :: Nil)
@ -420,7 +420,7 @@ trait APIMethods200 {
|Authentication via OAuth is not required.""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagAccount, apiTagPublicData))
@ -450,7 +450,7 @@ trait APIMethods200 {
|${authenticationRequiredMessage(false)}""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagCustomer, apiTagKyc))
@ -459,7 +459,7 @@ trait APIMethods200 {
user => {
for {
u <- user ?~! ErrorMessages.UserNotLoggedIn
customer <- Customer.customerProvider.vend.getCustomerByCustomerId(customerId) ?~ ErrorMessages.CustomerNotFoundByCustomerId
customer <- Customer.customerProvider.vend.getCustomerByCustomerId(customerId) ?~! ErrorMessages.CustomerNotFoundByCustomerId
} yield {
val kycDocuments = KycDocuments.kycDocumentProvider.vend.getKycDocuments(customerId)
val json = JSONFactory200.createKycDocumentsJSON(kycDocuments)
@ -482,7 +482,7 @@ trait APIMethods200 {
|${authenticationRequiredMessage(true)}""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagCustomer, apiTagKyc))
@ -491,7 +491,7 @@ trait APIMethods200 {
user => {
for {
u <- user ?~! ErrorMessages.UserNotLoggedIn
customer <- Customer.customerProvider.vend.getCustomerByCustomerId(customerId) ?~ ErrorMessages.CustomerNotFoundByCustomerId
customer <- Customer.customerProvider.vend.getCustomerByCustomerId(customerId) ?~! ErrorMessages.CustomerNotFoundByCustomerId
} yield {
val kycMedias = KycMedias.kycMediaProvider.vend.getKycMedias(customer.number)
val json = JSONFactory200.createKycMediasJSON(kycMedias)
@ -514,7 +514,7 @@ trait APIMethods200 {
|${authenticationRequiredMessage(true)}""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagCustomer, apiTagKyc))
@ -523,7 +523,7 @@ trait APIMethods200 {
user => {
for {
u <- user ?~! ErrorMessages.UserNotLoggedIn
customer <- Customer.customerProvider.vend.getCustomerByCustomerId(customerId) ?~ ErrorMessages.CustomerNotFoundByCustomerId
customer <- Customer.customerProvider.vend.getCustomerByCustomerId(customerId) ?~! ErrorMessages.CustomerNotFoundByCustomerId
} yield {
val kycChecks = KycChecks.kycCheckProvider.vend.getKycChecks(customerId)
val json = JSONFactory200.createKycChecksJSON(kycChecks)
@ -544,7 +544,7 @@ trait APIMethods200 {
|${authenticationRequiredMessage(true)}""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagCustomer, apiTagKyc))
@ -553,7 +553,7 @@ trait APIMethods200 {
user => {
for {
u <- user ?~! ErrorMessages.UserNotLoggedIn
customer <- Customer.customerProvider.vend.getCustomerByCustomerId(customerId) ?~ ErrorMessages.CustomerNotFoundByCustomerId
customer <- Customer.customerProvider.vend.getCustomerByCustomerId(customerId) ?~! ErrorMessages.CustomerNotFoundByCustomerId
} yield {
val kycStatuses = KycStatuses.kycStatusProvider.vend.getKycStatuses(customerId)
val json = JSONFactory200.createKycStatusesJSON(kycStatuses)
@ -575,7 +575,7 @@ trait APIMethods200 {
|${authenticationRequiredMessage(true)}""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagCustomer, apiTagKyc))
@ -586,7 +586,7 @@ trait APIMethods200 {
u <- user ?~! ErrorMessages.UserNotLoggedIn
bank <- Bank(bankId) ?~! {ErrorMessages.BankNotFound}
canGetSocialMediaHandles <- booleanToBox(hasEntitlement(bank.bankId.value, u.userId, CanGetSocialMediaHandles), s"$CanGetSocialMediaHandles entitlement required")
customer <- Customer.customerProvider.vend.getCustomerByCustomerId(customerId) ?~ ErrorMessages.CustomerNotFoundByCustomerId
customer <- Customer.customerProvider.vend.getCustomerByCustomerId(customerId) ?~! ErrorMessages.CustomerNotFoundByCustomerId
} yield {
val kycSocialMedias = SocialMediaHandle.socialMediaHandleProvider.vend.getSocialMedias(customer.number)
val json = JSONFactory200.createSocialMediasJSON(kycSocialMedias)
@ -609,7 +609,7 @@ trait APIMethods200 {
"Add a KYC document for the customer specified by CUSTOMER_ID. KYC Documents contain the document type (e.g. passport), place of issue, expiry etc. ",
PostKycDocumentJSON("1234", "passport", "123567", exampleDate, "London", exampleDate),
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagCustomer, apiTagKyc)
)
@ -663,7 +663,7 @@ trait APIMethods200 {
"98FRd987auhf87jab"
),
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagCustomer, apiTagKyc)
)
@ -687,7 +687,7 @@ trait APIMethods200 {
postedData.url,
postedData.date,
postedData.relates_to_kyc_document_id,
postedData.relates_to_kyc_check_id) ?~ "Server error: could not add message"
postedData.relates_to_kyc_check_id) ?~! "Server error: could not add message"
} yield {
val json = JSONFactory200.createKycMediaJSON(kycMediaCreated)
successJsonResponse(Extraction.decompose(json))
@ -706,7 +706,7 @@ trait APIMethods200 {
"Add a KYC check for the customer specified by CUSTOMER_ID. KYC Checks store details of checks on a customer made by the KYC team, their comments and a satisfied status.",
PostKycCheckJSON("1239879", exampleDate, "online_meeting", "67876", "Simon Redfern", true, ""),
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagCustomer, apiTagKyc)
)
@ -731,7 +731,7 @@ trait APIMethods200 {
postedData.staff_user_id,
postedData.staff_name,
postedData.satisfied,
postedData.comments) ?~ "Server error: could not add message"
postedData.comments) ?~! "Server error: could not add message"
} yield {
val json = JSONFactory200.createKycCheckJSON(kycCheckCreated)
successJsonResponse(Extraction.decompose(json))
@ -750,7 +750,7 @@ trait APIMethods200 {
"Add a kyc_status for the customer specified by CUSTOMER_ID. KYC Status is a timeline of the KYC status of the customer",
PostKycStatusJSON("8762893876", true, exampleDate),
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagCustomer, apiTagKyc)
)
@ -770,7 +770,7 @@ trait APIMethods200 {
customerId,
postedData.customer_number,
postedData.ok,
postedData.date) ?~ "Server error: could not add message"
postedData.date) ?~! "Server error: could not add message"
} yield {
val json = JSONFactory200.createKycStatusJSON(kycStatusCreated)
successJsonResponse(Extraction.decompose(json))
@ -789,7 +789,7 @@ trait APIMethods200 {
"Add a social media handle for the customer specified by CUSTOMER_ID.",
SocialMediaJSON("8762893876", "twitter", "susan@example.com", exampleDate, exampleDate),
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagCustomer)
)
@ -841,7 +841,7 @@ trait APIMethods200 {
|OAuth authentication is required""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(Core, PSD2, notOBWG),
apiTagAccount :: Nil)
@ -892,7 +892,7 @@ trait APIMethods200 {
|**Date format parameter**: "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" (2014-07-01T00:00:00.000Z) ==> time zone is UTC.""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(Core, PSD2, OBWG),
List(apiTagAccount, apiTagTransaction))
@ -944,7 +944,7 @@ trait APIMethods200 {
|""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
apiTagAccount :: Nil)
@ -957,7 +957,7 @@ trait APIMethods200 {
account <- BankAccount(bank.bankId, accountId) ?~! {ErrorMessages.AccountNotFound} // Check Account exists.
availableViews <- Full(account.permittedViews(user))
view <- View.fromUrl(viewId, account) ?~! {ErrorMessages.ViewNotFound}
canUserAccessView <- tryo(availableViews.find(_ == viewId)) ?~ {"Current user does not have access to the view " + viewId}
canUserAccessView <- tryo(availableViews.find(_ == viewId)) ?~! {"Current user does not have access to the view " + viewId}
moderatedAccount <- account.moderatedBankAccount(view, user)
} yield {
val viewsAvailable = availableViews.map(JSONFactory121.createViewJSON).sortBy(_.short_name)
@ -983,7 +983,7 @@ trait APIMethods200 {
|OAuth authentication is required and the user needs to have access to the owner view.""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagPerson, apiTagUser, apiTagAccount, apiTagView, apiTagEntitlement)
)
@ -1017,7 +1017,7 @@ trait APIMethods200 {
|OAuth authentication is required and the user needs to have access to the owner view.""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagPerson, apiTagUser, apiTagAccount, apiTagView, apiTagEntitlement))
@ -1057,7 +1057,7 @@ trait APIMethods200 {
|Note: The Amount must be zero.""".stripMargin,
CreateAccountJSON("A user_id","CURRENT", "Label", AmountOfMoneyJSON121("EUR", "0")),
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagAccount)
)
@ -1076,20 +1076,20 @@ trait APIMethods200 {
for {
loggedInUser <- user ?~! ErrorMessages.UserNotLoggedIn
jsonBody <- tryo (json.extract[CreateAccountJSON]) ?~ ErrorMessages.InvalidJsonFormat
user_id <- tryo (if (jsonBody.user_id.nonEmpty) jsonBody.user_id else loggedInUser.userId) ?~ ErrorMessages.InvalidUserId
jsonBody <- tryo (json.extract[CreateAccountJSON]) ?~! ErrorMessages.InvalidJsonFormat
user_id <- tryo (if (jsonBody.user_id.nonEmpty) jsonBody.user_id else loggedInUser.userId) ?~! ErrorMessages.InvalidUserId
isValidAccountIdFormat <- tryo(assert(isValidID(accountId.value)))?~! ErrorMessages.InvalidAccountIdFormat
isValidBankId <- tryo(assert(isValidID(bankId.value)))?~! ErrorMessages.InvalidBankIdFormat
postedOrLoggedInUser <- User.findByUserId(user_id) ?~! ErrorMessages.UserNotFoundById
bank <- Bank(bankId) ?~ s"Bank $bankId not found"
bank <- Bank(bankId) ?~! s"Bank $bankId not found"
// User can create account for self or an account for another user if they have CanCreateAccount role
isAllowed <- booleanToBox(hasEntitlement(bankId.value, loggedInUser.userId, CanCreateAccount) == true || (user_id == loggedInUser.userId) , s"User must either create account for self or have role $CanCreateAccount")
initialBalanceAsString <- tryo (jsonBody.balance.amount) ?~ ErrorMessages.InvalidAccountBalanceAmount
accountType <- tryo(jsonBody.`type`) ?~ ErrorMessages.InvalidAccountType
accountLabel <- tryo(jsonBody.`type`) //?~ ErrorMessages.InvalidAccountLabel
initialBalanceAsString <- tryo (jsonBody.balance.amount) ?~! ErrorMessages.InvalidAccountBalanceAmount
accountType <- tryo(jsonBody.`type`) ?~! ErrorMessages.InvalidAccountType
accountLabel <- tryo(jsonBody.`type`) //?~! ErrorMessages.InvalidAccountLabel
initialBalanceAsNumber <- tryo {BigDecimal(initialBalanceAsString)} ?~! ErrorMessages.InvalidAccountInitialBalance
isTrue <- booleanToBox(0 == initialBalanceAsNumber) ?~ s"Initial balance must be zero"
currency <- tryo (jsonBody.balance.currency) ?~ ErrorMessages.InvalidAccountBalanceCurrency
isTrue <- booleanToBox(0 == initialBalanceAsNumber) ?~! s"Initial balance must be zero"
currency <- tryo (jsonBody.balance.currency) ?~! ErrorMessages.InvalidAccountBalanceCurrency
// TODO Since this is a PUT, we should replace the resource if it already exists but will need to check persmissions
accountDoesNotExist <- booleanToBox(BankAccount(bankId, accountId).isEmpty,
s"Account with id $accountId already exists at bank $bankId")
@ -1141,7 +1141,7 @@ trait APIMethods200 {
|${authenticationRequiredMessage(!getTransactionTypesIsPublic)}""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(Core, PSD2, notOBWG),
List(apiTagBank)
)
@ -1225,7 +1225,7 @@ trait APIMethods200 {
"A description for the transaction to be created"
),
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(Core, PSD2, OBWG),
List(apiTagTransactionRequest))
@ -1239,8 +1239,8 @@ trait APIMethods200 {
* check if user has access using the view that is given (now it checks if user has access to owner view), will need some new permissions for transaction requests
* test: functionality, error messages if user not given or invalid, if any other value is not existing
*/
u <- user ?~ ErrorMessages.UserNotLoggedIn
transBodyJson <- tryo{json.extract[TransactionRequestBodyJsonV200]} ?~ {ErrorMessages.InvalidJsonFormat}
u <- user ?~! ErrorMessages.UserNotLoggedIn
transBodyJson <- tryo{json.extract[TransactionRequestBodyJsonV200]} ?~! {ErrorMessages.InvalidJsonFormat}
transBody <- tryo{getTransactionRequestBodyFromJson(transBodyJson)}
isValidBankIdFormat <- tryo(assert(isValidID(bankId.value)))?~! ErrorMessages.InvalidBankIdFormat
isValidAccountIdFormat <- tryo(assert(isValidID(accountId.value)))?~! ErrorMessages.InvalidAccountIdFormat
@ -1249,7 +1249,7 @@ trait APIMethods200 {
availableViews <- Full(fromAccount.permittedViews(user))
view <- View.fromUrl(viewId, fromAccount) ?~! {ErrorMessages.ViewNotFound}
canUserAccessView <- tryo(availableViews.find(_ == viewId)) ?~ {"Current user does not have access to the view " + viewId}
canUserAccessView <- tryo(availableViews.find(_ == viewId)) ?~! {"Current user does not have access to the view " + viewId}
isOwnerOrHasEntitlement <- booleanToBox(u.ownerAccess(fromAccount) == true || hasEntitlement(fromAccount.bankId.value, u.userId, CanCreateAnyTransactionRequest) == true , ErrorMessages.InsufficientAuthorisationToCreateTransactionRequest)
toBankId <- tryo(BankId(transBodyJson.to.bank_id))
@ -1284,7 +1284,7 @@ trait APIMethods200 {
"In Sandbox mode, any string that can be converted to a positive integer will be accepted as an answer.",
ChallengeAnswerJSON("89123812", "123345"),
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(Core, PSD2, OBWG),
List(apiTagTransactionRequest))
@ -1294,17 +1294,17 @@ trait APIMethods200 {
user =>
if (Props.getBool("transactionRequests_enabled", false)) {
for {
u: User <- user ?~ ErrorMessages.UserNotLoggedIn
u: User <- user ?~! ErrorMessages.UserNotLoggedIn
isValidAccountIdFormat <- tryo(assert(isValidID(accountId.value)))?~! ErrorMessages.InvalidAccountIdFormat
isValidBankIdFormat <- tryo(assert(isValidID(bankId.value)))?~! ErrorMessages.InvalidBankIdFormat
fromBank <- Bank(bankId) ?~! {ErrorMessages.BankNotFound}
fromAccount <- BankAccount(bankId, accountId) ?~! {"Unknown bank account"}
view <- tryo(fromAccount.permittedViews(user).find(_ == viewId)) ?~ {"Current user does not have access to the view " + viewId}
view <- tryo(fromAccount.permittedViews(user).find(_ == viewId)) ?~! {"Current user does not have access to the view " + viewId}
// Note: These checks are not in the ideal order. See version 2.1.0 which supercedes this
answerJson <- tryo{json.extract[ChallengeAnswerJSON]} ?~ {"Invalid json format"}
answerJson <- tryo{json.extract[ChallengeAnswerJSON]} ?~! {"Invalid json format"}
answerOk <- Connector.connector.vend.answerTransactionRequestChallenge(transReqId, answerJson.answer)
//check the transReqId validation.
existingTransactionRequest <- Connector.connector.vend.getTransactionRequestImpl(transReqId) ?~! {ErrorMessages.InvalidTransactionRequestId}
@ -1369,7 +1369,7 @@ trait APIMethods200 {
""".stripMargin,
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(Core, PSD2, OBWG),
List(apiTagTransactionRequest))
@ -1378,10 +1378,10 @@ trait APIMethods200 {
user =>
if (Props.getBool("transactionRequests_enabled", false)) {
for {
u <- user ?~ ErrorMessages.UserNotLoggedIn
u <- user ?~! ErrorMessages.UserNotLoggedIn
fromBank <- Bank(bankId) ?~! {ErrorMessages.BankNotFound}
fromAccount <- BankAccount(bankId, accountId) ?~! {ErrorMessages.AccountNotFound}
view <- tryo(fromAccount.permittedViews(user).find(_ == viewId)) ?~ {"Current user does not have access to the view " + viewId}
view <- tryo(fromAccount.permittedViews(user).find(_ == viewId)) ?~! {"Current user does not have access to the view " + viewId}
transactionRequests <- Connector.connector.vend.getTransactionRequests(u, fromAccount)
}
yield {
@ -1417,7 +1417,7 @@ trait APIMethods200 {
|""",
CreateUserJson("someone@example.com", "my-username", "my-secure-password", "James", "Brown"),
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(Core, notPSD2, notOBWG),
List(apiTagOnboarding, apiTagUser))
@ -1484,7 +1484,7 @@ trait APIMethods200 {
""".stripMargin,
CreateMeetingJson("tokbox", "onboarding"),
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagMeeting, apiTagKyc, apiTagCustomer, apiTagUser, apiTagExperimental))
@ -1497,7 +1497,7 @@ trait APIMethods200 {
// TODO use these keys to get session and tokens from tokbox
providerApiKey <- Props.get("meeting.tokbox_api_key") ~> APIFailure(ErrorMessages.MeetingApiKeyNotConfigured, 403)
providerSecret <- Props.get("meeting.tokbox_api_secret") ~> APIFailure(ErrorMessages.MeetingApiSecretNotConfigured, 403)
u <- user ?~ ErrorMessages.UserNotLoggedIn
u <- user ?~! ErrorMessages.UserNotLoggedIn
isValidBankIdFormat <- tryo(assert(isValidID(bankId.value)))?~! ErrorMessages.InvalidBankIdFormat
bank <- Bank(bankId) ?~! {ErrorMessages.BankNotFound}
postedData <- tryo {json.extract[CreateMeetingJson]} ?~! ErrorMessages.InvalidJsonFormat
@ -1535,7 +1535,7 @@ trait APIMethods200 {
""".stripMargin,
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagMeeting, apiTagKyc, apiTagCustomer, apiTagUser, apiTagExperimental))
@ -1545,11 +1545,11 @@ trait APIMethods200 {
user =>
if (Props.getBool("meeting.tokbox_enabled", false)) {
for {
u <- user ?~ ErrorMessages.UserNotLoggedIn
u <- user ?~! ErrorMessages.UserNotLoggedIn
fromBank <- Bank(bankId) ?~! {ErrorMessages.BankNotFound}
providerApiKey <- Props.get("meeting.tokbox_api_key") ~> APIFailure(ErrorMessages.MeetingApiKeyNotConfigured, 403)
providerSecret <- Props.get("meeting.tokbox_api_secret") ~> APIFailure(ErrorMessages.MeetingApiSecretNotConfigured, 403)
u <- user ?~ ErrorMessages.UserNotLoggedIn
u <- user ?~! ErrorMessages.UserNotLoggedIn
bank <- Bank(bankId) ?~! {ErrorMessages.BankNotFound}
// now = Calendar.getInstance().getTime()
meetings <- Meeting.meetingProvider.vend.getMeetings(bank.bankId, u)
@ -1585,7 +1585,7 @@ trait APIMethods200 {
""".stripMargin,
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagMeeting, apiTagKyc, apiTagCustomer, apiTagUser, apiTagExperimental))
@ -1595,7 +1595,7 @@ trait APIMethods200 {
user =>
if (Props.getBool("meeting.tokbox_enabled", false)) {
for {
u <- user ?~ ErrorMessages.UserNotLoggedIn
u <- user ?~! ErrorMessages.UserNotLoggedIn
fromBank <- Bank(bankId) ?~! {ErrorMessages.BankNotFound}
providerApiKey <- Props.get("meeting.tokbox_api_key") ~> APIFailure(ErrorMessages.MeetingApiKeyNotConfigured, 403)
providerSecret <- Props.get("meeting.tokbox_api_secret") ~> APIFailure(ErrorMessages.MeetingApiSecretNotConfigured, 403)
@ -1635,7 +1635,7 @@ trait APIMethods200 {
"+44 07972 444 876", "person@example.com", CustomerFaceImageJson("www.example.com/person/123/image.png", exampleDate),
exampleDate, "Single", 1, List(exampleDate), "Bachelors Degree", "Employed", true, exampleDate),
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagPerson, apiTagCustomer))
@ -1661,7 +1661,7 @@ trait APIMethods200 {
requiredEntitlementsTxt = requiredEntitlements.mkString(" and ")
hasEntitlements <- booleanToBox(hasAllEntitlements(bankId.value, u.userId, requiredEntitlements), s"$requiredEntitlementsTxt entitlements required")
checkAvailable <- tryo(assert(Customer.customerProvider.vend.checkCustomerNumberAvailable(bankId, postedData.customer_number) == true)) ?~! ErrorMessages.CustomerNumberAlreadyExists
user_id <- tryo (if (postedData.user_id.nonEmpty) postedData.user_id else u.userId) ?~ s"Problem getting user_id"
user_id <- tryo (if (postedData.user_id.nonEmpty) postedData.user_id else u.userId) ?~! s"Problem getting user_id"
customer_user <- User.findByUserId(user_id) ?~! ErrorMessages.UserNotFoundById
customer <- Customer.customerProvider.vend.addCustomer(bankId,
postedData.customer_number,
@ -1679,7 +1679,7 @@ trait APIMethods200 {
postedData.last_ok_date,
None,
None) ?~! "Could not create customer"
userCustomerLink <- booleanToBox(UserCustomerLink.userCustomerLink.vend.getUserCustomerLink(user_id, customer.customerId).isEmpty == true) ?~ ErrorMessages.CustomerAlreadyExistsForUser
userCustomerLink <- booleanToBox(UserCustomerLink.userCustomerLink.vend.getUserCustomerLink(user_id, customer.customerId).isEmpty == true) ?~! ErrorMessages.CustomerAlreadyExistsForUser
userCustomerLink <- UserCustomerLink.userCustomerLink.vend.createUserCustomerLink(user_id, customer.customerId, exampleDate, true) ?~! "Could not create user_customer_links"
} yield {
val json = JSONFactory1_4_0.createCustomerJson(customer)
@ -1704,7 +1704,7 @@ trait APIMethods200 {
""".stripMargin,
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(Core, notPSD2, notOBWG),
List(apiTagPerson, apiTagUser))
@ -1713,7 +1713,7 @@ trait APIMethods200 {
case "users" :: "current" :: Nil JsonGet _ => {
user =>
for {
u <- user ?~ ErrorMessages.UserNotLoggedIn
u <- user ?~! ErrorMessages.UserNotLoggedIn
}
yield {
// Format the data as V2.0.0 json
@ -1739,7 +1739,7 @@ trait APIMethods200 {
""".stripMargin,
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(Core, notPSD2, notOBWG),
List(apiTagPerson, apiTagUser))
@ -1748,7 +1748,7 @@ trait APIMethods200 {
case "users" :: userEmail :: Nil JsonGet _ => {
user =>
for {
l <- user ?~ ErrorMessages.UserNotLoggedIn
l <- user ?~! ErrorMessages.UserNotLoggedIn
canGetAnyUser <- booleanToBox(hasEntitlement("", l.userId, ApiRole.CanGetAnyUser), "CanGetAnyUser entitlement required")
// Workaround to get userEmail address directly from URI without needing to URL-encode it
users <- tryo{AuthUser.getResourceUsersByEmail(CurrentReq.value.uri.split("/").last)} ?~! {ErrorMessages.UserNotFoundByEmail}
@ -1776,7 +1776,7 @@ trait APIMethods200 {
|""",
CreateUserCustomerLinkJson("be106783-b4fa-48e6-b102-b178a11a8e9b", "02141bc6-0a69-4fba-b4db-a17e5fbbbdcc"),
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagPerson, apiTagUser, apiTagCustomer))
@ -1791,13 +1791,13 @@ trait APIMethods200 {
isValidBankIdFormat <- tryo(assert(isValidID(bankId.value)))?~! ErrorMessages.InvalidBankIdFormat
bank <- Bank(bankId) ?~! {ErrorMessages.BankNotFound}
postedData <- tryo{json.extract[CreateUserCustomerLinkJson]} ?~! ErrorMessages.InvalidJsonFormat
user_id <- booleanToBox(postedData.user_id.nonEmpty) ?~ "Field user_id is not defined in the posted json!"
user_id <- booleanToBox(postedData.user_id.nonEmpty) ?~! "Field user_id is not defined in the posted json!"
user <- User.findByUserId(postedData.user_id) ?~! ErrorMessages.UserNotFoundById
customer_id <- booleanToBox(postedData.customer_id.nonEmpty) ?~ "Field customer_id is not defined in the posted json!"
customer <- Customer.customerProvider.vend.getCustomerByCustomerId(postedData.customer_id) ?~ ErrorMessages.CustomerNotFoundByCustomerId
customer_id <- booleanToBox(postedData.customer_id.nonEmpty) ?~! "Field customer_id is not defined in the posted json!"
customer <- Customer.customerProvider.vend.getCustomerByCustomerId(postedData.customer_id) ?~! ErrorMessages.CustomerNotFoundByCustomerId
canCreateUserCustomerLink <- booleanToBox(hasEntitlement(bank.bankId.value, u.userId, CanCreateUserCustomerLink), s"$CanCreateUserCustomerLink entitlement required")
isEqual <- booleanToBox(customer.bank == bank.bankId.value, "Bank of the customer specified by the CUSTOMER_ID has to matches BANK_ID")
userCustomerLink <- booleanToBox(UserCustomerLink.userCustomerLink.vend.getUserCustomerLink(postedData.user_id, postedData.customer_id).isEmpty == true) ?~ ErrorMessages.CustomerAlreadyExistsForUser
userCustomerLink <- booleanToBox(UserCustomerLink.userCustomerLink.vend.getUserCustomerLink(postedData.user_id, postedData.customer_id).isEmpty == true) ?~! ErrorMessages.CustomerAlreadyExistsForUser
userCustomerLink <- UserCustomerLink.userCustomerLink.vend.createUserCustomerLink(postedData.user_id, postedData.customer_id, new Date(), true) ?~! "Could not create user_customer_links"
} yield {
val successJson = Extraction.decompose(code.api.v2_0_0.JSONFactory200.createUserCustomerLinkJSON(userCustomerLink))
@ -1824,7 +1824,7 @@ trait APIMethods200 {
|Authentication is required and the user needs to be a Super Admin. Super Admins are listed in the Props file.""",
CreateEntitlementJSON("obp-bank-x-gh", "CanQueryOtherUser"),
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagUser))
@ -1833,16 +1833,16 @@ trait APIMethods200 {
case "users" :: userId :: "entitlements" :: Nil JsonPost json -> _ => {
user =>
for {
u <- user ?~ ErrorMessages.UserNotLoggedIn
u <- user ?~! ErrorMessages.UserNotLoggedIn
user <- User.findByUserId(userId) ?~! ErrorMessages.UserNotFoundById
postedData <- tryo{json.extract[CreateEntitlementJSON]} ?~ "wrong format JSON"
postedData <- tryo{json.extract[CreateEntitlementJSON]} ?~! "wrong format JSON"
role <- tryo{valueOf(postedData.role_name)} ?~! "wrong role name"
isBankOrSystemRoleOk <- booleanToBox(ApiRole.valueOf(postedData.role_name).requiresBankId == postedData.bank_id.nonEmpty) ?~!
{if (ApiRole.valueOf(postedData.role_name).requiresBankId) ErrorMessages.EntitlementIsBankRole else ErrorMessages.EntitlementIsSystemRole}
allowedEntitlements = CanCreateEntitlementAtOneBank ::
CanCreateEntitlementAtAnyBank ::
Nil
isSuperAdmin <- booleanToBox(isSuperAdmin(u.userId) || hasAtLeastOneEntitlement(postedData.bank_id, u.userId, allowedEntitlements) == true) ?~ {"Logged user is not super admin or does not have entitlements: " + allowedEntitlements.mkString(", ") + "!"}
isSuperAdmin <- booleanToBox(isSuperAdmin(u.userId) || hasAtLeastOneEntitlement(postedData.bank_id, u.userId, allowedEntitlements) == true) ?~! {"Logged user is not super admin or does not have entitlements: " + allowedEntitlements.mkString(", ") + "!"}
bank <- booleanToBox(postedData.bank_id.nonEmpty == false || Bank(BankId(postedData.bank_id)).isEmpty == false) ?~! {ErrorMessages.BankNotFound}
role <- tryo{valueOf(postedData.role_name)} ?~! "wrong role name"
hasEntitlement <- booleanToBox(hasEntitlement(postedData.bank_id, userId, role) == false, "Entitlement already exists for the user." )
@ -1869,7 +1869,7 @@ trait APIMethods200 {
""".stripMargin,
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(Core, notPSD2, notOBWG),
List(apiTagUser, apiTagEntitlement))
@ -1878,7 +1878,7 @@ trait APIMethods200 {
case "users" :: userId :: "entitlements" :: Nil JsonGet _ => {
user =>
for {
u <- user ?~ ErrorMessages.UserNotLoggedIn
u <- user ?~! ErrorMessages.UserNotLoggedIn
canGetEntitlementsForAnyUserAtAnyBank <- booleanToBox(hasEntitlement("", u.userId, CanGetEntitlementsForAnyUserAtAnyBank), s"$CanGetEntitlementsForAnyUserAtAnyBank entitlement required")
entitlements <- Entitlement.entitlement.vend.getEntitlements(userId)
}
@ -1914,7 +1914,7 @@ trait APIMethods200 {
""".stripMargin,
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(Core, notPSD2, notOBWG),
List(apiTagUser, apiTagEntitlement))
@ -1923,9 +1923,9 @@ trait APIMethods200 {
case "users" :: userId :: "entitlement" :: entitlementId :: Nil JsonDelete _ => {
user =>
for {
u <- user ?~ ErrorMessages.UserNotLoggedIn
isSuperAdmin <- booleanToBox(isSuperAdmin(u.userId)) ?~ "User is not super admin!"
entitlement <- tryo{Entitlement.entitlement.vend.getEntitlement(entitlementId)} ?~ "EntitlementId not found"
u <- user ?~! ErrorMessages.UserNotLoggedIn
isSuperAdmin <- booleanToBox(isSuperAdmin(u.userId)) ?~! "User is not super admin!"
entitlement <- tryo{Entitlement.entitlement.vend.getEntitlement(entitlementId)} ?~! "EntitlementId not found"
deleted <- Entitlement.entitlement.vend.deleteEntitlement(entitlement)
}
yield noContentJsonResponse
@ -1948,7 +1948,7 @@ trait APIMethods200 {
""".stripMargin,
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(Core, notPSD2, notOBWG),
List(apiTagUser, apiTagEntitlement))
@ -1957,8 +1957,8 @@ trait APIMethods200 {
case "entitlements" :: Nil JsonGet _ => {
user =>
for {
u <- user ?~ ErrorMessages.UserNotLoggedIn
isSuperAdmin <- booleanToBox(isSuperAdmin(u.userId)) ?~ "Logged user is not super admin!"
u <- user ?~! ErrorMessages.UserNotLoggedIn
isSuperAdmin <- booleanToBox(isSuperAdmin(u.userId)) ?~! "Logged user is not super admin!"
entitlements <- Entitlement.entitlement.vend.getEntitlements
}
yield {
@ -2043,7 +2043,7 @@ trait APIMethods200 {
""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List())
@ -2052,9 +2052,9 @@ trait APIMethods200 {
case "search" :: "warehouse" :: queryString :: Nil JsonGet _ => {
user =>
for {
u <- user ?~ ErrorMessages.UserNotLoggedIn
u <- user ?~! ErrorMessages.UserNotLoggedIn
b <- tryo{Bank.all.headOption} ?~! {ErrorMessages.BankNotFound} //TODO: This is a temp workaround
canSearchWarehouse <- Entitlement.entitlement.vend.getEntitlement(b.get.bankId.value, u.userId, ApiRole.CanSearchWarehouse.toString) ?~ "CanSearchWarehouse entitlement required"
canSearchWarehouse <- Entitlement.entitlement.vend.getEntitlement(b.get.bankId.value, u.userId, ApiRole.CanSearchWarehouse.toString) ?~! "CanSearchWarehouse entitlement required"
} yield {
successJsonResponse(Extraction.decompose(esw.searchProxy(u.userId, queryString)))
}
@ -2130,7 +2130,7 @@ trait APIMethods200 {
""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List())
@ -2139,9 +2139,9 @@ trait APIMethods200 {
case "search" :: "metrics" :: queryString :: Nil JsonGet _ => {
user =>
for {
u <- user ?~ ErrorMessages.UserNotLoggedIn
u <- user ?~! ErrorMessages.UserNotLoggedIn
b <- tryo{Bank.all.headOption} ?~! {ErrorMessages.BankNotFound} //TODO: This is a temp workaround
canSearchMetrics <- Entitlement.entitlement.vend.getEntitlement(b.get.bankId.value, u.userId, ApiRole.CanSearchMetrics.toString) ?~ "CanSearchMetrics entitlement required"
canSearchMetrics <- Entitlement.entitlement.vend.getEntitlement(b.get.bankId.value, u.userId, ApiRole.CanSearchMetrics.toString) ?~! "CanSearchMetrics entitlement required"
} yield {
successJsonResponse(Extraction.decompose(esm.searchProxy(u.userId, queryString)))
}
@ -2161,7 +2161,7 @@ trait APIMethods200 {
|Authentication via OAuth is required.""",
emptyObjectJson,
emptyObjectJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagPerson, apiTagCustomer))

View File

@ -103,7 +103,7 @@ trait APIMethods210 {
|""",
emptyObjectJson,
successMessage,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagAccount, apiTagPrivateData, apiTagPublicData))
@ -141,7 +141,7 @@ trait APIMethods210 {
|""",
emptyObjectJson,
transactionRequestTypesJSON,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagBank, apiTagTransactionRequest))
@ -242,7 +242,7 @@ trait APIMethods210 {
""".stripMargin,
transactionRequestBodyJsonV200,
transactionRequestWithChargeJSON210,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(Core, PSD2, OBWG),
List(apiTagTransactionRequest))
@ -264,7 +264,7 @@ trait APIMethods210 {
""".stripMargin,
transactionRequestBodyCounterpartyJSON,
transactionRequestWithChargeJSON210,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(Core, PSD2, OBWG),
List(apiTagTransactionRequest))
@ -290,7 +290,7 @@ trait APIMethods210 {
""".stripMargin,
transactionRequestBodySEPAJSON,
transactionRequestWithChargeJSON210,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(Core, PSD2, OBWG),
List(apiTagTransactionRequest))
@ -474,7 +474,7 @@ trait APIMethods210 {
"In Sandbox mode, any string that can be converted to a positive integer will be accepted as an answer.",
challengeAnswerJSON,
transactionRequestWithChargeJSON,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(Core, PSD2, OBWG),
List(apiTagTransactionRequest))
@ -503,7 +503,7 @@ trait APIMethods210 {
fromAccount <- BankAccount(bankId, accountId) ?~! {ErrorMessages.BankAccountNotFound}
// Check User has access to the View
view <- tryo(fromAccount.permittedViews(user).find(_ == viewId)) ?~ {ErrorMessages.ViewAccessNoPermission}
view <- tryo(fromAccount.permittedViews(user).find(_ == viewId)) ?~ {ErrorMessages.UserNoPermissionAccessView}
// Check transReqId is valid
existingTransactionRequest <- Connector.connector.vend.getTransactionRequestImpl(transReqId) ?~! {ErrorMessages.InvalidTransactionRequestId}
@ -572,7 +572,7 @@ trait APIMethods210 {
""".stripMargin,
emptyObjectJson,
transactionRequestWithChargeJSONs210,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(Core, PSD2, OBWG),
List(apiTagTransactionRequest))
@ -584,7 +584,7 @@ trait APIMethods210 {
u <- user ?~ ErrorMessages.UserNotLoggedIn
fromBank <- Bank(bankId) ?~! {ErrorMessages.BankNotFound}
fromAccount <- BankAccount(bankId, accountId) ?~! {ErrorMessages.AccountNotFound}
view <- tryo(fromAccount.permittedViews(user).find(_ == viewId)) ?~ {"Current user does not have access to the view " + viewId}
view <- tryo(fromAccount.permittedViews(user).find(_ == viewId)) ?~! {"Current user does not have access to the view " + viewId}
transactionRequests <- Connector.connector.vend.getTransactionRequests210(u, fromAccount)
}
yield {
@ -614,7 +614,7 @@ trait APIMethods210 {
""".stripMargin,
emptyObjectJson,
availableRolesJSON,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(Core, PSD2, OBWG),
List(apiTagUser, apiTagEntitlement))
@ -648,7 +648,7 @@ trait APIMethods210 {
""".stripMargin,
emptyObjectJson,
entitlementJSONs,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(Core, PSD2, OBWG),
List(apiTagUser, apiTagEntitlement))
@ -696,7 +696,7 @@ trait APIMethods210 {
|""",
emptyObjectJson,
consumerJSON,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
Nil)
@ -729,7 +729,7 @@ trait APIMethods210 {
|""",
emptyObjectJson,
consumersJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
Nil)
@ -762,7 +762,7 @@ trait APIMethods210 {
|""",
putEnabledJSON,
putEnabledJSON,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
Nil)
@ -804,7 +804,7 @@ trait APIMethods210 {
|""",
postPhysicalCardJSON,
physicalCardJSON,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagAccount, apiTagPrivateData, apiTagPublicData))
@ -819,7 +819,7 @@ trait APIMethods210 {
postJson <- tryo {json.extract[PostPhysicalCardJSON]} ?~! {ErrorMessages.InvalidJsonFormat}
postedAllows <- postJson.allows match {
case List() => booleanToBox(true)
case _ => booleanToBox(postJson.allows.forall(a => CardAction.availableValues.contains(a))) ?~ {"Allowed values are: " + CardAction.availableValues.mkString(", ")}
case _ => booleanToBox(postJson.allows.forall(a => CardAction.availableValues.contains(a))) ?~! {"Allowed values are: " + CardAction.availableValues.mkString(", ")}
}
account <- BankAccount(bankId, AccountId(postJson.account_id)) ?~! {ErrorMessages.AccountNotFound}
card <- Connector.connector.vend.AddPhysicalCard(
@ -864,7 +864,7 @@ trait APIMethods210 {
""".stripMargin,
emptyObjectJson,
usersJSONV200,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(Core, notPSD2, notOBWG),
List(apiTagPerson, apiTagUser))
@ -906,7 +906,7 @@ trait APIMethods210 {
|${authenticationRequiredMessage(getTransactionTypesIsPublic)}""",
transactionTypeJsonV200,
transactionType,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagBank)
)
@ -948,7 +948,7 @@ trait APIMethods210 {
|${authenticationRequiredMessage(!getAtmsIsPublic)}""",
emptyObjectJson,
atmJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, OBWG),
List(apiTagBank)
)
@ -994,7 +994,7 @@ trait APIMethods210 {
|${authenticationRequiredMessage(!getBranchesIsPublic)}""",
emptyObjectJson,
branchJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, OBWG),
List(apiTagBank)
)
@ -1043,7 +1043,7 @@ trait APIMethods210 {
|${authenticationRequiredMessage(!getProductsIsPublic)}""",
emptyObjectJson,
productJsonV210,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, OBWG),
List(apiTagBank)
)
@ -1090,7 +1090,7 @@ trait APIMethods210 {
|${authenticationRequiredMessage(!getProductsIsPublic)}""",
emptyObjectJson,
productsJsonV210,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(Core, notPSD2, OBWG),
List(apiTagBank)
)
@ -1153,7 +1153,7 @@ trait APIMethods210 {
|""",
postCounterpartyJSON,
counterpartyJsonV220,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List())
@ -1170,7 +1170,7 @@ trait APIMethods210 {
postJson <- tryo {json.extract[PostCounterpartyJSON]} ?~! {ErrorMessages.InvalidJsonFormat}
availableViews <- Full(account.permittedViews(user))
view <- View.fromUrl(viewId, account) ?~! {ErrorMessages.ViewNotFound}
canUserAccessView <- tryo(availableViews.find(_ == viewId)) ?~ {"Current user does not have access to the view " + viewId}
canUserAccessView <- tryo(availableViews.find(_ == viewId)) ?~! {"Current user does not have access to the view " + viewId}
canAddCounterparty <- booleanToBox(view.canAddCounterparty == true, "The current view does not have can_add_counterparty permission. Please use a view with that permission or add the permission to this view.")
checkAvailable <- tryo(assert(Counterparties.counterparties.vend.
checkCounterpartyAvailable(postJson.name,bankId.value, accountId.value,viewId.value) == true)
@ -1189,7 +1189,7 @@ trait APIMethods210 {
isBeneficiary=postJson.is_beneficiary
)
// Now just comment the following lines, keep the same return tpyle of V220 "getCounterpartiesForAccount".
// metadata <- Counterparties.counterparties.vend.getMetadata(bankId, accountId, counterparty.counterpartyId) ?~ "Cannot find the metadata"
// metadata <- Counterparties.counterparties.vend.getMetadata(bankId, accountId, counterparty.counterpartyId) ?~! "Cannot find the metadata"
// moderated <- Connector.connector.vend.getCounterparty(bankId, accountId, counterparty.counterpartyId).flatMap(oAcc => view.moderate(oAcc))
} yield {
val list = JSONFactory220.createCounterpartyJSON(counterparty)
@ -1216,7 +1216,7 @@ trait APIMethods210 {
|""",
postCustomerJsonV210,
customerJsonV210,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagPerson, apiTagCustomer))
@ -1240,7 +1240,7 @@ trait APIMethods210 {
requiredEntitlementsTxt = requiredEntitlements.mkString(" and ")
hasEntitlements <- booleanToBox(hasAllEntitlements(bankId.value, u.userId, requiredEntitlements), s"$requiredEntitlementsTxt entitlements required")
checkAvailable <- tryo(assert(Customer.customerProvider.vend.checkCustomerNumberAvailable(bankId, postedData.customer_number) == true)) ?~! ErrorMessages.CustomerNumberAlreadyExists
user_id <- tryo (if (postedData.user_id.nonEmpty) postedData.user_id else u.userId) ?~ s"Problem getting user_id"
user_id <- tryo (if (postedData.user_id.nonEmpty) postedData.user_id else u.userId) ?~! s"Problem getting user_id"
customer_user <- User.findByUserId(user_id) ?~! ErrorMessages.UserNotFoundById
customer <- Customer.customerProvider.vend.addCustomer(bankId,
postedData.customer_number,
@ -1258,7 +1258,7 @@ trait APIMethods210 {
postedData.last_ok_date,
Option(MockCreditRating(postedData.credit_rating.rating, postedData.credit_rating.source)),
Option(MockCreditLimit(postedData.credit_limit.currency, postedData.credit_limit.amount))) ?~! "Could not create customer"
userCustomerLink <- booleanToBox(UserCustomerLink.userCustomerLink.vend.getUserCustomerLink(user_id, customer.customerId).isEmpty == true) ?~ ErrorMessages.CustomerAlreadyExistsForUser
userCustomerLink <- booleanToBox(UserCustomerLink.userCustomerLink.vend.getUserCustomerLink(user_id, customer.customerId).isEmpty == true) ?~! ErrorMessages.CustomerAlreadyExistsForUser
userCustomerLink <- UserCustomerLink.userCustomerLink.vend.createUserCustomerLink(user_id, customer.customerId, exampleDate, true) ?~! "Could not create user_customer_links"
} yield {
val json = JSONFactory210.createCustomerJson(customer)
@ -1280,7 +1280,7 @@ trait APIMethods210 {
|Authentication via OAuth is required.""",
emptyObjectJson,
metricsJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagPerson, apiTagCustomer))
@ -1311,7 +1311,7 @@ trait APIMethods210 {
|Authentication via OAuth is required.""",
emptyObjectJson,
customerJsonV210,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagCustomer))
@ -1346,7 +1346,7 @@ trait APIMethods210 {
|""",
branchJsonPut,
branchJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, OBWG),
List(apiTagAccount, apiTagPrivateData, apiTagPublicData))
@ -1385,7 +1385,7 @@ trait APIMethods210 {
|""",
branchJsonPost,
branchJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, OBWG),
List(apiTagAccount, apiTagPrivateData, apiTagPublicData))
@ -1425,7 +1425,7 @@ trait APIMethods210 {
""".stripMargin,
consumerRedirectUrlJSON,
consumerJSON,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
Nil
)
@ -1498,7 +1498,7 @@ trait APIMethods210 {
""".stripMargin,
emptyObjectJson,
metricsJson,
UserNotLoggedIn :: Nil,
List(UserNotLoggedIn, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
Nil)

View File

@ -26,8 +26,7 @@ import code.util.Helper._
import net.liftweb.common.{Box, Full}
import net.liftweb.http.JsonResponse
import net.liftweb.http.rest.RestHelper
import code.api.util.ErrorMessages._
import code.api.ResourceDocs1_4_0.SwaggerJSONFactory._
import code.api.util.ErrorMessages.{BankAccountNotFound, _}
import code.api.util.ErrorMessages._
@ -114,7 +113,11 @@ trait APIMethods220 {
|OAuth authentication is required and the user needs to have access to the owner view.""",
emptyObjectJson,
viewsJSONV220,
UserNotLoggedIn :: Nil,
List(
UserNotLoggedIn,
BankAccountNotFound,
UnKnownError
),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagAccount, apiTagView))
@ -124,7 +127,7 @@ trait APIMethods220 {
user =>
for {
u <- user ?~ UserNotLoggedIn
account <- BankAccount(bankId, accountId)
account <- BankAccount(bankId, accountId) ?~! BankAccountNotFound
views <- account views u // In other words: views = account.views(u) This calls BankingData.scala BankAccount.views
} yield {
val viewsJSON = JSONFactory220.createViewsJSON(views)
@ -159,7 +162,12 @@ trait APIMethods220 {
| """,
createViewJSON,
viewJSONV220,
UserNotLoggedIn :: Nil,
List(
UserNotLoggedIn,
InvalidJsonFormat,
BankAccountNotFound,
UnKnownError
),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagAccount, apiTagView))
@ -168,9 +176,9 @@ trait APIMethods220 {
case "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: "views" :: Nil JsonPost json -> _ => {
user =>
for {
u <- user ?~ UserNotLoggedIn
json <- tryo{json.extract[CreateViewJSON]} ?~ "wrong JSON format"
account <- BankAccount(bankId, accountId)
json <- tryo{json.extract[CreateViewJSON]} ?~!InvalidJsonFormat
u <- user ?~!UserNotLoggedIn
account <- BankAccount(bankId, accountId) ?~! BankAccountNotFound
view <- account createView (u, json)
} yield {
val viewJSON = JSONFactory220.createViewJSON(view)
@ -195,18 +203,24 @@ trait APIMethods220 {
|of a view is not editable (it is only set when a view is created)""",
updateViewJSON,
viewJSONV220,
UserNotLoggedIn :: Nil,
List(
InvalidJsonFormat,
UserNotLoggedIn,
BankAccountNotFound,
UnKnownError
),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagAccount, apiTagView))
List(apiTagAccount, apiTagView)
)
lazy val updateViewForBankAccount : PartialFunction[Req, Box[User] => Box[JsonResponse]] = {
//updates a view on a bank account
case "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: "views" :: ViewId(viewId) :: Nil JsonPut json -> _ => {
user =>
for {
account <- BankAccount(bankId, accountId)
u <- user ?~ UserNotLoggedIn
updateJson <- tryo{json.extract[UpdateViewJSON]} ?~ "wrong JSON format"
updateJson <- tryo{json.extract[UpdateViewJSON]} ?~!InvalidJsonFormat
u <- user ?~!UserNotLoggedIn
account <- BankAccount(bankId, accountId) ?~!BankAccountNotFound
updatedView <- account.updateView(u, viewId, updateJson)
} yield {
val viewJSON = JSONFactory220.createViewJSON(updatedView)
@ -225,7 +239,7 @@ trait APIMethods220 {
"""Get the latest FXRate specified by FROM_CURRENCY_CODE and TO_CURRENCY_CODE """,
emptyObjectJson,
fXRateJSON,
UserNotLoggedIn :: Nil,
List(InvalidISOCurrencyCode,UserNotLoggedIn,FXCurrencyCodeCombinationsNotSupported, UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
Nil)
@ -233,9 +247,9 @@ trait APIMethods220 {
case "fx" :: fromCurrencyCode :: toCurrencyCode :: Nil JsonGet json => {
user =>
for {
u <- user ?~! UserNotLoggedIn
isValidCurrencyISOCodeFrom <- tryo(assert(isValidCurrencyISOCode(fromCurrencyCode))) ?~! ErrorMessages.InvalidISOCurrencyCode
isValidCurrencyISOCodeTo <- tryo(assert(isValidCurrencyISOCode(toCurrencyCode))) ?~! ErrorMessages.InvalidISOCurrencyCode
u <- user ?~! UserNotLoggedIn
fxRate <- tryo(Connector.connector.vend.getCurrentFxRate(fromCurrencyCode, toCurrencyCode).get) ?~! ErrorMessages.FXCurrencyCodeCombinationsNotSupported
} yield {
val viewJSON = JSONFactory220.createFXRateJSON(fxRate)
@ -257,7 +271,14 @@ trait APIMethods220 {
|""",
emptyObjectJson,
counterpartiesJsonV220,
UserNotLoggedIn :: Nil,
List(
UserNotLoggedIn,
BankAccountNotFound,
ViewNotFound,
ViewNoPermission,
UserNoPermissionAccessView,
UnKnownError
),
Catalogs(Core, PSD2, OBWG),
List(apiTagPerson, apiTagUser, apiTagAccount, apiTagCounterparty))
@ -267,12 +288,11 @@ trait APIMethods220 {
user =>
for {
u <- user ?~! UserNotLoggedIn
account <- BankAccount(bankId, accountId)
view <- View.fromUrl(viewId, account)?~! {ErrorMessages.ViewNotFound}
canAddCounterparty <- booleanToBox(view.canAddCounterparty == true, "The current view does not have can_add_counterparty permission. Please use a view with that permission or add the permission to this view.")
availableViews <- Full(account.permittedViews(user))
canUserAccessView <- tryo(availableViews.find(_ == viewId)) ?~ {"Current user does not have access to the view " + viewId}
counterparties <- Connector.connector.vend.getCounterparties(bankId,accountId,viewId) ?~ {"Connector.connector.vend.getCounterparties faild, can not get data from Database or Kafka .." }
account <- BankAccount(bankId, accountId) ?~! BankAccountNotFound
view <- View.fromUrl(viewId, account)?~! ViewNotFound
canAddCounterparty <- booleanToBox(view.canAddCounterparty == true, s"${ViewNoPermission}canAddCounterparty")
canUserAccessView <- Full(account.permittedViews(user).find(_ == viewId)) ?~! UserNoPermissionAccessView
counterparties <- Connector.connector.vend.getCounterparties(bankId,accountId,viewId)
} yield {
val counterpartiesJson = JSONFactory220.createCounterpartiesJSON(counterparties)
successJsonResponse(Extraction.decompose(counterpartiesJson))
@ -293,7 +313,7 @@ trait APIMethods220 {
""".stripMargin,
emptyObjectJson,
messageDocsJson,
UserNotLoggedIn :: Nil,
List(UnKnownError),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagApiInfo)
)
@ -325,7 +345,12 @@ trait APIMethods220 {
|""",
bankJSONV220,
bankJSONV220,
UserNotLoggedIn :: Nil,
List(
InvalidJsonFormat,
UserNotLoggedIn,
InsufficientAuthorisationToCreateBank,
UnKnownError
),
Catalogs(notCore, notPSD2, OBWG),
Nil
)
@ -334,9 +359,9 @@ trait APIMethods220 {
case "banks" :: Nil JsonPost json -> _ => {
user =>
for {
u <- user ?~ ErrorMessages.UserNotLoggedIn
canCreateBank <- booleanToBox(hasEntitlement("", u.userId, CanCreateBank) == true, ErrorMessages.InsufficientAuthorisationToCreateBank)
bank <- tryo{ json.extract[BankJSONV220] } ?~! ErrorMessages.InvalidJsonFormat
u <- user ?~!ErrorMessages.UserNotLoggedIn
canCreateBank <- booleanToBox(hasEntitlement("", u.userId, CanCreateBank) == true, ErrorMessages.InsufficientAuthorisationToCreateBank)
success <- Connector.connector.vend.createOrUpdateBank(
bank.id,
bank.full_name,
@ -367,7 +392,12 @@ trait APIMethods220 {
|""",
branchJSONV220,
branchJSONV220,
UserNotLoggedIn :: Nil,
List(
UserNotLoggedIn,
BankNotFound,
InsufficientAuthorisationToCreateBranch,
UnKnownError
),
Catalogs(notCore, notPSD2, OBWG),
Nil
)
@ -376,7 +406,7 @@ trait APIMethods220 {
case "banks" :: BankId(bankId) :: "branches" :: Nil JsonPost json -> _ => {
user =>
for {
u <- user ?~ ErrorMessages.UserNotLoggedIn
u <- user ?~!ErrorMessages.UserNotLoggedIn
bank <- Bank(bankId)?~! {ErrorMessages.BankNotFound}
canCreateBranch <- booleanToBox(hasEntitlement(bank.bankId.value, u.userId, CanCreateBranch) == true, ErrorMessages.InsufficientAuthorisationToCreateBranch)
branch <- tryo {json.extract[BranchJSONV220]} ?~! ErrorMessages.InvalidJsonFormat
@ -419,7 +449,22 @@ trait APIMethods220 {
|Note: The Amount must be zero.""".stripMargin,
createAccountJSONV220,
createAccountJSONV220,
UserNotLoggedIn :: Nil,
List(
InvalidJsonFormat,
BankNotFound,
UserNotLoggedIn,
InvalidUserId,
InvalidAccountIdFormat,
InvalidBankIdFormat,
UserNotFoundById,
UserDoesNotHaveRole,
InvalidAccountBalanceAmount,
InvalidAccountInitialBalance,
InitialBalanceMustBeZero,
InvalidAccountBalanceCurrency,
AccountIdHasExsited,
UnKnownError
),
Catalogs(notCore, notPSD2, notOBWG),
List(apiTagAccount)
)
@ -429,26 +474,24 @@ trait APIMethods220 {
// Create a new account
case "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: Nil JsonPut json -> _ => {
user => {
for {
loggedInUser <- user ?~! ErrorMessages.UserNotLoggedIn
jsonBody <- tryo (json.extract[CreateAccountJSONV220]) ?~ ErrorMessages.InvalidJsonFormat
user_id <- tryo (if (jsonBody.user_id.nonEmpty) jsonBody.user_id else loggedInUser.userId) ?~ ErrorMessages.InvalidUserId
isValidAccountIdFormat <- tryo(assert(isValidID(accountId.value)))?~! ErrorMessages.InvalidAccountIdFormat
isValidBankId <- tryo(assert(isValidID(accountId.value)))?~! ErrorMessages.InvalidBankIdFormat
postedOrLoggedInUser <- User.findByUserId(user_id) ?~! ErrorMessages.UserNotFoundById
bank <- Bank(bankId) ?~ s"Bank $bankId not found"
jsonBody <- tryo (json.extract[CreateAccountJSONV220]) ?~! InvalidJsonFormat
bank <- Bank(bankId) ?~! BankNotFound
loggedInUser <- user ?~! UserNotLoggedIn
user_id <- tryo (if (jsonBody.user_id.nonEmpty) jsonBody.user_id else loggedInUser.userId) ?~! InvalidUserId
isValidAccountIdFormat <- tryo(assert(isValidID(accountId.value)))?~! InvalidAccountIdFormat
isValidBankId <- tryo(assert(isValidID(accountId.value)))?~! InvalidBankIdFormat
postedOrLoggedInUser <- User.findByUserId(user_id) ?~! UserNotFoundById
// User can create account for self or an account for another user if they have CanCreateAccount role
isAllowed <- booleanToBox(hasEntitlement(bankId.value, loggedInUser.userId, CanCreateAccount) == true || (user_id == loggedInUser.userId) ,
s"User must either create account for self or have role $CanCreateAccount")
initialBalanceAsString <- tryo (jsonBody.balance.amount) ?~ ErrorMessages.InvalidAccountBalanceAmount
accountType <- tryo(jsonBody.`type`) ?~ ErrorMessages.InvalidAccountType
accountLabel <- tryo(jsonBody.`type`) //?~ ErrorMessages.InvalidAccountLabel
initialBalanceAsNumber <- tryo {BigDecimal(initialBalanceAsString)} ?~! ErrorMessages.InvalidAccountInitialBalance
isTrue <- booleanToBox(0 == initialBalanceAsNumber) ?~ s"Initial balance must be zero"
currency <- tryo (jsonBody.balance.currency) ?~ ErrorMessages.InvalidAccountBalanceCurrency
accountDoesNotExist <- booleanToBox(BankAccount(bankId, accountId).isEmpty,
s"Account with id $accountId already exists at bank $bankId")
isAllowed <- booleanToBox(hasEntitlement(bankId.value, loggedInUser.userId, CanCreateAccount) == true || (user_id == loggedInUser.userId) ,
s"${UserDoesNotHaveRole} CanCreateAccount or create account for self")
initialBalanceAsString <- tryo (jsonBody.balance.amount) ?~! InvalidAccountBalanceAmount
accountType <- tryo(jsonBody.`type`) ?~! InvalidAccountType
accountLabel <- tryo(jsonBody.`type`) //?~! ErrorMessages.InvalidAccountLabel
initialBalanceAsNumber <- tryo {BigDecimal(initialBalanceAsString)} ?~! InvalidAccountInitialBalance
isTrue <- booleanToBox(0 == initialBalanceAsNumber) ?~! InitialBalanceMustBeZero
currency <- tryo (jsonBody.balance.currency) ?~!ErrorMessages.InvalidAccountBalanceCurrency
accountDoesNotExist <- booleanToBox(BankAccount(bankId, accountId).isEmpty, AccountIdHasExsited)
bankAccount <- Connector.connector.vend.createSandboxBankAccount(
bankId,
accountId,
@ -486,14 +529,18 @@ trait APIMethods220 {
|* Cached function """,
emptyObjectJson,
configurationJSON,
UserNotLoggedIn :: Nil,
List(
UserNotLoggedIn,
UserDoesNotHaveRole,
UnKnownError
),
Catalogs(Core, notPSD2, OBWG),
apiTagApiInfo :: Nil)
lazy val config : PartialFunction[Req, Box[User] => Box[JsonResponse]] = {
case "config" :: Nil JsonGet _ => user => for {
u <- user ?~! ErrorMessages.UserNotLoggedIn
_ <- booleanToBox(hasEntitlement("", u.userId, CanGetConfig), s"$CanGetConfig entitlement required")
_ <- booleanToBox(hasEntitlement("", u.userId, CanGetConfig), s"$UserDoesNotHaveRole $CanGetConfig")
} yield {
successJsonResponse(getConfigInfoJSON(), 200)
}
@ -539,7 +586,10 @@ trait APIMethods220 {
""".stripMargin,
emptyObjectJson,
connectorMetricsJson,
UserNotLoggedIn :: Nil,
List(
InvalidDateFormat,
UnKnownError
),
Catalogs(notCore, notPSD2, notOBWG),
Nil)
@ -562,10 +612,10 @@ trait APIMethods220 {
//(defaults to one week before current date
startDate <- tryo(inputDateFormat.parse(S.param("start_date").getOrElse(defaultStartDate))) ?~!
s"${ErrorMessages.InvalidDateFormat } start_date:${S.param("start_date").get }. Support format is yyyy-MM-dd"
s"${InvalidDateFormat } start_date:${S.param("start_date").get }. Support format is yyyy-MM-dd"
// defaults to current date
endDate <- tryo(inputDateFormat.parse(S.param("end_date").getOrElse(defaultEndDate))) ?~!
s"${ErrorMessages.InvalidDateFormat } end_date:${S.param("end_date").get }. Support format is yyyy-MM-dd"
s"${InvalidDateFormat } end_date:${S.param("end_date").get }. Support format is yyyy-MM-dd"
// default 1000, return 1000 items
limit <- tryo(
S.param("limit") match {
@ -573,10 +623,10 @@ trait APIMethods220 {
case Full(l) => l.toInt
case _ => 1000
}
) ?~! s"${ErrorMessages.InvalidNumber } limit:${S.param("limit").get }"
) ?~! s"${InvalidNumber } limit:${S.param("limit").get }"
// default0, start from page 0
offset <- tryo(S.param("offset").getOrElse("0").toInt) ?~!
s"${ErrorMessages.InvalidNumber } offset:${S.param("offset").get }"
s"${InvalidNumber } offset:${S.param("offset").get }"
metrics <- Full(ConnMetrics.metrics.vend.getAllMetrics(List(OBPLimit(limit), OBPOffset(offset), OBPFromDate(startDate), OBPToDate(endDate))))