11module Types where
22
3+ import Data.Aeson (FromJSON , ToJSON , object , parseJSON , toJSON , withObject , (.!=) , (.:) , (.:?) )
4+ import Data.Aeson.Types (Value (.. ))
35import Data.Function ((&) )
4- import Data.Text (Text )
5- import qualified LaunchDarkly.Server as LD
6- import Data.Aeson.Types (Value (.. ))
76import Data.HashMap.Strict (HashMap )
8- import Data.Aeson (FromJSON , ToJSON , toJSON , parseJSON , object , withObject , (.:) , (.:?) , (.!=) )
9- import GHC.Generics (Generic )
7+ import Data.Maybe (fromMaybe )
108import Data.Set (Set )
9+ import Data.Text (Text )
10+ import GHC.Generics (Generic )
1111import GHC.Natural (Natural )
12- import Data.Maybe ( fromMaybe )
12+ import qualified LaunchDarkly.Server as LD
1313
1414data CreateClientParams = CreateClientParams
1515 { tag :: ! Text
1616 , configuration :: ! ConfigurationParams
17- } deriving (FromJSON , ToJSON , Show , Generic )
17+ }
18+ deriving (FromJSON , ToJSON , Show , Generic )
1819
1920data ConfigurationParams = ConfigurationParams
2021 { credential :: ! Text
@@ -24,17 +25,20 @@ data ConfigurationParams = ConfigurationParams
2425 , polling :: ! (Maybe PollingParams )
2526 , events :: ! (Maybe EventParams )
2627 , tags :: ! (Maybe TagParams )
27- } deriving (FromJSON , ToJSON , Show , Generic )
28+ }
29+ deriving (FromJSON , ToJSON , Show , Generic )
2830
2931data StreamingParams = StreamingParams
3032 { baseUri :: ! (Maybe Text )
3133 , initialRetryDelayMs :: ! (Maybe Int )
32- } deriving (FromJSON , ToJSON , Show , Generic )
34+ }
35+ deriving (FromJSON , ToJSON , Show , Generic )
3336
3437data PollingParams = PollingParams
3538 { baseUri :: ! (Maybe Text )
3639 , pollIntervalMs :: ! (Maybe Natural )
37- } deriving (FromJSON , ToJSON , Show , Generic )
40+ }
41+ deriving (FromJSON , ToJSON , Show , Generic )
3842
3943data EventParams = EventParams
4044 { baseUri :: ! (Maybe Text )
@@ -43,12 +47,15 @@ data EventParams = EventParams
4347 , allAttributesPrivate :: ! (Maybe Bool )
4448 , globalPrivateAttributes :: ! (Maybe (Set Text ))
4549 , flushIntervalMs :: ! (Maybe Natural )
46- } deriving (FromJSON , ToJSON , Show , Generic )
50+ , omitAnonymousContexts :: ! (Maybe Bool )
51+ }
52+ deriving (FromJSON , ToJSON , Show , Generic )
4753
4854data TagParams = TagParams
4955 { applicationId :: ! (Maybe Text )
5056 , applicationVersion :: ! (Maybe Text )
51- } deriving (FromJSON , ToJSON , Show , Generic )
57+ }
58+ deriving (FromJSON , ToJSON , Show , Generic )
5259
5360data CommandParams = CommandParams
5461 { command :: ! Text
@@ -59,40 +66,46 @@ data CommandParams = CommandParams
5966 , contextBuild :: ! (Maybe ContextBuildParams )
6067 , contextConvert :: ! (Maybe ContextConvertParams )
6168 , secureModeHash :: ! (Maybe SecureModeHashParams )
62- } deriving (FromJSON , Generic )
69+ }
70+ deriving (FromJSON , Generic )
6371
6472data EvaluateFlagParams = EvaluateFlagParams
6573 { flagKey :: ! Text
6674 , context :: ! LD. Context
6775 , valueType :: ! Text
6876 , defaultValue :: ! Value
6977 , detail :: ! Bool
70- } deriving (FromJSON , Generic )
78+ }
79+ deriving (FromJSON , Generic )
7180
7281data EvaluateFlagResponse = EvaluateFlagResponse
7382 { value :: ! Value
7483 , variationIndex :: ! (Maybe Integer )
7584 , reason :: ! (Maybe LD. EvaluationReason )
76- } deriving (ToJSON , Show , Generic )
85+ }
86+ deriving (ToJSON , Show , Generic )
7787
7888data EvaluateAllFlagsParams = EvaluateAllFlagsParams
7989 { context :: ! LD. Context
8090 , withReasons :: ! Bool
8191 , clientSideOnly :: ! Bool
8292 , detailsOnlyForTrackedFlags :: ! Bool
83- } deriving (FromJSON , Generic )
93+ }
94+ deriving (FromJSON , Generic )
8495
8596data EvaluateAllFlagsResponse = EvaluateAllFlagsResponse
8697 { state :: ! LD. AllFlagsState
87- } deriving (ToJSON , Show , Generic )
98+ }
99+ deriving (ToJSON , Show , Generic )
88100
89101data CustomEventParams = CustomEventParams
90102 { eventKey :: ! Text
91103 , context :: ! LD. Context
92104 , dataValue :: ! (Maybe Value )
93105 , omitNullData :: ! (Maybe Bool )
94106 , metricValue :: ! (Maybe Double )
95- } deriving (Generic )
107+ }
108+ deriving (Generic )
96109
97110instance FromJSON CustomEventParams where
98111 parseJSON = withObject " CustomEvent" $ \ o -> do
@@ -101,16 +114,18 @@ instance FromJSON CustomEventParams where
101114 dataValue <- o .:? " data"
102115 omitNullData <- o .:? " omitNullData"
103116 metricValue <- o .:? " metricValue"
104- return $ CustomEventParams { .. }
117+ return $ CustomEventParams {.. }
105118
106119data IdentifyEventParams = IdentifyEventParams
107120 { context :: ! LD. Context
108- } deriving (FromJSON , Generic )
121+ }
122+ deriving (FromJSON , Generic )
109123
110124data ContextBuildParams = ContextBuildParams
111125 { single :: ! (Maybe ContextBuildParam )
112126 , multi :: ! (Maybe [ContextBuildParam ])
113- } deriving (FromJSON , Generic )
127+ }
128+ deriving (FromJSON , Generic )
114129
115130data ContextBuildParam = ContextBuildParam
116131 { kind :: ! (Maybe Text )
@@ -119,26 +134,31 @@ data ContextBuildParam = ContextBuildParam
119134 , anonymous :: ! (Maybe Bool )
120135 , private :: ! (Maybe (Set Text ))
121136 , custom :: ! (Maybe (HashMap Text Value ))
122- } deriving (FromJSON , Generic )
137+ }
138+ deriving (FromJSON , Generic )
123139
124140data ContextConvertParams = ContextConvertParams
125141 { input :: ! Text
126- } deriving (FromJSON , Generic )
142+ }
143+ deriving (FromJSON , Generic )
127144
128145data ContextResponse = ContextResponse
129146 { output :: ! (Maybe Text )
130147 , errorMessage :: ! (Maybe Text )
131- } deriving (Generic )
148+ }
149+ deriving (Generic )
132150
133151instance ToJSON ContextResponse where
134- toJSON (ContextResponse { output = Just o, errorMessage = Nothing }) = object [ (" output" , String o) ]
135- toJSON (ContextResponse { output = _, errorMessage = Just e }) = object [ (" error" , String e) ]
136- toJSON _ = object [ (" error" , String " Invalid context response was generated" ) ]
152+ toJSON (ContextResponse {output = Just o, errorMessage = Nothing }) = object [(" output" , String o)]
153+ toJSON (ContextResponse {output = _, errorMessage = Just e}) = object [(" error" , String e)]
154+ toJSON _ = object [(" error" , String " Invalid context response was generated" )]
137155
138156data SecureModeHashParams = SecureModeHashParams
139157 { context :: ! (Maybe LD. Context )
140- } deriving (FromJSON , Generic )
158+ }
159+ deriving (FromJSON , Generic )
141160
142161data SecureModeHashResponse = SecureModeHashResponse
143162 { result :: ! Text
144- } deriving (ToJSON , Show , Generic )
163+ }
164+ deriving (ToJSON , Show , Generic )
0 commit comments