public function setup($data) {

    if (is_object($data[0])) {
      $data = Converter::toArray($data[0]);
    }

    foreach ($data as $k => $d) {
      if (!in_array($k,array("token","expires"))) {
        throw new CatapultApiException("$k is not a valid key for endpoint token");
      }
    }
    $arr = array('token', 'expires');
    foreach ($arr as $a) {
      if (isset($data[$a])) {
        $this->$a = $data[$a];
      }
    }
    // important don't serialize
    // when sending in a Endpoints object
    $this->serialize = FALSE;
  }