From e75a1da9729684ab7a46bd98a3aba809ea78f2fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Mili=C4=87?= Date: Wed, 23 Aug 2023 11:31:36 +0200 Subject: [PATCH 1/3] feature/Add function apiFailureToString --- .../src/main/scala/code/api/util/ErrorMessages.scala | 11 +++++++++++ obp-api/src/main/scala/code/api/util/FutureUtil.scala | 6 +----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/obp-api/src/main/scala/code/api/util/ErrorMessages.scala b/obp-api/src/main/scala/code/api/util/ErrorMessages.scala index 12c536f260..a198ced265 100644 --- a/obp-api/src/main/scala/code/api/util/ErrorMessages.scala +++ b/obp-api/src/main/scala/code/api/util/ErrorMessages.scala @@ -3,10 +3,12 @@ package code.api.util import java.util.Objects import java.util.regex.Pattern +import code.api.APIFailureNewStyle import com.openbankproject.commons.model.enums.TransactionRequestStatus._ import code.api.Constant._ import code.api.util.ApiRole.{CanCreateAnyTransactionRequest, canCreateEntitlementAtAnyBank, canCreateEntitlementAtOneBank} import code.views.system.ViewDefinition +import net.liftweb.json.{Extraction, JsonAST} import net.liftweb.util.StringHelpers object ErrorMessages { @@ -20,6 +22,15 @@ object ErrorMessages { // 6) Any messaage defined here should be considered "fair game" to return over the API. Thus: // 7) Since the existance of "OBP-..." in a message is used to determine if we should display to a user if display_internal_errors=false, do *not* concatenate internal or core banking system error messages to these strings. + + def apiFailureToString(code: Int, message: String, context: Option[CallContext]): String = JsonAST.compactRender( + Extraction.decompose( + APIFailureNewStyle(failMsg = message, failCode = code, context.map(_.toLight)) + ) + ) + def apiFailureToString(code: Int, message: String, context: CallContext): String = + apiFailureToString(code, message, Some(context)) + // Infrastructure / config level messages (OBP-00XXX) val HostnameNotSpecified = "OBP-00001: Hostname not specified. Could not get hostname from Props. Please edit your props file. Here are some example settings: hostname=http://127.0.0.1:8080 or hostname=https://www.example.com" val DataImportDisabled = "OBP-00002: Data import is disabled for this API instance." diff --git a/obp-api/src/main/scala/code/api/util/FutureUtil.scala b/obp-api/src/main/scala/code/api/util/FutureUtil.scala index 37258e3ae2..aca761eb0a 100644 --- a/obp-api/src/main/scala/code/api/util/FutureUtil.scala +++ b/obp-api/src/main/scala/code/api/util/FutureUtil.scala @@ -43,11 +43,7 @@ object FutureUtil { val timerTask = new TimerTask() { def run() : Unit = { p.tryFailure { - val error: String = JsonAST.compactRender( - Extraction.decompose( - APIFailureNewStyle(failMsg = ErrorMessages.requestTimeout, failCode = 408, cc.context.map(_.toLight)) - ) - ) + val error: String = ErrorMessages.apiFailureToString(408, ErrorMessages.requestTimeout, cc.context) new TimeoutException(error) } } From ec421046b2dbdffb4fc32184ddee35ff630a0140 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Mili=C4=87?= Date: Thu, 24 Aug 2023 06:59:27 +0200 Subject: [PATCH 2/3] feature/Enable Metric regarding Request Timeout --- .../main/scala/code/api/util/APIUtil.scala | 1 + .../scala/code/api/v3_1_0/APIMethods310.scala | 193 ++++--- .../scala/code/api/v4_0_0/APIMethods400.scala | 529 +++++++++--------- .../scala/code/api/v5_0_0/APIMethods500.scala | 70 ++- .../scala/code/api/v5_1_0/APIMethods510.scala | 68 +-- 5 files changed, 451 insertions(+), 410 deletions(-) diff --git a/obp-api/src/main/scala/code/api/util/APIUtil.scala b/obp-api/src/main/scala/code/api/util/APIUtil.scala index 755ce22209..348b4596db 100644 --- a/obp-api/src/main/scala/code/api/util/APIUtil.scala +++ b/obp-api/src/main/scala/code/api/util/APIUtil.scala @@ -1879,6 +1879,7 @@ object APIUtil extends MdcLoggable with CustomJsonFormats{ * - We cannot assign the role to non existing bank */ cc: CallContext => { + implicit val ec = EndpointContext(Some(cc)) // Supply call context in case of saving row to the metric table // if authentication check, do authorizedAccess, else do Rate Limit check for { (boxUser, callContext) <- checkAuth(cc) diff --git a/obp-api/src/main/scala/code/api/v3_1_0/APIMethods310.scala b/obp-api/src/main/scala/code/api/v3_1_0/APIMethods310.scala index 8f96c37f10..835b7c0181 100644 --- a/obp-api/src/main/scala/code/api/v3_1_0/APIMethods310.scala +++ b/obp-api/src/main/scala/code/api/v3_1_0/APIMethods310.scala @@ -2,10 +2,10 @@ package code.api.v3_1_0 import code.api.Constant import code.api.Constant.{SYSTEM_OWNER_VIEW_ID, localIdentityProvider} - import java.text.SimpleDateFormat import java.util.UUID import java.util.regex.Pattern + import code.api.ResourceDocs1_4_0.SwaggerDefinitionsJSON._ import code.api.ResourceDocs1_4_0.{MessageDocsSwaggerDefinitions, ResourceDocsAPIMethodsUtil, SwaggerDefinitionsJSON, SwaggerJSONFactory} import code.api.util.APIUtil.{getWebUIPropsPairs, _} @@ -13,6 +13,7 @@ import code.api.util.ApiRole._ import code.api.util.ApiTag._ import code.api.util.ErrorMessages.{BankAccountNotFound, _} import code.api.util.ExampleValue._ +import code.api.util.FutureUtil.{EndpointContext, endpointContext} import code.api.util.NewStyle.HttpCode import code.api.util._ import code.api.v1_2_1.{JSONFactory, RateLimiting} @@ -100,7 +101,7 @@ trait APIMethods310 { lazy val getCheckbookOrders : OBPEndpoint = { case "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: ViewId(viewId) :: "checkbook" :: "orders" :: Nil JsonGet req => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) @@ -141,7 +142,7 @@ trait APIMethods310 { lazy val getStatusOfCreditCardOrder : OBPEndpoint = { case "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: ViewId(viewId) :: "credit_cards" :: "orders" :: Nil JsonGet req => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) @@ -226,7 +227,7 @@ trait APIMethods310 { lazy val getTopAPIs : OBPEndpoint = { case "management" :: "metrics" :: "top-apis" :: Nil JsonGet req => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) @@ -313,7 +314,7 @@ trait APIMethods310 { lazy val getMetricsTopConsumers : OBPEndpoint = { case "management" :: "metrics" :: "top-consumers" :: Nil JsonGet req => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) @@ -369,7 +370,7 @@ trait APIMethods310 { lazy val getFirehoseCustomers : OBPEndpoint = { //get private accounts for all banks case "banks" :: BankId(bankId):: "firehose" :: "customers" :: Nil JsonGet req => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) _ <- Helper.booleanToFuture(failMsg = AccountFirehoseNotAllowedOnThisInstance , cc=callContext) { @@ -420,7 +421,7 @@ trait APIMethods310 { lazy val getBadLoginStatus : OBPEndpoint = { //get private accounts for all banks case "users" :: username:: "lock-status" :: Nil JsonGet req => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) _ <- NewStyle.function.hasEntitlement("", u.userId, ApiRole.canReadUserLockedStatus, callContext) @@ -458,7 +459,7 @@ trait APIMethods310 { lazy val unlockUser : OBPEndpoint = { //get private accounts for all banks case "users" :: username:: "lock-status" :: Nil JsonPut req => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) user <- Users.users.vend.getUserByProviderAndUsernameFuture(Constant.localIdentityProvider, username) map { @@ -511,7 +512,7 @@ trait APIMethods310 { lazy val callsLimit : OBPEndpoint = { case "management" :: "consumers" :: consumerId :: "consumer" :: "call-limits" :: Nil JsonPut json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) _ <- NewStyle.function.hasEntitlement("", u.userId, canSetCallLimits, callContext) @@ -572,7 +573,7 @@ trait APIMethods310 { lazy val getCallsLimit : OBPEndpoint = { case "management" :: "consumers" :: consumerId :: "consumer" :: "call-limits" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) _ <- NewStyle.function.hasEntitlement("", u.userId, canReadCallLimits, callContext) @@ -615,7 +616,7 @@ trait APIMethods310 { lazy val checkFundsAvailable : OBPEndpoint = { case "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: ViewId(viewId) :: "funds-available" :: Nil JsonGet req => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) val amount = "amount" val currency = "currency" for { @@ -680,7 +681,7 @@ trait APIMethods310 { lazy val getConsumer: OBPEndpoint = { case "management" :: "consumers" :: consumerId :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) _ <- NewStyle.function.hasEntitlement("", u.userId, ApiRole.canGetConsumers, callContext) @@ -715,7 +716,7 @@ trait APIMethods310 { lazy val getConsumersForCurrentUser: OBPEndpoint = { case "management" :: "users" :: "current" :: "consumers" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) consumer <- Consumers.consumers.vend.getConsumersByUserIdFuture(u.userId) @@ -751,7 +752,7 @@ trait APIMethods310 { lazy val getConsumers: OBPEndpoint = { case "management" :: "consumers" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) _ <- NewStyle.function.hasEntitlement("", u.userId, ApiRole.canGetConsumers, callContext) @@ -793,7 +794,7 @@ trait APIMethods310 { lazy val createAccountWebhook : OBPEndpoint = { case "banks" :: BankId(bankId) :: "account-web-hooks" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) (_, callContext) <- NewStyle.function.getBank(bankId, callContext) @@ -850,7 +851,7 @@ trait APIMethods310 { lazy val enableDisableAccountWebhook : OBPEndpoint = { case "banks" :: BankId(bankId) :: "account-web-hooks" :: Nil JsonPut json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) (_, callContext) <- NewStyle.function.getBank(bankId, callContext) @@ -910,7 +911,7 @@ trait APIMethods310 { lazy val getAccountWebhooks: OBPEndpoint = { case "management" :: "banks" :: BankId(bankId) ::"account-web-hooks" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) (_, callContext) <- NewStyle.function.getBank(bankId, callContext) @@ -951,7 +952,7 @@ trait APIMethods310 { lazy val config: OBPEndpoint = { case "config" :: Nil JsonGet _ => - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) _ <- NewStyle.function.hasEntitlement("", u.userId, ApiRole.canGetConfig, callContext) @@ -982,7 +983,7 @@ trait APIMethods310 { lazy val getAdapterInfo: OBPEndpoint = { case "adapter" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) _ <- NewStyle.function.hasEntitlement("", u.userId, ApiRole.canGetAdapterInfo, callContext) @@ -1015,7 +1016,7 @@ trait APIMethods310 { lazy val getTransactionByIdForBankAccount : OBPEndpoint = { case "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: ViewId(viewId) :: "transactions" :: TransactionId(transactionId) :: "transaction" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (user, callContext) <- authenticatedAccess(cc) _ <- passesPsd2Pisp(callContext) @@ -1080,7 +1081,7 @@ trait APIMethods310 { lazy val getTransactionRequests: OBPEndpoint = { case "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: ViewId(viewId) :: "transaction-requests" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) _ <- NewStyle.function.isEnabledTransactionRequests(callContext) @@ -1134,7 +1135,7 @@ trait APIMethods310 { ) lazy val createCustomer : OBPEndpoint = { case "banks" :: BankId(bankId) :: "customers" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) @@ -1201,7 +1202,7 @@ trait APIMethods310 { lazy val getRateLimitingInfo: OBPEndpoint = { case "rate-limiting" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (_, callContext) <- anonymousAccess(cc) rateLimiting <- NewStyle.function.tryons("", 400, callContext) { @@ -1247,7 +1248,7 @@ trait APIMethods310 { lazy val getCustomerByCustomerId : OBPEndpoint = { case "banks" :: BankId(bankId) :: "customers" :: customerId :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) (_, callContext) <- NewStyle.function.getBank(bankId, callContext) @@ -1290,7 +1291,7 @@ trait APIMethods310 { lazy val getCustomerByCustomerNumber : OBPEndpoint = { case "banks" :: BankId(bankId) :: "customers" :: "customer-number" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) (bank, callContext) <- NewStyle.function.getBank(bankId, callContext) @@ -1334,7 +1335,7 @@ trait APIMethods310 { lazy val createUserAuthContext : OBPEndpoint = { case "users" :: userId ::"auth-context" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) _ <- NewStyle.function.hasEntitlement("", u.userId, canCreateUserAuthContext, callContext) @@ -1376,7 +1377,7 @@ trait APIMethods310 { lazy val getUserAuthContexts : OBPEndpoint = { case "users" :: userId :: "auth-context" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) _ <- NewStyle.function.hasEntitlement("", u.userId, canGetUserAuthContext, callContext) @@ -1414,7 +1415,7 @@ trait APIMethods310 { lazy val deleteUserAuthContexts : OBPEndpoint = { case "users" :: userId :: "auth-context" :: Nil JsonDelete _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) _ <- NewStyle.function.hasEntitlement("", u.userId, canDeleteUserAuthContext, callContext) @@ -1452,7 +1453,7 @@ trait APIMethods310 { lazy val deleteUserAuthContextById : OBPEndpoint = { case "users" :: userId :: "auth-context" :: userAuthContextId :: Nil JsonDelete _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) _ <- NewStyle.function.hasEntitlement("", u.userId, canDeleteUserAuthContext, callContext) @@ -1490,7 +1491,7 @@ trait APIMethods310 { lazy val createTaxResidence : OBPEndpoint = { case "banks" :: BankId(bankId) :: "customers" :: customerId :: "tax-residence" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) (_, callContext) <- NewStyle.function.getBank(bankId, callContext) @@ -1532,7 +1533,7 @@ trait APIMethods310 { lazy val getTaxResidence : OBPEndpoint = { case "banks" :: BankId(bankId) :: "customers" :: customerId :: "tax-residences" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) (_, callContext) <- NewStyle.function.getBank(bankId, callContext) @@ -1570,7 +1571,7 @@ trait APIMethods310 { lazy val deleteTaxResidence : OBPEndpoint = { case "banks" :: BankId(bankId) :: "customers" :: customerId :: "tax_residencies" :: taxResidenceId :: Nil JsonDelete _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) (_, callContext) <- NewStyle.function.getBank(bankId, callContext) @@ -1608,7 +1609,7 @@ trait APIMethods310 { lazy val getAllEntitlements: OBPEndpoint = { case "entitlements" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) _ <- NewStyle.function.hasEntitlement("", u.userId, canGetEntitlementsForAnyUserAtAnyBank, callContext) @@ -1650,7 +1651,7 @@ trait APIMethods310 { lazy val createCustomerAddress : OBPEndpoint = { case "banks" :: BankId(bankId) :: "customers" :: customerId :: "address" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) (_, callContext) <- NewStyle.function.getBank(bankId, callContext) @@ -1706,7 +1707,7 @@ trait APIMethods310 { lazy val updateCustomerAddress : OBPEndpoint = { case "banks" :: BankId(bankId) :: "customers" :: customerId :: "addresses" :: customerAddressId :: Nil JsonPut json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) (_, callContext) <- NewStyle.function.getBank(bankId, callContext) @@ -1761,7 +1762,7 @@ trait APIMethods310 { lazy val getCustomerAddresses : OBPEndpoint = { case "banks" :: BankId(bankId) :: "customers" :: customerId :: "addresses" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) (_, callContext) <- NewStyle.function.getBank(bankId, callContext) @@ -1800,7 +1801,7 @@ trait APIMethods310 { lazy val deleteCustomerAddress : OBPEndpoint = { case "banks" :: BankId(bankId) :: "customers" :: customerId :: "addresses" :: customerAddressId :: Nil JsonDelete _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) (_, callContext) <- NewStyle.function.getBank(bankId, callContext) @@ -1841,7 +1842,7 @@ trait APIMethods310 { lazy val getObpConnectorLoopback : OBPEndpoint = { case "connector" :: "loopback" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (_, callContext) <- anonymousAccess(cc) connectorVersion = APIUtil.getPropsValue("connector").openOrThrowException("connector props field `connector` not set") @@ -1884,7 +1885,7 @@ trait APIMethods310 { lazy val refreshUser : OBPEndpoint = { case "users" :: userId :: "refresh" :: Nil JsonPost _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) _ <- NewStyle.function.hasEntitlement("", userId, canRefreshUser, callContext) @@ -1953,7 +1954,7 @@ trait APIMethods310 { lazy val createProductAttribute : OBPEndpoint = { case "banks" :: bankId :: "products" :: productCode:: "attribute" :: Nil JsonPost json -> _=> { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) _ <- NewStyle.function.hasEntitlement(bankId, u.userId, canCreateProductAttribute, callContext) @@ -2012,7 +2013,7 @@ trait APIMethods310 { lazy val getProductAttribute : OBPEndpoint = { case "banks" :: bankId :: "products" :: productCode:: "attributes" :: productAttributeId :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) _ <- NewStyle.function.hasEntitlement(bankId, u.userId, canGetProductAttribute, callContext) @@ -2054,7 +2055,7 @@ trait APIMethods310 { lazy val updateProductAttribute : OBPEndpoint = { case "banks" :: bankId :: "products" :: productCode:: "attributes" :: productAttributeId :: Nil JsonPut json -> _ =>{ - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) _ <- NewStyle.function.hasEntitlement(bankId, u.userId, canUpdateProductAttribute, callContext) @@ -2113,7 +2114,7 @@ trait APIMethods310 { lazy val deleteProductAttribute : OBPEndpoint = { case "banks" :: bankId :: "products" :: productCode:: "attributes" :: productAttributeId :: Nil JsonDelete _=> { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) _ <- NewStyle.function.hasEntitlement(bankId, u.userId, canDeleteProductAttribute, callContext) @@ -2147,7 +2148,7 @@ trait APIMethods310 { lazy val createAccountApplication : OBPEndpoint = { case "banks" :: BankId(bankId) :: "account-applications" :: Nil JsonPost json -> _=> { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) @@ -2209,7 +2210,7 @@ trait APIMethods310 { lazy val getAccountApplications : OBPEndpoint = { case "banks" :: BankId(bankId) ::"account-applications" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) @@ -2252,7 +2253,7 @@ trait APIMethods310 { lazy val getAccountApplication : OBPEndpoint = { case "banks" :: BankId(bankId) ::"account-applications":: accountApplicationId :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) @@ -2299,7 +2300,7 @@ trait APIMethods310 { lazy val updateAccountApplicationStatus : OBPEndpoint = { case "banks" :: BankId(bankId) ::"account-applications" :: accountApplicationId :: Nil JsonPut json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) @@ -2392,7 +2393,7 @@ trait APIMethods310 { lazy val createProduct: OBPEndpoint = { case "banks" :: BankId(bankId) :: "products" :: ProductCode(productCode) :: Nil JsonPut json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) _ <- NewStyle.function.hasAtLeastOneEntitlement(failMsg = createProductEntitlementsRequiredText)(bankId.value, u.userId, createProductEntitlements, callContext) @@ -2468,6 +2469,7 @@ trait APIMethods310 { lazy val getProduct: OBPEndpoint = { case "banks" :: BankId(bankId) :: "products" :: ProductCode(productCode) :: Nil JsonGet _ => { cc => { + implicit val ec = EndpointContext(Some(cc)) for { (_, callContext) <- getProductsIsPublic match { case false => authenticatedAccess(cc) @@ -2531,6 +2533,7 @@ trait APIMethods310 { } } cc => { + implicit val ec = EndpointContext(Some(cc)) for { (_, callContext) <- getProductsIsPublic match { case false => authenticatedAccess(cc) @@ -2586,6 +2589,7 @@ trait APIMethods310 { lazy val getProducts : OBPEndpoint = { case "banks" :: BankId(bankId) :: "products" :: Nil JsonGet req => { cc => { + implicit val ec = EndpointContext(Some(cc)) for { (_, callContext) <- getProductsIsPublic match { case false => authenticatedAccess(cc) @@ -2659,7 +2663,7 @@ trait APIMethods310 { lazy val createAccountAttribute : OBPEndpoint = { case "banks" :: bankId :: "accounts" :: accountId :: "products" :: productCode :: "attribute" :: Nil JsonPost json -> _=> { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) (_, callContext) <- NewStyle.function.getBank(BankId(bankId), callContext) @@ -2735,7 +2739,7 @@ trait APIMethods310 { lazy val updateAccountAttribute : OBPEndpoint = { case "banks" :: bankId :: "accounts" :: accountId :: "products" :: productCode :: "attributes" :: accountAttributeId :: Nil JsonPut json -> _=> { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) (_, callContext) <- NewStyle.function.getBank(BankId(bankId), callContext) @@ -2819,7 +2823,7 @@ trait APIMethods310 { lazy val createProductCollection: OBPEndpoint = { case "banks" :: BankId(bankId) :: "product-collections" :: collectionCode :: Nil JsonPut json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) _ <- NewStyle.function.hasEntitlement(bankId.value, u.userId, canMaintainProductCollection, callContext) @@ -2879,6 +2883,7 @@ trait APIMethods310 { lazy val getProductCollection : OBPEndpoint = { case "banks" :: BankId(bankId) :: "product-collections" :: collectionCode :: Nil JsonGet _ => { cc => { + implicit val ec = EndpointContext(Some(cc)) for { (_, callContext) <- authenticatedAccess(cc) (_, callContext) <- NewStyle.function.getBank(bankId, callContext) @@ -2921,7 +2926,7 @@ trait APIMethods310 { lazy val deleteBranch: OBPEndpoint = { case "banks" :: BankId(bankId) :: "branches" :: BranchId(branchId) :: Nil JsonDelete _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) allowedEntitlements = canDeleteBranch ::canDeleteBranchAtAnyBank:: Nil @@ -2967,7 +2972,7 @@ trait APIMethods310 { lazy val createMeeting: OBPEndpoint = { case "banks" :: BankId(bankId) :: "meetings" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) (bank, callContext) <- NewStyle.function.getBank(bankId, callContext) @@ -3043,7 +3048,7 @@ trait APIMethods310 { lazy val getMeetings: OBPEndpoint = { case "banks" :: BankId(bankId) :: "meetings" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) (bank, callContext) <- NewStyle.function.getBank(bankId, callContext) @@ -3083,7 +3088,7 @@ trait APIMethods310 { lazy val getMeeting: OBPEndpoint = { case "banks" :: BankId(bankId) :: "meetings" :: meetingId :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) (bank, callContext) <- NewStyle.function.getBank(bankId, callContext) @@ -3115,7 +3120,7 @@ trait APIMethods310 { lazy val getServerJWK: OBPEndpoint = { case "certs" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (_, callContext) <- anonymousAccess(cc) } yield { @@ -3153,6 +3158,7 @@ trait APIMethods310 { case "message-docs" :: restConnectorVersion ::"swagger2.0" :: Nil JsonGet _ => { val (resourceDocTags, partialFunctions, locale, contentParam, apiCollectionIdParam, cacheModifierParam) = ResourceDocsAPIMethodsUtil.getParams() cc => { + implicit val ec = EndpointContext(Some(cc)) for { (_, callContext) <- anonymousAccess(cc) messageDocsSwagger = RestConnector_vMar2019.messageDocs.map(toResourceDoc).toList @@ -3469,7 +3475,7 @@ trait APIMethods310 { lazy val createConsent : OBPEndpoint = { case "banks" :: BankId(bankId) :: "my" :: "consents" :: scaMethod :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(user), callContext) <- authenticatedAccess(cc) (_, callContext) <- NewStyle.function.getBank(bankId, callContext) @@ -3640,7 +3646,7 @@ trait APIMethods310 { lazy val answerConsentChallenge : OBPEndpoint = { case "banks" :: BankId(bankId) :: "consents" :: consentId :: "challenge" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (_, callContext) <- authenticatedAccess(cc) (_, callContext) <- NewStyle.function.getBank(bankId, callContext) @@ -3681,7 +3687,7 @@ trait APIMethods310 { lazy val getConsents: OBPEndpoint = { case "banks" :: BankId(bankId) :: "my" :: "consents" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(user), callContext) <- authenticatedAccess(cc) (_, callContext) <- NewStyle.function.getBank(bankId, callContext) @@ -3726,7 +3732,7 @@ trait APIMethods310 { lazy val revokeConsent: OBPEndpoint = { case "banks" :: BankId(bankId) :: "my" :: "consents" :: consentId :: "revoke" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(user), callContext) <- authenticatedAccess(cc) (_, callContext) <- NewStyle.function.getBank(bankId, callContext) @@ -3774,7 +3780,7 @@ trait APIMethods310 { lazy val createUserAuthContextUpdateRequest : OBPEndpoint = { case "banks" :: BankId(bankId) :: "users" :: "current" ::"auth-context-updates" :: scaMethod :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(user), callContext) <- authenticatedAccess(cc) _ <- Helper.booleanToFuture(failMsg = ConsumerHasMissingRoles + CanCreateUserAuthContextUpdate, cc=callContext) { @@ -3819,7 +3825,7 @@ trait APIMethods310 { lazy val answerUserAuthContextUpdateChallenge : OBPEndpoint = { case "banks" :: BankId(bankId) :: "users" :: "current" ::"auth-context-updates" :: authContextUpdateId :: "challenge" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (_, callContext) <- authenticatedAccess(cc) failMsg = s"$InvalidJsonFormat The Json body should be the $PostUserAuthContextUpdateJsonV310 " @@ -3884,7 +3890,7 @@ trait APIMethods310 { lazy val getSystemView: OBPEndpoint = { case "system-views" :: viewId :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(user), callContext) <- authenticatedAccess(cc) _ <- NewStyle.function.hasEntitlement("", user.userId, canGetSystemView, callContext) @@ -3933,7 +3939,7 @@ trait APIMethods310 { lazy val createSystemView : OBPEndpoint = { //creates a system view case "system-views" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(user), callContext) <- authenticatedAccess(cc) _ <- NewStyle.function.hasEntitlement("", user.userId, canCreateSystemView, callContext) @@ -3978,7 +3984,7 @@ trait APIMethods310 { lazy val deleteSystemView: OBPEndpoint = { //deletes a view on an bank account case "system-views" :: viewId :: Nil JsonDelete req => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(user), callContext) <- authenticatedAccess(cc) _ <- NewStyle.function.hasEntitlement("", user.userId, canDeleteSystemView, callContext) @@ -4019,7 +4025,7 @@ trait APIMethods310 { lazy val updateSystemView : OBPEndpoint = { //updates a view on a bank account case "system-views" :: viewId :: Nil JsonPut json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(user), callContext) <- authenticatedAccess(cc) _ <- NewStyle.function.hasEntitlement("", user.userId, canUpdateSystemView, callContext) @@ -4059,7 +4065,7 @@ trait APIMethods310 { lazy val getOAuth2ServerJWKsURIs: OBPEndpoint = { case "jwks-uris" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (_, callContext) <- anonymousAccess(cc) } yield { @@ -4105,7 +4111,7 @@ trait APIMethods310 { lazy val getMethodRoutings: OBPEndpoint = { case "management" :: "method_routings":: Nil JsonGet req => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) _ <- NewStyle.function.hasEntitlement("", u.userId, ApiRole.canGetMethodRoutings, callContext) @@ -4208,7 +4214,7 @@ trait APIMethods310 { lazy val createMethodRouting : OBPEndpoint = { case "management" :: "method_routings" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) _ <- NewStyle.function.hasEntitlement("", u.userId, canCreateMethodRouting, callContext) @@ -4311,7 +4317,7 @@ trait APIMethods310 { lazy val updateMethodRouting : OBPEndpoint = { case "management" :: "method_routings" :: methodRoutingId :: Nil JsonPut json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) _ <- NewStyle.function.hasEntitlement("", u.userId, canUpdateMethodRouting, callContext) @@ -4386,7 +4392,7 @@ trait APIMethods310 { lazy val deleteMethodRouting : OBPEndpoint = { case "management" :: "method_routings" :: methodRoutingId :: Nil JsonDelete _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) (_, callContext) <- NewStyle.function.getMethodRoutingById(methodRoutingId, callContext) @@ -4426,7 +4432,7 @@ trait APIMethods310 { lazy val updateCustomerEmail : OBPEndpoint = { case "banks" :: BankId(bankId) :: "customers" :: customerId :: "email" :: Nil JsonPut json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) (_, callContext) <- NewStyle.function.getBank(bankId, callContext) @@ -4475,7 +4481,7 @@ trait APIMethods310 { lazy val updateCustomerNumber : OBPEndpoint = { case "banks" :: BankId(bankId) :: "customers" :: customerId :: "number" :: Nil JsonPut json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) (_, callContext) <- NewStyle.function.getBank(bankId, callContext) @@ -4530,7 +4536,7 @@ trait APIMethods310 { lazy val updateCustomerMobileNumber : OBPEndpoint = { case "banks" :: BankId(bankId) :: "customers" :: customerId :: "mobile-number" :: Nil JsonPut json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) (_, callContext) <- NewStyle.function.getBank(bankId, callContext) @@ -4578,7 +4584,7 @@ trait APIMethods310 { ) lazy val updateCustomerIdentity : OBPEndpoint = { case "banks" :: BankId(bankId) :: "customers" :: customerId :: "identity" :: Nil JsonPut json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) (_, callContext) <- NewStyle.function.getBank(bankId, callContext) @@ -4636,7 +4642,7 @@ trait APIMethods310 { lazy val updateCustomerCreditLimit : OBPEndpoint = { case "banks" :: BankId(bankId) :: "customers" :: customerId :: "credit-limit" :: Nil JsonPut json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) (_, callContext) <- NewStyle.function.getBank(bankId, callContext) @@ -4685,7 +4691,7 @@ trait APIMethods310 { lazy val updateCustomerCreditRatingAndSource : OBPEndpoint = { case "banks" :: BankId(bankId) :: "customers" :: customerId :: "credit-rating-and-source" :: Nil JsonPut json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) (_, callContext) <- NewStyle.function.getBank(bankId, callContext) @@ -4728,7 +4734,7 @@ trait APIMethods310 { lazy val updateAccount : OBPEndpoint = { case "management" :: "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: Nil JsonPut json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) _ <- NewStyle.function.hasEntitlement(bankId.value, u.userId, ApiRole.canUpdateAccount, callContext) @@ -4793,7 +4799,7 @@ trait APIMethods310 { Some(List(canCreateCardsForBank))) lazy val addCardForBank: OBPEndpoint = { case "management" :: "banks" :: BankId(bankId) :: "cards" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) @@ -4888,7 +4894,7 @@ trait APIMethods310 { Some(List(canUpdateCardsForBank))) lazy val updatedCardForBank: OBPEndpoint = { case "management" :: "banks" :: BankId(bankId) :: "cards" :: cardId :: Nil JsonPut json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) _ <- NewStyle.function.hasEntitlement(bankId.value, u.userId, ApiRole.canUpdateCardsForBank, callContext) @@ -4969,6 +4975,7 @@ trait APIMethods310 { lazy val getCardsForBank : OBPEndpoint = { case "management" :: "banks" :: BankId(bankId) :: "cards" :: Nil JsonGet _ => { cc => { + implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) httpParams <- NewStyle.function.extractHttpParamsFromUrl(cc.url) @@ -5004,6 +5011,7 @@ trait APIMethods310 { lazy val getCardForBank : OBPEndpoint = { case "management" :: "banks" :: BankId(bankId) :: "cards" :: cardId :: Nil JsonGet _ => { cc => { + implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) _ <- NewStyle.function.hasEntitlement(bankId.value, u.userId, ApiRole.canGetCardsForBank, callContext) @@ -5042,7 +5050,7 @@ trait APIMethods310 { Some(List(canCreateCardsForBank))) lazy val deleteCardForBank: OBPEndpoint = { case "management"::"banks" :: BankId(bankId) :: "cards" :: cardId :: Nil JsonDelete _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) _ <- NewStyle.function.hasEntitlement(bankId.value, u.userId, ApiRole.canDeleteCardsForBank, callContext) @@ -5093,7 +5101,7 @@ trait APIMethods310 { lazy val createCardAttribute : OBPEndpoint = { case "management"::"banks" :: bankId :: "cards" :: cardId :: "attribute" :: Nil JsonPost json -> _=> { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (_, callContext) <- authenticatedAccess(cc) (_, callContext) <- NewStyle.function.getBank(BankId(bankId), callContext) @@ -5164,7 +5172,7 @@ trait APIMethods310 { lazy val updateCardAttribute : OBPEndpoint = { case "management"::"banks" :: bankId :: "cards" :: cardId :: "attributes" :: cardAttributeId :: Nil JsonPut json -> _=> { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (_, callContext) <- authenticatedAccess(cc) (_, callContext) <- NewStyle.function.getBank(BankId(bankId), callContext) @@ -5224,7 +5232,7 @@ trait APIMethods310 { ) lazy val updateCustomerBranch : OBPEndpoint = { case "banks" :: BankId(bankId) :: "customers" :: customerId :: "branch" :: Nil JsonPut json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) (_, callContext) <- NewStyle.function.getBank(bankId, callContext) @@ -5280,7 +5288,7 @@ trait APIMethods310 { ) lazy val updateCustomerData : OBPEndpoint = { case "banks" :: BankId(bankId) :: "customers" :: customerId :: "data" :: Nil JsonPut json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) (_, callContext) <- NewStyle.function.getBank(bankId, callContext) @@ -5357,6 +5365,7 @@ trait APIMethods310 { // Create a new account case "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: Nil JsonPut json -> _ => { cc =>{ + implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) (account, callContext) <- Connector.connector.vend.checkBankAccountExists(bankId, accountId, callContext) @@ -5468,7 +5477,7 @@ trait APIMethods310 { apiTagAccount :: Nil) lazy val getPrivateAccountByIdFull : OBPEndpoint = { case "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: ViewId(viewId) :: "account" :: Nil JsonGet req => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) (account, callContext) <- NewStyle.function.checkBankAccountExists(bankId, accountId, callContext) @@ -5581,7 +5590,7 @@ trait APIMethods310 { lazy val saveHistoricalTransaction : OBPEndpoint = { case "management" :: "historical" :: "transactions" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) _ <- NewStyle.function.hasEntitlement("", u.userId, ApiRole.canCreateHistoricalTransaction, callContext) @@ -5721,7 +5730,7 @@ trait APIMethods310 { lazy val getWebUiProps: OBPEndpoint = { case "management" :: "webui_props":: Nil JsonGet req => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) val active = S.param("active").getOrElse("false") for { (Full(u), callContext) <- authenticatedAccess(cc) @@ -5811,7 +5820,7 @@ trait APIMethods310 { lazy val createWebUiProps : OBPEndpoint = { case "management" :: "webui_props" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) _ <- NewStyle.function.hasEntitlement("", u.userId, canCreateWebUiProps, callContext) @@ -5856,7 +5865,7 @@ trait APIMethods310 { lazy val deleteWebUiProps : OBPEndpoint = { case "management" :: "webui_props" :: webUiPropsId :: Nil JsonDelete _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) _ <- NewStyle.function.hasEntitlement("", u.userId, canDeleteWebUiProps, callContext) @@ -5885,7 +5894,7 @@ trait APIMethods310 { lazy val getBankAccountsBalances : OBPEndpoint = { case "banks" :: BankId(bankId) :: "balances" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) (_, callContext) <- NewStyle.function.getBank(bankId, callContext) @@ -5922,7 +5931,7 @@ trait APIMethods310 { lazy val enableDisableConsumers: OBPEndpoint = { case "management" :: "consumers" :: consumerId :: Nil JsonPut json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) putData <- NewStyle.function.tryons(InvalidJsonFormat, 400, cc.callContext) { diff --git a/obp-api/src/main/scala/code/api/v4_0_0/APIMethods400.scala b/obp-api/src/main/scala/code/api/v4_0_0/APIMethods400.scala index 13b55d7f7b..cfa5dad4af 100644 --- a/obp-api/src/main/scala/code/api/v4_0_0/APIMethods400.scala +++ b/obp-api/src/main/scala/code/api/v4_0_0/APIMethods400.scala @@ -4,6 +4,7 @@ import java.net.URLEncoder import java.text.SimpleDateFormat import java.util import java.util.{Calendar, Date} + import code.DynamicData.{DynamicData, DynamicDataProvider} import code.DynamicEndpoint.DynamicEndpointSwagger import code.accountattribute.AccountAttributeX @@ -43,6 +44,7 @@ import code.api.v4_0_0.JSONFactory400._ import code.api.dynamic.endpoint.helper._ import code.api.dynamic.endpoint.helper.practise.PractiseEndpoint import code.api.dynamic.entity.helper.{DynamicEntityHelper, DynamicEntityInfo} +import code.api.util.FutureUtil.{EndpointContext, endpointContext} import code.api.v5_0_0.OBPAPI5_0_0 import code.api.{ChargePolicy, Constant, JsonResponseException} import code.apicollection.MappedApiCollectionsProvider @@ -147,9 +149,11 @@ trait APIMethods400 { lazy val getMapperDatabaseInfo: OBPEndpoint = { case "database" :: "info" :: Nil JsonGet _ => { - cc => Future { - (Migration.DbFunction.mapperDatabaseInfo(), HttpCode.`200`(cc.callContext)) - } + cc => + implicit val ec = EndpointContext(Some(cc)) + Future { + (Migration.DbFunction.mapperDatabaseInfo(), HttpCode.`200`(cc.callContext)) + } } } @@ -172,7 +176,9 @@ trait APIMethods400 { lazy val getLogoutLink: OBPEndpoint = { case "users" :: "current" :: "logout-link" :: Nil JsonGet _ => { - cc => Future { + cc => + implicit val ec = EndpointContext(Some(cc)) + Future { val link = code.api.Constant.HostName + AuthUser.logoutPath.foldLeft("")(_ + "/" + _) val logoutLink = LogoutLinkJson(link) (logoutLink, HttpCode.`200`(cc.callContext)) @@ -216,7 +222,7 @@ trait APIMethods400 { lazy val callsLimit : OBPEndpoint = { case "management" :: "consumers" :: consumerId :: "consumer" :: "call-limits" :: Nil JsonPut json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) _ <- NewStyle.function.hasEntitlement("", u.userId, canSetCallLimits, callContext) @@ -268,7 +274,8 @@ trait APIMethods400 { lazy val getBanks: OBPEndpoint = { case "banks" :: Nil JsonGet _ => { - cc => + cc => + implicit val ec = EndpointContext(Some(cc)) for { (banks, callContext) <- NewStyle.function.getBanks(cc.callContext) } yield { @@ -300,7 +307,7 @@ trait APIMethods400 { lazy val getBank : OBPEndpoint = { case "banks" :: BankId(bankId) :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (bank, callContext) <- NewStyle.function.getBank(bankId, cc.callContext) (attributes, callContext) <- NewStyle.function.getBankAttributesByBank(bankId, callContext) @@ -328,7 +335,7 @@ trait APIMethods400 { lazy val ibanChecker: OBPEndpoint = { case "account" :: "check" :: "scheme" :: "iban" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) val failMsg = s"$InvalidJsonFormat The Json body should be the ${prettyRender(Extraction.decompose(ibanCheckerPostJsonV400))}" for { ibanJson <- NewStyle.function.tryons(failMsg, 400, cc.callContext) { @@ -376,7 +383,7 @@ trait APIMethods400 { lazy val getDoubleEntryTransaction : OBPEndpoint = { case "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: ViewId(viewId) :: "transactions" :: TransactionId(transactionId) :: "double-entry-transaction" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (user @Full(u), _, account, view, callContext) <- SS.userBankAccountView (_, callContext) <- NewStyle.function.getTransaction(bankId, accountId, transactionId, cc.callContext) @@ -412,7 +419,7 @@ trait APIMethods400 { lazy val getBalancingTransaction : OBPEndpoint = { case "transactions" :: TransactionId(transactionId) :: "balancing-transaction" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (doubleEntryTransaction, callContext) <- NewStyle.function.getBalancingTransaction(transactionId, cc.callContext) _ <- NewStyle.function.checkBalancingTransactionAccountAccessAndReturnView(doubleEntryTransaction, cc.user, cc.callContext) @@ -469,7 +476,7 @@ trait APIMethods400 { lazy val createSettlementAccount: OBPEndpoint = { case "banks" :: BankId(bankId) :: "settlement-accounts" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) val failMsg = s"$InvalidJsonFormat The Json body should be the ${prettyRender(Extraction.decompose(settlementAccountRequestJson))}" for { createAccountJson <- NewStyle.function.tryons(failMsg, 400, cc.callContext) { @@ -570,7 +577,7 @@ trait APIMethods400 { lazy val getSettlementAccounts: OBPEndpoint = { case "banks" :: BankId(bankId) :: "settlement-accounts" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { _ <- NewStyle.function.hasEntitlement(bankId.value, cc.userId, canGetSettlementAccountAtOneBank, cc.callContext) @@ -1366,7 +1373,7 @@ trait APIMethods400 { lazy val createTransactionRequestAccount: OBPEndpoint = { case "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: ViewId(viewId) :: "transaction-request-types" :: "ACCOUNT" :: "transaction-requests" :: Nil JsonPost json -> _ => - cc => + cc => implicit val ec = EndpointContext(Some(cc)) val transactionRequestType = TransactionRequestType("ACCOUNT") createTransactionRequest(bankId, accountId, viewId , transactionRequestType, json) } @@ -1374,7 +1381,7 @@ trait APIMethods400 { lazy val createTransactionRequestAccountOtp: OBPEndpoint = { case "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: ViewId(viewId) :: "transaction-request-types" :: "ACCOUNT_OTP" :: "transaction-requests" :: Nil JsonPost json -> _ => - cc => + cc => implicit val ec = EndpointContext(Some(cc)) val transactionRequestType = TransactionRequestType("ACCOUNT_OTP") createTransactionRequest(bankId, accountId, viewId , transactionRequestType, json) } @@ -1382,7 +1389,7 @@ trait APIMethods400 { lazy val createTransactionRequestSepa: OBPEndpoint = { case "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: ViewId(viewId) :: "transaction-request-types" :: "SEPA" :: "transaction-requests" :: Nil JsonPost json -> _ => - cc => + cc => implicit val ec = EndpointContext(Some(cc)) val transactionRequestType = TransactionRequestType("SEPA") createTransactionRequest(bankId, accountId, viewId , transactionRequestType, json) } @@ -1390,7 +1397,7 @@ trait APIMethods400 { lazy val createTransactionRequestCounterparty: OBPEndpoint = { case "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: ViewId(viewId) :: "transaction-request-types" :: "COUNTERPARTY" :: "transaction-requests" :: Nil JsonPost json -> _ => - cc => + cc => implicit val ec = EndpointContext(Some(cc)) val transactionRequestType = TransactionRequestType("COUNTERPARTY") createTransactionRequest(bankId, accountId, viewId , transactionRequestType, json) } @@ -1398,7 +1405,7 @@ trait APIMethods400 { lazy val createTransactionRequestRefund: OBPEndpoint = { case "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: ViewId(viewId) :: "transaction-request-types" :: "REFUND" :: "transaction-requests" :: Nil JsonPost json -> _ => - cc => + cc => implicit val ec = EndpointContext(Some(cc)) val transactionRequestType = TransactionRequestType("REFUND") createTransactionRequest(bankId, accountId, viewId , transactionRequestType, json) } @@ -1406,7 +1413,7 @@ trait APIMethods400 { lazy val createTransactionRequestFreeForm: OBPEndpoint = { case "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: ViewId(viewId) :: "transaction-request-types" :: "FREE_FORM" :: "transaction-requests" :: Nil JsonPost json -> _ => - cc => + cc => implicit val ec = EndpointContext(Some(cc)) val transactionRequestType = TransactionRequestType("FREE_FORM") createTransactionRequest(bankId, accountId, viewId , transactionRequestType, json) } @@ -1414,7 +1421,7 @@ trait APIMethods400 { lazy val createTransactionRequestSimple: OBPEndpoint = { case "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: ViewId(viewId) :: "transaction-request-types" :: "SIMPLE" :: "transaction-requests" :: Nil JsonPost json -> _ => - cc => + cc => implicit val ec = EndpointContext(Some(cc)) val transactionRequestType = TransactionRequestType("SIMPLE") createTransactionRequest(bankId, accountId, viewId , transactionRequestType, json) } @@ -1460,7 +1467,7 @@ trait APIMethods400 { lazy val createTransactionRequestCard: OBPEndpoint = { case "transaction-request-types" :: "CARD" :: "transaction-requests" :: Nil JsonPost json -> _ => - cc => + cc => implicit val ec = EndpointContext(Some(cc)) val transactionRequestType = TransactionRequestType("CARD") createTransactionRequest(BankId(""), AccountId(""), ViewId("owner"), transactionRequestType, json) } @@ -1535,7 +1542,7 @@ trait APIMethods400 { lazy val answerTransactionRequestChallenge: OBPEndpoint = { case "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: ViewId(viewId) :: "transaction-request-types" :: TransactionRequestType(transactionRequestType) :: "transaction-requests" :: TransactionRequestId(transReqId) :: "challenge" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (user @Full(u), _, fromAccount, callContext) <- SS.userBankAccount _ <- NewStyle.function.isEnabledTransactionRequests(callContext) @@ -1687,7 +1694,7 @@ trait APIMethods400 { lazy val createTransactionRequestAttribute : OBPEndpoint = { case "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: "transaction-requests" :: TransactionRequestId(transactionRequestId) :: "attribute" :: Nil JsonPost json -> _=> { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) val failMsg = s"$InvalidJsonFormat The Json body should be the $transactionRequestAttributeJsonV400 " for { (_, callContext) <- NewStyle.function.getTransactionRequestImpl(transactionRequestId, cc.callContext) @@ -1742,7 +1749,7 @@ trait APIMethods400 { lazy val getTransactionRequestAttributeById : OBPEndpoint = { case "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: "transaction-requests" :: TransactionRequestId(transactionRequestId) :: "attributes" :: transactionRequestAttributeId :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (_, callContext) <- NewStyle.function.getTransactionRequestImpl(transactionRequestId, cc.callContext) (transactionRequestAttribute, callContext) <- NewStyle.function.getTransactionRequestAttributeById( @@ -1783,7 +1790,7 @@ trait APIMethods400 { lazy val getTransactionRequestAttributes : OBPEndpoint = { case "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: "transaction-requests" :: TransactionRequestId(transactionRequestId) :: "attributes" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (_, callContext) <- NewStyle.function.getTransactionRequestImpl(transactionRequestId, cc.callContext) (transactionRequestAttribute, callContext) <- NewStyle.function.getTransactionRequestAttributes( @@ -1825,7 +1832,7 @@ trait APIMethods400 { lazy val updateTransactionRequestAttribute : OBPEndpoint = { case "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: "transaction-requests" :: TransactionRequestId(transactionRequestId) :: "attributes" :: transactionRequestAttributeId :: Nil JsonPut json -> _=> { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) val failMsg = s"$InvalidJsonFormat The Json body should be the $TransactionRequestAttributeJsonV400" for { (_, callContext) <- NewStyle.function.getTransactionRequestImpl(transactionRequestId, cc.callContext) @@ -1883,7 +1890,7 @@ trait APIMethods400 { lazy val createOrUpdateTransactionRequestAttributeDefinition : OBPEndpoint = { case "banks" :: BankId(bankId) :: "attribute-definitions" :: "transaction-request" :: Nil JsonPut json -> _=> { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) val failMsg = s"$InvalidJsonFormat The Json body should be the $AttributeDefinitionJsonV400 " for { postedData <- NewStyle.function.tryons(failMsg, 400, cc.callContext) { @@ -1941,7 +1948,7 @@ trait APIMethods400 { lazy val getTransactionRequestAttributeDefinition : OBPEndpoint = { case "banks" :: BankId(bankId) :: "attribute-definitions" :: "transaction-request" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (attributeDefinitions, callContext) <- getAttributeDefinition( AttributeCategory.withName(AttributeCategory.TransactionRequest.toString), @@ -1978,7 +1985,7 @@ trait APIMethods400 { lazy val deleteTransactionRequestAttributeDefinition : OBPEndpoint = { case "banks" :: BankId(bankId) :: "attribute-definitions" :: attributeDefinitionId :: "transaction-request" :: Nil JsonDelete _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (deleted, callContext) <- deleteAttributeDefinition( attributeDefinitionId, @@ -2016,7 +2023,7 @@ trait APIMethods400 { lazy val getSystemDynamicEntities: OBPEndpoint = { case "management" :: "system-dynamic-entities" :: Nil JsonGet req => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { dynamicEntities <- Future(NewStyle.function.getDynamicEntities(None, false)) } yield { @@ -2052,7 +2059,7 @@ trait APIMethods400 { lazy val getBankLevelDynamicEntities: OBPEndpoint = { case "management" :: "banks" :: bankId :: "dynamic-entities" :: Nil JsonGet req => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { dynamicEntities <- Future(NewStyle.function.getDynamicEntities(Some(bankId),false)) } yield { @@ -2120,7 +2127,7 @@ trait APIMethods400 { lazy val createSystemDynamicEntity: OBPEndpoint = { case "management" :: "system-dynamic-entities" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) val dynamicEntity = DynamicEntityCommons(json.asInstanceOf[JObject], None, cc.userId, None) createDynamicEntityMethod(cc, dynamicEntity) } @@ -2164,7 +2171,7 @@ trait APIMethods400 { Some(List(canCreateBankLevelDynamicEntity))) lazy val createBankLevelDynamicEntity: OBPEndpoint = { case "management" ::"banks" :: BankId(bankId) :: "dynamic-entities" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) val dynamicEntity = DynamicEntityCommons(json.asInstanceOf[JObject], None, cc.userId, Some(bankId.value)) createDynamicEntityMethod(cc, dynamicEntity) } @@ -2229,7 +2236,7 @@ trait APIMethods400 { Some(List(canUpdateSystemDynamicEntity))) lazy val updateSystemDynamicEntity: OBPEndpoint = { case "management" :: "system-dynamic-entities" :: dynamicEntityId :: Nil JsonPut json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) updateDynamicEntityMethod(None, dynamicEntityId, json, cc) } } @@ -2272,7 +2279,7 @@ trait APIMethods400 { Some(List(canUpdateBankLevelDynamicEntity))) lazy val updateBankLevelDynamicEntity: OBPEndpoint = { case "management" :: "banks" :: bankId :: "dynamic-entities" :: dynamicEntityId :: Nil JsonPut json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) updateDynamicEntityMethod(Some(bankId),dynamicEntityId, json, cc) } } @@ -2298,7 +2305,7 @@ trait APIMethods400 { Some(List(canDeleteSystemLevelDynamicEntity))) lazy val deleteSystemDynamicEntity: OBPEndpoint = { case "management" :: "system-dynamic-entities" :: dynamicEntityId :: Nil JsonDelete _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) deleteDynamicEntityMethod(None, dynamicEntityId, cc) } } @@ -2340,7 +2347,7 @@ trait APIMethods400 { Some(List(canDeleteBankLevelDynamicEntity))) lazy val deleteBankLevelDynamicEntity: OBPEndpoint = { case "management" :: "banks" :: bankId :: "dynamic-entities" :: dynamicEntityId :: Nil JsonDelete _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) deleteDynamicEntityMethod(Some(bankId), dynamicEntityId, cc) } } @@ -2367,7 +2374,7 @@ trait APIMethods400 { lazy val getMyDynamicEntities: OBPEndpoint = { case "my" :: "dynamic-entities" :: Nil JsonGet req => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { dynamicEntities <- Future(NewStyle.function.getDynamicEntitiesByUserId(cc.userId)) } yield { @@ -2416,7 +2423,7 @@ trait APIMethods400 { lazy val updateMyDynamicEntity: OBPEndpoint = { case "my" :: "dynamic-entities" :: dynamicEntityId :: Nil JsonPut json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { dynamicEntities <- Future(NewStyle.function.getDynamicEntitiesByUserId(cc.userId)) entityOption = dynamicEntities.find(_.dynamicEntityId.equals(Some(dynamicEntityId))) @@ -2460,7 +2467,7 @@ trait APIMethods400 { lazy val deleteMyDynamicEntity: OBPEndpoint = { case "my" :: "dynamic-entities" :: dynamicEntityId :: Nil JsonDelete _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { dynamicEntities <- Future(NewStyle.function.getDynamicEntitiesByUserId(cc.userId)) entityOption = dynamicEntities.find(_.dynamicEntityId.equals(Some(dynamicEntityId))) @@ -2516,7 +2523,7 @@ trait APIMethods400 { lazy val resetPasswordUrl : OBPEndpoint = { case "management" :: "user" :: "reset-password-url" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { _ <- Helper.booleanToFuture(failMsg = ErrorMessages.NotAllowedEndpoint, cc=cc.callContext) { APIUtil.getPropsAsBoolValue("ResetPasswordUrlEnabled", false) @@ -2571,7 +2578,8 @@ trait APIMethods400 { lazy val addAccount : OBPEndpoint = { // Create a new account case "banks" :: BankId(bankId) :: "accounts" :: Nil JsonPost json -> _ => { - cc =>{ + cc => { + implicit val ec = EndpointContext(Some(cc)) val failMsg = s"$InvalidJsonFormat The Json body should be the ${prettyRender(Extraction.decompose(createAccountRequestJsonV310))} " for { createAccountJson <- NewStyle.function.tryons(failMsg, 400, cc.callContext) { @@ -2695,9 +2703,11 @@ trait APIMethods400 { def root (apiVersion : ApiVersion, apiVersionStatus: String): OBPEndpoint = { case (Nil | "root" :: Nil) JsonGet _ => { - cc => Future { - getApiInfoJSON(apiVersion, apiVersionStatus) -> HttpCode.`200`(cc.callContext) - } + cc => + implicit val ec = EndpointContext(Some(cc)) + Future { + getApiInfoJSON(apiVersion, apiVersionStatus) -> HttpCode.`200`(cc.callContext) + } } } @@ -2720,7 +2730,9 @@ trait APIMethods400 { lazy val getCallContext: OBPEndpoint = { case "development" :: "call_context" :: Nil JsonGet _ => { - cc => Future{ + cc => + implicit val ec = EndpointContext(Some(cc)) + Future{ (cc.callContext, HttpCode.`200`(cc.callContext)) } } @@ -2744,7 +2756,9 @@ trait APIMethods400 { lazy val verifyRequestSignResponse: OBPEndpoint = { case "development" :: "echo":: "jws-verified-request-jws-signed-response" :: Nil JsonGet _ => { - cc => Future{ + cc => + implicit val ec = EndpointContext(Some(cc)) + Future{ (cc.callContext, HttpCode.`200`(cc.callContext)) } } @@ -2772,7 +2786,7 @@ trait APIMethods400 { lazy val updateAccountLabel : OBPEndpoint = { case "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), account, callContext) <- SS.userAccount failMsg = s"$InvalidJsonFormat The Json body should be the $InvalidJsonFormat " @@ -2820,7 +2834,7 @@ trait APIMethods400 { lazy val lockUser : OBPEndpoint = { case "users" :: username :: "locks" :: Nil JsonPost req => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- SS.user userLocks <- Future { UserLocksProvider.lockUser(localIdentityProvider,username) } map { @@ -2882,7 +2896,7 @@ trait APIMethods400 { lazy val createUserWithRoles: OBPEndpoint = { case "user-entitlements" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(loggedInUser), callContext) <- authenticatedAccess(cc) failMsg = s"$InvalidJsonFormat The Json body should be the $PostCreateUserWithRolesJsonV400 " @@ -2945,7 +2959,7 @@ trait APIMethods400 { lazy val getEntitlements: OBPEndpoint = { case "users" :: userId :: "entitlements" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { entitlements <- NewStyle.function.getEntitlementsByUserId(userId, cc.callContext) } yield { @@ -2984,7 +2998,7 @@ trait APIMethods400 { lazy val getEntitlementsForBank: OBPEndpoint = { case "banks" :: bankId :: "entitlements" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { entitlements <- NewStyle.function.getEntitlementsByBankId(bankId, cc.callContext) } yield { @@ -3022,7 +3036,7 @@ trait APIMethods400 { lazy val addTagForViewOnAccount : OBPEndpoint = { //add a tag case "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: ViewId(viewId) :: "metadata" :: "tags" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (user @Full(u), _, account, view, callContext) <- SS.userBankAccountView _ <- Helper.booleanToFuture(failMsg = s"$NoViewPermission can_add_tag. Current ViewId($viewId)", cc=callContext) { @@ -3066,7 +3080,7 @@ trait APIMethods400 { lazy val deleteTagForViewOnAccount : OBPEndpoint = { //delete a tag case "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: ViewId(viewId) :: "metadata" :: "tags" :: tagId :: Nil JsonDelete _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (user @Full(u), _, account, view, callContext) <- SS.userBankAccountView _ <- Helper.booleanToFuture(failMsg = s"$NoViewPermission can_delete_tag. Current ViewId($viewId)", cc=callContext) { @@ -3108,7 +3122,7 @@ trait APIMethods400 { lazy val getTagsForViewOnAccount : OBPEndpoint = { //get tags case "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: ViewId(viewId) :: "metadata" :: "tags" :: Nil JsonGet req => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (user @Full(u), _, account, view, callContext) <- SS.userBankAccountView _ <- Helper.booleanToFuture(failMsg = s"$NoViewPermission can_see_tags. Current ViewId($viewId)", cc=callContext) { @@ -3155,7 +3169,7 @@ trait APIMethods400 { lazy val getCoreAccountById : OBPEndpoint = { //get account by id (assume owner view requested) case "my" :: "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: "account" :: Nil JsonGet req => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (user @Full(u), account, callContext) <- SS.userAccount view <- NewStyle.function.checkOwnerViewAccessAndReturnOwnerView(u, BankIdAccountId(account.bankId, account.accountId), callContext) @@ -3203,7 +3217,7 @@ trait APIMethods400 { ) lazy val getPrivateAccountByIdFull : OBPEndpoint = { case "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: ViewId(viewId) :: "account" :: Nil JsonGet req => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (user @Full(u), _, account, view, callContext) <- SS.userBankAccountView moderatedAccount <- NewStyle.function.moderatedBankAccountCore(account, view, user, callContext) @@ -3248,7 +3262,7 @@ trait APIMethods400 { ) lazy val getAccountByAccountRouting : OBPEndpoint = { case "management" :: "accounts" :: "account-routing-query" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) val failMsg = s"$InvalidJsonFormat The Json body should be the $accountRoutingJsonV121" for { postJson <- NewStyle.function.tryons(failMsg, 400, cc.callContext) { @@ -3320,7 +3334,7 @@ trait APIMethods400 { ) lazy val getAccountsByAccountRoutingRegex : OBPEndpoint = { case "management" :: "accounts" :: "account-routing-regex-query" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) val failMsg = s"$InvalidJsonFormat The Json body should be the $accountRoutingJsonV121" for { postJson <- NewStyle.function.tryons(failMsg, 400, cc.callContext) { @@ -3371,7 +3385,7 @@ trait APIMethods400 { lazy val getBankAccountsBalances : OBPEndpoint = { case "banks" :: BankId(bankId) :: "balances" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- SS.user availablePrivateAccounts <- Views.views.vend.getPrivateBankAccountsFuture(u, bankId) @@ -3398,7 +3412,7 @@ trait APIMethods400 { lazy val getBankAccountBalances : OBPEndpoint = { case "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: "balances" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- SS.user availablePrivateAccounts <- Views.views.vend.getPrivateBankAccountsFuture(u, bankId) @@ -3451,7 +3465,7 @@ trait APIMethods400 { lazy val getFirehoseAccountsAtOneBank : OBPEndpoint = { //get private accounts for all banks case "banks" :: BankId(bankId):: "firehose" :: "accounts" :: "views" :: ViewId(viewId):: Nil JsonGet req => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), bank, callContext) <- SS.userBank _ <- Helper.booleanToFuture(failMsg = AccountFirehoseNotAllowedOnThisInstance, cc=cc.callContext) { @@ -3533,7 +3547,7 @@ trait APIMethods400 { lazy val getFastFirehoseAccountsAtOneBank : OBPEndpoint = { //get private accounts for all banks case "management":: "banks" :: BankId(bankId):: "fast-firehose" :: "accounts" :: Nil JsonGet req => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), bank, callContext) <- SS.userBank _ <- Helper.booleanToFuture(failMsg = AccountFirehoseNotAllowedOnThisInstance, cc=cc.callContext) { @@ -3576,7 +3590,7 @@ trait APIMethods400 { lazy val getCustomersByCustomerPhoneNumber : OBPEndpoint = { case "banks" :: BankId(bankId) :: "search" :: "customers" :: "mobile-phone-number" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) val failMsg = s"$InvalidJsonFormat The Json body should be the $PostCustomerPhoneNumberJsonV400 " for { postedData <- NewStyle.function.tryons(failMsg, 400, cc.callContext) { @@ -3608,6 +3622,7 @@ trait APIMethods400 { lazy val getCurrentUserId: OBPEndpoint = { case "users" :: "current" :: "user_id" :: Nil JsonGet _ => { cc => { + implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) } yield { @@ -3639,7 +3654,7 @@ trait APIMethods400 { lazy val getUserByUserId: OBPEndpoint = { case "users" :: "user_id" :: userId :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { user <- Users.users.vend.getUserByUserIdFuture(userId) map { x => unboxFullOrFail(x, cc.callContext, s"$UserNotFoundByUserId Current UserId($userId)") @@ -3679,7 +3694,7 @@ trait APIMethods400 { lazy val getUserByUsername: OBPEndpoint = { case "users" :: "username" :: username :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { user <- Users.users.vend.getUserByProviderAndUsernameFuture(Constant.localIdentityProvider, username) map { x => unboxFullOrFail(x, cc.callContext, UserNotFoundByProviderAndUsername, 404) @@ -3715,7 +3730,7 @@ trait APIMethods400 { lazy val getUsersByEmail: OBPEndpoint = { case "users" :: "email" :: email :: "terminator" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { users <- Users.users.vend.getUsersByEmail(email) } yield { @@ -3753,7 +3768,7 @@ trait APIMethods400 { lazy val getUsers: OBPEndpoint = { case "users" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { httpParams <- NewStyle.function.extractHttpParamsFromUrl(cc.url) (obpQueryParams, callContext) <- createQueriesByHttpParamsFuture(httpParams, cc.callContext) @@ -3806,7 +3821,7 @@ trait APIMethods400 { lazy val createUserInvitation : OBPEndpoint = { case "banks" :: BankId(bankId) :: "user-invitation" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) val failMsg = s"$InvalidJsonFormat The Json body should be the $PostUserInvitationJsonV400 " for { postedData <- NewStyle.function.tryons(failMsg, 400, cc.callContext) { @@ -3875,7 +3890,7 @@ trait APIMethods400 { lazy val getUserInvitationAnonymous : OBPEndpoint = { case "banks" :: BankId(bankId) :: "user-invitations" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) val failMsg = s"$InvalidJsonFormat The Json body should be the $PostUserInvitationAnonymousJsonV400 " for { postedData <- NewStyle.function.tryons(failMsg, 400, cc.callContext) { @@ -3923,7 +3938,7 @@ trait APIMethods400 { lazy val getUserInvitation : OBPEndpoint = { case "banks" :: BankId(bankId) :: "user-invitations" :: secretLink :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (invitation, callContext) <- NewStyle.function.getUserInvitation(bankId, secretLink.toLong, cc.callContext) } yield { @@ -3958,7 +3973,7 @@ trait APIMethods400 { lazy val getUserInvitations : OBPEndpoint = { case "banks" :: BankId(bankId) :: "user-invitations" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (invitations, callContext) <- NewStyle.function.getUserInvitations(bankId, cc.callContext) } yield { @@ -3993,7 +4008,7 @@ trait APIMethods400 { lazy val deleteUser : OBPEndpoint = { case "users" :: userId :: Nil JsonDelete _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (user, callContext) <- NewStyle.function.findByUserId(userId, cc.callContext) (userDeleted, callContext) <- NewStyle.function.deleteUser(user.userPrimaryKey, callContext) @@ -4038,7 +4053,7 @@ trait APIMethods400 { lazy val createBank: OBPEndpoint = { case "banks" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) val failMsg = s"$InvalidJsonFormat The Json body should be the $BankJson400 " for { bank <- NewStyle.function.tryons(failMsg, 400, cc.callContext) { @@ -4124,7 +4139,7 @@ trait APIMethods400 { lazy val createDirectDebit : OBPEndpoint = { case "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: ViewId(viewId) :: "direct-debit" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (user @Full(u), _, account, view, callContext) <- SS.userBankAccountView _ <- Helper.booleanToFuture(failMsg = s"$NoViewPermission can_create_direct_debit. Current ViewId($viewId)", cc=callContext) { @@ -4184,7 +4199,7 @@ trait APIMethods400 { lazy val createDirectDebitManagement : OBPEndpoint = { case "management" :: "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: "direct-debit" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) val failMsg = s"$InvalidJsonFormat The Json body should be the $PostDirectDebitJsonV400 " for { postJson <- NewStyle.function.tryons(failMsg, 400, cc.callContext) { @@ -4243,7 +4258,7 @@ trait APIMethods400 { lazy val createStandingOrder : OBPEndpoint = { case "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: ViewId(viewId) :: "standing-order" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (user @Full(u), _, account, view, callContext) <- SS.userBankAccountView _ <- Helper.booleanToFuture(failMsg = s"$NoViewPermission can_create_standing_order. Current ViewId($viewId)", cc=callContext) { @@ -4318,7 +4333,7 @@ trait APIMethods400 { lazy val createStandingOrderManagement : OBPEndpoint = { case "management" :: "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: "standing-order" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) val failMsg = s"$InvalidJsonFormat The Json body should be the $PostStandingOrderJsonV400 " for { postJson <- NewStyle.function.tryons(failMsg, 400, cc.callContext) { @@ -4386,7 +4401,7 @@ trait APIMethods400 { lazy val grantUserAccessToView : OBPEndpoint = { //add access for specific user to a specific system view case "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: "account-access" :: "grant" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) val failMsg = s"$InvalidJsonFormat The Json body should be the $PostAccountAccessJsonV400 " for { (Full(u), callContext) <- SS.user @@ -4443,7 +4458,7 @@ trait APIMethods400 { lazy val createUserWithAccountAccess : OBPEndpoint = { case "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: "user-account-access" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) val failMsg = s"$InvalidJsonFormat The Json body should be the $PostCreateUserAccountAccessJsonV400 " for { (Full(u), callContext) <- SS.user @@ -4498,7 +4513,7 @@ trait APIMethods400 { lazy val revokeUserAccessToView : OBPEndpoint = { //add access for specific user to a specific system view case "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: "account-access" :: "revoke" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) val failMsg = s"$InvalidJsonFormat The Json body should be the $PostAccountAccessJsonV400 " for { (Full(u), callContext) <- SS.user @@ -4553,7 +4568,7 @@ trait APIMethods400 { lazy val revokeGrantUserAccessToViews : OBPEndpoint = { case "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: "account-access" :: Nil JsonPut json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) val failMsg = s"$InvalidJsonFormat The Json body should be the $PostAccountAccessJsonV400 " for { (Full(u), callContext) <- SS.user @@ -4604,7 +4619,7 @@ trait APIMethods400 { lazy val createCustomerAttribute : OBPEndpoint = { case "banks" :: bankId :: "customers" :: customerId :: "attribute" :: Nil JsonPost json -> _=> { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) val failMsg = s"$InvalidJsonFormat The Json body should be the $CustomerAttributeJsonV400 " for { postedData <- NewStyle.function.tryons(failMsg, 400, cc.callContext) { @@ -4659,7 +4674,7 @@ trait APIMethods400 { lazy val updateCustomerAttribute : OBPEndpoint = { case "banks" :: bankId :: "customers" :: customerId :: "attributes" :: customerAttributeId :: Nil JsonPut json -> _=> { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) val failMsg = s"$InvalidJsonFormat The Json body should be the $CustomerAttributeJsonV400" for { postedData <- NewStyle.function.tryons(failMsg, 400, cc.callContext) { @@ -4717,7 +4732,7 @@ trait APIMethods400 { lazy val getCustomerAttributes : OBPEndpoint = { case "banks" :: bankId :: "customers" :: customerId :: "attributes" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (customer, callContext) <- NewStyle.function.getCustomerByCustomerId(customerId, cc.callContext) _ <- Helper.booleanToFuture(InvalidCustomerBankId.replaceAll("Bank Id.",s"Bank Id ($bankId).").replaceAll("The Customer",s"The Customer($customerId)"), cc=callContext){customer.bankId == bankId} @@ -4758,7 +4773,7 @@ trait APIMethods400 { lazy val getCustomerAttributeById : OBPEndpoint = { case "banks" :: bankId :: "customers" :: customerId :: "attributes" :: customerAttributeId ::Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (customer, callContext) <- NewStyle.function.getCustomerByCustomerId(customerId, cc.callContext) _ <- Helper.booleanToFuture(InvalidCustomerBankId.replaceAll("Bank Id.",s"Bank Id ($bankId).").replaceAll("The Customer",s"The Customer($customerId)"), cc=callContext){customer.bankId == bankId} @@ -4803,7 +4818,7 @@ trait APIMethods400 { lazy val getCustomersByAttributes : OBPEndpoint = { case "banks" :: BankId(bankId) :: "customers" :: Nil JsonGet req => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (customerIds, callContext) <- NewStyle.function.getCustomerIdsByAttributeNameValues(bankId, req.params, Some(cc)) list: List[CustomerWithAttributesJsonV310] <- { @@ -4854,7 +4869,7 @@ trait APIMethods400 { lazy val createTransactionAttribute : OBPEndpoint = { case "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: "transactions" :: TransactionId(transactionId) :: "attribute" :: Nil JsonPost json -> _=> { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) val failMsg = s"$InvalidJsonFormat The Json body should be the $TransactionAttributeJsonV400 " for { (_, callContext) <- NewStyle.function.getTransaction(bankId, accountId, transactionId, cc.callContext) @@ -4909,7 +4924,7 @@ trait APIMethods400 { lazy val updateTransactionAttribute : OBPEndpoint = { case "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: "transactions" :: TransactionId(transactionId) :: "attributes" :: transactionAttributeId :: Nil JsonPut json -> _=> { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) val failMsg = s"$InvalidJsonFormat The Json body should be the $TransactionAttributeJsonV400" for { (_, callContext) <- NewStyle.function.getTransaction(bankId, accountId, transactionId, cc.callContext) @@ -4964,7 +4979,7 @@ trait APIMethods400 { lazy val getTransactionAttributes : OBPEndpoint = { case "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: "transactions" :: TransactionId(transactionId) :: "attributes" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (_, callContext) <- NewStyle.function.getTransaction(bankId, accountId, transactionId, cc.callContext) (accountAttribute, callContext) <- NewStyle.function.getTransactionAttributes( @@ -5005,7 +5020,7 @@ trait APIMethods400 { lazy val getTransactionAttributeById : OBPEndpoint = { case "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: "transactions" :: TransactionId(transactionId) :: "attributes" :: transactionAttributeId :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (_, callContext) <- NewStyle.function.getTransaction(bankId, accountId, transactionId, cc.callContext) (accountAttribute, callContext) <- NewStyle.function.getTransactionAttributeById( @@ -5066,7 +5081,7 @@ trait APIMethods400 { lazy val createHistoricalTransactionAtBank : OBPEndpoint = { case "banks" :: BankId(bankId) :: "management" :: "historical" :: "transactions" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) _ <- NewStyle.function.hasEntitlement(bankId.value, u.userId, ApiRole.canCreateHistoricalTransactionAtBank, callContext) @@ -5168,7 +5183,7 @@ trait APIMethods400 { lazy val getTransactionRequest: OBPEndpoint = { case "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: ViewId(viewId) :: "transaction-requests" :: TransactionRequestId(requestId) :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (user @Full(u), _, account, view, callContext) <- SS.userBankAccountView _ <- NewStyle.function.isEnabledTransactionRequests(callContext) @@ -5213,7 +5228,7 @@ trait APIMethods400 { lazy val getPrivateAccountsAtOneBank: OBPEndpoint = { case "banks" :: BankId(bankId) :: "accounts" :: Nil JsonGet req => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), bank, callContext) <- SS.userBank (privateViewsUserCanAccessAtOneBank, privateAccountAccess) = Views.views.vend.privateViewsUserCanAccessAtBank(u, bankId) @@ -5274,7 +5289,7 @@ trait APIMethods400 { lazy val createConsumer: OBPEndpoint = { case "management" :: "consumers" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- SS.user postedJson <- NewStyle.function.tryons(InvalidJsonFormat, 400, callContext) { @@ -5331,6 +5346,7 @@ trait APIMethods400 { lazy val getCustomersAtAnyBank : OBPEndpoint = { case "customers" :: Nil JsonGet _ => { cc => { + implicit val ec = EndpointContext(Some(cc)) for { (requestParams, callContext) <- extractQueryParams(cc.url, List("limit","offset","sort_direction"), cc.callContext) (customers, callContext) <- getCustomersAtAllBanks(callContext, requestParams) @@ -5367,6 +5383,7 @@ trait APIMethods400 { lazy val getCustomersMinimalAtAnyBank : OBPEndpoint = { case "customers-minimal" :: Nil JsonGet _ => { cc => { + implicit val ec = EndpointContext(Some(cc)) for { (requestParams, callContext) <- extractQueryParams(cc.url, List("limit","offset","sort_direction"), cc.callContext) (customers, callContext) <- getCustomersAtAllBanks(callContext, requestParams) @@ -5398,7 +5415,7 @@ trait APIMethods400 { lazy val getScopes: OBPEndpoint = { case "consumers" :: uuidOfConsumer :: "scopes" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) consumer <- Future{callContext.get.consumer} map { @@ -5446,7 +5463,7 @@ trait APIMethods400 { lazy val addScope : OBPEndpoint = { case "consumers" :: consumerId :: "scopes" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) consumer <- NewStyle.function.getConsumerByConsumerId(consumerId, callContext) @@ -5513,7 +5530,7 @@ trait APIMethods400 { lazy val deleteCustomerAttribute : OBPEndpoint = { case "banks" :: bankId :: "customers" :: "attributes" :: customerAttributeId :: Nil JsonDelete _=> { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (customerAttribute, callContext) <- NewStyle.function.deleteCustomerAttribute(customerAttributeId, cc.callContext) } yield { @@ -5554,7 +5571,7 @@ trait APIMethods400 { lazy val createDynamicEndpoint: OBPEndpoint = { case "management" :: "dynamic-endpoints" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) createDynamicEndpointMethod(None, json, cc) } } @@ -5592,7 +5609,7 @@ trait APIMethods400 { lazy val createBankLevelDynamicEndpoint: OBPEndpoint = { case "management" :: "banks" :: BankId(bankId) ::"dynamic-endpoints" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) createDynamicEndpointMethod(Some(bankId.value), json, cc) } } @@ -5621,7 +5638,7 @@ trait APIMethods400 { lazy val updateDynamicEndpointHost: OBPEndpoint = { case "management" :: "dynamic-endpoints" :: dynamicEndpointId :: "host" :: Nil JsonPut json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) updateDynamicEndpointHostMethod(None, dynamicEndpointId, json, cc) } } @@ -5664,7 +5681,7 @@ trait APIMethods400 { lazy val updateBankLevelDynamicEndpointHost: OBPEndpoint = { case "management" :: "banks" :: bankId :: "dynamic-endpoints" :: dynamicEndpointId :: "host" :: Nil JsonPut json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) updateDynamicEndpointHostMethod(Some(bankId), dynamicEndpointId, json, cc) } } @@ -5696,7 +5713,7 @@ trait APIMethods400 { lazy val getDynamicEndpoint: OBPEndpoint = { case "management" :: "dynamic-endpoints" :: dynamicEndpointId :: Nil JsonGet req => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) getDynamicEndpointMethod(None, dynamicEndpointId, cc) } } @@ -5729,7 +5746,7 @@ trait APIMethods400 { lazy val getDynamicEndpoints: OBPEndpoint = { case "management" :: "dynamic-endpoints" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) getDynamicEndpointsMethod(None, cc) } } @@ -5770,7 +5787,7 @@ trait APIMethods400 { lazy val getBankLevelDynamicEndpoint: OBPEndpoint = { case "management" :: "banks" :: bankId :: "dynamic-endpoints" :: dynamicEndpointId :: Nil JsonGet req => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) getDynamicEndpointMethod(Some(bankId), dynamicEndpointId, cc) } } @@ -5814,7 +5831,7 @@ trait APIMethods400 { lazy val getBankLevelDynamicEndpoints: OBPEndpoint = { case "management" :: "banks" :: bankId :: "dynamic-endpoints" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) getDynamicEndpointsMethod(Some(bankId), cc) } } @@ -5847,7 +5864,7 @@ trait APIMethods400 { lazy val deleteDynamicEndpoint : OBPEndpoint = { case "management" :: "dynamic-endpoints" :: dynamicEndpointId :: Nil JsonDelete _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) deleteDynamicEndpointMethod(None, dynamicEndpointId, cc) } } @@ -5873,7 +5890,7 @@ trait APIMethods400 { lazy val deleteBankLevelDynamicEndpoint : OBPEndpoint = { case "management" :: "banks" :: bankId :: "dynamic-endpoints" :: dynamicEndpointId :: Nil JsonDelete _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) deleteDynamicEndpointMethod(Some(bankId), dynamicEndpointId, cc) } } @@ -5901,7 +5918,7 @@ trait APIMethods400 { lazy val getMyDynamicEndpoints: OBPEndpoint = { case "my" :: "dynamic-endpoints" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (dynamicEndpoints, _) <- NewStyle.function.getDynamicEndpointsByUserId(cc.userId, cc.callContext) } yield { @@ -5934,7 +5951,7 @@ trait APIMethods400 { lazy val deleteMyDynamicEndpoint : OBPEndpoint = { case "my" :: "dynamic-endpoints" :: dynamicEndpointId :: Nil JsonDelete _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (dynamicEndpoint, callContext) <- NewStyle.function.getDynamicEndpoint(None, dynamicEndpointId, cc.callContext) _ <- Helper.booleanToFuture(InvalidMyDynamicEndpointUser, cc=callContext) { @@ -5977,7 +5994,7 @@ trait APIMethods400 { lazy val createOrUpdateCustomerAttributeAttributeDefinition : OBPEndpoint = { case "banks" :: BankId(bankId) :: "attribute-definitions" :: "customer" :: Nil JsonPut json -> _=> { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) val failMsg = s"$InvalidJsonFormat The Json body should be the $AttributeDefinitionJsonV400 " for { postedData <- NewStyle.function.tryons(failMsg, 400, cc.callContext) { @@ -6041,7 +6058,7 @@ trait APIMethods400 { lazy val createOrUpdateAccountAttributeDefinition : OBPEndpoint = { case "banks" :: BankId(bankId) :: "attribute-definitions" :: "account" :: Nil JsonPut json -> _=> { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) val failMsg = s"$InvalidJsonFormat The Json body should be the $AttributeDefinitionJsonV400 " for { postedData <- NewStyle.function.tryons(failMsg, 400, cc.callContext) { @@ -6104,7 +6121,7 @@ trait APIMethods400 { lazy val createOrUpdateProductAttributeDefinition : OBPEndpoint = { case "banks" :: BankId(bankId) :: "attribute-definitions" :: "product" :: Nil JsonPut json -> _=> { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) val failMsg = s"$InvalidJsonFormat The Json body should be the $AttributeDefinitionJsonV400 " for { postedData <- NewStyle.function.tryons(failMsg, 400, cc.callContext) { @@ -6191,7 +6208,7 @@ trait APIMethods400 { lazy val createProductAttribute : OBPEndpoint = { case "banks" :: bankId :: "products" :: productCode:: "attribute" :: Nil JsonPost json -> _=> { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) _ <- NewStyle.function.hasEntitlement(bankId, u.userId, canCreateProductAttribute, callContext) @@ -6253,7 +6270,7 @@ trait APIMethods400 { lazy val updateProductAttribute : OBPEndpoint = { case "banks" :: bankId :: "products" :: productCode:: "attributes" :: productAttributeId :: Nil JsonPut json -> _ =>{ - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) _ <- NewStyle.function.hasEntitlement(bankId, u.userId, canUpdateProductAttribute, callContext) @@ -6312,7 +6329,7 @@ trait APIMethods400 { lazy val getProductAttribute : OBPEndpoint = { case "banks" :: bankId :: "products" :: productCode:: "attributes" :: productAttributeId :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) _ <- NewStyle.function.hasEntitlement(bankId, u.userId, canGetProductAttribute, callContext) @@ -6351,7 +6368,7 @@ trait APIMethods400 { lazy val createProductFee : OBPEndpoint = { case "banks" :: bankId :: "products" :: productCode:: "fee" :: Nil JsonPost json -> _=> { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { postedData <- NewStyle.function.tryons(s"$InvalidJsonFormat The Json body should be the $ProductFeeJsonV400 " , 400, Some(cc)) { json.extract[ProductFeeJsonV400] @@ -6403,7 +6420,7 @@ trait APIMethods400 { lazy val updateProductFee : OBPEndpoint = { case "banks" :: bankId :: "products" :: productCode:: "fees" :: productFeeId :: Nil JsonPut json -> _ =>{ - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { postedData <- NewStyle.function.tryons(s"$InvalidJsonFormat The Json body should be the $ProductFeeJsonV400 ", 400, Some(cc)) { json.extract[ProductFeeJsonV400] @@ -6454,7 +6471,7 @@ trait APIMethods400 { lazy val getProductFee : OBPEndpoint = { case "banks" :: bankId :: "products" :: productCode:: "fees" :: productFeeId :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (_, callContext) <- getProductsIsPublic match { case false => authenticatedAccess(cc) @@ -6490,7 +6507,7 @@ trait APIMethods400 { lazy val getProductFees : OBPEndpoint = { case "banks" :: bankId :: "products" :: productCode:: "fees" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (_, callContext) <- getProductsIsPublic match { case false => authenticatedAccess(cc) @@ -6529,7 +6546,7 @@ trait APIMethods400 { lazy val deleteProductFee : OBPEndpoint = { case "banks" :: bankId :: "products" :: productCode:: "fees" :: productFeeId :: Nil JsonDelete _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (_, callContext) <- NewStyle.function.getProductFeeById(productFeeId, Some(cc)) (productFee, callContext) <- NewStyle.function.deleteProductFee(productFeeId, Some(cc)) @@ -6568,7 +6585,7 @@ trait APIMethods400 { lazy val createOrUpdateBankAttributeDefinition : OBPEndpoint = { case "banks" :: BankId(bankId) :: "attribute-definitions" :: "bank" :: Nil JsonPut json -> _=> { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) val failMsg = s"$InvalidJsonFormat The Json body should be the $AttributeDefinitionJsonV400 " for { postedData <- NewStyle.function.tryons(failMsg, 400, cc.callContext) { @@ -6643,7 +6660,7 @@ trait APIMethods400 { lazy val createBankAttribute : OBPEndpoint = { case "banks" :: bankId :: "attribute" :: Nil JsonPost json -> _=> { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) (_, callContext) <- NewStyle.function.getBank(BankId(bankId), callContext) @@ -6697,7 +6714,7 @@ trait APIMethods400 { lazy val getBankAttributes : OBPEndpoint = { case "banks" :: BankId(bankId) :: "attributes" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (attributes, callContext) <- NewStyle.function.getBankAttributesByBank(bankId, cc.callContext) } yield { @@ -6732,7 +6749,7 @@ trait APIMethods400 { lazy val getBankAttribute : OBPEndpoint = { case "banks" :: BankId(bankId) :: "attributes" :: bankAttributeId :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (attribute, callContext) <- NewStyle.function.getBankAttributeById(bankAttributeId, cc.callContext) } yield { @@ -6766,7 +6783,7 @@ trait APIMethods400 { lazy val updateBankAttribute : OBPEndpoint = { case "banks" :: bankId :: "attributes" :: bankAttributeId :: Nil JsonPut json -> _ =>{ - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) _ <- NewStyle.function.hasEntitlement(bankId, u.userId, canUpdateBankAttribute, callContext) @@ -6822,7 +6839,7 @@ trait APIMethods400 { lazy val deleteBankAttribute : OBPEndpoint = { case "banks" :: bankId :: "attributes" :: bankAttributeId :: Nil JsonDelete _=> { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) _ <- NewStyle.function.hasEntitlement(bankId, u.userId, canDeleteBankAttribute, callContext) @@ -6864,7 +6881,7 @@ trait APIMethods400 { lazy val createOrUpdateTransactionAttributeDefinition : OBPEndpoint = { case "banks" :: BankId(bankId) :: "attribute-definitions" :: "transaction" :: Nil JsonPut json -> _=> { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) val failMsg = s"$InvalidJsonFormat The Json body should be the $AttributeDefinitionJsonV400 " for { postedData <- NewStyle.function.tryons(failMsg, 400, cc.callContext) { @@ -6928,7 +6945,7 @@ trait APIMethods400 { lazy val createOrUpdateCardAttributeDefinition : OBPEndpoint = { case "banks" :: BankId(bankId) :: "attribute-definitions" :: "card" :: Nil JsonPut json -> _=> { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) val failMsg = s"$InvalidJsonFormat The Json body should be the $AttributeDefinitionJsonV400 " for { postedData <- NewStyle.function.tryons(failMsg, 400, cc.callContext) { @@ -6987,7 +7004,7 @@ trait APIMethods400 { lazy val deleteTransactionAttributeDefinition : OBPEndpoint = { case "banks" :: BankId(bankId) :: "attribute-definitions" :: attributeDefinitionId :: "transaction" :: Nil JsonDelete _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (deleted, callContext) <- deleteAttributeDefinition( attributeDefinitionId, @@ -7025,7 +7042,7 @@ trait APIMethods400 { lazy val deleteCustomerAttributeDefinition : OBPEndpoint = { case "banks" :: BankId(bankId) :: "attribute-definitions" :: attributeDefinitionId :: "customer" :: Nil JsonDelete _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (deleted, callContext) <- deleteAttributeDefinition( attributeDefinitionId, @@ -7063,7 +7080,7 @@ trait APIMethods400 { lazy val deleteAccountAttributeDefinition : OBPEndpoint = { case "banks" :: BankId(bankId) :: "attribute-definitions" :: attributeDefinitionId :: "account" :: Nil JsonDelete _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (deleted, callContext) <- deleteAttributeDefinition( attributeDefinitionId, @@ -7101,7 +7118,7 @@ trait APIMethods400 { lazy val deleteProductAttributeDefinition : OBPEndpoint = { case "banks" :: BankId(bankId) :: "attribute-definitions" :: attributeDefinitionId :: "product" :: Nil JsonDelete _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (deleted, callContext) <- deleteAttributeDefinition( attributeDefinitionId, @@ -7139,7 +7156,7 @@ trait APIMethods400 { lazy val deleteCardAttributeDefinition : OBPEndpoint = { case "banks" :: BankId(bankId) :: "attribute-definitions" :: attributeDefinitionId :: "card" :: Nil JsonDelete _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (deleted, callContext) <- deleteAttributeDefinition( attributeDefinitionId, @@ -7177,7 +7194,7 @@ trait APIMethods400 { lazy val getProductAttributeDefinition : OBPEndpoint = { case "banks" :: BankId(bankId) :: "attribute-definitions" :: "product" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (attributeDefinitions, callContext) <- getAttributeDefinition( AttributeCategory.withName(AttributeCategory.Product.toString), @@ -7214,7 +7231,7 @@ trait APIMethods400 { lazy val getCustomerAttributeDefinition : OBPEndpoint = { case "banks" :: BankId(bankId) :: "attribute-definitions" :: "customer" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (attributeDefinitions, callContext) <- getAttributeDefinition( AttributeCategory.withName(AttributeCategory.Customer.toString), @@ -7251,7 +7268,7 @@ trait APIMethods400 { lazy val getAccountAttributeDefinition : OBPEndpoint = { case "banks" :: BankId(bankId) :: "attribute-definitions" :: "account" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (attributeDefinitions, callContext) <- getAttributeDefinition( AttributeCategory.withName(AttributeCategory.Account.toString), @@ -7288,7 +7305,7 @@ trait APIMethods400 { lazy val getTransactionAttributeDefinition : OBPEndpoint = { case "banks" :: BankId(bankId) :: "attribute-definitions" :: "transaction" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (attributeDefinitions, callContext) <- getAttributeDefinition( AttributeCategory.withName(AttributeCategory.Transaction.toString), @@ -7326,7 +7343,7 @@ trait APIMethods400 { lazy val getCardAttributeDefinition : OBPEndpoint = { case "banks" :: BankId(bankId) :: "attribute-definitions" :: "card" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (attributeDefinitions, callContext) <- getAttributeDefinition( AttributeCategory.withName(AttributeCategory.Card.toString), @@ -7364,7 +7381,7 @@ trait APIMethods400 { lazy val deleteUserCustomerLink : OBPEndpoint = { case "banks" :: BankId(bankId) :: "user_customer_links" :: userCustomerLinkId :: Nil JsonDelete _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (deleted, callContext) <- UserCustomerLinkNewStyle.deleteUserCustomerLink( userCustomerLinkId, @@ -7401,7 +7418,7 @@ trait APIMethods400 { lazy val getUserCustomerLinksByUserId : OBPEndpoint = { case "banks" :: BankId(bankId) :: "user_customer_links" :: "users" :: userId :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (userCustomerLinks, callContext) <- UserCustomerLinkNewStyle.getUserCustomerLinksByUserId( userId, @@ -7443,7 +7460,7 @@ trait APIMethods400 { lazy val createUserCustomerLinks : OBPEndpoint = { case "banks" :: BankId(bankId):: "user_customer_links" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { _ <- NewStyle.function.tryons(s"$InvalidBankIdFormat", 400, cc.callContext) { assert(isValidID(bankId.value)) @@ -7500,7 +7517,7 @@ trait APIMethods400 { lazy val getUserCustomerLinksByCustomerId : OBPEndpoint = { case "banks" :: BankId(bankId) :: "user_customer_links" :: "customers" :: customerId :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (userCustomerLinks, callContext) <- getUserCustomerLinks(customerId, cc.callContext) } yield { @@ -7533,7 +7550,7 @@ trait APIMethods400 { lazy val getCorrelatedUsersInfoByCustomerId : OBPEndpoint = { case "banks" :: BankId(bankId) :: "customers" :: customerId :: "correlated-users" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (customer, callContext) <- NewStyle.function.getCustomerByCustomerId(customerId, cc.callContext) (userCustomerLinks, callContext) <- getUserCustomerLinks(customerId, callContext) @@ -7577,7 +7594,7 @@ trait APIMethods400 { lazy val getMyCorrelatedEntities : OBPEndpoint = { case "my" :: "correlated-entities" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- SS.user (userCustomerLinks, callContext) <- UserCustomerLinkNewStyle.getUserCustomerLinksByUserId( @@ -7629,7 +7646,7 @@ trait APIMethods400 { ) lazy val createCustomer : OBPEndpoint = { case "banks" :: BankId(bankId) :: "customers" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { postedData <- NewStyle.function.tryons(s"$InvalidJsonFormat The Json body should be the $PostCustomerJsonV310 ", 400, cc.callContext) { json.extract[PostCustomerJsonV310] @@ -7689,7 +7706,7 @@ trait APIMethods400 { lazy val getAccountsMinimalByCustomerId : OBPEndpoint = { case "customers" :: customerId :: "accounts-minimal" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (_, callContext) <- getCustomerByCustomerId(customerId, cc.callContext) (userCustomerLinks, callContext) <- getUserCustomerLinks(customerId, callContext) @@ -7729,7 +7746,7 @@ trait APIMethods400 { lazy val deleteTransactionCascade : OBPEndpoint = { case "management" :: "cascading" :: "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: "transactions" :: TransactionId(transactionId) :: Nil JsonDelete _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (_, callContext) <- NewStyle.function.getTransaction(bankId, accountId, transactionId, cc.callContext) _ <- Future(DeleteTransactionCascade.atomicDelete(bankId, accountId, transactionId)) @@ -7766,7 +7783,7 @@ trait APIMethods400 { lazy val deleteAccountCascade : OBPEndpoint = { case "management" :: "cascading" :: "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: Nil JsonDelete _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { result <- Future(DeleteAccountCascade.atomicDelete(bankId, accountId)) } yield { @@ -7804,7 +7821,7 @@ trait APIMethods400 { lazy val deleteBankCascade : OBPEndpoint = { case "management" :: "cascading" :: "banks" :: BankId(bankId) :: Nil JsonDelete _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { _ <- Future(DeleteBankCascade.atomicDelete(bankId)) } yield { @@ -7840,7 +7857,7 @@ trait APIMethods400 { lazy val deleteProductCascade : OBPEndpoint = { case "management" :: "cascading" :: "banks" :: BankId(bankId) :: "products" :: ProductCode(code) :: Nil JsonDelete _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (_, callContext) <- NewStyle.function.getProduct(bankId, code, Some(cc)) _ <- Future(DeleteProductCascade.atomicDelete(bankId, code)) @@ -7878,7 +7895,7 @@ trait APIMethods400 { lazy val deleteCustomerCascade : OBPEndpoint = { case "management" :: "cascading" :: "banks" :: BankId(bankId) :: "customers" :: CustomerId(customerId) :: Nil JsonDelete _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (_, callContext) <- NewStyle.function.getCustomerByCustomerId(customerId.value, Some(cc)) _ <- Future(DeleteCustomerCascade.atomicDelete(customerId)) @@ -7997,7 +8014,7 @@ trait APIMethods400 { lazy val createExplicitCounterparty: OBPEndpoint = { case "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: ViewId(viewId) :: "counterparties" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (user @Full(u), _, account, view, callContext) <- SS.userBankAccountView _ <- Helper.booleanToFuture(InvalidAccountIdFormat, cc=callContext) {isValidID(accountId.value)} @@ -8101,7 +8118,7 @@ trait APIMethods400 { lazy val deleteExplicitCounterparty: OBPEndpoint = { case "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: ViewId(viewId) :: "counterparties" :: CounterpartyId(counterpartyId) :: Nil JsonDelete _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (user @Full(u), _, account, view, callContext) <- SS.userBankAccountView _ <- Helper.booleanToFuture(InvalidAccountIdFormat, cc=callContext) {isValidID(accountId.value)} @@ -8149,7 +8166,7 @@ trait APIMethods400 { lazy val deleteCounterpartyForAnyAccount: OBPEndpoint = { case "management" :: "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: ViewId(viewId) :: "counterparties" :: CounterpartyId(counterpartyId) :: Nil JsonDelete _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (user @Full(u), bank, account, callContext) <- SS.userBankAccount @@ -8277,7 +8294,7 @@ trait APIMethods400 { lazy val createCounterpartyForAnyAccount: OBPEndpoint = { case "management" :: "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: ViewId(viewId):: "counterparties" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (user @Full(u), bank, account, callContext) <- SS.userBankAccount postJson <- NewStyle.function.tryons(InvalidJsonFormat, 400, callContext) { @@ -8371,7 +8388,7 @@ trait APIMethods400 { lazy val getExplictCounterpartiesForAccount : OBPEndpoint = { case "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: ViewId(viewId) :: "counterparties" :: Nil JsonGet req => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (user @Full(u), _, account, view, callContext) <- SS.userBankAccountView _ <- Helper.booleanToFuture(failMsg = s"${NoViewPermission}can_add_counterparty", 403, cc=callContext) { @@ -8424,7 +8441,7 @@ trait APIMethods400 { lazy val getCounterpartiesForAnyAccount : OBPEndpoint = { case "management" :: "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: ViewId(viewId) :: "counterparties" :: Nil JsonGet req => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (user @Full(u), bank, account, callContext) <- SS.userBankAccount (counterparties, callContext) <- NewStyle.function.getCounterparties(bankId,accountId,viewId, callContext) @@ -8468,7 +8485,7 @@ trait APIMethods400 { lazy val getExplictCounterpartyById : OBPEndpoint = { case "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: ViewId(viewId) :: "counterparties" :: CounterpartyId(counterpartyId) :: Nil JsonGet req => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (user @Full(u), _, account, view, callContext) <- SS.userBankAccountView _ <- Helper.booleanToFuture(failMsg = s"${NoViewPermission}can_get_counterparty", 403, cc=callContext) { @@ -8512,7 +8529,7 @@ trait APIMethods400 { lazy val getCounterpartyByNameForAnyAccount: OBPEndpoint = { case "management" :: "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: ViewId(viewId):: "counterparty-names" :: counterpartyName :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (user @Full(u), bank, account, callContext) <- SS.userBankAccount @@ -8561,7 +8578,7 @@ trait APIMethods400 { lazy val getCounterpartyByIdForAnyAccount: OBPEndpoint = { case "management" :: "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: ViewId(viewId):: "counterparties" :: CounterpartyId(counterpartyId) :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (user @Full(u), _, account, callContext) <- SS.userBankAccount (counterparty, callContext) <- NewStyle.function.getCounterpartyByCounterpartyId(counterpartyId, callContext) @@ -8609,7 +8626,7 @@ trait APIMethods400 { lazy val addConsentUser : OBPEndpoint = { case "banks" :: BankId(bankId) :: "consents" :: consentId :: "user-update-request" :: Nil JsonPut json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (_, callContext) <- SS.user failMsg = s"$InvalidJsonFormat The Json body should be the $PutConsentUserJsonV400 " @@ -8666,7 +8683,7 @@ trait APIMethods400 { lazy val updateConsentStatus : OBPEndpoint = { case "banks" :: BankId(bankId) :: "consents" :: consentId :: Nil JsonPut json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(user), callContext) <- SS.user failMsg = s"$InvalidJsonFormat The Json body should be the $PutConsentStatusJsonV400 " @@ -8717,7 +8734,7 @@ trait APIMethods400 { lazy val getConsents: OBPEndpoint = { case "banks" :: BankId(bankId) :: "my" :: "consents" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { consents <- Future { Consents.consentProvider.vend.getConsentsByUser(cc.userId) .sortBy(i => (i.creationDateTime, i.apiStandard)).reverse @@ -8753,7 +8770,7 @@ trait APIMethods400 { lazy val getConsentInfos: OBPEndpoint = { case "banks" :: BankId(bankId) :: "my" :: "consent-infos" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { consents <- Future { Consents.consentProvider.vend.getConsentsByUser(cc.userId) .sortBy(i => (i.creationDateTime, i.apiStandard)).reverse @@ -8787,7 +8804,7 @@ trait APIMethods400 { lazy val getMyPersonalUserAttributes: OBPEndpoint = { case "my" :: "user" :: "attributes" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (attributes, callContext) <- NewStyle.function.getPersonalUserAttributes(cc.userId, cc.callContext) } yield { @@ -8820,7 +8837,7 @@ trait APIMethods400 { lazy val getUserWithAttributes: OBPEndpoint = { case "users" :: userId :: "attributes" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (user, callContext) <- NewStyle.function.getUserByUserId(userId, cc.callContext) (attributes, callContext) <- NewStyle.function.getUserAttributes(user.userId, callContext) @@ -8857,7 +8874,7 @@ trait APIMethods400 { lazy val createMyPersonalUserAttribute : OBPEndpoint = { case "my" :: "user" :: "attributes" :: Nil JsonPost json -> _=> { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) val failMsg = s"$InvalidJsonFormat The Json body should be the $UserAttributeJsonV400 " for { postedData <- NewStyle.function.tryons(failMsg, 400, cc.callContext) { @@ -8909,7 +8926,7 @@ trait APIMethods400 { lazy val updateMyPersonalUserAttribute : OBPEndpoint = { case "my" :: "user" :: "attributes" :: userAttributeId :: Nil JsonPut json -> _=> { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (attributes, callContext) <- NewStyle.function.getPersonalUserAttributes(cc.userId, cc.callContext) failMsg = s"$UserAttributeNotFound" @@ -8962,7 +8979,7 @@ trait APIMethods400 { lazy val getScannedApiVersions: OBPEndpoint = { case "api" :: "versions" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) Future { val versions: List[ScannedApiVersion] = ApiVersion.allScannedApiVersion.asScala.toList (ListResult("scanned_api_versions", versions), HttpCode.`200`(cc.callContext)) @@ -8994,7 +9011,7 @@ trait APIMethods400 { lazy val createMyApiCollection: OBPEndpoint = { case "my" :: "api-collections" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { postJson <- NewStyle.function.tryons(s"$InvalidJsonFormat The Json body should be the $PostApiCollectionJson400", 400, cc.callContext) { json.extract[PostApiCollectionJson400] @@ -9039,7 +9056,7 @@ trait APIMethods400 { lazy val getMyApiCollectionByName: OBPEndpoint = { case "my" :: "api-collections" :: "name" ::apiCollectionName :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (apiCollection, callContext) <- NewStyle.function.getApiCollectionByUserIdAndCollectionName(cc.userId, apiCollectionName, Some(cc)) } yield { @@ -9071,7 +9088,7 @@ trait APIMethods400 { lazy val getMyApiCollectionById: OBPEndpoint = { case "my" :: "api-collections" :: apiCollectionId :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (apiCollection, callContext) <- NewStyle.function.getApiCollectionById(apiCollectionId, Some(cc)) } yield { @@ -9100,7 +9117,7 @@ trait APIMethods400 { lazy val getSharableApiCollectionById: OBPEndpoint = { case "api-collections" :: "sharable" :: apiCollectionId :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (apiCollection, callContext) <- NewStyle.function.getApiCollectionById(apiCollectionId, cc.callContext) _ <- Helper.booleanToFuture(failMsg = s"$ApiCollectionEndpointNotFound Current api_collection_id(${apiCollectionId}) is not sharable.", cc=callContext) { @@ -9135,7 +9152,7 @@ trait APIMethods400 { lazy val getApiCollectionsForUser: OBPEndpoint = { case "users" :: userId :: "api-collections" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (_, callContext) <- NewStyle.function.findByUserId(userId, Some(cc)) (apiCollections, callContext) <- NewStyle.function.getApiCollectionsByUserId(userId, callContext) @@ -9166,7 +9183,7 @@ trait APIMethods400 { lazy val getFeaturedApiCollections: OBPEndpoint = { case "api-collections" :: "featured" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (apiCollections, callContext) <- NewStyle.function.getFeaturedApiCollections(cc.callContext) } yield { @@ -9199,7 +9216,7 @@ trait APIMethods400 { lazy val getMyApiCollections: OBPEndpoint = { case "my" :: "api-collections" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (apiCollections, callContext) <- NewStyle.function.getApiCollectionsByUserId(cc.userId, Some(cc)) } yield { @@ -9236,7 +9253,7 @@ trait APIMethods400 { lazy val deleteMyApiCollection : OBPEndpoint = { case "my" :: "api-collections" :: apiCollectionId :: Nil JsonDelete _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (apiCollection, callContext) <- NewStyle.function.getApiCollectionById(apiCollectionId, Some(cc)) (deleted, callContext) <- NewStyle.function.deleteApiCollectionById(apiCollectionId, callContext) @@ -9273,7 +9290,7 @@ trait APIMethods400 { lazy val createMyApiCollectionEndpoint: OBPEndpoint = { case "my" :: "api-collections" :: apiCollectionName :: "api-collection-endpoints" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { postJson <- NewStyle.function.tryons(s"$InvalidJsonFormat The Json body should be the $PostApiCollectionEndpointJson400", 400, cc.callContext) { json.extract[PostApiCollectionEndpointJson400] @@ -9322,7 +9339,7 @@ trait APIMethods400 { lazy val createMyApiCollectionEndpointById: OBPEndpoint = { case "my" :: "api-collection-ids" :: apiCollectionId :: "api-collection-endpoints" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { postJson <- NewStyle.function.tryons(s"$InvalidJsonFormat The Json body should be the $PostApiCollectionEndpointJson400", 400, cc.callContext) { json.extract[PostApiCollectionEndpointJson400] @@ -9369,7 +9386,7 @@ trait APIMethods400 { lazy val getMyApiCollectionEndpoint: OBPEndpoint = { case "my" :: "api-collections" :: apiCollectionName :: "api-collection-endpoints" :: operationId :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (apiCollection, callContext) <- NewStyle.function.getApiCollectionByUserIdAndCollectionName(cc.userId, apiCollectionName, Some(cc) ) (apiCollectionEndpoint, callContext) <- NewStyle.function.getApiCollectionEndpointByApiCollectionIdAndOperationId( @@ -9405,7 +9422,7 @@ trait APIMethods400 { lazy val getApiCollectionEndpoints: OBPEndpoint = { case "api-collections" :: apiCollectionId :: "api-collection-endpoints" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (apiCollectionEndpoints, callContext) <- NewStyle.function.getApiCollectionEndpoints(apiCollectionId, Some(cc)) } yield { @@ -9437,7 +9454,7 @@ trait APIMethods400 { lazy val getMyApiCollectionEndpoints: OBPEndpoint = { case "my" :: "api-collections" :: apiCollectionName :: "api-collection-endpoints":: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (apiCollection, callContext) <- NewStyle.function.getApiCollectionByUserIdAndCollectionName(cc.userId, apiCollectionName, Some(cc) ) (apiCollectionEndpoints, callContext) <- NewStyle.function.getApiCollectionEndpoints(apiCollection.apiCollectionId, callContext) @@ -9470,7 +9487,7 @@ trait APIMethods400 { lazy val getMyApiCollectionEndpointsById: OBPEndpoint = { case "my" :: "api-collection-ids" :: apiCollectionId :: "api-collection-endpoints":: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (apiCollection, callContext) <- NewStyle.function.getApiCollectionById(apiCollectionId, Some(cc) ) (apiCollectionEndpoints, callContext) <- NewStyle.function.getApiCollectionEndpoints(apiCollection.apiCollectionId, callContext) @@ -9507,7 +9524,7 @@ trait APIMethods400 { lazy val deleteMyApiCollectionEndpoint : OBPEndpoint = { case "my" :: "api-collections" :: apiCollectionName :: "api-collection-endpoints" :: operationId :: Nil JsonDelete _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (apiCollection, callContext) <- NewStyle.function.getApiCollectionByUserIdAndCollectionName(cc.userId, apiCollectionName, Some(cc) ) (apiCollectionEndpoint, callContext) <- NewStyle.function.getApiCollectionEndpointByApiCollectionIdAndOperationId(apiCollection.apiCollectionId, operationId, callContext) @@ -9544,7 +9561,7 @@ trait APIMethods400 { lazy val deleteMyApiCollectionEndpointByOperationId : OBPEndpoint = { case "my" :: "api-collection-ids" :: apiCollectionId :: "api-collection-endpoints" :: operationId :: Nil JsonDelete _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (apiCollection, callContext) <- NewStyle.function.getApiCollectionById(apiCollectionId, Some(cc) ) (apiCollectionEndpoint, callContext) <- NewStyle.function.getApiCollectionEndpointByApiCollectionIdAndOperationId(apiCollection.apiCollectionId, operationId, callContext) @@ -9581,7 +9598,7 @@ trait APIMethods400 { lazy val deleteMyApiCollectionEndpointById : OBPEndpoint = { case "my" :: "api-collection-ids" :: apiCollectionId :: "api-collection-endpoint-ids" :: apiCollectionEndpointId :: Nil JsonDelete _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (apiCollection, callContext) <- NewStyle.function.getApiCollectionById(apiCollectionId, Some(cc) ) (apiCollectionEndpoint, callContext) <- NewStyle.function.getApiCollectionEndpointById(apiCollectionEndpointId, callContext) @@ -9617,7 +9634,7 @@ trait APIMethods400 { lazy val createJsonSchemaValidation: OBPEndpoint = { case "management" :: "json-schema-validations" :: operationId :: Nil JsonPost _ -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) val httpBody: String = cc.httpBody.getOrElse("") for { (Full(u), callContext) <- SS.user @@ -9663,7 +9680,7 @@ trait APIMethods400 { lazy val updateJsonSchemaValidation: OBPEndpoint = { case "management" :: "json-schema-validations" :: operationId :: Nil JsonPut _ -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) val httpBody: String = cc.httpBody.getOrElse("") for { (Full(u), callContext) <- SS.user @@ -9708,7 +9725,7 @@ trait APIMethods400 { lazy val deleteJsonSchemaValidation: OBPEndpoint = { case "management" :: "json-schema-validations" :: operationId :: Nil JsonDelete _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- SS.user @@ -9745,7 +9762,7 @@ trait APIMethods400 { lazy val getJsonSchemaValidation: OBPEndpoint = { case "management" :: "json-schema-validations" :: operationId :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (validation, callContext) <- NewStyle.function.getJsonSchemaValidationByOperationId(operationId, cc.callContext) } yield { @@ -9778,7 +9795,7 @@ trait APIMethods400 { lazy val getAllJsonSchemaValidations: OBPEndpoint = { case ("management" | "endpoints") :: "json-schema-validations" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (jsonSchemaValidations, callContext) <- NewStyle.function.getJsonSchemaValidations(cc.callContext) } yield { @@ -9839,7 +9856,7 @@ trait APIMethods400 { lazy val createAuthenticationTypeValidation: OBPEndpoint = { case "management" :: "authentication-type-validations" :: operationId :: Nil JsonPost jArray -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- SS.user @@ -9883,7 +9900,7 @@ trait APIMethods400 { lazy val updateAuthenticationTypeValidation: OBPEndpoint = { case "management" :: "authentication-type-validations" :: operationId :: Nil JsonPut jArray -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- SS.user @@ -9926,7 +9943,7 @@ trait APIMethods400 { lazy val deleteAuthenticationTypeValidation: OBPEndpoint = { case "management" :: "authentication-type-validations" :: operationId :: Nil JsonDelete _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- SS.user @@ -9964,7 +9981,7 @@ trait APIMethods400 { lazy val getAuthenticationTypeValidation: OBPEndpoint = { case "management" :: "authentication-type-validations" :: operationId :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (authenticationTypeValidation, callContext) <- NewStyle.function.getAuthenticationTypeValidationByOperationId(operationId, cc.callContext) } yield { @@ -9997,7 +10014,7 @@ trait APIMethods400 { lazy val getAllAuthenticationTypeValidations: OBPEndpoint = { case ("management" | "endpoints") :: "authentication-type-validations" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (authenticationTypeValidations, callContext) <- NewStyle.function.getAuthenticationTypeValidations(cc.callContext) } yield { @@ -10054,7 +10071,7 @@ trait APIMethods400 { lazy val createConnectorMethod: OBPEndpoint = { case "management" :: "connector-methods" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { jsonConnectorMethod <- NewStyle.function.tryons(s"$InvalidJsonFormat The Json body should be the $JsonConnectorMethod", 400, cc.callContext) { json.extract[JsonConnectorMethod] @@ -10101,7 +10118,7 @@ trait APIMethods400 { lazy val updateConnectorMethod: OBPEndpoint = { case "management" :: "connector-methods" :: connectorMethodId :: Nil JsonPut json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { connectorMethodBody <- NewStyle.function.tryons(s"$InvalidJsonFormat The Json body should be the $JsonConnectorMethod", 400, cc.callContext) { json.extract[JsonConnectorMethodMethodBody] @@ -10144,7 +10161,7 @@ trait APIMethods400 { lazy val getConnectorMethod: OBPEndpoint = { case "management" :: "connector-methods" :: connectorMethodId :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (connectorMethod, callContext) <- NewStyle.function.getJsonConnectorMethodById(connectorMethodId, cc.callContext) } yield { @@ -10175,7 +10192,7 @@ trait APIMethods400 { lazy val getAllConnectorMethods: OBPEndpoint = { case "management" :: "connector-methods" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (connectorMethods, callContext) <- NewStyle.function.getJsonConnectorMethods(cc.callContext) } yield { @@ -10208,7 +10225,7 @@ trait APIMethods400 { lazy val createDynamicResourceDoc: OBPEndpoint = { case "management" :: "dynamic-resource-docs" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { jsonDynamicResourceDoc <- NewStyle.function.tryons(s"$InvalidJsonFormat The Json body should be the $JsonDynamicResourceDoc", 400, cc.callContext) { json.extract[JsonDynamicResourceDoc] @@ -10272,7 +10289,7 @@ trait APIMethods400 { lazy val updateDynamicResourceDoc: OBPEndpoint = { case "management" :: "dynamic-resource-docs" :: dynamicResourceDocId :: Nil JsonPut json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { dynamicResourceDocBody <- NewStyle.function.tryons(s"$InvalidJsonFormat The Json body should be the $JsonDynamicResourceDoc", 400, cc.callContext) { json.extract[JsonDynamicResourceDoc] @@ -10334,7 +10351,7 @@ trait APIMethods400 { lazy val deleteDynamicResourceDoc: OBPEndpoint = { case "management" :: "dynamic-resource-docs" :: dynamicResourceDocId :: Nil JsonDelete _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (_, callContext) <- NewStyle.function.getJsonDynamicResourceDocById(None, dynamicResourceDocId, cc.callContext) (dynamicResourceDoc, callContext) <- NewStyle.function.deleteJsonDynamicResourceDocById(None, dynamicResourceDocId, callContext) @@ -10366,7 +10383,7 @@ trait APIMethods400 { lazy val getDynamicResourceDoc: OBPEndpoint = { case "management" :: "dynamic-resource-docs" :: dynamicResourceDocId :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (dynamicResourceDoc, callContext) <- NewStyle.function.getJsonDynamicResourceDocById(None, dynamicResourceDocId, cc.callContext) } yield { @@ -10397,7 +10414,7 @@ trait APIMethods400 { lazy val getAllDynamicResourceDocs: OBPEndpoint = { case "management" :: "dynamic-resource-docs" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (dynamicResourceDocs, callContext) <- NewStyle.function.getJsonDynamicResourceDocs(None, cc.callContext) } yield { @@ -10431,7 +10448,7 @@ trait APIMethods400 { lazy val createBankLevelDynamicResourceDoc: OBPEndpoint = { case "management" :: "banks" :: bankId :: "dynamic-resource-docs" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { jsonDynamicResourceDoc <- NewStyle.function.tryons(s"$InvalidJsonFormat The Json body should be the $JsonDynamicResourceDoc", 400, cc.callContext) { json.extract[JsonDynamicResourceDoc] @@ -10503,7 +10520,7 @@ trait APIMethods400 { lazy val updateBankLevelDynamicResourceDoc: OBPEndpoint = { case "management" :: "banks" :: bankId :: "dynamic-resource-docs" :: dynamicResourceDocId :: Nil JsonPut json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { dynamicResourceDocBody <- NewStyle.function.tryons(s"$InvalidJsonFormat The Json body should be the $JsonDynamicResourceDoc", 400, cc.callContext) { json.extract[JsonDynamicResourceDoc] @@ -10573,7 +10590,7 @@ trait APIMethods400 { lazy val deleteBankLevelDynamicResourceDoc: OBPEndpoint = { case "management" :: "banks" :: bankId :: "dynamic-resource-docs" :: dynamicResourceDocId :: Nil JsonDelete _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (_, callContext) <- NewStyle.function.getJsonDynamicResourceDocById(Some(bankId), dynamicResourceDocId, cc.callContext) (dynamicResourceDoc, callContext) <- NewStyle.function.deleteJsonDynamicResourceDocById(Some(bankId), dynamicResourceDocId, callContext) @@ -10606,7 +10623,7 @@ trait APIMethods400 { lazy val getBankLevelDynamicResourceDoc: OBPEndpoint = { case "management" :: "banks" :: bankId :: "dynamic-resource-docs" :: dynamicResourceDocId :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (dynamicResourceDoc, callContext) <- NewStyle.function.getJsonDynamicResourceDocById(Some(bankId), dynamicResourceDocId, cc.callContext) } yield { @@ -10638,7 +10655,7 @@ trait APIMethods400 { lazy val getAllBankLevelDynamicResourceDocs: OBPEndpoint = { case "management" :: "banks" :: bankId :: "dynamic-resource-docs" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (dynamicResourceDocs, callContext) <- NewStyle.function.getJsonDynamicResourceDocs(Some(bankId), cc.callContext) } yield { @@ -10671,7 +10688,7 @@ trait APIMethods400 { lazy val buildDynamicEndpointTemplate: OBPEndpoint = { case "management" :: "dynamic-resource-docs" :: "endpoint-code" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { resourceDocFragment <- NewStyle.function.tryons(s"$InvalidJsonFormat The Json body should be the $ResourceDocFragment", 400, cc.callContext) { json.extract[ResourceDocFragment] @@ -10720,7 +10737,7 @@ trait APIMethods400 { lazy val createDynamicMessageDoc: OBPEndpoint = { case "management" :: "dynamic-message-docs" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { dynamicMessageDoc <- NewStyle.function.tryons(s"$InvalidJsonFormat The Json body should be the $JsonDynamicMessageDoc", 400, cc.callContext) { json.extract[JsonDynamicMessageDoc] @@ -10765,7 +10782,7 @@ trait APIMethods400 { lazy val createBankLevelDynamicMessageDoc: OBPEndpoint = { case "management" :: "banks" :: bankId ::"dynamic-message-docs" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { dynamicMessageDoc <- NewStyle.function.tryons(s"$InvalidJsonFormat The Json body should be the $JsonDynamicMessageDoc", 400, cc.callContext) { json.extract[JsonDynamicMessageDoc] @@ -10809,7 +10826,7 @@ trait APIMethods400 { lazy val updateDynamicMessageDoc: OBPEndpoint = { case "management" :: "dynamic-message-docs" :: dynamicMessageDocId :: Nil JsonPut json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { dynamicMessageDocBody <- NewStyle.function.tryons(s"$InvalidJsonFormat The Json body should be the $JsonDynamicMessageDoc", 400, cc.callContext) { json.extract[JsonDynamicMessageDoc] @@ -10850,7 +10867,7 @@ trait APIMethods400 { lazy val getDynamicMessageDoc: OBPEndpoint = { case "management" :: "dynamic-message-docs" :: dynamicMessageDocId :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (dynamicMessageDoc, callContext) <- NewStyle.function.getJsonDynamicMessageDocById(None, dynamicMessageDocId, cc.callContext) } yield { @@ -10881,7 +10898,7 @@ trait APIMethods400 { lazy val getAllDynamicMessageDocs: OBPEndpoint = { case "management" :: "dynamic-message-docs" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (dynamicMessageDocs, callContext) <- NewStyle.function.getJsonDynamicMessageDocs(None, cc.callContext) } yield { @@ -10912,7 +10929,7 @@ trait APIMethods400 { lazy val deleteDynamicMessageDoc: OBPEndpoint = { case "management" :: "dynamic-message-docs" :: dynamicMessageDocId :: Nil JsonDelete _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (_, callContext) <- NewStyle.function.getJsonDynamicMessageDocById(None, dynamicMessageDocId, cc.callContext) (dynamicResourceDoc, callContext) <- NewStyle.function.deleteJsonDynamicMessageDocById(None, dynamicMessageDocId, callContext) @@ -10945,7 +10962,7 @@ trait APIMethods400 { lazy val updateBankLevelDynamicMessageDoc: OBPEndpoint = { case "management" :: "banks" :: bankId::"dynamic-message-docs" :: dynamicMessageDocId :: Nil JsonPut json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { dynamicMessageDocBody <- NewStyle.function.tryons(s"$InvalidJsonFormat The Json body should be the $JsonDynamicMessageDoc", 400, cc.callContext) { json.extract[JsonDynamicMessageDoc] @@ -10987,7 +11004,7 @@ trait APIMethods400 { lazy val getBankLevelDynamicMessageDoc: OBPEndpoint = { case "management" :: "banks" :: bankId :: "dynamic-message-docs" :: dynamicMessageDocId :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (dynamicMessageDoc, callContext) <- NewStyle.function.getJsonDynamicMessageDocById(None, dynamicMessageDocId, cc.callContext) } yield { @@ -11019,7 +11036,7 @@ trait APIMethods400 { lazy val getAllBankLevelDynamicMessageDocs: OBPEndpoint = { case "management" :: "banks" :: bankId :: "dynamic-message-docs" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (dynamicMessageDocs, callContext) <- NewStyle.function.getJsonDynamicMessageDocs(Some(bankId), cc.callContext) } yield { @@ -11051,7 +11068,7 @@ trait APIMethods400 { lazy val deleteBankLevelDynamicMessageDoc: OBPEndpoint = { case "management" :: "banks" :: bankId :: "dynamic-message-docs" :: dynamicMessageDocId :: Nil JsonDelete _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (_, callContext) <- NewStyle.function.getJsonDynamicMessageDocById(Some(bankId), dynamicMessageDocId, cc.callContext) (dynamicResourceDoc, callContext) <- NewStyle.function.deleteJsonDynamicMessageDocById(Some(bankId), dynamicMessageDocId, callContext) @@ -11085,7 +11102,7 @@ trait APIMethods400 { lazy val createEndpointMapping: OBPEndpoint = { case "management" :: "endpoint-mappings" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) createEndpointMappingMethod(None, json, cc) } } @@ -11126,7 +11143,7 @@ trait APIMethods400 { lazy val updateEndpointMapping: OBPEndpoint = { case "management" :: "endpoint-mappings" :: endpointMappingId :: Nil JsonPut json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) updateEndpointMappingMethod(None, endpointMappingId, json, cc) } } @@ -11172,7 +11189,7 @@ trait APIMethods400 { lazy val getEndpointMapping: OBPEndpoint = { case "management" :: "endpoint-mappings" :: endpointMappingId :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) getEndpointMappingMethod(None, endpointMappingId, cc) } } @@ -11208,7 +11225,7 @@ trait APIMethods400 { lazy val getAllEndpointMappings: OBPEndpoint = { case "management" :: "endpoint-mappings" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) getEndpointMappingsMethod(None, cc) } } @@ -11244,7 +11261,7 @@ trait APIMethods400 { lazy val deleteEndpointMapping: OBPEndpoint = { case "management" :: "endpoint-mappings" :: endpointMappingId :: Nil JsonDelete _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) deleteEndpointMappingMethod(None, endpointMappingId, cc) } } @@ -11282,7 +11299,7 @@ trait APIMethods400 { lazy val createBankLevelEndpointMapping: OBPEndpoint = { case "management" :: "banks" :: bankId :: "endpoint-mappings" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) createEndpointMappingMethod(Some(bankId), json, cc) } } @@ -11310,7 +11327,7 @@ trait APIMethods400 { lazy val updateBankLevelEndpointMapping: OBPEndpoint = { case "management" :: "banks" :: bankId :: "endpoint-mappings" :: endpointMappingId :: Nil JsonPut json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) updateEndpointMappingMethod(Some(bankId), endpointMappingId, json, cc) } } @@ -11338,7 +11355,7 @@ trait APIMethods400 { lazy val getBankLevelEndpointMapping: OBPEndpoint = { case "management" :: "banks" :: bankId :: "endpoint-mappings" :: endpointMappingId :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) getEndpointMappingMethod(Some(bankId), endpointMappingId, cc) } } @@ -11366,7 +11383,7 @@ trait APIMethods400 { lazy val getAllBankLevelEndpointMappings: OBPEndpoint = { case "management" :: "banks" :: bankId :: "endpoint-mappings" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) getEndpointMappingsMethod(Some(bankId), cc) } } @@ -11394,7 +11411,7 @@ trait APIMethods400 { lazy val deleteBankLevelEndpointMapping: OBPEndpoint = { case "management" :: "banks" :: bankId :: "endpoint-mappings" :: endpointMappingId :: Nil JsonDelete _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) deleteEndpointMappingMethod(Some(bankId), endpointMappingId, cc) } } @@ -11420,7 +11437,7 @@ trait APIMethods400 { lazy val updateAtmSupportedCurrencies : OBPEndpoint = { case "banks" :: BankId(bankId) :: "atms" :: AtmId(atmId) :: "supported-currencies" :: Nil JsonPut json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { supportedCurrencies <- NewStyle.function.tryons(s"$InvalidJsonFormat The Json body should be the ${classOf[SupportedCurrenciesJson]}", 400, cc.callContext) { json.extract[SupportedCurrenciesJson].supported_currencies @@ -11454,7 +11471,7 @@ trait APIMethods400 { lazy val updateAtmSupportedLanguages : OBPEndpoint = { case "banks" :: BankId(bankId) :: "atms" :: AtmId(atmId) :: "supported-languages" :: Nil JsonPut json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { supportedLanguages <- NewStyle.function.tryons(s"$InvalidJsonFormat The Json body should be the ${classOf[SupportedLanguagesJson]}", 400, cc.callContext) { json.extract[SupportedLanguagesJson].supported_languages @@ -11488,7 +11505,7 @@ trait APIMethods400 { lazy val updateAtmAccessibilityFeatures : OBPEndpoint = { case "banks" :: BankId(bankId) :: "atms" :: AtmId(atmId) :: "accessibility-features" :: Nil JsonPut json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { accessibilityFeatures <- NewStyle.function.tryons(s"$InvalidJsonFormat The Json body should be the ${classOf[AccessibilityFeaturesJson]}", 400, cc.callContext) { json.extract[AccessibilityFeaturesJson].accessibility_features @@ -11522,7 +11539,7 @@ trait APIMethods400 { lazy val updateAtmServices : OBPEndpoint = { case "banks" :: BankId(bankId) :: "atms" :: AtmId(atmId) :: "services" :: Nil JsonPut json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { services <- NewStyle.function.tryons(s"$InvalidJsonFormat The Json body should be the ${classOf[AtmServicesJsonV400]}", 400, cc.callContext) { json.extract[AtmServicesJsonV400].services @@ -11556,7 +11573,7 @@ trait APIMethods400 { lazy val updateAtmNotes : OBPEndpoint = { case "banks" :: BankId(bankId) :: "atms" :: AtmId(atmId) :: "notes" :: Nil JsonPut json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { notes <- NewStyle.function.tryons(s"$InvalidJsonFormat The Json body should be the ${classOf[AtmNotesJsonV400]}", 400, cc.callContext) { json.extract[AtmNotesJsonV400].notes @@ -11590,7 +11607,7 @@ trait APIMethods400 { lazy val updateAtmLocationCategories : OBPEndpoint = { case "banks" :: BankId(bankId) :: "atms" :: AtmId(atmId) :: "location-categories" :: Nil JsonPut json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { locationCategories <- NewStyle.function.tryons(s"$InvalidJsonFormat The Json body should be the ${classOf[AtmLocationCategoriesJsonV400]}", 400, cc.callContext) { json.extract[AtmLocationCategoriesJsonV400].location_categories @@ -11623,7 +11640,7 @@ trait APIMethods400 { ) lazy val createAtm : OBPEndpoint = { case "banks" :: BankId(bankId) :: "atms" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { atmJsonV400 <- NewStyle.function.tryons(s"$InvalidJsonFormat The Json body should be the ${classOf[AtmJsonV400]}", 400, cc.callContext) { val atm = json.extract[AtmJsonV400] @@ -11662,7 +11679,7 @@ trait APIMethods400 { ) lazy val updateAtm : OBPEndpoint = { case "banks" :: BankId(bankId) :: "atms" :: AtmId(atmId) :: Nil JsonPut json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (atm, callContext) <- NewStyle.function.getAtm(bankId, atmId, cc.callContext) atmJsonV400 <- NewStyle.function.tryons(s"$InvalidJsonFormat The Json body should be the ${classOf[AtmJsonV400]}", 400, cc.callContext) { @@ -11698,7 +11715,7 @@ trait APIMethods400 { ) lazy val deleteAtm : OBPEndpoint = { case "banks" :: BankId(bankId) :: "atms" :: AtmId(atmId) :: Nil JsonDelete _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (atm, callContext) <- NewStyle.function.getAtm(bankId, atmId, cc.callContext) (deleted, callContext) <- NewStyle.function.deleteAtm(atm, callContext) @@ -11738,7 +11755,7 @@ trait APIMethods400 { ) lazy val getAtms : OBPEndpoint = { case "banks" :: BankId(bankId) :: "atms" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) val limit = S.param("limit") val offset = S.param("offset") for { @@ -11790,7 +11807,7 @@ trait APIMethods400 { ) lazy val getAtm : OBPEndpoint = { case "banks" :: BankId(bankId) :: "atms" :: AtmId(atmId) :: Nil JsonGet req => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (_, callContext) <- getAtmsIsPublic match { case false => authenticatedAccess(cc) @@ -11823,7 +11840,7 @@ trait APIMethods400 { Some(List(canCreateSystemLevelEndpointTag))) lazy val createSystemLevelEndpointTag: OBPEndpoint = { case "management" :: "endpoints" :: operationId :: "tags" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { endpointTag <- NewStyle.function.tryons(s"$InvalidJsonFormat The Json body should be the $EndpointTagJson400", 400, cc.callContext) { json.extract[EndpointTagJson400] @@ -11864,7 +11881,7 @@ trait APIMethods400 { Some(List(canUpdateSystemLevelEndpointTag))) lazy val updateSystemLevelEndpointTag: OBPEndpoint = { case "management" :: "endpoints" :: operationId :: "tags" :: endpointTagId :: Nil JsonPut json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { endpointTag <- NewStyle.function.tryons(s"$InvalidJsonFormat The Json body should be the $EndpointTagJson400", 400, cc.callContext) { json.extract[EndpointTagJson400] @@ -11904,7 +11921,7 @@ trait APIMethods400 { Some(List(canGetSystemLevelEndpointTag))) lazy val getSystemLevelEndpointTags: OBPEndpoint = { case "management" :: "endpoints" :: operationId :: "tags" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (endpointTags, callContext) <- NewStyle.function.getSystemLevelEndpointTags(operationId, cc.callContext) } yield { @@ -11936,7 +11953,7 @@ trait APIMethods400 { Some(List(canDeleteSystemLevelEndpointTag))) lazy val deleteSystemLevelEndpointTag: OBPEndpoint = { case "management" :: "endpoints" :: operationId :: "tags" :: endpointTagId :: Nil JsonDelete _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (_, callContext) <- NewStyle.function.getEndpointTag(endpointTagId, cc.callContext) @@ -11968,7 +11985,7 @@ trait APIMethods400 { Some(List(canCreateBankLevelEndpointTag))) lazy val createBankLevelEndpointTag: OBPEndpoint = { case "management" :: "banks" :: bankId :: "endpoints" :: operationId :: "tags" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { endpointTag <- NewStyle.function.tryons(s"$InvalidJsonFormat The Json body should be the $EndpointTagJson400", 400, cc.callContext) { json.extract[EndpointTagJson400] @@ -12011,7 +12028,7 @@ trait APIMethods400 { Some(List(canUpdateBankLevelEndpointTag))) lazy val updateBankLevelEndpointTag: OBPEndpoint = { case "management":: "banks" :: bankId :: "endpoints" :: operationId :: "tags" :: endpointTagId :: Nil JsonPut json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { endpointTag <- NewStyle.function.tryons(s"$InvalidJsonFormat The Json body should be the $EndpointTagJson400", 400, cc.callContext) { json.extract[EndpointTagJson400] @@ -12053,7 +12070,7 @@ trait APIMethods400 { Some(List(canGetBankLevelEndpointTag))) lazy val getBankLevelEndpointTags: OBPEndpoint = { case "management":: "banks" :: bankId :: "endpoints" :: operationId :: "tags" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (endpointTags, callContext) <- NewStyle.function.getBankLevelEndpointTags(bankId, operationId, cc.callContext) } yield { @@ -12087,7 +12104,7 @@ trait APIMethods400 { Some(List(canDeleteBankLevelEndpointTag))) lazy val deleteBankLevelEndpointTag: OBPEndpoint = { case "management":: "banks" :: bankId :: "endpoints" :: operationId :: "tags" :: endpointTagId :: Nil JsonDelete _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (_, callContext) <- NewStyle.function.getEndpointTag(endpointTagId, cc.callContext) @@ -12116,7 +12133,7 @@ trait APIMethods400 { ) lazy val getMySpaces: OBPEndpoint = { case "my" :: "spaces" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- SS.user entitlements <- NewStyle.function.getEntitlementsByUserId(u.userId, callContext) @@ -12165,6 +12182,7 @@ trait APIMethods400 { lazy val getProducts : OBPEndpoint = { case "banks" :: BankId(bankId) :: "products" :: Nil JsonGet req => { cc => { + implicit val ec = EndpointContext(Some(cc)) for { (_, callContext) <- getProductsIsPublic match { case false => authenticatedAccess(cc) @@ -12220,7 +12238,7 @@ trait APIMethods400 { ) lazy val createProduct: OBPEndpoint = { case "banks" :: BankId(bankId) :: "products" :: ProductCode(productCode) :: Nil JsonPut json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- SS.user _ <- NewStyle.function.hasAtLeastOneEntitlement(failMsg = createProductEntitlementsRequiredText)(bankId.value, u.userId, createProductEntitlements, callContext) @@ -12294,6 +12312,7 @@ trait APIMethods400 { lazy val getProduct: OBPEndpoint = { case "banks" :: BankId(bankId) :: "products" :: ProductCode(productCode) :: Nil JsonGet _ => { cc => { + implicit val ec = EndpointContext(Some(cc)) for { (_, callContext) <- getProductsIsPublic match { case false => authenticatedAccess(cc) @@ -12338,6 +12357,7 @@ trait APIMethods400 { lazy val createCustomerMessage : OBPEndpoint = { case "banks" :: BankId(bankId) :: "customers" :: customerId :: "messages" :: Nil JsonPost json -> _ => { cc =>{ + implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- SS.user failMsg = s"$InvalidJsonFormat The Json body should be the $CreateMessageJsonV400 " @@ -12384,6 +12404,7 @@ trait APIMethods400 { lazy val getCustomerMessages: OBPEndpoint = { case "banks" :: BankId(bankId) :: "customers" :: customerId :: "messages" :: Nil JsonGet _ => { cc =>{ + implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- SS.user (customer, callContext) <- NewStyle.function.getCustomerByCustomerId(customerId, callContext) @@ -12458,7 +12479,7 @@ trait APIMethods400 { lazy val createSystemAccountNotificationWebhook : OBPEndpoint = { case "web-hooks" ::"account" ::"notifications" ::"on-create-transaction" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) failMsg = s"$InvalidJsonFormat The Json body should be the $AccountNotificationWebhookPostJson " @@ -12515,7 +12536,7 @@ trait APIMethods400 { lazy val createBankAccountNotificationWebhook : OBPEndpoint = { case "banks" :: BankId(bankId) :: "web-hooks" ::"account" ::"notifications" ::"on-create-transaction" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) failMsg = s"$InvalidJsonFormat The Json body should be the $AccountNotificationWebhookPostJson " diff --git a/obp-api/src/main/scala/code/api/v5_0_0/APIMethods500.scala b/obp-api/src/main/scala/code/api/v5_0_0/APIMethods500.scala index 8b8edd272c..15bdef5978 100644 --- a/obp-api/src/main/scala/code/api/v5_0_0/APIMethods500.scala +++ b/obp-api/src/main/scala/code/api/v5_0_0/APIMethods500.scala @@ -1,6 +1,7 @@ package code.api.v5_0_0 import java.util.concurrent.ThreadLocalRandom + import code.accountattribute.AccountAttributeX import code.api.ResourceDocs1_4_0.SwaggerDefinitionsJSON import code.api.ResourceDocs1_4_0.SwaggerDefinitionsJSON._ @@ -39,10 +40,11 @@ import net.liftweb.json import net.liftweb.json.{Extraction, compactRender, prettyRender} import net.liftweb.util.Helpers.tryo import net.liftweb.util.{Helpers, Props, StringHelpers} - import java.util.concurrent.ThreadLocalRandom + import code.accountattribute.AccountAttributeX import code.api.Constant.SYSTEM_OWNER_VIEW_ID +import code.api.util.FutureUtil.{EndpointContext, endpointContext} import code.util.Helper.booleanToFuture import code.views.system.{AccountAccess, ViewDefinition} @@ -102,7 +104,7 @@ trait APIMethods500 { lazy val getBank : OBPEndpoint = { case "banks" :: BankId(bankId) :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (bank, callContext) <- NewStyle.function.getBank(bankId, cc.callContext) (attributes, callContext) <- NewStyle.function.getBankAttributesByBank(bankId, callContext) @@ -144,7 +146,7 @@ trait APIMethods500 { lazy val createBank: OBPEndpoint = { case "banks" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) val failMsg = s"$InvalidJsonFormat The Json body should be the $PostBankJson500 " for { postJson <- NewStyle.function.tryons(failMsg, 400, cc.callContext) { @@ -224,7 +226,7 @@ trait APIMethods500 { lazy val updateBank: OBPEndpoint = { case "banks" :: Nil JsonPut json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) val failMsg = s"$InvalidJsonFormat The Json body should be the $PostBankJson500 " for { bank <- NewStyle.function.tryons(failMsg, 400, cc.callContext) { @@ -308,6 +310,7 @@ trait APIMethods500 { // Create a new account case "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: Nil JsonPut json -> _ => { cc =>{ + implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) (account, callContext) <- Connector.connector.vend.checkBankAccountExists(bankId, accountId, callContext) @@ -423,7 +426,7 @@ trait APIMethods500 { Some(List(canCreateUserAuthContext))) lazy val createUserAuthContext : OBPEndpoint = { case "users" :: userId ::"auth-context" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) _ <- NewStyle.function.hasEntitlement("", u.userId, canCreateUserAuthContext, callContext) @@ -465,7 +468,7 @@ trait APIMethods500 { ) lazy val getUserAuthContexts : OBPEndpoint = { case "users" :: userId :: "auth-context" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) _ <- NewStyle.function.hasEntitlement("", u.userId, canGetUserAuthContext, callContext) @@ -506,7 +509,7 @@ trait APIMethods500 { lazy val createUserAuthContextUpdateRequest : OBPEndpoint = { case "banks" :: BankId(bankId) :: "users" :: "current" ::"auth-context-updates" :: scaMethod :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(user), callContext) <- authenticatedAccess(cc) _ <- Helper.booleanToFuture(failMsg = ConsumerHasMissingRoles + CanCreateUserAuthContextUpdate, cc=callContext) { @@ -550,7 +553,7 @@ trait APIMethods500 { lazy val answerUserAuthContextUpdateChallenge : OBPEndpoint = { case "banks" :: BankId(bankId) :: "users" :: "current" ::"auth-context-updates" :: authContextUpdateId :: "challenge" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (_, callContext) <- authenticatedAccess(cc) failMsg = s"$InvalidJsonFormat The Json body should be the $PostUserAuthContextUpdateJsonV310 " @@ -623,7 +626,7 @@ trait APIMethods500 { lazy val createConsentRequest : OBPEndpoint = { case "consumer" :: "consent-requests" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (_, callContext) <- applicationAccess(cc) _ <- passesPsd2Aisp(callContext) @@ -673,7 +676,7 @@ trait APIMethods500 { lazy val getConsentRequest : OBPEndpoint = { case "consumer" :: "consent-requests" :: consentRequestId :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (_, callContext) <- applicationAccess(cc) _ <- passesPsd2Aisp(callContext) @@ -712,7 +715,7 @@ trait APIMethods500 { List(apiTagConsent, apiTagPSD2AIS, apiTagPsd2)) lazy val getConsentByConsentRequestId: OBPEndpoint = { case "consumer" :: "consent-requests" :: consentRequestId :: "consents" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (_, callContext) <- applicationAccess(cc) consent <- Future { Consents.consentProvider.vend.getConsentByConsentRequestId(consentRequestId)} map { @@ -871,7 +874,7 @@ trait APIMethods500 { status } } - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(user), callContext) <- authenticatedAccess(cc) createdConsentRequest <- Future(ConsentRequests.consentRequestProvider.vend.getConsentRequestById( @@ -1024,7 +1027,7 @@ trait APIMethods500 { ) lazy val headAtms : OBPEndpoint = { case "banks" :: BankId(bankId) :: "atms" :: Nil JsonHead _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (_, callContext) <- getAtmsIsPublic match { case false => authenticatedAccess(cc) @@ -1070,7 +1073,7 @@ trait APIMethods500 { ) lazy val createCustomer : OBPEndpoint = { case "banks" :: BankId(bankId) :: "customers" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { postedData <- NewStyle.function.tryons(s"$InvalidJsonFormat The Json body should be the $PostCustomerJsonV310 ", 400, cc.callContext) { json.extract[PostCustomerJsonV500] @@ -1142,7 +1145,7 @@ trait APIMethods500 { lazy val getCustomerOverview : OBPEndpoint = { case "banks" :: BankId(bankId) :: "customers" :: "customer-number-query" :: "overview" :: Nil JsonPost json -> req => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { postedData <- NewStyle.function.tryons(s"$InvalidJsonFormat The Json body should be the $PostCustomerOverviewJsonV500 ", 400, cc.callContext) { json.extract[PostCustomerOverviewJsonV500] @@ -1191,7 +1194,7 @@ trait APIMethods500 { lazy val getCustomerOverviewFlat : OBPEndpoint = { case "banks" :: BankId(bankId) :: "customers" :: "customer-number-query" :: "overview-flat" :: Nil JsonPost json -> req => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { postedData <- NewStyle.function.tryons(s"$InvalidJsonFormat The Json body should be the $PostCustomerOverviewJsonV500 ", 400, cc.callContext) { json.extract[PostCustomerOverviewJsonV500] @@ -1237,6 +1240,7 @@ trait APIMethods500 { lazy val getMyCustomersAtAnyBank : OBPEndpoint = { case "my" :: "customers" :: Nil JsonGet _ => { cc => { + implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- SS.user (customers, callContext) <- Connector.connector.vend.getCustomersByUserId(u.userId, callContext) map { @@ -1274,6 +1278,7 @@ trait APIMethods500 { lazy val getMyCustomersAtBank : OBPEndpoint = { case "banks" :: BankId(bankId) :: "my" :: "customers" :: Nil JsonGet _ => { cc => { + implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- SS.user (_, callContext) <- NewStyle.function.getBank(bankId, callContext) @@ -1318,6 +1323,7 @@ trait APIMethods500 { lazy val getCustomersAtOneBank : OBPEndpoint = { case "banks" :: BankId(bankId) :: "customers" :: Nil JsonGet _ => { cc => { + implicit val ec = EndpointContext(Some(cc)) for { (requestParams, callContext) <- extractQueryParams(cc.url, List("limit","offset","sort_direction"), cc.callContext) customers <- NewStyle.function.getCustomers(bankId, callContext, requestParams) @@ -1352,6 +1358,7 @@ trait APIMethods500 { lazy val getCustomersMinimalAtOneBank : OBPEndpoint = { case "banks" :: BankId(bankId) :: "customers-minimal" :: Nil JsonGet _ => { cc => { + implicit val ec = EndpointContext(Some(cc)) for { (requestParams, callContext) <- extractQueryParams(cc.url, List("limit","offset","sort_direction"), cc.callContext) customers <- NewStyle.function.getCustomers(bankId, callContext, requestParams) @@ -1401,7 +1408,7 @@ trait APIMethods500 { ) lazy val createProduct: OBPEndpoint = { case "banks" :: BankId(bankId) :: "products" :: ProductCode(productCode) :: Nil JsonPut json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- SS.user _ <- NewStyle.function.hasAtLeastOneEntitlement(failMsg = createProductEntitlementsRequiredText)(bankId.value, u.userId, createProductEntitlements, callContext) @@ -1466,7 +1473,7 @@ trait APIMethods500 { Some(List(canCreateCardsForBank))) lazy val addCardForBank: OBPEndpoint = { case "management" :: "banks" :: BankId(bankId) :: "cards" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), _,callContext) <- SS.userBank @@ -1584,7 +1591,7 @@ trait APIMethods500 { lazy val getViewsForBankAccount : OBPEndpoint = { //get the available views on an bank account case "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: "views" :: Nil JsonGet req => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) val res = for { (Full(u), callContext) <- SS.user @@ -1629,7 +1636,7 @@ trait APIMethods500 { lazy val deleteSystemView: OBPEndpoint = { case "system-views" :: viewId :: Nil JsonDelete req => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { _ <- NewStyle.function.systemView(ViewId(viewId), cc.callContext) view <- NewStyle.function.deleteSystemView(ViewId(viewId), cc.callContext) @@ -1716,6 +1723,7 @@ trait APIMethods500 { lazy val getMetricsAtBank : OBPEndpoint = { case "management" :: "metrics" :: "banks" :: bankId :: Nil JsonGet _ => { cc => { + implicit val ec = EndpointContext(Some(cc)) for { httpParams <- NewStyle.function.extractHttpParamsFromUrl(cc.url) (obpQueryParams, callContext) <- createQueriesByHttpParamsFuture(httpParams, cc.callContext) @@ -1752,7 +1760,7 @@ trait APIMethods500 { lazy val getSystemView: OBPEndpoint = { case "system-views" :: viewId :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { view <- NewStyle.function.systemView(ViewId(viewId), cc.callContext) } yield { @@ -1786,7 +1794,7 @@ trait APIMethods500 { lazy val getSystemViewsIds: OBPEndpoint = { case "system-views-ids" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { views <- NewStyle.function.systemViews() } yield { @@ -1833,7 +1841,7 @@ trait APIMethods500 { lazy val createSystemView : OBPEndpoint = { //creates a system view case "system-views" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { createViewJson <- NewStyle.function.tryons(failMsg = s"$InvalidJsonFormat The Json body should be the $CreateViewJson ", 400, cc.callContext) { json.extract[CreateViewJsonV500] @@ -1881,7 +1889,7 @@ trait APIMethods500 { lazy val updateSystemView : OBPEndpoint = { //updates a view on a bank account case "system-views" :: viewId :: Nil JsonPut json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { updateJson <- Future { tryo{json.extract[UpdateViewJsonV500]} } map { val msg = s"$InvalidJsonFormat The Json body should be the $UpdateViewJSON " @@ -1927,7 +1935,7 @@ trait APIMethods500 { Some(List(canCreateCustomerAccountLink))) lazy val createCustomerAccountLink : OBPEndpoint = { case "banks" :: BankId(bankId):: "customer-account-links" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (_, _,callContext) <- SS.userBank @@ -1978,7 +1986,7 @@ trait APIMethods500 { Some(List(canGetCustomerAccountLinks))) lazy val getCustomerAccountLinksByCustomerId : OBPEndpoint = { case "banks" :: BankId(bankId) :: "customers" :: customerId :: "customer-account-links" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (customer, callContext) <- NewStyle.function.getCustomerByCustomerId(customerId, cc.callContext) _ <- booleanToFuture(s"Bank of the customer specified by the CUSTOMER_ID(${customer.bankId}) has to matches BANK_ID(${bankId.value}) in URL", 400, callContext) { @@ -2016,7 +2024,7 @@ trait APIMethods500 { Some(List(canGetCustomerAccountLinks))) lazy val getCustomerAccountLinksByBankIdAccountId : OBPEndpoint = { case "banks" :: bankId :: "accounts" :: accountId :: "customer-account-links" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (_, _,callContext) <- SS.userBank (customerAccountLinks, callContext) <- NewStyle.function.getCustomerAccountLinksByBankIdAccountId(bankId, accountId, callContext) @@ -2050,7 +2058,7 @@ trait APIMethods500 { Some(List(canGetCustomerAccountLink))) lazy val getCustomerAccountLinkById : OBPEndpoint = { case "banks" :: BankId(bankId) :: "customer-account-links" :: customerAccountLinkId :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (_, _,callContext) <- SS.userBank (customerAccountLink, callContext) <- NewStyle.function.getCustomerAccountLinkById(customerAccountLinkId, callContext) @@ -2084,7 +2092,7 @@ trait APIMethods500 { Some(List(canUpdateCustomerAccountLink))) lazy val updateCustomerAccountLinkById : OBPEndpoint = { case "banks" :: BankId(bankId) :: "customer-account-links" :: customerAccountLinkId :: Nil JsonPut json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), _,callContext) <- SS.userBank postedData <- NewStyle.function.tryons(s"$InvalidJsonFormat The Json body should be the $UpdateCustomerAccountLinkJson ", 400, callContext) { @@ -2123,7 +2131,7 @@ trait APIMethods500 { Some(List(canDeleteCustomerAccountLink))) lazy val deleteCustomerAccountLinkById : OBPEndpoint = { case "banks" :: BankId(bankId) :: "customer-account-links" :: customerAccountLinkId :: Nil JsonDelete _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), _,callContext) <- SS.userBank (_, callContext) <- NewStyle.function.getCustomerAccountLinkById(customerAccountLinkId, callContext) @@ -2154,7 +2162,7 @@ trait APIMethods500 { ) lazy val getAdapterInfo: OBPEndpoint = { case "adapter" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (_, callContext) <- SS.user (adapterInfo,_) <- NewStyle.function.getAdapterInfo(callContext) diff --git a/obp-api/src/main/scala/code/api/v5_1_0/APIMethods510.scala b/obp-api/src/main/scala/code/api/v5_1_0/APIMethods510.scala index 21366d3fd5..9953920617 100644 --- a/obp-api/src/main/scala/code/api/v5_1_0/APIMethods510.scala +++ b/obp-api/src/main/scala/code/api/v5_1_0/APIMethods510.scala @@ -7,7 +7,7 @@ import code.api.util.APIUtil._ import code.api.util.ApiRole._ import code.api.util.ApiTag._ import code.api.util.ErrorMessages.{$UserNotLoggedIn, BankNotFound, ConsentNotFound, InvalidJsonFormat, UnknownError, UserNotFoundByUserId, UserNotLoggedIn, _} -import code.api.util.FutureUtil.EndpointTimeout +import code.api.util.FutureUtil.{EndpointContext, EndpointTimeout, endpointContext} import code.api.util.NewStyle.HttpCode import code.api.util._ import code.api.v2_0_0.{EntitlementJSONs, JSONFactory200} @@ -85,7 +85,7 @@ trait APIMethods510 { def root (apiVersion : ApiVersion, apiVersionStatus: String) : OBPEndpoint = { case (Nil | "root" :: Nil) JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { _ <- Future() // Just start async call } yield { @@ -113,7 +113,7 @@ trait APIMethods510 { lazy val waitingForGodot: OBPEndpoint = { case "waiting-for-godot" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) implicit val timeout = EndpointTimeout(Constant.mediumEndpointTimeoutInMillis) // Set endpoint timeout explicitly for { httpParams <- NewStyle.function.extractHttpParamsFromUrl(cc.url) @@ -150,7 +150,7 @@ trait APIMethods510 { lazy val getAllApiCollections: OBPEndpoint = { case "management" :: "api-collections" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (apiCollections, callContext) <- NewStyle.function.getAllApiCollections(cc.callContext) } yield { @@ -186,7 +186,7 @@ trait APIMethods510 { lazy val createNonPersonalUserAttribute: OBPEndpoint = { case "users" :: userId ::"non-personal":: "attributes" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) val failMsg = s"$InvalidJsonFormat The Json body should be the $UserAttributeJsonV510 " for { (user, callContext) <- NewStyle.function.getUserByUserId(userId, cc.callContext) @@ -237,7 +237,7 @@ trait APIMethods510 { lazy val deleteNonPersonalUserAttribute: OBPEndpoint = { case "users" :: userId :: "non-personal" :: "attributes" :: userAttributeId :: Nil JsonDelete _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (_, callContext) <- authenticatedAccess(cc) (_, callContext) <- NewStyle.function.getUserByUserId(userId, callContext) @@ -277,7 +277,7 @@ trait APIMethods510 { lazy val getNonPersonalUserAttributes: OBPEndpoint = { case "users" :: userId :: "non-personal" ::"attributes" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (_, callContext) <- authenticatedAccess(cc) (user, callContext) <- NewStyle.function.getUserByUserId(userId, callContext) @@ -317,7 +317,7 @@ trait APIMethods510 { lazy val getEntitlementsAndPermissions: OBPEndpoint = { case "users" :: userId :: "entitlements-and-permissions" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (user, callContext) <- NewStyle.function.getUserByUserId(userId, cc.callContext) entitlements <- NewStyle.function.getEntitlementsByUserId(userId, callContext) @@ -353,7 +353,7 @@ trait APIMethods510 { lazy val customViewNamesCheck: OBPEndpoint = { case "management" :: "system" :: "integrity" :: "custom-view-names-check" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { incorrectViews: List[ViewDefinition] <- Future { ViewDefinition.getCustomViews().filter { view => @@ -389,7 +389,7 @@ trait APIMethods510 { lazy val systemViewNamesCheck: OBPEndpoint = { case "management" :: "system" :: "integrity" :: "system-view-names-check" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { incorrectViews: List[ViewDefinition] <- Future { ViewDefinition.getSystemViews().filter { view => @@ -426,7 +426,7 @@ trait APIMethods510 { lazy val accountAccessUniqueIndexCheck: OBPEndpoint = { case "management" :: "system" :: "integrity" :: "account-access-unique-index-1-check" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { groupedRows: Map[String, List[AccountAccess]] <- Future { AccountAccess.findAll().groupBy { a => @@ -462,7 +462,7 @@ trait APIMethods510 { lazy val accountCurrencyCheck: OBPEndpoint = { case "management" :: "system" :: "integrity" :: "banks" :: BankId(bankId) :: "account-currency-check" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { currencies: List[String] <- Future { MappedBankAccount.findAll().map(_.accountCurrency.get).distinct @@ -496,7 +496,7 @@ trait APIMethods510 { lazy val getCurrenciesAtBank: OBPEndpoint = { case "banks" :: BankId(bankId) :: "currencies" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { _ <- Helper.booleanToFuture(failMsg = ConsumerHasMissingRoles + CanReadFx, cc=cc.callContext) { checkScope(bankId.value, getConsumerPrimaryKey(cc.callContext), ApiRole.canReadFx) @@ -536,7 +536,7 @@ trait APIMethods510 { lazy val orphanedAccountCheck: OBPEndpoint = { case "management" :: "system" :: "integrity" :: "banks" :: BankId(bankId) :: "orphaned-account-check" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { accountAccesses: List[String] <- Future { AccountAccess.findAll(By(AccountAccess.bank_id, bankId.value)).map(_.account_id.get) @@ -588,7 +588,7 @@ trait APIMethods510 { lazy val createAtmAttribute : OBPEndpoint = { case "banks" :: BankId(bankId) :: "atms" :: AtmId(atmId) :: "attributes" :: Nil JsonPost json -> _=> { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (_, callContext) <- NewStyle.function.getAtm(bankId, atmId, cc.callContext) failMsg = s"$InvalidJsonFormat The Json body should be the $AtmAttributeJsonV510 " @@ -642,7 +642,7 @@ trait APIMethods510 { lazy val getAtmAttributes : OBPEndpoint = { case "banks" :: BankId(bankId) :: "atms" :: AtmId(atmId) :: "attributes" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (_, callContext) <- NewStyle.function.getAtm(bankId, atmId, cc.callContext) (attributes, callContext) <- NewStyle.function.getAtmAttributesByAtm(bankId, atmId, callContext) @@ -678,7 +678,7 @@ trait APIMethods510 { lazy val getAtmAttribute : OBPEndpoint = { case "banks" :: BankId(bankId) :: "atms" :: AtmId(atmId) :: "attributes" :: atmAttributeId :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (_, callContext) <- NewStyle.function.getAtm(bankId, atmId, cc.callContext) (attribute, callContext) <- NewStyle.function.getAtmAttributeById(atmAttributeId, callContext) @@ -717,7 +717,7 @@ trait APIMethods510 { lazy val updateAtmAttribute : OBPEndpoint = { case "banks" :: BankId(bankId) :: "atms" :: AtmId(atmId) :: "attributes" :: atmAttributeId :: Nil JsonPut json -> _ =>{ - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (_, callContext) <- NewStyle.function.getAtm(bankId, atmId, cc.callContext) failMsg = s"$InvalidJsonFormat The Json body should be the $AtmAttributeJsonV510 " @@ -775,7 +775,7 @@ trait APIMethods510 { lazy val deleteAtmAttribute : OBPEndpoint = { case "banks" :: BankId(bankId) :: "atms" :: AtmId(atmId) :: "attributes" :: atmAttributeId :: Nil JsonDelete _=> { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (_, callContext) <- NewStyle.function.getAtm(bankId, atmId, cc.callContext) (atmAttribute, callContext) <- NewStyle.function.deleteAtmAttribute(atmAttributeId, callContext) @@ -809,7 +809,7 @@ trait APIMethods510 { List(apiTagConsent, apiTagPSD2AIS, apiTagPsd2)) lazy val getConsentByConsentId: OBPEndpoint = { case "consumer" :: "consents" :: consentId :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { consent <- Future { Consents.consentProvider.vend.getConsentByConsentId(consentId)} map { unboxFullOrFail(_, cc.callContext, ConsentNotFound) @@ -857,7 +857,7 @@ trait APIMethods510 { lazy val revokeConsentAtBank: OBPEndpoint = { case "banks" :: BankId(bankId) :: "consents" :: consentId :: Nil JsonDelete _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(user), callContext) <- authenticatedAccess(cc) (_, callContext) <- NewStyle.function.getBank(bankId, callContext) @@ -908,7 +908,7 @@ trait APIMethods510 { ) lazy val selfRevokeConsent: OBPEndpoint = { case "my" :: "consent" :: "current" :: Nil JsonDelete _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(user), callContext) <- authenticatedAccess(cc) consentId = getConsentIdRequestHeaderValue(cc.requestHeaders).getOrElse("") @@ -949,7 +949,7 @@ trait APIMethods510 { ) lazy val mtlsClientCertificateInfo: OBPEndpoint = { case "my" :: "mtls" :: "certificate" :: "current" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(_), callContext) <- authenticatedAccess(cc) info <- Future(X509.getCertificateInfo(APIUtil.`getPSD2-CERT`(cc.requestHeaders))) map { @@ -986,7 +986,7 @@ trait APIMethods510 { lazy val updateMyApiCollection: OBPEndpoint = { case "my" :: "api-collections" :: apiCollectionId :: Nil JsonPut json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { putJson <- NewStyle.function.tryons(s"$InvalidJsonFormat The Json body should be the $PostApiCollectionJson400", 400, cc.callContext) { json.extract[PostApiCollectionJson400] @@ -1029,7 +1029,7 @@ trait APIMethods510 { lazy val getUserByProviderAndUsername: OBPEndpoint = { case "users" :: "provider" :: provider :: "username" :: username :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { user <- Users.users.vend.getUserByProviderAndUsernameFuture(provider, username) map { x => unboxFullOrFail(x, cc.callContext, UserNotFoundByProviderAndUsername, 404) @@ -1063,7 +1063,7 @@ trait APIMethods510 { lazy val getUserLockStatus: OBPEndpoint = { //get private accounts for all banks case "users" ::provider :: username :: "lock-status" :: Nil JsonGet req => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- SS.user _ <- NewStyle.function.hasEntitlement("", u.userId, ApiRole.canReadUserLockedStatus, callContext) @@ -1104,7 +1104,7 @@ trait APIMethods510 { lazy val unlockUserByProviderAndUsername: OBPEndpoint = { //get private accounts for all banks case "users" :: provider :: username :: "lock-status" :: Nil JsonPut req => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- SS.user _ <- NewStyle.function.hasEntitlement("", u.userId, ApiRole.canUnlockUser, callContext) @@ -1148,7 +1148,7 @@ trait APIMethods510 { Some(List(canLockUser))) lazy val lockUserByProviderAndUsername: OBPEndpoint = { case "users" :: provider :: username :: "locks" :: Nil JsonPost req => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- SS.user userLocks <- Future { @@ -1223,6 +1223,7 @@ trait APIMethods510 { lazy val getAggregateMetrics: OBPEndpoint = { case "management" :: "aggregate-metrics" :: Nil JsonGet _ => { cc => { + implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) _ <- NewStyle.function.hasEntitlement("", u.userId, ApiRole.canReadAggregateMetrics, callContext) @@ -1267,6 +1268,7 @@ trait APIMethods510 { lazy val getCustomersForUserIdsOnly : OBPEndpoint = { case "users" :: "current" :: "customers" :: "customer_ids" :: Nil JsonGet _ => { cc => { + implicit val ec = EndpointContext(Some(cc)) for { (customers, callContext) <- Connector.connector.vend.getCustomersByUserId(cc.userId, cc.callContext) map { connectorEmptyResponse(_, cc.callContext) @@ -1299,7 +1301,7 @@ trait APIMethods510 { ) lazy val createAtm: OBPEndpoint = { case "banks" :: BankId(bankId) :: "atms" :: Nil JsonPost json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { atmJsonV510 <- NewStyle.function.tryons(s"$InvalidJsonFormat The Json body should be the ${classOf[AtmJsonV510]}", 400, cc.callContext) { val atm = json.extract[PostAtmJsonV510] @@ -1341,7 +1343,7 @@ trait APIMethods510 { ) lazy val updateAtm: OBPEndpoint = { case "banks" :: BankId(bankId) :: "atms" :: AtmId(atmId) :: Nil JsonPut json -> _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (atm, callContext) <- NewStyle.function.getAtm(bankId, atmId, cc.callContext) atmJsonV510 <- NewStyle.function.tryons(s"$InvalidJsonFormat The Json body should be the ${classOf[AtmJsonV510]}", 400, callContext) { @@ -1391,7 +1393,7 @@ trait APIMethods510 { ) lazy val getAtms: OBPEndpoint = { case "banks" :: BankId(bankId) :: "atms" :: Nil JsonGet _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) val limit = S.param("limit") val offset = S.param("offset") for { @@ -1451,7 +1453,7 @@ trait APIMethods510 { ) lazy val getAtm: OBPEndpoint = { case "banks" :: BankId(bankId) :: "atms" :: AtmId(atmId) :: Nil JsonGet req => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (_, callContext) <- getAtmsIsPublic match { case false => authenticatedAccess(cc) @@ -1489,7 +1491,7 @@ trait APIMethods510 { ) lazy val deleteAtm: OBPEndpoint = { case "banks" :: BankId(bankId) :: "atms" :: AtmId(atmId) :: Nil JsonDelete _ => { - cc => + cc => implicit val ec = EndpointContext(Some(cc)) for { (atm, callContext) <- NewStyle.function.getAtm(bankId, atmId, cc.callContext) (deleted, callContext) <- NewStyle.function.deleteAtm(atm, callContext) From 6e6ed995898a7cdf8f74be800e0dc1539447fa60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Mili=C4=87?= Date: Thu, 24 Aug 2023 07:46:57 +0200 Subject: [PATCH 3/3] feature/Enable Metric regarding Request Timeout 2 --- obp-api/src/main/scala/code/api/v3_1_0/APIMethods310.scala | 2 +- obp-api/src/main/scala/code/api/v4_0_0/APIMethods400.scala | 2 +- obp-api/src/main/scala/code/api/v5_0_0/APIMethods500.scala | 2 +- obp-api/src/main/scala/code/api/v5_1_0/APIMethods510.scala | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/obp-api/src/main/scala/code/api/v3_1_0/APIMethods310.scala b/obp-api/src/main/scala/code/api/v3_1_0/APIMethods310.scala index 835b7c0181..0ba4cd2a3d 100644 --- a/obp-api/src/main/scala/code/api/v3_1_0/APIMethods310.scala +++ b/obp-api/src/main/scala/code/api/v3_1_0/APIMethods310.scala @@ -13,7 +13,7 @@ import code.api.util.ApiRole._ import code.api.util.ApiTag._ import code.api.util.ErrorMessages.{BankAccountNotFound, _} import code.api.util.ExampleValue._ -import code.api.util.FutureUtil.{EndpointContext, endpointContext} +import code.api.util.FutureUtil.{EndpointContext} import code.api.util.NewStyle.HttpCode import code.api.util._ import code.api.v1_2_1.{JSONFactory, RateLimiting} diff --git a/obp-api/src/main/scala/code/api/v4_0_0/APIMethods400.scala b/obp-api/src/main/scala/code/api/v4_0_0/APIMethods400.scala index cfa5dad4af..41e672a555 100644 --- a/obp-api/src/main/scala/code/api/v4_0_0/APIMethods400.scala +++ b/obp-api/src/main/scala/code/api/v4_0_0/APIMethods400.scala @@ -44,7 +44,7 @@ import code.api.v4_0_0.JSONFactory400._ import code.api.dynamic.endpoint.helper._ import code.api.dynamic.endpoint.helper.practise.PractiseEndpoint import code.api.dynamic.entity.helper.{DynamicEntityHelper, DynamicEntityInfo} -import code.api.util.FutureUtil.{EndpointContext, endpointContext} +import code.api.util.FutureUtil.{EndpointContext} import code.api.v5_0_0.OBPAPI5_0_0 import code.api.{ChargePolicy, Constant, JsonResponseException} import code.apicollection.MappedApiCollectionsProvider diff --git a/obp-api/src/main/scala/code/api/v5_0_0/APIMethods500.scala b/obp-api/src/main/scala/code/api/v5_0_0/APIMethods500.scala index 15bdef5978..a3ef0cc79c 100644 --- a/obp-api/src/main/scala/code/api/v5_0_0/APIMethods500.scala +++ b/obp-api/src/main/scala/code/api/v5_0_0/APIMethods500.scala @@ -44,7 +44,7 @@ import java.util.concurrent.ThreadLocalRandom import code.accountattribute.AccountAttributeX import code.api.Constant.SYSTEM_OWNER_VIEW_ID -import code.api.util.FutureUtil.{EndpointContext, endpointContext} +import code.api.util.FutureUtil.{EndpointContext} import code.util.Helper.booleanToFuture import code.views.system.{AccountAccess, ViewDefinition} diff --git a/obp-api/src/main/scala/code/api/v5_1_0/APIMethods510.scala b/obp-api/src/main/scala/code/api/v5_1_0/APIMethods510.scala index 9953920617..2194967aca 100644 --- a/obp-api/src/main/scala/code/api/v5_1_0/APIMethods510.scala +++ b/obp-api/src/main/scala/code/api/v5_1_0/APIMethods510.scala @@ -7,7 +7,7 @@ import code.api.util.APIUtil._ import code.api.util.ApiRole._ import code.api.util.ApiTag._ import code.api.util.ErrorMessages.{$UserNotLoggedIn, BankNotFound, ConsentNotFound, InvalidJsonFormat, UnknownError, UserNotFoundByUserId, UserNotLoggedIn, _} -import code.api.util.FutureUtil.{EndpointContext, EndpointTimeout, endpointContext} +import code.api.util.FutureUtil.{EndpointContext, EndpointTimeout} import code.api.util.NewStyle.HttpCode import code.api.util._ import code.api.v2_0_0.{EntitlementJSONs, JSONFactory200}