diff --git a/obp-api/src/main/scala/code/api/ResourceDocs1_4_0/SwaggerDefinitionsJSON.scala b/obp-api/src/main/scala/code/api/ResourceDocs1_4_0/SwaggerDefinitionsJSON.scala index 6c7b6c3897..4176e67555 100644 --- a/obp-api/src/main/scala/code/api/ResourceDocs1_4_0/SwaggerDefinitionsJSON.scala +++ b/obp-api/src/main/scala/code/api/ResourceDocs1_4_0/SwaggerDefinitionsJSON.scala @@ -5245,7 +5245,16 @@ object SwaggerDefinitionsJSON { category = Some("category1"), more_info_url = Some("https://example.com/more-info"), terms_and_conditions_url = Some("https://example.com/terms"), - description = Some("Description of the product") + description = Some("Description of the product"), + collection_id = Some("collection-abc"), + monthly_subscription_currency = Some("EUR"), + monthly_subscription_amount = Some("9.99"), + per_second_call_limit = Some(10L), + per_minute_call_limit = Some(100L), + per_hour_call_limit = Some(1000L), + per_day_call_limit = Some(10000L), + per_week_call_limit = Some(50000L), + per_month_call_limit = Some(200000L) ) lazy val apiProductJsonV600 = ApiProductJsonV600( api_product_id = "api-product-id-123", @@ -5257,6 +5266,15 @@ object SwaggerDefinitionsJSON { more_info_url = "https://example.com/more-info", terms_and_conditions_url = "https://example.com/terms", description = "Description of the product", + collection_id = "collection-abc", + monthly_subscription_currency = "EUR", + monthly_subscription_amount = "9.99", + per_second_call_limit = 10L, + per_minute_call_limit = 100L, + per_hour_call_limit = 1000L, + per_day_call_limit = 10000L, + per_week_call_limit = 50000L, + per_month_call_limit = 200000L, attributes = Some(List(apiProductAttributeResponseJsonV600)) ) lazy val apiProductsJsonV600 = ApiProductsJsonV600(List(apiProductJsonV600)) diff --git a/obp-api/src/main/scala/code/api/util/NewStyle.scala b/obp-api/src/main/scala/code/api/util/NewStyle.scala index ca62a40011..94972c7f60 100644 --- a/obp-api/src/main/scala/code/api/util/NewStyle.scala +++ b/obp-api/src/main/scala/code/api/util/NewStyle.scala @@ -3823,11 +3823,23 @@ object NewStyle extends MdcLoggable{ moreInfoUrl: String, termsAndConditionsUrl: String, description: String, + collectionId: String, + monthlySubscriptionCurrency: String, + monthlySubscriptionAmount: String, + perSecondCallLimit: Long, + perMinuteCallLimit: Long, + perHourCallLimit: Long, + perDayCallLimit: Long, + perWeekCallLimit: Long, + perMonthCallLimit: Long, callContext: Option[CallContext] ): OBPReturnType[ApiProductTrait] = { Future(MappedApiProductsProvider.createOrUpdateApiProduct( bankId, apiProductCode, parentApiProductCode, name, category, - moreInfoUrl, termsAndConditionsUrl, description + moreInfoUrl, termsAndConditionsUrl, description, + collectionId, monthlySubscriptionCurrency, monthlySubscriptionAmount, + perSecondCallLimit, perMinuteCallLimit, perHourCallLimit, + perDayCallLimit, perWeekCallLimit, perMonthCallLimit )) map { i => (unboxFullOrFail(i, callContext, CreateApiProductError), callContext) } @@ -3874,6 +3886,12 @@ object NewStyle extends MdcLoggable{ } } + def deleteApiProductAttributesByBankIdAndCode(bankId: String, apiProductCode: String, callContext: Option[CallContext]): OBPReturnType[Boolean] = { + Future(MappedApiProductAttributesProvider.deleteApiProductAttributesByBankIdAndCode(bankId, apiProductCode)) map { + i => (unboxFullOrFail(i, callContext, s"$DeleteApiProductAttributeError Current BANK_ID($bankId) API_PRODUCT_CODE($apiProductCode)"), callContext) + } + } + def createApiCollectionEndpoint( apiCollectionId: String, operationId: String, diff --git a/obp-api/src/main/scala/code/api/v6_0_0/APIMethods600.scala b/obp-api/src/main/scala/code/api/v6_0_0/APIMethods600.scala index 4ddd59d100..f14f0f926d 100644 --- a/obp-api/src/main/scala/code/api/v6_0_0/APIMethods600.scala +++ b/obp-api/src/main/scala/code/api/v6_0_0/APIMethods600.scala @@ -3940,7 +3940,7 @@ trait APIMethods600 { nameOf(addUserToGroup), "POST", "/users/USER_ID/group-entitlements", - "Grant User Group Entitlements", + "Grant User Membership to Group Entitlements", s"""Grant the User Group Entitlements. | |This endpoint creates entitlements for every Role in the Group. If the user @@ -8291,6 +8291,15 @@ trait APIMethods600 { postJson.more_info_url.getOrElse(""), postJson.terms_and_conditions_url.getOrElse(""), postJson.description.getOrElse(""), + postJson.collection_id.getOrElse(""), + postJson.monthly_subscription_currency.getOrElse(""), + postJson.monthly_subscription_amount.getOrElse(""), + postJson.per_second_call_limit.getOrElse(-1L), + postJson.per_minute_call_limit.getOrElse(-1L), + postJson.per_hour_call_limit.getOrElse(-1L), + postJson.per_day_call_limit.getOrElse(-1L), + postJson.per_week_call_limit.getOrElse(-1L), + postJson.per_month_call_limit.getOrElse(-1L), callContext ) } yield { @@ -8343,6 +8352,15 @@ trait APIMethods600 { postJson.more_info_url.getOrElse(""), postJson.terms_and_conditions_url.getOrElse(""), postJson.description.getOrElse(""), + postJson.collection_id.getOrElse(""), + postJson.monthly_subscription_currency.getOrElse(""), + postJson.monthly_subscription_amount.getOrElse(""), + postJson.per_second_call_limit.getOrElse(-1L), + postJson.per_minute_call_limit.getOrElse(-1L), + postJson.per_hour_call_limit.getOrElse(-1L), + postJson.per_day_call_limit.getOrElse(-1L), + postJson.per_week_call_limit.getOrElse(-1L), + postJson.per_month_call_limit.getOrElse(-1L), callContext ) } yield { @@ -8472,6 +8490,7 @@ trait APIMethods600 { (Full(u), callContext) <- authenticatedAccess(cc) _ <- NewStyle.function.hasEntitlement(bankId.value, u.userId, canDeleteApiProduct, callContext) _ <- NewStyle.function.getBank(bankId, callContext) + (_, callContext) <- NewStyle.function.deleteApiProductAttributesByBankIdAndCode(bankId.value, apiProductCode, callContext) (_, callContext) <- NewStyle.function.deleteApiProduct(bankId.value, apiProductCode, callContext) } yield { (Full(true), HttpCode.`204`(callContext)) diff --git a/obp-api/src/main/scala/code/api/v6_0_0/JSONFactory6.0.0.scala b/obp-api/src/main/scala/code/api/v6_0_0/JSONFactory6.0.0.scala index fdddf73f5a..ef0c020fe9 100644 --- a/obp-api/src/main/scala/code/api/v6_0_0/JSONFactory6.0.0.scala +++ b/obp-api/src/main/scala/code/api/v6_0_0/JSONFactory6.0.0.scala @@ -764,7 +764,16 @@ case class PostPutApiProductJsonV600( category: Option[String], more_info_url: Option[String], terms_and_conditions_url: Option[String], - description: Option[String] + description: Option[String], + collection_id: Option[String], + monthly_subscription_currency: Option[String], + monthly_subscription_amount: Option[String], + per_second_call_limit: Option[Long], + per_minute_call_limit: Option[Long], + per_hour_call_limit: Option[Long], + per_day_call_limit: Option[Long], + per_week_call_limit: Option[Long], + per_month_call_limit: Option[Long] ) case class ApiProductJsonV600( @@ -777,6 +786,15 @@ case class ApiProductJsonV600( more_info_url: String, terms_and_conditions_url: String, description: String, + collection_id: String, + monthly_subscription_currency: String, + monthly_subscription_amount: String, + per_second_call_limit: Long, + per_minute_call_limit: Long, + per_hour_call_limit: Long, + per_day_call_limit: Long, + per_week_call_limit: Long, + per_month_call_limit: Long, attributes: Option[List[ApiProductAttributeResponseJsonV600]] ) @@ -2048,6 +2066,15 @@ object JSONFactory600 extends CustomJsonFormats with MdcLoggable { more_info_url = product.moreInfoUrl, terms_and_conditions_url = product.termsAndConditionsUrl, description = product.description, + collection_id = product.collectionId, + monthly_subscription_currency = product.monthlySubscriptionCurrency, + monthly_subscription_amount = product.monthlySubscriptionAmount, + per_second_call_limit = product.perSecondCallLimit, + per_minute_call_limit = product.perMinuteCallLimit, + per_hour_call_limit = product.perHourCallLimit, + per_day_call_limit = product.perDayCallLimit, + per_week_call_limit = product.perWeekCallLimit, + per_month_call_limit = product.perMonthCallLimit, attributes = attributes.map(_.map(createApiProductAttributeResponseJsonV600)) ) } diff --git a/obp-api/src/main/scala/code/apiproduct/ApiProduct.scala b/obp-api/src/main/scala/code/apiproduct/ApiProduct.scala index 3a2812e0ad..73ce363a3d 100644 --- a/obp-api/src/main/scala/code/apiproduct/ApiProduct.scala +++ b/obp-api/src/main/scala/code/apiproduct/ApiProduct.scala @@ -15,6 +15,15 @@ class ApiProduct extends ApiProductTrait with LongKeyedMapper[ApiProduct] with I object MoreInfoUrl extends MappedString(this, 2000) object TermsAndConditionsUrl extends MappedString(this, 2000) object Description extends MappedString(this, 2000) + object CollectionId extends MappedString(this, 50) + object MonthlySubscriptionCurrency extends MappedString(this, 3) + object MonthlySubscriptionAmount extends MappedString(this, 50) + object PerSecondCallLimit extends MappedLong(this) { override def defaultValue = -1L } + object PerMinuteCallLimit extends MappedLong(this) { override def defaultValue = -1L } + object PerHourCallLimit extends MappedLong(this) { override def defaultValue = -1L } + object PerDayCallLimit extends MappedLong(this) { override def defaultValue = -1L } + object PerWeekCallLimit extends MappedLong(this) { override def defaultValue = -1L } + object PerMonthCallLimit extends MappedLong(this) { override def defaultValue = -1L } override def apiProductId: String = ApiProductId.get override def bankId: String = BankId.get @@ -25,6 +34,15 @@ class ApiProduct extends ApiProductTrait with LongKeyedMapper[ApiProduct] with I override def moreInfoUrl: String = MoreInfoUrl.get override def termsAndConditionsUrl: String = TermsAndConditionsUrl.get override def description: String = Description.get + override def collectionId: String = CollectionId.get + override def monthlySubscriptionCurrency: String = MonthlySubscriptionCurrency.get + override def monthlySubscriptionAmount: String = MonthlySubscriptionAmount.get + override def perSecondCallLimit: Long = PerSecondCallLimit.get + override def perMinuteCallLimit: Long = PerMinuteCallLimit.get + override def perHourCallLimit: Long = PerHourCallLimit.get + override def perDayCallLimit: Long = PerDayCallLimit.get + override def perWeekCallLimit: Long = PerWeekCallLimit.get + override def perMonthCallLimit: Long = PerMonthCallLimit.get } object ApiProduct extends ApiProduct with LongKeyedMetaMapper[ApiProduct] { @@ -41,4 +59,13 @@ trait ApiProductTrait { def moreInfoUrl: String def termsAndConditionsUrl: String def description: String + def collectionId: String + def monthlySubscriptionCurrency: String + def monthlySubscriptionAmount: String + def perSecondCallLimit: Long + def perMinuteCallLimit: Long + def perHourCallLimit: Long + def perDayCallLimit: Long + def perWeekCallLimit: Long + def perMonthCallLimit: Long } diff --git a/obp-api/src/main/scala/code/apiproduct/ApiProductsProvider.scala b/obp-api/src/main/scala/code/apiproduct/ApiProductsProvider.scala index f1d0033815..61106f4da1 100644 --- a/obp-api/src/main/scala/code/apiproduct/ApiProductsProvider.scala +++ b/obp-api/src/main/scala/code/apiproduct/ApiProductsProvider.scala @@ -14,7 +14,16 @@ trait ApiProductsProvider { category: String, moreInfoUrl: String, termsAndConditionsUrl: String, - description: String + description: String, + collectionId: String, + monthlySubscriptionCurrency: String, + monthlySubscriptionAmount: String, + perSecondCallLimit: Long, + perMinuteCallLimit: Long, + perHourCallLimit: Long, + perDayCallLimit: Long, + perWeekCallLimit: Long, + perMonthCallLimit: Long ): Box[ApiProductTrait] def getApiProductByBankIdAndCode( @@ -42,7 +51,16 @@ object MappedApiProductsProvider extends MdcLoggable with ApiProductsProvider { category: String, moreInfoUrl: String, termsAndConditionsUrl: String, - description: String + description: String, + collectionId: String, + monthlySubscriptionCurrency: String, + monthlySubscriptionAmount: String, + perSecondCallLimit: Long, + perMinuteCallLimit: Long, + perHourCallLimit: Long, + perDayCallLimit: Long, + perWeekCallLimit: Long, + perMonthCallLimit: Long ): Box[ApiProductTrait] = { val existing = ApiProduct.find( By(ApiProduct.BankId, bankId), @@ -58,6 +76,15 @@ object MappedApiProductsProvider extends MdcLoggable with ApiProductsProvider { .MoreInfoUrl(moreInfoUrl) .TermsAndConditionsUrl(termsAndConditionsUrl) .Description(description) + .CollectionId(collectionId) + .MonthlySubscriptionCurrency(monthlySubscriptionCurrency) + .MonthlySubscriptionAmount(monthlySubscriptionAmount) + .PerSecondCallLimit(perSecondCallLimit) + .PerMinuteCallLimit(perMinuteCallLimit) + .PerHourCallLimit(perHourCallLimit) + .PerDayCallLimit(perDayCallLimit) + .PerWeekCallLimit(perWeekCallLimit) + .PerMonthCallLimit(perMonthCallLimit) .saveMe() ) case _ => @@ -72,6 +99,15 @@ object MappedApiProductsProvider extends MdcLoggable with ApiProductsProvider { .MoreInfoUrl(moreInfoUrl) .TermsAndConditionsUrl(termsAndConditionsUrl) .Description(description) + .CollectionId(collectionId) + .MonthlySubscriptionCurrency(monthlySubscriptionCurrency) + .MonthlySubscriptionAmount(monthlySubscriptionAmount) + .PerSecondCallLimit(perSecondCallLimit) + .PerMinuteCallLimit(perMinuteCallLimit) + .PerHourCallLimit(perHourCallLimit) + .PerDayCallLimit(perDayCallLimit) + .PerWeekCallLimit(perWeekCallLimit) + .PerMonthCallLimit(perMonthCallLimit) .saveMe() ) } diff --git a/obp-api/src/main/scala/code/apiproductattribute/ApiProductAttributesProvider.scala b/obp-api/src/main/scala/code/apiproductattribute/ApiProductAttributesProvider.scala index e7fefe9422..2c0eac5183 100644 --- a/obp-api/src/main/scala/code/apiproductattribute/ApiProductAttributesProvider.scala +++ b/obp-api/src/main/scala/code/apiproductattribute/ApiProductAttributesProvider.scala @@ -28,6 +28,11 @@ trait ApiProductAttributesProvider { def deleteApiProductAttribute( apiProductAttributeId: String ): Box[Boolean] + + def deleteApiProductAttributesByBankIdAndCode( + bankId: String, + apiProductCode: String + ): Box[Boolean] } object MappedApiProductAttributesProvider extends MdcLoggable with ApiProductAttributesProvider { @@ -107,4 +112,17 @@ object MappedApiProductAttributesProvider extends MdcLoggable with ApiProductAtt ): Box[Boolean] = { ApiProductAttribute.find(By(ApiProductAttribute.ApiProductAttributeId, apiProductAttributeId)).map(_.delete_!) } + + override def deleteApiProductAttributesByBankIdAndCode( + bankId: String, + apiProductCode: String + ): Box[Boolean] = { + tryo { + ApiProductAttribute.findAll( + By(ApiProductAttribute.BankId, bankId), + By(ApiProductAttribute.ApiProductCode, apiProductCode) + ).foreach(_.delete_!) + true + } + } }