Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: haskell-client-doc #194

Merged
merged 1 commit into from
Aug 2, 2024
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
4 changes: 2 additions & 2 deletions clients/haskell/hs-cac-client/src/Client.hs
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ getCacClient tenant = do
then Left <$> getError
else Right <$> newForeignPtr c_free_cac_client cacClient

getFullConfigStateWithFilter :: ForeignPtr CacClient -> Maybe String -> Maybe String -> IO (Either Error Value)
getFullConfigStateWithFilter :: ForeignPtr CacClient -> Maybe String -> Maybe [String] -> IO (Either Error Value)
getFullConfigStateWithFilter client mbFilters mbPrefix = do
cFilters <- case mbFilters of
Just filters -> newCAString filters
Nothing -> return nullPtr
cPrefix <- case mbPrefix of
Just prefix -> newCAString prefix
Just prefix -> newCAString (intercalate "," prefix)
Nothing -> return nullPtr
config <- withForeignPtr client $ \client -> c_get_config client cFilters cPrefix
_ <- cleanup [cFilters]
Expand Down
2 changes: 1 addition & 1 deletion clients/haskell/hs-cac-client/src/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ main = do
lastModified <- getCacLastModified client
overrides <- getResolvedConfig client "{\"country\": \"India\"}" $ Just ["country_image_url", "hyperpay_version"]
defaults <- getDefaultConfig client $ Just ["country_image_url", "hyperpay_version"]
filteredConfig <- getFullConfigStateWithFilter client (Just "{\"os\": \"android\"}") (Just "hyperpay")
filteredConfig <- getFullConfigStateWithFilter client (Just "{\"os\": \"android\"}") $ Just ["hyperpay"]
print config
print lastModified
print overrides
Expand Down
12 changes: 9 additions & 3 deletions docs/client-context-aware-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,14 @@ Get the full config definition of your tenants configuration from superposition.
##### Funtion Definition

```
getFullConfigStateWithFilter :: ForeignPtr CacClient -> Maybe String -> IO (Either Error Value)
getFullConfigStateWithFilter :: ForeignPtr CacClient -> Maybe String -> Maybe [String] -> IO (Either Error Value)
```
##### Params

| Param | type | description | Example value |
| --------- | ------------------ | ----------------------------------------------------------------------------------------------- | --------------------------------------------- |
| `context` | Maybe (String) | Specifies the context for which you want the configurations, If empty, all contexts are returned | Just `{"os": "android", "merchant": "juspay"}` |
| `prefix` | Maybe([String]) | The keys for which you want the values. If empty, all configuration keys are returned | `Just ([payment, network, color])` |

#### Get the last modified Time

Expand Down Expand Up @@ -358,11 +364,11 @@ main = do
getCacClient "dev" >>= \case
Left err -> putStrLn err
Right client -> do
config <- getFullConfigStateWithFilter client Nothing
config <- getFullConfigStateWithFilter client Nothing Nothing
lastModified <- getCacLastModified client
overrides <- getResolvedConfig client "{\"country\": \"India\"}" $ Just ["country_image_url", "hyperpay_version"]
defaults <- getDefaultConfig client $ Just ["country_image_url", "hyperpay_version"]
filteredConfig <- getFullConfigStateWithFilter client $ Just "{\"prefix\": \"hyperpay\"}"
filteredConfig <- getFullConfigStateWithFilter client (Just "{\"os\": \"android\"}") $ Just ["hyperpay"]
print config
print lastModified
print overrides
Expand Down
Loading