Skip to content

Developers

How can we help you?

← Go back

Mapping

The mapping is used to name the values given on an enumeration entry

A mapping looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<mapping>
  <id type="integer">7</id>
  <name>Distribution Channel</name>
  <link rel="self" href="https://movida.bebanjo.net/api/mappings/7"/>
  <link rel="enumeration" href="https://movida.bebanjo.net/api/enumerations/879"/>
</mapping>
{
  "resource_type": "mapping",
  "id": 7,
  "name": "Distribution Channel",
  "self_link": "https://movida.bebanjo.net/api/mappings/7",
  "enumeration_link": "https://movida.bebanjo.net/api/enumerations/879"
}

Note: currently mappings cannot be updated/destroyed through the API. Please, contact your Technical Account Manager in order to define the list of enumerations and mappings suitable for your company.

Valid attributes

  • name (required): string used internally to identify that entry.
  • enumeration (optional): The enumeration it belongs to.

Get a list of all mappings for an enumeration

Mappigns are accessed via the Enumeration they belong to, as in the example below, through the link identified by the mappings link:

<?xml version='1.0' encoding='utf-8' ?>
<enumerations type="array">
  <enumeration>
    <id type="integer">879</id>
    <name>Mediagenix On-Demand:Platform Configuration</name>
    <link rel="self" href="https://movida.bebanjo.net/api/enumerations/879"/>
    <link rel="entries" href="https://movida.bebanjo.net/api/enumerations/879/entries"/>
    <link rel="mappings" href="https://movida.bebanjo.net/api/enumerations/879/mappings"/>
  </enumeration>
</enumerations>
{
  "resource_type": "enumeration",
  "id": 879,
  "name": "Mediagenix On-Demand:Platform Configuration",
  "self_link": "https://movida.bebanjo.net/api/enumerations/879",
  "entries_link": "https://movida.bebanjo.net/api/enumerations/879/entries",
  "mappings_link": "https://movida.bebanjo.net/api/enumerations/879/mappings"
}

If we follow that link, we can fetch the list of all entries for that enumeration.

$ curl --digest -u robot_user:password https://movida.bebanjo.net/api/enumerations/879/mappings
$ curl --digest -u robot_user:password -H "Accept: application/json" https://movida.bebanjo.net/api/enumerations/879/mappings
<?xml version="1.0" encoding="UTF-8"?>
<mappings type="array">
  <mapping>
    <id type="integer">9</id>
    <name>Business Model</name>
    <link rel="self" href="https://movida.bebanjo.net/api/mappings/9"/>
    <link rel="enumeration" href="https://movida.bebanjo.net/api/enumerations/879"/>
  </mapping>
  <mapping>
    <id type="integer">8</id>
    <name>Channel Brand</name>
    <link rel="self" href="https://movida.bebanjo.net/api/mappings/8"/>
    <link rel="enumeration" href="https://movida.bebanjo.net/api/enumerations/879"/>
  </mapping>
</mappings>
{
  "entries": [
    {
      "resource_type": "mapping",
      "id": 9,
      "name": "Business Model",
      "self_link": "https://movida.bebanjo.net/api/mappings/9",
      "enumeration_link": "https://movida.bebanjo.net/api/enumerations/879"
    },
    {
      "resource_type": "mapping",
      "id": 8,
      "name": "Channel Brand",
      "self_link": "https://movida.bebanjo.net/api/mappings/8",
      "enumeration_link": "https://movida.bebanjo.net/api/enumerations/879"
    }
  ]
}

Creating a new mapping for an existing enumeration

To create a new mapping, you just need to POST proper XML/JSON mapping representation to the mappings URL of an enumeration. That URL can be found in a link which rel attribute equals to mappings.

For example, this POST would create a mapping (we will use curl’s @ option, which reads data to be posted from a file):

$ cat mapping.xml
$ cat mapping.json
<mapping>
  <name>Territory</name>
</mapping>
{
    "name": "Territory"
}
$ curl --digest -u robot_user:password -H "Content-type: application/xml" -X POST -d @mapping.xml https://movida.bebanjo.net/api/enumerations/879/mappings

$ curl --digest -u robot_user:password -H "Content-type: application/json" -X POST -d @mapping.json https://movida.bebanjo.net/api/enumerations/879/mappings

Mediagenix On-Demand will return the full XML/JSON of the mapping just created:

<mapping>
  <id type="integer">10</id>
  <name>Territory</name>
  <link rel="self" href="https://movida.bebanjo.net/api/mappings/10"/>
  <link rel="enumeration" href="https://movida.bebanjo.net/api/enumerations/879"/>
</mapping>
{
  "resource_type": "mapping",
  "id": 10,
  "name": "Territory",
  "self_link": "https://movida.bebanjo.net/api/mappings/10",
  "enumeration_link": "https://movida.bebanjo.net/api/enumerations/879"
}