Tweaked names regarding account tags

This commit is contained in:
Marko Milić 2019-10-22 13:05:45 +02:00
parent 0dac7febec
commit 2ca237cfdc
6 changed files with 64 additions and 25 deletions

View File

@ -177,7 +177,7 @@ The two user models are now called AuthUser and ResourceUser
* Answer Transaction Request Challenge (updated)
* Get Transaction Requests (updated)
* Get Roles (new)
* Get Entitlements By Bank And User (naaew)
* Get Entitlements By Bank And User (new)
* Get Consumer (App) (new)
* Get Consumers (App) (new)
* Enable Disable Consumers (Apps) (new)

View File

@ -15,7 +15,7 @@ import code.api.v3_0_0.JSONFactory300.createBranchJsonV300
import code.api.v3_0_0.custom.JSONFactoryCustom300
import code.api.v3_0_0.{LobbyJsonV330, _}
import code.api.v3_1_0.{AccountBalanceV310, AccountsBalancesV310Json, BadLoginStatusJson, ContactDetailsJson, InviteeJson, ObpApiLoopbackJson, PhysicalCardWithAttributesJsonV310, PutUpdateCustomerEmailJsonV310, _}
import code.api.v4_0_0.{APIInfoJson400, EnergySource400, HostedAt400, HostedBy400, ModeratedCoreAccountJsonV400}
import code.api.v4_0_0.{APIInfoJson400, AccountTagJSON, AccountTagsJSON, EnergySource400, HostedAt400, HostedBy400, ModeratedCoreAccountJsonV400, PostAccountTagJSON}
import code.branches.Branches.{Branch, DriveUpString, LobbyString}
import code.consent.ConsentStatus
import code.sandbox.SandboxData
@ -505,6 +505,9 @@ object SwaggerDefinitionsJSON {
val postTransactionTagJSON = PostTransactionTagJSON(
value = "String"
)
val postAccountTagJSON = PostAccountTagJSON(
value = "String"
)
val aliasJSON = AliasJSON(
alias = "String"
)
@ -895,6 +898,16 @@ object SwaggerDefinitionsJSON {
tags = List(transactionTagJSON)
)
val accountTagJSON = AccountTagJSON(
id = "5995d6a2-01b3-423c-a173-5481df49bdaf",
value = "OBP",
date = DateWithDayExampleObject,
user = userJSONV121
)
val accountTagsJSON = AccountTagsJSON(
tags = List(accountTagJSON)
)
val transactionMetadataJSON = TransactionMetadataJSON(
narrative = "NONE",
comments = List(transactionCommentJSON),
@ -3367,7 +3380,7 @@ object SwaggerDefinitionsJSON {
views_basic = List(viewBasicV300),
account_attributes = List(accountAttributeResponseJson)
)
val newModeratedCoreAccountJsonV400 = ModeratedCoreAccountJsonV400(
val moderatedCoreAccountJsonV400 = ModeratedCoreAccountJsonV400(
id = accountIdExample.value,
bank_id= bankIdExample.value,
label= labelExample.value,
@ -3378,7 +3391,7 @@ object SwaggerDefinitionsJSON {
account_routings = List(accountRoutingJsonV121),
views_basic = List(viewBasicV300),
account_attributes = List(accountAttributeResponseJson),
tags = List(transactionTagJSON)
tags = List(accountTagJSON)
)
val postHistoricalTransactionJson = PostHistoricalTransactionJson(

View File

@ -1104,8 +1104,8 @@ trait APIMethods400 {
|${authenticationRequiredMessage(true)}
|
|Authentication is required as the tag is linked with the user.""",
postTransactionTagJSON,
transactionTagJSON,
postAccountTagJSON,
accountTagJSON,
List(
UserNotLoggedIn,
BankAccountNotFound,
@ -1136,7 +1136,7 @@ trait APIMethods400 {
i => (connectorEmptyResponse(i, callContext), callContext)
}
} yield {
(JSONFactory.createTransactionTagJSON(postedTag), HttpCode.`201`(callContext))
(JSONFactory400.createAccountTagJSON(postedTag), HttpCode.`201`(callContext))
}
}
}
@ -1196,7 +1196,7 @@ trait APIMethods400 {
|
|Authentication is required as the tag is linked with the user.""",
emptyObjectJson,
transactionTagJSON,
accountTagsJSON,
List(
BankAccountNotFound,
NoViewPermission,
@ -1221,7 +1221,7 @@ trait APIMethods400 {
}
tags <- Future(Tags.tags.vend.getTagsOnAccount(bankId, accountId)(viewId))
} yield {
val json = JSONFactory.createTransactionTagsJSON(tags)
val json = JSONFactory400.createAccountTagsJSON(tags)
(json, HttpCode.`200`(callContext))
}
}
@ -1246,6 +1246,8 @@ trait APIMethods400 {
|* Balance - Currency and Value
|* Account Routings - A list that might include IBAN or national account identifiers
|* Account Rules - A list that might include Overdraft and other bank specific rules
|* Account Attributes - A list that might include custom defined account attribute
|* Tags - A list of Tags assigned to this account
|
|This call returns the owner view and requires access to that view.
|
@ -1254,7 +1256,7 @@ trait APIMethods400 {
|
|""".stripMargin,
emptyObjectJson,
newModeratedCoreAccountJsonV400,
moderatedCoreAccountJsonV400,
List(BankAccountNotFound,UnknownError),
Catalogs(Core, PSD2, notOBWG),
apiTagAccount :: apiTagPSD2AIS :: apiTagNewStyle :: Nil)

View File

@ -30,18 +30,17 @@ import java.util.Date
import code.api.util.APIUtil
import code.api.util.APIUtil.{stringOptionOrNull, stringOrNull}
import code.api.v1_2_1.JSONFactory.{createAmountOfMoneyJSON, createOwnersJSON, createTransactionTagJSON}
import code.api.v1_2_1.{BankRoutingJsonV121, TransactionTagJSON, UserJSONV121, ViewJSONV121}
import code.api.v1_2_1.JSONFactory.{createAmountOfMoneyJSON, createOwnersJSON}
import code.api.v1_2_1.{BankRoutingJsonV121, JSONFactory, UserJSONV121, ViewJSONV121}
import code.api.v1_4_0.JSONFactory1_4_0.TransactionRequestAccountJsonV140
import code.api.v2_0_0.TransactionRequestChargeJsonV200
import code.api.v3_0_0.JSONFactory300.createAccountRoutingsJSON
import code.api.v3_0_0.{NewModeratedCoreAccountJsonV300, ViewBasicV300}
import code.api.v3_0_0.ViewBasicV300
import code.api.v3_1_0.AccountAttributeResponseJson
import code.api.v3_1_0.JSONFactory310.createAccountAttributeJson
import code.model.ModeratedBankAccount
import code.transactionrequests.TransactionRequests.TransactionChallengeTypes
import code.transactionrequests.TransactionRequests.TransactionRequestTypes.ACCOUNT_OTP
import com.openbankproject.commons.model.{AccountAttribute, AccountRoutingJsonV121, AmountOfMoneyJsonV121, Bank, TransactionRequest, TransactionRequestBodyAllTypes, TransactionTag, View}
import com.openbankproject.commons.model._
import scala.collection.immutable.List
@ -114,7 +113,7 @@ case class ModeratedCoreAccountJsonV400(
account_routings: List[AccountRoutingJsonV121],
views_basic: List[ViewBasicV300],
account_attributes: List[AccountAttributeResponseJson],
tags: List[TransactionTagJSON]
tags: List[AccountTagJSON]
)
case class ModeratedAccountJSON400(
@ -128,9 +127,22 @@ case class ModeratedAccountJSON400(
bank_id : String,
account_routing :AccountRoutingJsonV121,
account_attributes: List[AccountAttributeResponseJson],
tags: List[TransactionTagJSON]
tags: List[AccountTagJSON]
)
case class AccountTagJSON(
id : String,
value : String,
date : Date,
user : UserJSONV121
)
case class AccountTagsJSON(
tags: List[AccountTagJSON]
)
case class PostAccountTagJSON(
value : String
)
object JSONFactory400 {
def createBankJSON400(bank: Bank): BankJson400 = {
val obp = BankRoutingJsonV121("OBP", bank.bankId.value)
@ -227,7 +239,7 @@ object JSONFactory400 {
createAccountRoutingsJSON(account.accountRoutings),
views_basic = availableViews.map(view => code.api.v3_0_0.ViewBasicV300(id = view.viewId.value, short_name = view.name, description = view.description, is_public = view.isPublic)),
accountAttributes.map(createAccountAttributeJson),
tags.map(createTransactionTagJSON)
tags.map(createAccountTagJSON)
)
}
@ -248,7 +260,20 @@ object JSONFactory400 {
stringOrNull(account.bankId.value),
AccountRoutingJsonV121(stringOptionOrNull(account.accountRoutingScheme),stringOptionOrNull(account.accountRoutingAddress)),
accountAttributes.map(createAccountAttributeJson),
tags.map(createTransactionTagJSON)
tags.map(createAccountTagJSON)
)
}
def createAccountTagsJSON(tags : List[TransactionTag]) : AccountTagsJSON = {
new AccountTagsJSON(tags.map(createAccountTagJSON))
}
def createAccountTagJSON(tag : TransactionTag) : AccountTagJSON = {
new AccountTagJSON(
id = tag.id_,
value = tag.value,
date = tag.datePosted,
user = JSONFactory.createUserJSON(tag.postedBy)
)
}

View File

@ -5,7 +5,6 @@ import code.api.ResourceDocs1_4_0.SwaggerDefinitionsJSON
import code.api.util.APIUtil.OAuth._
import code.api.util.ApiVersion
import code.api.util.ErrorMessages.UserNotLoggedIn
import code.api.v1_2_1.{TransactionTagJSON, TransactionTagsJSON}
import code.api.v4_0_0.OBPAPI4_0_0.Implementations4_0_0
import com.github.dwickern.macros.NameOf.nameOf
import net.liftweb.json.Serialization.write
@ -24,7 +23,7 @@ class AccountTagTest extends V400ServerSetup {
object ApiEndpoint2 extends Tag(nameOf(Implementations4_0_0.deleteTagForViewOnAccount))
object ApiEndpoint3 extends Tag(nameOf(Implementations4_0_0.getTagsForViewOnAccount))
lazy val accountTag = SwaggerDefinitionsJSON.transactionTagJSON
lazy val accountTag = SwaggerDefinitionsJSON.accountTagJSON
lazy val bankId = randomBankId
lazy val bankAccount = randomPrivateAccount(bankId)
lazy val view = randomOwnerViewPermalink(bankId, bankAccount)
@ -71,12 +70,12 @@ class AccountTagTest extends V400ServerSetup {
Then("We should get a 201 and check the response body")
response.code should equal(201)
response.body.extract[TransactionTagJSON]
response.body.extract[AccountTagJSON]
val requestGet = (v4_0_0_Request / "banks" / bankId / "accounts" / bankAccount.id / view / "metadata" / "tags").GET <@ (user1)
val responseGet = makeGetRequest(requestGet)
responseGet.code should equal(200)
val tags = responseGet.body.extract[TransactionTagsJSON].tags
val tags = responseGet.body.extract[AccountTagsJSON].tags
tags.exists(_.value == accountTag.value) equals true
val tagId = tags.map(_.id).headOption.getOrElse("")

View File

@ -164,8 +164,8 @@ case class UpdateViewJSON(
* @define canEditOwnerComment If true, the view can edit the Transaction Owner Comment
* @define canAddComment If true, the view can add a Transaction Comment
* @define canDeleteComment If true, the view can delete a Transaction Comment
* @define canAddTag If true, the view can add a Transaction Tag
* @define canDeleteTag If true, the view can delete a Transaction Tag
* @define canAddTag If true, the view can add a Transaction/Account Tag
* @define canDeleteTag If true, the view can delete a Transaction/Account Tag
* @define canAddImage If true, the view can add a Transaction Image
* @define canDeleteImage If true, the view can delete a Transaction Image
* @define canAddWhereTag If true, the view can add a Transaction Where Tag