Skip to content

Commit

Permalink
Merge pull request #2260 from constantine2nd/develop
Browse files Browse the repository at this point in the history
Old Style Endpoints
  • Loading branch information
simonredfern authored Sep 7, 2023
2 parents 76457e4 + 0c17579 commit a2de5be
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 29 deletions.
1 change: 1 addition & 0 deletions obp-api/src/main/scala/code/api/util/ApiTag.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ object ApiTag {
// Use the *singular* case. for both the variable name and string.
// e.g. "This call is Payment related"
// When using these tags in resource docs, as we now have many APIs, it's best not to have too use too many tags per endpoint.
val apiTagOldStyle = ResourceDocTag("Old-Style")
val apiTagTransactionRequest = ResourceDocTag("Transaction-Request")
val apiTagApi = ResourceDocTag("API")
val apiTagBank = ResourceDocTag("Bank")
Expand Down
55 changes: 31 additions & 24 deletions obp-api/src/main/scala/code/api/v1_2_1/APIMethods121.scala
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,15 @@ trait APIMethods121 {
apiTagApi :: Nil)

def root(apiVersion : ApiVersion, apiVersionStatus: String) : OBPEndpoint = {
case "root" :: Nil JsonGet req => cc =>Full(successJsonResponse(getApiInfoJSON(apiVersion, apiVersionStatus), 200))
case Nil JsonGet req => cc =>Full(successJsonResponse(getApiInfoJSON(apiVersion, apiVersionStatus), 200))
case (Nil | "root" :: Nil) JsonGet _ => {
cc =>
implicit val ec = EndpointContext(Some(cc))
for {
_ <- Future() // Just start async call
} yield {
(getApiInfoJSON(apiVersion,apiVersionStatus), HttpCode.`200`(cc.callContext))
}
}
}


Expand All @@ -177,7 +184,7 @@ trait APIMethods121 {
emptyObjectJson,
banksJSON,
List(UnknownError),
apiTagBank :: apiTagPsd2 :: Nil)
apiTagBank :: apiTagPsd2 :: apiTagOldStyle :: Nil)

lazy val getBanks : OBPEndpoint = {
//get banks
Expand Down Expand Up @@ -212,7 +219,7 @@ trait APIMethods121 {
emptyObjectJson,
bankJSON,
List(UserNotLoggedIn, UnknownError, BankNotFound),
apiTagBank :: apiTagPsd2 :: Nil)
apiTagBank :: apiTagPsd2 :: apiTagOldStyle :: Nil)


lazy val bankById : OBPEndpoint = {
Expand Down Expand Up @@ -244,7 +251,7 @@ trait APIMethods121 {
emptyObjectJson,
accountJSON,
List(UserNotLoggedIn, UnknownError),
apiTagAccount :: apiTagPsd2 :: Nil)
apiTagAccount :: apiTagPsd2 :: apiTagOldStyle :: Nil)

//TODO double check with `lazy val privateAccountsAllBanks :`, they are the same now.
lazy val getPrivateAccountsAllBanks : OBPEndpoint = {
Expand Down Expand Up @@ -277,7 +284,7 @@ trait APIMethods121 {
emptyObjectJson,
accountJSON,
List(UserNotLoggedIn, UnknownError),
apiTagAccount :: apiTagPsd2 :: Nil)
apiTagAccount :: apiTagPsd2 :: apiTagOldStyle :: Nil)

lazy val privateAccountsAllBanks : OBPEndpoint = {
//get private accounts for all banks
Expand Down Expand Up @@ -309,7 +316,7 @@ trait APIMethods121 {
emptyObjectJson,
accountJSON,
List(UnknownError),
apiTagAccount :: Nil)
apiTagAccount :: apiTagOldStyle :: Nil)

lazy val publicAccountsAllBanks : OBPEndpoint = {
//get public accounts for all banks
Expand Down Expand Up @@ -341,7 +348,7 @@ trait APIMethods121 {
emptyObjectJson,
accountJSON,
List(UserNotLoggedIn, UnknownError, BankNotFound),
apiTagAccount :: Nil)
apiTagAccount :: apiTagOldStyle :: Nil)

lazy val getPrivateAccountsAtOneBank : OBPEndpoint = {
//get accounts for a single bank (private + public)
Expand Down Expand Up @@ -374,7 +381,7 @@ trait APIMethods121 {
emptyObjectJson,
accountJSON,
List(UserNotLoggedIn, UnknownError, BankNotFound),
List(apiTagAccount, apiTagPsd2))
List(apiTagAccount, apiTagPsd2, apiTagOldStyle))

lazy val privateAccountsAtOneBank : OBPEndpoint = {
//get private accounts for a single bank
Expand Down Expand Up @@ -406,7 +413,7 @@ trait APIMethods121 {
emptyObjectJson,
accountJSON,
List(UserNotLoggedIn, UnknownError, BankNotFound),
apiTagAccountPublic :: apiTagAccount :: apiTagPublicData :: Nil)
apiTagAccountPublic :: apiTagAccount :: apiTagPublicData :: apiTagOldStyle :: Nil)

lazy val publicAccountsAtOneBank : OBPEndpoint = {
//get public accounts for a single bank
Expand Down Expand Up @@ -449,7 +456,7 @@ trait APIMethods121 {
emptyObjectJson,
moderatedAccountJSON,
List(UserNotLoggedIn, UnknownError, BankAccountNotFound),
apiTagAccount :: Nil)
apiTagAccount :: apiTagOldStyle :: Nil)

lazy val accountById : OBPEndpoint = {
//get account by id
Expand Down Expand Up @@ -551,7 +558,7 @@ trait APIMethods121 {
emptyObjectJson,
viewsJSONV121,
List(UserNotLoggedIn, BankAccountNotFound, UnknownError, "user does not have owner access"),
List(apiTagView, apiTagAccount))
List(apiTagView, apiTagAccount, apiTagOldStyle))

lazy val getViewsForBankAccount : OBPEndpoint = {
//get the available views on an bank account
Expand Down Expand Up @@ -603,7 +610,7 @@ trait APIMethods121 {
UnknownError,
"user does not have owner access"
),
List(apiTagAccount, apiTagView)
List(apiTagAccount, apiTagView, apiTagOldStyle)
)

lazy val createViewForBankAccount : OBPEndpoint = {
Expand Down Expand Up @@ -662,7 +669,7 @@ trait APIMethods121 {
UnknownError,
"user does not have owner access"
),
List(apiTagAccount, apiTagView)
List(apiTagAccount, apiTagView, apiTagOldStyle)
)

lazy val updateViewForBankAccount: OBPEndpoint = {
Expand Down Expand Up @@ -761,7 +768,7 @@ trait APIMethods121 {
emptyObjectJson,
permissionsJSON,
List(UserNotLoggedIn, UnknownError),
List(apiTagView, apiTagAccount, apiTagEntitlement)
List(apiTagView, apiTagAccount, apiTagEntitlement, apiTagOldStyle)
)

lazy val getPermissionsForBankAccount: OBPEndpoint = {
Expand Down Expand Up @@ -804,7 +811,7 @@ trait APIMethods121 {
UnknownError,
"user does not have access to owner view on account"
),
List(apiTagAccount, apiTagView, apiTagEntitlement)
List(apiTagAccount, apiTagView, apiTagEntitlement, apiTagOldStyle)
)


Expand Down Expand Up @@ -1028,7 +1035,7 @@ trait APIMethods121 {
BankAccountNotFound,
UnknownError
),
List(apiTagCounterparty, apiTagAccount, apiTagPsd2))
List(apiTagCounterparty, apiTagAccount, apiTagPsd2, apiTagOldStyle))

lazy val getOtherAccountsForBankAccount : OBPEndpoint = {
//get other accounts for one account
Expand Down Expand Up @@ -1058,7 +1065,7 @@ trait APIMethods121 {
emptyObjectJson,
otherAccountJSON,
List(BankAccountNotFound, UnknownError),
List(apiTagCounterparty, apiTagAccount))
List(apiTagCounterparty, apiTagAccount, apiTagOldStyle))

lazy val getOtherAccountByIdForBankAccount : OBPEndpoint = {
//get one other account by id
Expand Down Expand Up @@ -2101,7 +2108,7 @@ trait APIMethods121 {
"Coordinates not possible",
"Corporate Location cannot be deleted",
UnknownError),
List(apiTagCounterpartyMetaData, apiTagCounterparty))
List(apiTagCounterpartyMetaData, apiTagCounterparty, apiTagOldStyle))

lazy val addCounterpartyCorporateLocation : OBPEndpoint = {
//add corporate location to other bank account
Expand Down Expand Up @@ -2144,7 +2151,7 @@ trait APIMethods121 {
"Coordinates not possible",
"Corporate Location cannot be updated",
UnknownError),
List(apiTagCounterpartyMetaData, apiTagCounterparty))
List(apiTagCounterpartyMetaData, apiTagCounterparty, apiTagOldStyle))

lazy val updateCounterpartyCorporateLocation : OBPEndpoint = {
//update corporate location of other bank account
Expand Down Expand Up @@ -2236,7 +2243,7 @@ trait APIMethods121 {
"Coordinates not possible",
"Physical Location cannot be added",
UnknownError),
List(apiTagCounterpartyMetaData, apiTagCounterparty))
List(apiTagCounterpartyMetaData, apiTagCounterparty, apiTagOldStyle))

lazy val addCounterpartyPhysicalLocation : OBPEndpoint = {
//add physical location to other bank account
Expand Down Expand Up @@ -2280,7 +2287,7 @@ trait APIMethods121 {
"Coordinates not possible",
"Physical Location cannot be updated",
UnknownError),
List(apiTagCounterpartyMetaData, apiTagCounterparty))
List(apiTagCounterpartyMetaData, apiTagCounterparty, apiTagOldStyle))

lazy val updateCounterpartyPhysicalLocation : OBPEndpoint = {
//update physical location to other bank account
Expand Down Expand Up @@ -2369,7 +2376,7 @@ trait APIMethods121 {
emptyObjectJson,
transactionsJSON,
List(BankAccountNotFound, UnknownError),
List(apiTagTransaction, apiTagAccount, apiTagPsd2))
List(apiTagTransaction, apiTagAccount, apiTagPsd2, apiTagOldStyle))



Expand Down Expand Up @@ -2435,7 +2442,7 @@ trait APIMethods121 {
emptyObjectJson,
transactionJSON,
List(BankAccountNotFound, UnknownError),
List(apiTagTransaction, apiTagPsd2))
List(apiTagTransaction, apiTagPsd2, apiTagOldStyle))

lazy val getTransactionByIdForBankAccount : OBPEndpoint = {
//get transaction by id
Expand Down
16 changes: 11 additions & 5 deletions obp-api/src/main/scala/code/api/v4_0_0/APIMethods400.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2704,9 +2704,11 @@ trait APIMethods400 {
def root (apiVersion : ApiVersion, apiVersionStatus: String): OBPEndpoint = {
case (Nil | "root" :: Nil) JsonGet _ => {
cc =>
implicit val ec = EndpointContext(Some(cc))
Future {
getApiInfoJSON(apiVersion, apiVersionStatus) -> HttpCode.`200`(cc.callContext)
implicit val ec = EndpointContext(Some(cc))
for {
_ <- Future() // Just start async call
} yield {
(getApiInfoJSON(apiVersion,apiVersionStatus), HttpCode.`200`(cc.callContext))
}
}
}
Expand All @@ -2732,7 +2734,9 @@ trait APIMethods400 {
case "development" :: "call_context" :: Nil JsonGet _ => {
cc =>
implicit val ec = EndpointContext(Some(cc))
Future{
for {
_ <- Future() // Just start async call
} yield {
(cc.callContext, HttpCode.`200`(cc.callContext))
}
}
Expand All @@ -2758,7 +2762,9 @@ trait APIMethods400 {
case "development" :: "echo":: "jws-verified-request-jws-signed-response" :: Nil JsonGet _ => {
cc =>
implicit val ec = EndpointContext(Some(cc))
Future{
for {
_ <- Future() // Just start async call
} yield {
(cc.callContext, HttpCode.`200`(cc.callContext))
}
}
Expand Down

0 comments on commit a2de5be

Please sign in to comment.