Constants

Constants can be used in indicator formulas.

For instance: one could define a constant for the average hourly rate of an external consultant. This constant could be used to calculate the total costs of consultants by multiplying the constant with the measured hours.

Another example would be the assumption that 0.5% of all website visitors eventually convert into customers. Constants have “values” and can change throughout time.

Constants are often used when you need to make assumptions.

Show

GET /constants/#{id}.xml

Returns a single constant with its current value. It also includes all the historic and future values it may have.

Request

curl -u TOKEN:x -X GET https://dashboard.kpilibrary.com/api/v2/constants/CONSTANT_ID.xml

Response

Status: 200

<?xml version="1.0" encoding="UTF-8"?>
<constant>
  <id type="integer">11</id>
  <name>Euro Exchange Rate</name>
  <date type="date">2010-07-01</date>
  <value type="float">0.98</value>
  <values>
    <value>
      <date type="date">2010-07-01</date>
      <value>0.98</value>
    </value>
    <value>
      <date type="date">2010-06-01</date>
      <value>0.95</value>
    </value>
    <value>
      <date type="date">2010-05-01</date>
      <value>0.96</value>
    </value>
  </values>
</constant>

Create

POST /constants.xml

Creates a new constant. You may provide an initial value. If no date is provided it registers the value using the current date in UTC. The format to use for the date property is: YYYY-MM-DD.

Request

curl -u TOKEN:x -X POST -H "Content-Type: application/xml; charset=utf-8" \
  -d "<constant><name>Euro Conversion Rate</name><value>0.91&lt/value></constant>" \
  https://dashboard.kpilibrary.com/api/v2/constants.xml

Response

Status: 201
Location: https://dashboard.kpilibrary.com/api/v2/constants/NEW_CONSTANT_ID.xml

<?xml version="1.0" encoding="UTF-8"?>
<constant>
  <id type="integer">NEW_CONSTANT_ID</id>
</constant>

Update

PUT /constants/#{id}.xml

Updates the name and/or value of a constant. If a value is given but no date is provided it registers the value using the current date in UTC. If a value already exists at the date it overwrites the value. If no value is given but a date is given, the value at the given date is removed. The format to use for the date property is: YYYY-MM-DD.

Request

curl -u TOKEN:x -X PUT -H "Content-Type: application/xml; charset=utf-8" \
  -d "<constant><name>YU</name><date>2010-06-01&lt/date><value>5&lt/value></constant>" \
  https://dashboard.kpilibrary.com/api/v2/constants/CONSTANT_ID.xml

Response

Status: 200

Delete

DELETE /constants/#{id}.xml

Destroys the constant at the referenced URL.

Request

curl -u TOKEN:x -X DELETE https://dashboard.kpilibrary.com/api/v2/constants/CONSTANT_ID.xml

Response

Status: 200

List

GET /constants.xml

Returns a list of constants with their current values.

Request

curl -u TOKEN:x -X GET https://dashboard.kpilibrary.com/api/v2/constants.xml

Response

Status: 200

<?xml version="1.0" encoding="UTF-8"?>
<constants type="array">
  <constant>
    <id type="integer">11</id>
    <name>Euro Exchange Rate</name>
    <date type="date">2010-06-25</date>
    <value type="float">0.98</value>
  </constant>
  <constant>
    <id type="integer">19</id>
    <name>Avg Cost of Deployment</name>
  </constant>
</constants>