APIs & services / portfolio-service

Load app config: feature flags, current season, retry delay, pagination and chunk sizes.

Endpointtoday's app
Call
GET /gateway/portfolio-service/api/v1/ref-data/class/CLASS.PORTFOLIO_APP_CONFIG?page&size=100&direction=ASC
Service
portfolio-service
Features
Data download (Cadre), Data download (Unit / FMT), Home and bottom bar, Program configuration and instructions
When
Data download, every Home open, and hourly (FetchRefDataWorker)
Auth
X-SESSIONID header (AuthInterceptor adds it; re-auth on 401/400)
In the App Service

Use case

Online read of the PORTFOLIO_APP_CONFIG reference data (feature switches, current season, retry delay/threshold, pagination and chunk sizes). Called during data download (DataSetupViewModel / UnitDataSetupViewModel via SetupService), on every Home open (HomeViewModel.fetchAppConfigs) and hourly by FetchRefDataWorker. Pages of 100 are requested while the server answers 206; the full list is saved as JSON in preferences (SHARED_PREF_KEY_CURRENT_SEASON_VALUE) and each switch is read by code, using description as the value. On failure data download marks the step as error; Home and the worker silently keep the previous config.

Headers

HeaderValueNotes
X-SESSIONID<session token>Added by AuthInterceptor (data/net/AuthInterceptor.kt) when the call does not set it; on HTTP 401 or 400 the interceptor invalidates the token, fetches a new one and retries the request once.

Parameters

ParamInRequiredExampleNotes
pagequeryYes11-based; incremented while status is 206.
sizequeryYes100Fixed 100.
directionqueryYesASCDefault ASC.

Request

No body. page, size (HTTP 206 = more pages)

Response

Example response body (synthetic data)
[
  {
    "code": "PORTFOLIO_APP_CONFIG.CURRENT_SEASON",
    "description": "KHARIF_2026",
    "refClass": {
      "code": "CLASS.PORTFOLIO_APP_CONFIG"
    },
    "labelsList": [
      {
        "refDataId": null,
        "id": 1,
        "language": {
          "code": "ENG",
          "label": "English"
        },
        "text": "Current season"
      }
    ]
  },
  {
    "code": "PORTFOLIO_APP_CONFIG.FF_COMPACT_BLOCK",
    "description": "true",
    "refClass": {
      "code": "CLASS.PORTFOLIO_APP_CONFIG"
    },
    "labelsList": []
  },
  {
    "code": "PORTFOLIO_APP_CONFIG.FARMERS_PAGINATION",
    "description": "500",
    "refClass": {
      "code": "CLASS.PORTFOLIO_APP_CONFIG"
    },
    "labelsList": []
  }
]
FieldTypeRequiredNotes
[].codestringConfig key, e.g. CURRENT_SEASON, *_EXTERNAL_SWITCH flags, FARMERS_PAGINATION, ASSET_ATTACHMENT_PAGINATION, DEVICE_BINDING_EXTERNAL_SWITCH, FIREBASE_ATTACHMENT_UPLOAD_FLAG, retry settings.
[].descriptionstringThe value (boolean/int/string as text); empty -> app default.
[].refClass.codestringAlways CLASS.PORTFOLIO_APP_CONFIG; not used.
[].labelsListarrayLocalised labels; not read for config.
HTTP status 206statusMore pages available.

Errors

StatusWhenWhat the app does
401 / 400Session token expiredAuthInterceptor invalidates the token, gets a fresh session id and retries the request once.
any non-2xxOther failuresData download: step marked STATUS_ERROR with code/message and can be retried; Home/worker: loop stops, previous config kept.

Source

  • data/src/main/java/org/mindtree/app/agricultor/data/setup/SetupService.kt
  • app/src/main/java/org/platformcommons/urvi/datasource/network/retrofit/APIInterface.kt
  • app/src/main/java/org/platformcommons/urvi/view/datasetup/DataSetupViewModel.kt
  • app/src/main/java/org/platformcommons/urvi/view/datasetup/UnitDataSetupViewModel.kt
  • app/src/main/java/org/platformcommons/urvi/view/home/HomeViewModel.kt
  • app/src/main/java/org/platformcommons/urvi/datasource/service/FetchRefDataWorker.kt
  • data/src/main/java/org/mindtree/app/agricultor/data/entity/RefData.kt
  • app/src/main/java/org/platformcommons/urvi/utility/AppUtils.kt
  • data/src/main/java/org/mindtree/app/agricultor/data/net/AuthInterceptor.kt