APIs & services / Common TLD (ctld)

Load the tenant product (crop/input) master.

Endpointtoday's app
Call
GET /ctld/api/product/v1 (generated ProductAPI.getProduct)
Service
Common TLD (ctld)
Features
Home and bottom bar, Crop stock (inventory), Crop Plan, Crop Actual (portfolio)
When
Home open when the product table is empty, on language change
Auth
X-SESSIONID set by CoreAPI (dooNowOrThrow)
In the App Service

Use case

Online CoreAPI call (generated ProductAPI.getProduct, dooNowOrThrow) made by SetupServiceHelper.fetchTenantProduct from HomeActivity when the product table is empty or the language changes. The ProductDTO list is converted to the local Product entity, saved to the product table and used to build the product/SKU masters (crop pickers, inventory). On failure only a log line is written and the KEY_PRODUCT_DATA flag stays false, so it is retried on the next Home open.

Headers

HeaderValueNotes
X-SESSIONID<session token>Set by CoreAPIDefaultImpl.doOperation from the session manager; on 401 the session is invalidated and the call retried once (dooNowOrThrow = 1 retry).
Content-Typeapplication/jsonAlways added by CoreAPI for non-multipart requests.

Parameters

ParamInRequiredExampleNotes
criteriaqueryYesisActive=true AND tenant.id=11Built from the logged-in tenant id.
start / range / excludeAttributes / includeAttributesqueryNoPassed as null by the app.

Request

No body. criteria=isActive=true AND tenant.id=X

Response

Example response body (synthetic data)
[
  {
    "id": 7001,
    "productCode": "PRODUCT.PADDY",
    "name": "Paddy",
    "isActive": true,
    "productClass": {
      "label": "Crop",
      "dataCode": "PRODUCT_CLASS.CROP",
      "globalRefClass": {
        "classCode": "GREF.PRODUCT_CLASS",
        "name": "Product class"
      },
      "language": {
        "language": "English",
        "languageCode": "ENG"
      }
    },
    "productMajorType": {
      "label": "Cereal",
      "dataCode": "PRODUCT_MAJOR_TYPE.CEREAL"
    },
    "productMinorType": {
      "label": "Paddy",
      "dataCode": "PRODUCT_MINOR_TYPE.PADDY",
      "tenantRefClass": {
        "classCode": "TREF.PRODUCT_MINOR_TYPE",
        "name": "Minor type"
      }
    },
    "nameMLList": [
      {
        "text": "Paddy",
        "language": {
          "code": "ENG"
        }
      }
    ]
  }
]
FieldTypeRequiredNotes
[].id / productCode / name / isActivemixedproduct table columns; name also filtered against a JSON exclusion list for Vrutti tenants.
[].productClass / productMajorType / productMinorTypeobjectEmbedded columns used to group crops and inputs.
[].nameMLListarrayLocalised names.
other ProductDTO fieldsmixedNot read by the app.

Errors

StatusWhenWhat the app does
401Session token expiredCoreAPI invalidates the session and retries once.
503Service unavailableCoreAPI retries once.
any non-2xxOther failuresLogged (fetchTenantProduct: Unable to fetch tenant product); retried next Home open.

Source

  • app/src/main/java/org/platformcommons/urvi/datasource/service/SetupServiceHelper.kt
  • app/src/main/java/org/platformcommons/urvi/view/home/HomeActivity.kt
  • data/src/main/java/org/mindtree/app/agricultor/data/entity/Product.kt
  • BRCTLD-generated-java-api-9.0.5.jar: com/mindtree/bridge/framework/rest/client/ProductAPI.class (path /api/product/v1, TLD prefix ctld)