Skip to content

Commit 3e1a6a0

Browse files
committed
system views clean up
1 parent 1d236a3 commit 3e1a6a0

2 files changed

Lines changed: 89 additions & 63 deletions

File tree

obp-api/src/main/scala/code/api/v6_0_0/APIMethods600.scala

Lines changed: 83 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import code.api.v5_0_0.JSONFactory500
2626
import code.api.v5_0_0.{ViewJsonV500, ViewsJsonV500}
2727
import code.api.v5_1_0.{JSONFactory510, PostCustomerLegalNameJsonV510}
2828
import code.api.dynamic.entity.helper.{DynamicEntityHelper, DynamicEntityInfo}
29-
import code.api.v6_0_0.JSONFactory600.{DynamicEntityDiagnosticsJsonV600, DynamicEntityIssueJsonV600, GroupJsonV600, GroupMembershipJsonV600, GroupMembershipsJsonV600, GroupsJsonV600, PostGroupJsonV600, PostGroupMembershipJsonV600, PostResetPasswordUrlJsonV600, PutGroupJsonV600, ReferenceTypeJsonV600, ReferenceTypesJsonV600, ResetPasswordUrlJsonV600, RoleWithEntitlementCountJsonV600, RolesWithEntitlementCountsJsonV600, ScannedApiVersionJsonV600, UpdateViewJsonV600, ValidateUserEmailJsonV600, ValidateUserEmailResponseJsonV600, ViewJsonV600, ViewPermissionJsonV600, ViewPermissionsJsonV600, createActiveCallLimitsJsonV600, createCallLimitJsonV600, createCurrentUsageJson}
29+
import code.api.v6_0_0.JSONFactory600.{DynamicEntityDiagnosticsJsonV600, DynamicEntityIssueJsonV600, GroupJsonV600, GroupMembershipJsonV600, GroupMembershipsJsonV600, GroupsJsonV600, PostGroupJsonV600, PostGroupMembershipJsonV600, PostResetPasswordUrlJsonV600, PutGroupJsonV600, ReferenceTypeJsonV600, ReferenceTypesJsonV600, ResetPasswordUrlJsonV600, RoleWithEntitlementCountJsonV600, RolesWithEntitlementCountsJsonV600, ScannedApiVersionJsonV600, UpdateViewJsonV600, ValidateUserEmailJsonV600, ValidateUserEmailResponseJsonV600, ViewJsonV600, ViewPermissionJsonV600, ViewPermissionsJsonV600, ViewsJsonV600, createActiveCallLimitsJsonV600, createCallLimitJsonV600, createCurrentUsageJson}
3030
import code.api.v6_0_0.OBPAPI6_0_0
3131
import code.metrics.APIMetrics
3232
import code.bankconnectors.LocalMappedConnectorInternal
@@ -3055,11 +3055,28 @@ trait APIMethods600 {
30553055
|- auditor
30563056
|- standard
30573057
|
3058+
|Each view is returned with an `allowed_actions` array containing all permissions for that view.
3059+
|
30583060
|${userAuthenticationMessage(true)}
30593061
|
30603062
|""".stripMargin,
30613063
EmptyBody,
3062-
ViewsJsonV500(List()),
3064+
ViewsJsonV600(List(
3065+
ViewJsonV600(
3066+
view_id = "owner",
3067+
short_name = "Owner",
3068+
description = "The owner of the account",
3069+
metadata_view = "owner",
3070+
is_public = false,
3071+
is_system = true,
3072+
is_firehose = Some(false),
3073+
alias = "private",
3074+
hide_metadata_if_alias_used = false,
3075+
can_grant_access_to_views = List("owner"),
3076+
can_revoke_access_to_views = List("owner"),
3077+
allowed_actions = List("can_see_transaction_amount", "can_see_bank_account_balance")
3078+
)
3079+
)),
30633080
List(
30643081
UserNotLoggedIn,
30653082
UserHasMissingRoles,
@@ -3076,7 +3093,7 @@ trait APIMethods600 {
30763093
(Full(u), callContext) <- authenticatedAccess(cc)
30773094
views <- Views.views.vend.getSystemViews()
30783095
} yield {
3079-
(JSONFactory500.createViewsJsonV500(views), HttpCode.`200`(callContext))
3096+
(JSONFactory600.createViewsJsonV600(views), HttpCode.`200`(callContext))
30803097
}
30813098
}
30823099
}
@@ -3096,6 +3113,8 @@ trait APIMethods600 {
30963113
|- auditor
30973114
|- standard
30983115
|
3116+
|The view is returned with an `allowed_actions` array containing all permissions for that view.
3117+
|
30993118
|${userAuthenticationMessage(true)}
31003119
|
31013120
|""".stripMargin,
@@ -3141,66 +3160,67 @@ trait APIMethods600 {
31413160
}
31423161
}
31433162

3144-
staticResourceDocs += ResourceDoc(
3145-
getSystemView,
3146-
implementedInApiVersion,
3147-
nameOf(getSystemView),
3148-
"GET",
3149-
"/system-views/VIEW_ID",
3150-
"Get System View",
3151-
s"""Get a single system view by its ID.
3152-
|
3153-
|System views are predefined views that apply to all accounts, such as:
3154-
|- owner
3155-
|- accountant
3156-
|- auditor
3157-
|- standard
3158-
|
3159-
|This endpoint returns the view with an `allowed_actions` array containing all permissions.
3160-
|
3161-
|${userAuthenticationMessage(true)}
3162-
|
3163-
|""".stripMargin,
3164-
EmptyBody,
3165-
ViewJsonV600(
3166-
view_id = "owner",
3167-
short_name = "Owner",
3168-
description = "The owner of the account. Has full privileges.",
3169-
metadata_view = "owner",
3170-
is_public = false,
3171-
is_system = true,
3172-
is_firehose = Some(false),
3173-
alias = "private",
3174-
hide_metadata_if_alias_used = false,
3175-
can_grant_access_to_views = List("owner", "accountant"),
3176-
can_revoke_access_to_views = List("owner", "accountant"),
3177-
allowed_actions = List(
3178-
"can_see_transaction_amount",
3179-
"can_see_bank_account_balance",
3180-
"can_add_comment",
3181-
"can_create_custom_view"
3182-
)
3183-
),
3184-
List(
3185-
UserNotLoggedIn,
3186-
SystemViewNotFound,
3187-
UnknownError
3188-
),
3189-
List(apiTagSystemView, apiTagView),
3190-
Some(List(canGetSystemViews))
3191-
)
3192-
3193-
lazy val getSystemView: OBPEndpoint = {
3194-
case "system-views" :: viewId :: Nil JsonGet _ => {
3195-
cc => implicit val ec = EndpointContext(Some(cc))
3196-
for {
3197-
(Full(u), callContext) <- authenticatedAccess(cc)
3198-
view <- ViewNewStyle.systemView(ViewId(viewId), callContext)
3199-
} yield {
3200-
(JSONFactory600.createViewJsonV600(view), HttpCode.`200`(callContext))
3201-
}
3202-
}
3203-
}
3163+
// staticResourceDocs += ResourceDoc(
3164+
// getSystemView,
3165+
// implementedInApiVersion,
3166+
// nameOf(getSystemView),
3167+
// "GET",
3168+
// "/system-views/VIEW_ID",
3169+
// "Get System View",
3170+
// s"""Get a single system view by its ID.
3171+
// |
3172+
// |System views are predefined views that apply to all accounts, such as:
3173+
// |- owner
3174+
// |- accountant
3175+
// |- auditor
3176+
// |- standard
3177+
// |
3178+
// |This endpoint returns the view with an `allowed_actions` array containing all permissions.
3179+
// |
3180+
// |${userAuthenticationMessage(true)}
3181+
// |
3182+
// |""".stripMargin,
3183+
// EmptyBody,
3184+
// ViewJsonV600(
3185+
// view_id = "owner",
3186+
// short_name = "Owner",
3187+
// description = "The owner of the account. Has full privileges.",
3188+
// metadata_view = "owner",
3189+
// is_public = false,
3190+
// is_system = true,
3191+
// is_firehose = Some(false),
3192+
// alias = "private",
3193+
// hide_metadata_if_alias_used = false,
3194+
// can_grant_access_to_views = List("owner", "accountant"),
3195+
// can_revoke_access_to_views = List("owner", "accountant"),
3196+
// allowed_actions = List(
3197+
// "can_see_transaction_amount",
3198+
// "can_see_bank_account_balance",
3199+
// "can_add_comment",
3200+
// "can_create_custom_view"
3201+
// )
3202+
// ),
3203+
// List(
3204+
// UserNotLoggedIn,
3205+
// UserHasMissingRoles,
3206+
// SystemViewNotFound,
3207+
// UnknownError
3208+
// ),
3209+
// List(apiTagSystemView, apiTagView),
3210+
// Some(List(canGetSystemViews))
3211+
// )
3212+
//
3213+
// lazy val getSystemView: OBPEndpoint = {
3214+
// case "system-views" :: viewId :: Nil JsonGet _ => {
3215+
// cc => implicit val ec = EndpointContext(Some(cc))
3216+
// for {
3217+
// (Full(u), callContext) <- authenticatedAccess(cc)
3218+
// view <- ViewNewStyle.systemView(ViewId(viewId), callContext)
3219+
// } yield {
3220+
// (JSONFactory600.createViewJsonV600(view), HttpCode.`200`(callContext))
3221+
// }
3222+
// }
3223+
// }
32043224

32053225
staticResourceDocs += ResourceDoc(
32063226
updateSystemView,

obp-api/src/main/scala/code/api/v6_0_0/JSONFactory6.0.0.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,8 @@ case class ViewJsonV600(
678678
allowed_actions: List[String]
679679
)
680680

681+
case class ViewsJsonV600(views: List[ViewJsonV600])
682+
681683
case class UpdateViewJsonV600(
682684
description: String,
683685
metadata_view: String,
@@ -729,4 +731,8 @@ case class UpdateViewJsonV600(
729731
allowed_actions = allowed_actions
730732
)
731733
}
734+
735+
def createViewsJsonV600(views: List[View]): ViewsJsonV600 = {
736+
ViewsJsonV600(views.map(createViewJsonV600))
737+
}
732738
}

0 commit comments

Comments
 (0)