/* ****************************************************************************
*
* Notification::toJson -
*/
std::string Notification::toJson()
{
    JsonHelper jh;

    jh.addString("callback", this->callback);
    if (this->throttling > 0)
    {
        jh.addNumber("throttling", this->throttling);
    }
    if (this->timesSent > 0)
    {
        jh.addNumber("timesSent", this->timesSent);
    }
    if (this->lastNotification > 0)
    {
        jh.addDate("lastNotification", this->lastNotification);
    }
    jh.addRaw("attributes", vectorToJson(this->attributes));

    return jh.str();
}
Beispiel #2
0
  /* ****************************************************************************
  *
  * Notification::toJson -
  *
  * FIXME P2: we should move 'attrsFormat' from Subject class to Notification
  * class, to avoid passing attrsFormat as argument
  *
  */
  std::string Notification::toJson(const std::string& attrsFormat)
  {
    JsonHelper jh;

    if (this->timesSent > 0)
    {
      jh.addNumber("timesSent", this->timesSent);
    }
    if (this->lastNotification > 0)
    {
      jh.addDate("lastNotification", this->lastNotification);
    }

    if (!this->blacklist)
    {
      jh.addRaw("attrs", vectorToJson(this->attributes));
    }
    else
    {
      jh.addRaw("exceptAttrs", vectorToJson(this->attributes));
    }

    jh.addString("attrsFormat", attrsFormat);

    if (this->httpInfo.custom)
    {
      jh.addRaw("httpCustom", this->httpInfo.toJson());
    }
    else
    {
      jh.addRaw("http", this->httpInfo.toJson());
    }

    if (this->metadata.size() > 0)
    {
      jh.addRaw("metadata", vectorToJson(this->metadata));
    }

    return jh.str();
  }
Beispiel #3
0
  /* ****************************************************************************
  *
  * Subscription::toJson -
  */
  std::string Subscription::toJson()
  {
    JsonHelper jh;

    jh.addString("id", this->id);
    if (this->description != "")
    {
      jh.addString("description", this->description);
    }
    if (this->expires != PERMANENT_SUBS_DATETIME)
    {
      jh.addDate("expires", this->expires);
    }
    jh.addString("status", this->status);
    jh.addRaw("subject", this->subject.toJson());
    jh.addRaw("notification", this->notification.toJson(renderFormatToString(this->attrsFormat, true, true)));

    if (this->throttling > 0)
    {
      jh.addNumber("throttling", this->throttling);
    }

    return jh.str();
  }