APIs & services / portfolio-service

Download farming models (ATM/DKG) for a chunk of farmers.

Endpointtoday's app
Call
GET /gateway/portfolio-service/api/v1/farming-model/ownerEntities?ownerEntityIds=&ownerEntityType=ENTITY_TYPE.IE
Service
portfolio-service
Features
Data download (Cadre), Farmer hub (option tiles), ATM model (Anytime Money plot), 365 DKG kitchen garden
When
Data download; per-farmer refresh
Auth
X-SESSIONID header (AuthInterceptor adds it; re-auth on 401/400)
In the App Service

Use case

Online bulk read of farming models (ATM and DKG) during cadre data download (chunks of 30 farmers still pending ATM fetch) and farmer hub refresh. Saved to the farming_model table; their ids are then used to fetch farming-model attachments. Failures mark the farming_model step failed.

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
ownerEntityIdsqueryYes40001,40002CSV IE ids.
ownerEntityTypequeryYesENTITY_TYPE.IEDefault.

Request

No body. IE ids (chunk 30)

Response

Example response body (synthetic data)
[
  {
    "uuid": "fm-0000-4000-8000-000000000501",
    "appCreatedAt": 1780000000000,
    "id": 5501,
    "raisedBeds": true,
    "vegetableCrops": "PRODUCT.SPINACH,PRODUCT.OKRA",
    "maizeCultivation": false,
    "pulseCrops": "PRODUCT.REDGRAM",
    "practices": "PRACTICE.MULCHING",
    "relayCropping": false,
    "relayCroppingDetails": null,
    "incomeGeneration": true,
    "incomeGenerationDetails": "Sells surplus locally",
    "titleId": "TILE-0002",
    "owningEntityId": "40001",
    "owningEntityType": "ENTITY_TYPE.IE",
    "aliasId": "ie-alias-0001",
    "landSize": 0.1,
    "isDKG": false,
    "modelType": "MODEL_TYPE.ATM",
    "assetId": 9002,
    "asset": "ASSET-CODE-0002",
    "assetCheckSum": "<asset checksum>",
    "syncErrorId": null,
    "lastModifiedAt": null,
    "geoFencingFileId": null,
    "geoFencingFileName": null,
    "geoFencingCreatedOn": null,
    "geoFencingFilePath": null,
    "geotaggingFileName": null,
    "geotaggingCreatedOn": null,
    "geotaggingFilePath": null,
    "farmingModelLineItemDTOs": [
      {
        "actualOutput": null,
        "appCreatedAt": 1780000000000,
        "appLastModifiedAt": 1780000000000,
        "createdAt": null,
        "cropChangeReason": null,
        "cropSubType": "CROP_SUB_TYPE.LEAFY",
        "cropType": "CROP_TYPE.VEGETABLE",
        "earlyHarvestReason": null,
        "expectedHarvestDate": "2026-09-01",
        "expectedOutput": null,
        "genericProduct": "PRODUCT.SPINACH",
        "harvestCompleteDateTime": null,
        "harvestStartDateTime": null,
        "harvestStatus": "HARVEST_STATUS.PENDING",
        "harvestType": null,
        "id": 5601,
        "inactiveAt": null,
        "inactiveReason": null,
        "interestedInCropMarketing": false,
        "isActive": true,
        "isMajorCrop": false,
        "lastModifiedAt": null,
        "surplusOutput": null
      }
    ],
    "imageUrl": null,
    "imageAttachmentId": null,
    "imageCreatedAt": null
  }
]
FieldTypeRequiredNotes
[].id / uuid / titleId / owningEntityId / aliasIdmixedfarming_model keys.
[].modelType / isDKGmixedSplits ATM vs DKG lists.
[].raisedBeds ... incomeGenerationDetails, landSize, asset, assetId, assetCheckSummixedForm values shown on ATM/DKG screens.
[].farmingModelLineItemDTOs[]arrayCrops with harvest status/type/dates used by ATM harvest.

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 failuresStep marked STATUS_ERROR; user retries.

Source

  • data/src/main/java/org/mindtree/app/agricultor/data/setup/SetupService.kt
  • app/src/main/java/org/platformcommons/urvi/view/datasetup/DataSetupViewModel.kt
  • app/src/main/java/org/platformcommons/urvi/view/option/OptionViewModel.kt
  • data/src/main/java/org/mindtree/app/agricultor/data/entity/FarmingModel.kt