Skip to content

API Reminder

bazingaterry edited this page Dec 8, 2016 · 11 revisions

This API need token otherwise it will return token invalid error.

{
  "ret": 10,
  "msg": "token invalid."
}

/api/reminder?token={token}

GET

user's reminders sorted by last update

jQuery example

// Get Reminders (GET http://api.sysu.space/api/reminder)

jQuery.ajax({
    url: "http://api.sysu.space/api/reminder",
    type: "GET",
    data: {
        "token": "22b1a163b07c80c6991eb2c5ce76627",
    },
    headers: {
        "Content-Type": "application/x-www-form-urlencoded; charset=utf-8",
    },
})
.done(function(data, textStatus, jqXHR) {
    console.log("HTTP Request Succeeded: " + jqXHR.status);
    console.log(data);
})
.fail(function(jqXHR, textStatus, errorThrown) {
    console.log("HTTP Request Failed");
})
.always(function() {
    /* ... */
});

return type

{
  "ret": 0,
  "msg": "ok.",
  "reminders": [
    {
      "title": "Secret",
      "content": "Lu Xiaoyu",
      "due": "2015-04-11 12:00:00.0",
      "last_update": "2016-12-08 03:46:33.0",
      "id": 268,
      "priority": 1,
      "type": 1,
      "state": 0
    },
    {
      "title": "nami",
      "content": "123",
      "due": "2015-04-11 12:00:00.0",
      "last_update": "2016-12-08 03:46:33.0",
      "id": 270,
      "priority": 2,
      "type": 1,
      "state": 0,
      "channel": {
        "id": 168,
        "type": 1,
        "name": "naminamiting",
        "last_update": "2016-12-08 03:46:33.0"
      }
    }
  ]
}

POST

new reminder

form url-encoded parameter

  • title
  • content (optional)
  • due (yyyy-mm-dd hh:mm:ss, optional)
  • priority: LOW=0, MED=1, HIGH=2
  • type: send in channel=0, personal=1
  • channel_id (needed if type=0)

jQuery example

// New Channel Reminder (POST http://api.sysu.space/api/reminder)

jQuery.ajax({
    url: "http://api.sysu.space/api/reminder?" + jQuery.param({
        "token": "22b1a163b07c80c6991eb2c5ce76627",
    }),
    type: "POST",
    headers: {
        "Content-Type": "application/x-www-form-urlencoded; charset=utf-8",
    },
    contentType: "application/x-www-form-urlencoded",
    data: {
        "channel_id": "168",
        "title": "nami",
        "content": "123",
        "due": "2015-4-11 12:00:00",
        "priority": "2",
        "type": "0",
    },
})
.done(function(data, textStatus, jqXHR) {
    console.log("HTTP Request Succeeded: " + jqXHR.status);
    console.log(data);
})
.fail(function(jqXHR, textStatus, errorThrown) {
    console.log("HTTP Request Failed");
})
.always(function() {
    /* ... */
});
// New Personal Reminder (POST http://api.sysu.space/api/reminder)

jQuery.ajax({
    url: "http://api.sysu.space/api/reminder?" + jQuery.param({
        "token": "22b1a163b07c80c6991eb2c5ce76627",
    }),
    type: "POST",
    headers: {
        "Content-Type": "application/x-www-form-urlencoded; charset=utf-8",
    },
    contentType: "application/x-www-form-urlencoded",
    data: {
        "title": "Secret",
        "content": "Lu Xiaoyu",
        "due": "2015-4-11 12:00:00",
        "priority": "1",
        "type": "1",
    },
})
.done(function(data, textStatus, jqXHR) {
    console.log("HTTP Request Succeeded: " + jqXHR.status);
    console.log(data);
})
.fail(function(jqXHR, textStatus, errorThrown) {
    console.log("HTTP Request Failed");
})
.always(function() {
    /* ... */
});

return type

{
  "ret": 0,
  "msg": "ok.",
  "reminder": {
    "title": "nami",
    "content": "123",
    "due": "2015-4-11 12:00:00",
    "last_update": "2016-12-08 03:46:33",
    "id": 270,
    "priority": 2,
    "type": 0,
    "state": 0,
    "channel": {
      "id": 168,
      "type": 1,
      "name": "naminamiting",
      "last_update": "2016-12-08 03:46:33"
    }
  }
}
{
  "ret": 0,
  "msg": "ok.",
  "reminder": {
    "title": "Secret",
    "content": "Lu Xiaoyu",
    "due": "2015-4-11 12:00:00",
    "last_update": "2016-12-08 03:46:33",
    "id": 268,
    "priority": 1,
    "type": 1,
    "state": 0
  }
}
{
  "ret": 11,
  "msg": "not your channel."
}
{
  "ret": 3,
  "msg": "parameters error."
}

/api/reminder/{id}?token={token}

GET

reminder information

to be done

POST

update reminder

form url-encoded parameter

  • title (optional)
  • content (optional)
  • due (yyyy-mm-dd hh:mm:ss) (optional)
  • priority: LOW=0, MED=1, HIGH=2 (optional)
  • remark (optional, only for channel reminder)
  • state: UNDO=0, COMPLETED=1 (optional)

If you are a creator of a channel reminder, you can edit title, content, due, priority, remark and state.

If you are a subscriber of a channel reminder, you can edit remark and state.

If you are a creator of a personal reminder, you can edit all field of your reminder.

Any editing of a reminder will update its and its channel's last_update field.

jQuery example

// Edit Personal Reminder (POST http://localhost:8080/api/reminder/33)

jQuery.ajax({
    url: "http://localhost:8080/api/reminder/33?" + jQuery.param({
        "token": "3290ea5260335da58f5f221cd6302ace",
    }),
    type: "POST",
    headers: {
        "Content-Type": "application/x-www-form-urlencoded; charset=utf-8",
    },
    contentType: "application/x-www-form-urlencoded",
    data: {
        "remark": "remark oh!yeee!",
        "state": "0",
        "title": "Nihao!2",
        "content": "MieMieMie2",
        "due": "2016-4-12 12:00:00",
        "priority": "1",
    },
})
.done(function(data, textStatus, jqXHR) {
    console.log("HTTP Request Succeeded: " + jqXHR.status);
    console.log(data);
})
.fail(function(jqXHR, textStatus, errorThrown) {
    console.log("HTTP Request Failed");
})
.always(function() {
    /* ... */
});
// Edit Channel Reminder (POST http://localhost:8080/api/reminder/14)

jQuery.ajax({
    url: "http://localhost:8080/api/reminder/14?" + jQuery.param({
        "token": "3290ea5260335da58f5f221cd6302ace",
    }),
    type: "POST",
    headers: {
        "Content-Type": "application/x-www-form-urlencoded; charset=utf-8",
    },
    contentType: "application/x-www-form-urlencoded",
    data: {
        "title": "Nihao!!",
        "content": "MieMieMie233",
        "due": "2019-4-12 12:00:00",
        "priority": "3",
    },
})
.done(function(data, textStatus, jqXHR) {
    console.log("HTTP Request Succeeded: " + jqXHR.status);
    console.log(data);
})
.fail(function(jqXHR, textStatus, errorThrown) {
    console.log("HTTP Request Failed");
})
.always(function() {
    /* ... */
});

return type

{
  "ret": 0,
  "msg": "ok."
}

All invalid fields will be ignore without error.

{
  "ret": 3,
  "msg": "url id invalid."
}

DELETE

delete reminder

jQuery example

// Delete Reminder (DELETE http://localhost:8080/api/reminder/33)

jQuery.ajax({
    url: "http://localhost:8080/api/reminder/33?" + jQuery.param({
        "token": "3290ea5260335da58f5f221cd6302ace",
    }),
    type: "DELETE",
})
.done(function(data, textStatus, jqXHR) {
    console.log("HTTP Request Succeeded: " + jqXHR.status);
    console.log(data);
})
.fail(function(jqXHR, textStatus, errorThrown) {
    console.log("HTTP Request Failed");
})
.always(function() {
    /* ... */
});

return type

{
  "ret": 0,
  "msg": "ok."
}
{
  "ret": 11,
  "msg": "permission deny."
}