mirror of
https://github.com/OpenBankProject/OBP-API.git
synced 2026-02-06 13:26:51 +00:00
Merge remote-tracking branch 'hongwei/develop' into develop
This commit is contained in:
commit
50b7d757e1
@ -108,6 +108,7 @@ write_connector_metrics=true
|
||||
#es.warehouse.port.http=9200
|
||||
|
||||
#es.warehouse.allowed.indices = index1,index2 (or = ALL for all).
|
||||
#es.warehouse.allowed.maximum.size = 10000
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1994,6 +1994,8 @@ object SwaggerDefinitionsJSON {
|
||||
nameSuffix = ExampleValue.nameSuffixExample.value
|
||||
)
|
||||
|
||||
val customersJsonV300 = code.api.v3_0_0.CustomerJSONs(List(customerJsonV300))
|
||||
|
||||
val postCustomerJsonV310 =
|
||||
PostCustomerJsonV310(
|
||||
legal_name = ExampleValue.legalNameExample.value,
|
||||
|
||||
@ -92,6 +92,9 @@ object ApiRole {
|
||||
case class CanUpdateAccount(requiresBankId: Boolean = true) extends ApiRole
|
||||
lazy val canUpdateAccount = CanUpdateAccount()
|
||||
|
||||
case class CanUpdateAccountAttribute(requiresBankId: Boolean = true) extends ApiRole
|
||||
lazy val canUpdateAccountAttribute = CanUpdateAccountAttribute()
|
||||
|
||||
case class CanGetAnyUser (requiresBankId: Boolean = false) extends ApiRole
|
||||
lazy val canGetAnyUser = CanGetAnyUser()
|
||||
|
||||
@ -410,6 +413,7 @@ object ApiRole {
|
||||
canDeleteCustomerAddress ::
|
||||
canCreateAccount ::
|
||||
canUpdateAccount ::
|
||||
canUpdateAccountAttribute ::
|
||||
canGetAnyUser ::
|
||||
canCreateAnyTransactionRequest ::
|
||||
canAddSocialMediaHandle ::
|
||||
|
||||
@ -59,6 +59,7 @@ object NewStyle {
|
||||
(nameOf(Implementations2_0_0.addKycStatus), ApiVersion.v2_0_0.toString),
|
||||
(nameOf(Implementations2_0_0.addKycCheck), ApiVersion.v2_0_0.toString),
|
||||
(nameOf(Implementations2_1_0.getRoles), ApiVersion.v3_1_0.toString),
|
||||
(nameOf(Implementations2_1_0.getCustomersForCurrentUserAtBank), ApiVersion.v3_1_0.toString),
|
||||
(nameOf(Implementations2_2_0.config), ApiVersion.v2_2_0.toString),
|
||||
(nameOf(Implementations2_2_0.getViewsForBankAccount), ApiVersion.v2_2_0.toString),
|
||||
(nameOf(Implementations2_2_0.getCurrentFxRate), ApiVersion.v2_2_0.toString),
|
||||
|
||||
@ -1464,12 +1464,12 @@ trait APIMethods210 {
|
||||
"GET",
|
||||
"/banks/BANK_ID/customers",
|
||||
"Get Customers for current User at Bank",
|
||||
s"""Retuns a list of Customers at the Bank that are linked to the currently authenticated User.
|
||||
s"""Returns a list of Customers at the Bank that are linked to the currently authenticated User.
|
||||
|
|
||||
|
|
||||
|${authenticationRequiredMessage(true)}""",
|
||||
emptyObjectJson,
|
||||
customerJsonV210,
|
||||
customerJSONs,
|
||||
List(
|
||||
UserNotLoggedIn,
|
||||
BankNotFound,
|
||||
@ -1485,14 +1485,16 @@ trait APIMethods210 {
|
||||
case "banks" :: BankId(bankId) :: "customers" :: Nil JsonGet _ => {
|
||||
cc => {
|
||||
for {
|
||||
u <- cc.user ?~! UserNotLoggedIn
|
||||
(bank, callContext ) <- BankX(bankId, Some(cc)) ?~! {BankNotFound}
|
||||
customers <- tryo{CustomerX.customerProvider.vend.getCustomersByUserId(u.userId)} ?~! UserCustomerLinksNotFoundForUser
|
||||
// Filter so we only see the ones for the bank in question
|
||||
bankCustomers = customers.filter(_.bankId==bankId.value)
|
||||
(Full(u), callContext) <- authorizedAccess(cc)
|
||||
(_, callContext) <- NewStyle.function.getBank(bankId, callContext)
|
||||
(customers, callContext) <- Connector.connector.vend.getCustomersByUserId(u.userId, callContext) map {
|
||||
connectorEmptyResponse(_, callContext)
|
||||
}
|
||||
} yield {
|
||||
// Filter so we only see the ones for the bank in question
|
||||
val bankCustomers = customers.filter(_.bankId==bankId.value)
|
||||
val json = JSONFactory210.createCustomersJson(bankCustomers)
|
||||
successJsonResponse(Extraction.decompose(json))
|
||||
(json, HttpCode.`200`(callContext))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -40,8 +40,8 @@ import scala.collection.immutable.{List, Nil}
|
||||
import scala.collection.mutable.ArrayBuffer
|
||||
import scala.concurrent.ExecutionContext.Implicits.global
|
||||
import scala.concurrent.Future
|
||||
|
||||
import code.api.v2_0_0.AccountsHelper._
|
||||
import net.liftweb.json.JsonAST.JField
|
||||
|
||||
|
||||
trait APIMethods300 {
|
||||
@ -747,6 +747,18 @@ trait APIMethods300 {
|
||||
_ <- Helper.booleanToFuture(failMsg = ElasticSearchDisabled) {
|
||||
esw.isEnabled()
|
||||
}
|
||||
maximumSize = APIUtil.getPropsAsIntValue("es.warehouse.allowed.maximum.size", 10000)
|
||||
//This is for performance issue, we can not support query more than maximumSize records in one call.
|
||||
// If it contains the size and if it over maximumSize, we will throw the error back.
|
||||
_ <- Helper.booleanToFuture(failMsg = maximumLimitExceeded.replace("Maximum number is 10000.",s"Please check query body, the maximum size is $maximumSize.")) {
|
||||
// find all the size field.
|
||||
val allSizeFields = json filterField {
|
||||
case JField(key, _) => key.equals("size")
|
||||
}
|
||||
//loop all the items and if find any value is over maximumSize, then throw the proper error !
|
||||
allSizeFields.map(_.value.values.toString.toInt).find(_ > maximumSize).isEmpty
|
||||
}
|
||||
|
||||
indexPart <- Future { esw.getElasticSearchUri(index) } map {
|
||||
x => unboxFullOrFail(x, callContext, ElasticSearchIndexNotFound)
|
||||
}
|
||||
@ -816,6 +828,18 @@ trait APIMethods300 {
|
||||
_ <- Helper.booleanToFuture(failMsg = ElasticSearchDisabled) {
|
||||
esw.isEnabled()
|
||||
}
|
||||
maximumSize = APIUtil.getPropsAsIntValue("es.warehouse.allowed.maximum.size", 10000)
|
||||
//This is for performance issue, we can not support query more than maximumSize records in one call.
|
||||
// If it contains the size and if it over maximumSize, we will throw the error back.
|
||||
_ <- Helper.booleanToFuture(failMsg = maximumLimitExceeded.replace("Maximum number is 10000.",s"Please check query body, the maximum size is $maximumSize.")) {
|
||||
// find all the size field.
|
||||
val allSizeFields = json filterField {
|
||||
case JField(key, _) => key.equals("size")
|
||||
}
|
||||
//loop all the items and if find any value is over maximumSize, then throw the proper error !
|
||||
allSizeFields.map(_.value.values.toString.toInt).find(_ > maximumSize).isEmpty
|
||||
}
|
||||
|
||||
indexPart <- Future { esw.getElasticSearchUri(index) } map {
|
||||
x => unboxFullOrFail(x, callContext, ElasticSearchIndexNotFound)
|
||||
}
|
||||
@ -824,7 +848,7 @@ trait APIMethods300 {
|
||||
}
|
||||
result <- esw.searchProxyStatsAsyncV300(u.userId, indexPart, bodyPart, field)
|
||||
} yield {
|
||||
(esw.parseResponse(result), HttpCode.`201`(callContext))
|
||||
(esw.parseResponse(result, true), HttpCode.`201`(callContext))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1298,8 +1322,10 @@ trait APIMethods300 {
|
||||
}
|
||||
(_, callContext)<- NewStyle.function.getBank(bankId, callContext)
|
||||
(branches, callContext) <- Connector.connector.vend.getBranches(bankId, callContext) map {
|
||||
case Full((List(), _)) | Empty =>
|
||||
case Empty =>
|
||||
fullBoxOrException(Empty ?~! BranchesNotFound)
|
||||
case Full((List(), callContext)) =>
|
||||
Full(List())
|
||||
case Full((list, callContext)) =>
|
||||
val branchesWithLicense = for { branch <- list if branch.meta.license.name.size > 3 } yield branch
|
||||
if (branchesWithLicense.size == 0) fullBoxOrException(Empty ?~! branchesNotFoundLicense)
|
||||
@ -1424,8 +1450,10 @@ trait APIMethods300 {
|
||||
}
|
||||
(_, callContext) <- NewStyle.function.getBank(bankId, callContext)
|
||||
(atms, callContext) <- Connector.connector.vend.getAtms(bankId, callContext) map {
|
||||
case Full((List(),_)) | Empty =>
|
||||
case Empty =>
|
||||
fullBoxOrException(Empty ?~! atmsNotFound)
|
||||
case Full((List(), callContext)) =>
|
||||
Full(List())
|
||||
case Full((list, _)) =>
|
||||
val branchesWithLicense = for { branch <- list if branch.meta.license.name.size > 3 } yield branch
|
||||
if (branchesWithLicense.size == 0) fullBoxOrException(Empty ?~! atmsNotFoundLicense)
|
||||
@ -1507,7 +1535,7 @@ trait APIMethods300 {
|
||||
|
|
||||
|""",
|
||||
emptyObjectJson,
|
||||
customerJsonV300,
|
||||
customersJsonV300,
|
||||
List(
|
||||
UserNotLoggedIn,
|
||||
UserCustomerLinksNotFoundForUser,
|
||||
|
||||
@ -2840,14 +2840,16 @@ trait APIMethods310 {
|
||||
UnknownError
|
||||
),
|
||||
Catalogs(notCore, notPSD2, notOBWG),
|
||||
List(apiTagAccount, apiTagNewStyle))
|
||||
List(apiTagAccount, apiTagNewStyle),
|
||||
Some(List(canUpdateAccountAttribute))
|
||||
)
|
||||
|
||||
lazy val updateAccountAttribute : OBPEndpoint = {
|
||||
case "banks" :: bankId :: "accounts" :: accountId :: "products" :: productCode :: "attributes" :: accountAtrributeId :: Nil JsonPut json -> _=> {
|
||||
case "banks" :: bankId :: "accounts" :: accountId :: "products" :: productCode :: "attributes" :: accountAttributeId :: Nil JsonPut json -> _=> {
|
||||
cc =>
|
||||
for {
|
||||
(_, callContext) <- authorizedAccess(cc)
|
||||
|
||||
(Full(u), callContext) <- authorizedAccess(cc)
|
||||
_ <- NewStyle.function.hasEntitlement(bankId, u.userId, canUpdateAccountAttribute, callContext)
|
||||
failMsg = s"$InvalidJsonFormat The Json body should be the $AccountAttributeJson "
|
||||
postedData <- NewStyle.function.tryons(failMsg, 400, callContext) {
|
||||
json.extract[AccountAttributeJson]
|
||||
@ -2862,14 +2864,14 @@ trait APIMethods310 {
|
||||
(_, callContext) <- NewStyle.function.getBank(BankId(bankId), callContext)
|
||||
(_, callContext) <- NewStyle.function.getBankAccount(BankId(bankId), AccountId(accountId), callContext)
|
||||
(_, callContext) <- NewStyle.function.getProduct(BankId(bankId), ProductCode(productCode), callContext)
|
||||
(_, callContext) <- NewStyle.function.getAccountAttributeById(accountAtrributeId, callContext)
|
||||
(_, callContext) <- NewStyle.function.getAccountAttributeById(accountAttributeId, callContext)
|
||||
|
||||
|
||||
(accountAttribute, callContext) <- NewStyle.function.createOrUpdateAccountAttribute(
|
||||
BankId(bankId),
|
||||
AccountId(accountId),
|
||||
ProductCode(productCode),
|
||||
Some(accountAtrributeId),
|
||||
Some(accountAttributeId),
|
||||
postedData.name,
|
||||
accountAttributeType,
|
||||
postedData.value,
|
||||
|
||||
@ -1749,8 +1749,8 @@ object LocalMappedConnector extends Connector with MdcLoggable {
|
||||
// Insert...
|
||||
logger.info("Creating Branch...")
|
||||
MappedBranch.create
|
||||
.mBranchId(branch.branchId.toString)
|
||||
.mBankId(branch.bankId.toString)
|
||||
.mBranchId(branch.branchId.value)
|
||||
.mBankId(branch.bankId.value)
|
||||
.mName(branch.name)
|
||||
.mLine1(branch.address.line1)
|
||||
.mLine2(branch.address.line2)
|
||||
|
||||
@ -90,8 +90,6 @@ class elasticsearch extends MdcLoggable {
|
||||
val response = getAPIResponseAsync(request)
|
||||
logger.info (s"searchProxyAsyncV300 says response follows:")
|
||||
|
||||
// TODO Extract code and hits from response and log that.
|
||||
|
||||
response foreach {
|
||||
msg => logger.info(msg.body)
|
||||
}
|
||||
|
||||
@ -332,10 +332,10 @@ class BranchesTest extends V300ServerSetup with DefaultUsers {
|
||||
When("We make a request v3.0.0")
|
||||
val request300 = (v3_0Request / "banks" / BankWithoutBranches.value / "branches").GET <@(user1)
|
||||
val response300 = makeGetRequest(request300)
|
||||
Then("We should get a 400 and correct response json format")
|
||||
response300.code should equal(400)
|
||||
response300.body.extract[BranchesJsonV300]
|
||||
response300.body.extract[ErrorMessage].message should include (ErrorMessages.BranchesNotFound)
|
||||
Then("We should get a 200 and correct response json format")
|
||||
response300.code should equal(200)
|
||||
val result = response300.body.extract[BranchesJsonV300]
|
||||
result.branches.size should be (0)
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -3,6 +3,8 @@
|
||||
### Most recent changes at top of file
|
||||
```
|
||||
Date Commit Action
|
||||
04/10/2019 aa9659c7 Added props: es.warehouse.allowed.maximum.size. This is the maximum size in the query for warehouse apis.
|
||||
It has the default value 10000.
|
||||
03/09/2019 f953386c Added props: implicitly_convert_ids . it will convert Bank_Plan_Text_Reference to OBP-UUID implicitly.
|
||||
21/08/2019 4ac93f1c Added props: webui_register_consumer_success_message_webpage and webui_register_consumer_success_message_email.
|
||||
These messages will be shown to developers on the webpage or email, when they register the consumer successfully.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user