Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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))
Expand Down
20 changes: 19 additions & 1 deletion obp-api/src/main/scala/code/api/util/NewStyle.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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,
Expand Down
21 changes: 20 additions & 1 deletion obp-api/src/main/scala/code/api/v6_0_0/APIMethods600.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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))
Expand Down
29 changes: 28 additions & 1 deletion obp-api/src/main/scala/code/api/v6_0_0/JSONFactory6.0.0.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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]]
)

Expand Down Expand Up @@ -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))
)
}
Expand Down
27 changes: 27 additions & 0 deletions obp-api/src/main/scala/code/apiproduct/ApiProduct.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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] {
Expand All @@ -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
}
40 changes: 38 additions & 2 deletions obp-api/src/main/scala/code/apiproduct/ApiProductsProvider.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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),
Expand All @@ -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 _ =>
Expand All @@ -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()
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
}
}
Loading