Features

Key additions on client core

V1 settings endpoint

V1 GET global settings
https://<opensrp-server>/rest/settings/sync?serverVersion=0

V1 GET settings without resolving
https://<opensrp-server>/rest/settings/sync?teamId=<team-uuid>&serverVersion=0

V1 GET settings with resolving
https://<opensrp-server>/rest/settings/sync?teamId=<team-uuid>&locationId=<location-uuid>&serverVersion=0&resolve=true
For resolving to work the current user logged in location has to be provided. This helps us get the location hierarchy in which to look for setting before resolving.

V1 POST settings
https://<opensrp-server>/rest/settings/sync

Sample payload

{
  "settingConfigurations": [
    {
      "identifier": "site_characteristics",
      "settings": [
        {
          "description": "Is the HIV prevalence consistently &gt; 1% in pregnant women attending antenatal clinics at your facility?",
          "label": "Generalized HIV epidemic",
          "type": "Setting",
          "value": true,
          "key": "site_anc_hiv"
        }
      ],
      "providerId": "demo",
      "locationId": "44de66fb-e6c6-4bae-92bb-386dfe626eba",
      "teamId": "6c8d2b9b-2246-47c2-949b-4fe29e888cc8",
      "type": "SettingConfiguration",
      "team": "Bukesa"
    }
  ]
}

V1 PUT settings
https://<opensrp-server>/rest/settings/sync

Sample payload

{
  "settingConfigurations": [
    {
      "identifier": "site_characteristics",
      "settings": [
        {
          "settingMetadataId": "2",
          "serverVersion": 1590646367471,
          "description": "Is the HIV prevalence consistently &gt; 1% in pregnant women attending antenatal clinics at your facility?",
          "label": "Generalized HIV epidemic",
          "type": "Setting",
          "value": true,
          "uuid": "e42f3e1f-e8b9-4694-8efa-f021e66b5691",
          "key": "site_anc_hiv",
          "settingIdentifier": "site_characteristics"
        }
      ],
      "serverVersion": 1590645851816,
      "providerId": "demo",
      "locationId": "44de66fb-e6c6-4bae-92bb-386dfe626eba",
      "teamId": "6c8d2b9b-2246-47c2-949b-4fe29e888cc8",
      "_rev": "v1",
      "type": "SettingConfiguration",
      "team": "Bukesa"
    }
  ]
}

V2 settings endpoint

V2 GET global settings
https://<opensrp-server>/rest/v2/settings/?serverVersion=0

V2 GET without resolving setitngs
https://<opensrp-server>/rest/v2/settings/?teamId=<team-uuid>&serverVersion=0

V2 GET settings with location resolving
https://<opensrp-server>/rest/v2/settings/?teamId=<team-uuid>&serverVersion=0&locationId=<location-uuid>&resolve=true

V2 POST settings
https://<opensrp-server>/rest/v2/settings
Sample payload attached

{
    "description": "There is a national Hepatitis B ANC routine screening program in place.",
    "label": "National Hep B ANC routine screening program established",
    "value": "true",
    "key": "pop_hepb_screening",
    "type": "SettingConfiguration",
    "identifier": "population_characteristics",
    "providerId": "demo",
    "locationId": "02ebbc84-5e29-4cd5-9b79-c594058923e9",
    "settingsId": "e79b139c-3a20-4656-b684-d2d9ed83c94e"
}

The settingsId is the Id of the setting you would like this to be saved against. If its a new setting that doesn't have any set it belongs to created then do away with the settingsId property
- this can be found in the payloads returned by the GET endpoints
- in V1 its the _id e.g "_id": "20c89e10-a358-41c4-9062-9bd0eeb32c94"
- in V2 its the "documentId": "20c89e10-a358-41c4-9062-9bd0eeb32c94"

The locationId id is the Id of the location you would like this to be saved against. If its a new setting that doesn't have any location it belongs to then do away with the locationId property

V2 PUT settings
https://<opensrp-server>/rest/v2/settings/<id> - <id> parameter is the _id in the setting payload.
Sample payload attached

{
    "description": "Is the HIV prevalence consistently > 1% in pregnant women attending antenatal clinics at your facility?",
    "label": "Generalized HIV epidemic",
    "key": "site_anc_hiv",
    "value": "true",
    "type": "SettingConfiguration",
    "identifier": "site_characteristics",
    "providerId": "demo",
    "locationId": "44de66fb-e6c6-4bae-92bb-386dfe626eba",
    "uuid": "e42f3e1f-e8b9-4694-8efa-f021e66b5691",
    "teamId": "6c8d2b9b-2246-47c2-949b-4fe29e888cc8",
    "team": "Bukesa",
    "settingsId": "20c89e10-a358-41c4-9062-9bd0eeb32c94",
    "_id":"2"
}

The settingsId is exactly as explained above
The locationId is exactly as explained above
The uuid is the unique id for the settings. Its found in the property uuid in both the V1 & V2 endpoints.
The _id is the setting metadata id
- its named settingMetadataId in both V1 & v2 endpoints e.g "settingMetadataId": "1"
The identifier is the unique name the user assigns the settings on creation
- its named identifier & settingIdentifier in the v1 endpoint
- its named settingIdentifier in the v2 endpoint
The teamId is the id of the team that this settings belongs to. It can be added on both the POST & PUT payload if required
The team is the name of the team that this settings belongs to. It can be added on both the POST & PUT payload if required

V2 DELETE settings
https://<opensrp-server>/rest/v2/settings/<id> – where the id is the settingsMetadataId