Skip to content

Provide wrapper on existing service so that end user can simply mention codes and get conversion facors/scales

Linked to #19

The wrapper would allow end user to simply indicate valid code from Reference Entity UnitOfMeassure.

Such as ask for conversion from "ft" to meter".

Else it is too complex.

Expected error when user provides incompatible values in input UoM and output UoM. (example convert kg to meter).

POST {{osduonaws_base_url}}/api/unit/v3/conversion/abcd

Body

{
  "fromUnitPersistableReference": "{\"scaleOffset\":{\"scale\":0.3048,\"offset\":0.0},\"symbol\":\"ft\",\"baseMeasurement\":{\"ancestry\":\"Length\",\"type\":\"UM\"},\"type\":\"USO\"}",
  "toUnitPersistableReference": "{\"scaleOffset\":{\"scale\":1.0,\"offset\":0.0},\"symbol\":\"m\",\"baseMeasurement\":{\"ancestry\":\"L\",\"type\":\"UM\"},\"type\":\"USO\"}",
  "fromUnit": {
    "scaleOffset": {
      "scale": 0.3048,
      "offset": 0
    },
    "symbol": "ft",
    "baseMeasurement": {
      "ancestry": "Length",
      "type": "UM"
    },
    "type": "USO"
  },
  "toUnit": {
    "scaleOffset": {
      "scale": 1,
      "offset": 0
    },
    "symbol": "m",
    "baseMeasurement": {
      "ancestry": "L",
      "type": "UM"
    },
    "type": "USO"
  }
}

Response

{
    "abcd": {
        "a": 0.0,
        "b": 0.3048,
        "c": 1.0,
        "d": 0.0
    },
    "scaleOffset": null,
    "fromUnit": {
        "essence": {
            "abcd": null,
            "scaleOffset": {
                "scale": 0.3048,
                "offset": 0.0
            },
            "symbol": "ft",
            "baseMeasurement": {
                "ancestry": "Length",
                "type": "UM"
            },
            "type": "USO"
        },
        "deprecationInfo": null,
        "displaySymbol": "ft",
        "name": "foot (international)",
        "description": null,
        "lastModified": "19920228",
        "source": "APIRP661",
        "namespace": "RP66",
        "persistableReference": "{\"scaleOffset\":{\"scale\":0.3048,\"offset\":0.0},\"symbol\":\"ft\",\"baseMeasurement\":{\"ancestry\":\"Length\",\"type\":\"UM\"},\"type\":\"USO\"}"
    },
    "toUnit": {
        "essence": {
            "abcd": null,
            "scaleOffset": {
                "scale": 1.0,
                "offset": 0.0
            },
            "symbol": "m",
            "baseMeasurement": {
                "ancestry": "L",
                "type": "UM"
            },
            "type": "USO"
        },
        "deprecationInfo": null,
        "displaySymbol": "m",
        "name": "metre",
        "description": null,
        "lastModified": "20160322",
        "source": "Energistics",
        "namespace": "Energistics_UoM",
        "persistableReference": "{\"scaleOffset\":{\"scale\":1.0,\"offset\":0.0},\"symbol\":\"m\",\"baseMeasurement\":{\"ancestry\":\"L\",\"type\":\"UM\"},\"type\":\"USO\"}"
    }
}
Edited by Debasis Chatterjee