From ec91627347943d207416affd515ec506684a8e9a Mon Sep 17 00:00:00 2001 From: alexcardell <29524087+alexcardell@users.noreply.github.com> Date: Fri, 10 May 2024 16:14:12 +0100 Subject: [PATCH] Add int details methods --- .../cardell/openfeature/FeatureClient.scala | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/open-feature/sdk/src/main/scala/io/cardell/openfeature/FeatureClient.scala b/open-feature/sdk/src/main/scala/io/cardell/openfeature/FeatureClient.scala index 0053f71..4e089d9 100644 --- a/open-feature/sdk/src/main/scala/io/cardell/openfeature/FeatureClient.scala +++ b/open-feature/sdk/src/main/scala/io/cardell/openfeature/FeatureClient.scala @@ -95,6 +95,19 @@ trait FeatureClient[F[_]] { options: EvaluationOptions ): F[Int] + def getIntDetails(flagKey: String, default: Int): F[EvaluationDetails[Int]] + def getIntDetails( + flagKey: String, + default: Int, + context: EvaluationContext + ): F[EvaluationDetails[Int]] + def getIntDetails( + flagKey: String, + default: Int, + context: EvaluationContext, + options: EvaluationOptions + ): F[EvaluationDetails[Int]] + def getDoubleValue(flagKey: String, default: Double): F[Double] def getDoubleValue( flagKey: String, @@ -253,13 +266,35 @@ protected final class OpenFeatureClient[F[_]: Monad]( context: EvaluationContext, options: EvaluationOptions ): F[Int] = + getIntDetails(flagKey, default, context, options) + .map(_.value) + + override def getIntDetails( + flagKey: String, + default: Int + ): F[EvaluationDetails[Int]] = + getIntDetails(flagKey, default, EvaluationContext.empty) + + override def getIntDetails( + flagKey: String, + default: Int, + context: EvaluationContext + ): F[EvaluationDetails[Int]] = + getIntDetails(flagKey, default, context, EvaluationOptions.Defaults) + + override def getIntDetails( + flagKey: String, + default: Int, + context: EvaluationContext, + options: EvaluationOptions + ): F[EvaluationDetails[Int]] = provider .resolveIntValue( flagKey, default, clientEvaluationContext ++ context ) - .map(_.value) + .map(EvaluationDetails[Int](flagKey, _)) override def getDoubleValue(flagKey: String, default: Double): F[Double] = getDoubleValue(flagKey, default, EvaluationContext.empty)