APIs & services / portfolio-service

Load the active farming practices master.

Endpointtoday's app
Call
GET /gateway/portfolio-service/api/v1/practices/active?direction=ASC&page=1&size=100
Service
portfolio-service
Features
Data download (Cadre), Data download (Unit / FMT), Crop Actual (portfolio), Home and bottom bar
When
Data download and Home open
Auth
X-SESSIONID header (AuthInterceptor adds it; re-auth on 401/400)
In the App Service

Use case

Online read of the active farming practice master. Called during data download (syncPractices), from IePortfolioRepositoryImpl when the crop actual screen needs practices and from DataUtil.insertPracticeMaster on Home. The table practicemaster is cleared and replaced; each practice gets a display sequence from the bundled asset 'practicelocal'. On failure data download shows the step error; screen callers keep the old table.

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
directionqueryYesASCFixed in URL.
pagequeryYes1Fixed in URL.
sizequeryYes100Fixed in URL (no further paging).

Request

No body. page, size

Response

Example response body (synthetic data)
[
  {
    "id": 4,
    "uuid": "p-0004",
    "practiceCode": "PRACTICE.MULCHING",
    "descriptionList": [
      {
        "practiceMasterId": null,
        "id": 1,
        "text": "Cover soil with crop residue",
        "language": {
          "code": "ENG",
          "label": "English"
        }
      }
    ],
    "nameList": [
      {
        "practiceMasterId": null,
        "id": 2,
        "text": "Mulching",
        "language": {
          "code": "ENG",
          "label": "English"
        }
      }
    ]
  }
]
FieldTypeRequiredNotes
[].id / uuid / practiceCodemixedpracticemaster columns; practiceCode is what PLIs send in practiceMasterCodes.
[].nameList[]arraypracticemaster_name table, label per language.
[].descriptionList[]arraypracticemaster_description table.
[].sequenceintegerNot sent by server; set locally from the practicelocal asset.

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 throws 'Failed to fetch practice master: <code>' and marks the step failed.

Source

  • data/src/main/java/org/mindtree/app/agricultor/data/setup/SetupService.kt
  • app/src/main/java/org/platformcommons/urvi/datasource/network/URLInjector.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/datasource/repository/impl/IePortfolioRepositoryImpl.kt
  • app/src/main/java/org/platformcommons/urvi/utility/DataUtil.kt
  • data/src/main/java/org/mindtree/app/agricultor/data/entity/PracticeMaster.kt