Skip to content
Görkem Mülayim edited this page Jul 20, 2017 · 7 revisions

This is an overview of the API of Not2Do and will be primarily of interest to developers.

Table of Contents

Login

Signup

Follow

Unfollow

Show Not2Do

Friends Timeline

My Profile

Create Not2Do

Show Participants

Participate

Report Failure

Global Timeline

Show User

Signup

Register the given user and returns a token for the user.

  • URL

    /api/v1/sign_up

  • Method:

    POST

  • Data Params

    {
        username : [string],
        password : [alphanumeric],
        email : [alphanumeric],
        name : [string],
        surname : [string]
    }
  • Success Response:

    • Code: 200
      Content: { username: "johndoe", token : "abcsd832bdf3", error: false }
  • Error Response:

    • Code: 401 UNAUTHORIZED
      Content: { error: true, error_msg : "Email already using." }

    OR

    • Code: 401 UNAUTHORIZED
      Content: { error: true, error_msg : "Username already taken." }
  • Sample Call:

      $.ajax({
        url: "/api/v1/sign_up",
        data:     {
          username : username,
          password : password,
          email : email,
          name : name,
          surname : surname
      },
        type : "POST",
        success : function(r) {
          console.log(r);
        }
      });

Follow

Follows given username

  • URL

    /api/v1/follow/:username

  • Method:

    POST

  • URL Params

    username=[alphanumeric]

  • Data Params

    {
        username : [string],
        token : [alphanumeric]
    }
  • Success Response:

    • Code: 200
      Content: { message : "Success", err: 0 }
  • Error Response:

    • Code: 404 NOT FOUND
      Content: { error: true, error_msg : "User doesn't exist" }

    OR

    • Code: 401 UNAUTHORIZED
      Content: { error: true, error_msg : "You are unauthorized to make this request." }
  • Sample Call:

      $.ajax({
        url: "/api/v1/follow/johndoe",
        dataType: "json",
        data: { username: username, token: token},
        type : "POST",
        success : function(r) {
          console.log(r);
        }
      });

Unfollow

Unfollows given username

  • URL

    /api/v1/unfollow/:username

  • Method:

    POST

  • URL Params

    username=[alphanumeric]

  • Data Params

    {
        username : [string],
        token : [alphanumeric]
    }
  • Success Response:

    • Code: 200
      Content: { message : "Success", error: false }
  • Error Response:

    • Code: 404 NOT FOUND
      Content: { error: true, error_msg : "User doesn't exist" }

    OR

    • Code: 401 UNAUTHORIZED
      Content: { error: true, error_msg : "You are unauthorized to make this request." }
  • Sample Call:

      $.ajax({
        url: "/api/v1/unfollow/johndoe",
        dataType: "json",
        data: { username: username, token: token},
        type : "POST",
        success : function(r) {
          console.log(r);
        }
      });

Show a Not2Do

Gets a Not2Do

  • URL

    /api/v1/not2do/:not2do_id

  • Method:

    POST

  • Data Params

    {
        username : [string],
        token : [alphanumeric],
    }
  • Success Response:

    • Code: 200
      Content: `
      { error: false,
          not2do: {not2do_id: 125, username: "johndoe", name: "John", surname: "Doe", pp_url: null, content: "I wont smoke", created_at: "2017-07-02 16:08:02 +0000", participants: 135, failed: -1}
      }
  • Error Response:

    • Code: 404 NOT FOUND
      Content: { error: true, error_msg : "Not2Do doesn't exist." }

    OR

    • Code: 401 UNAUTHORIZED
      Content: { error: true, error_msg : "You are unauthorized to make this request." }

    OR

    • Code: 401 UNAUTHORIZED
      Content: { error: true, error_msg : "This not2do is private." }
  • Sample Call:

      $.ajax({
        url: "/api/v1/not2do/125",
        dataType: "json",
        data: { username: username, token: token},
        type : "POST",
        success : function(r) {
          console.log(r);
        }
      });

Show Friends Timeline

Returns not2dos json data from users followings.

  • URL

    /api/v1/following/:less

  • Method:

    POST

  • URL Params

    less=[numeric]

  • Data Params

    {
        username : [string],
        token : [alphanumeric]
    }
  • Success Response:

    • Code: 200
      Content:
      { error: false,
          not2dos: [
              {not2do_id: 1234, username: "johndoe", name: "John", surname: "Doe", pp_url: null, content: "I wont smoke", created_at: "2017-07-02 16:08:02 +0000", participants: 135, failed: -1},
              {not2do_id: 1235, username: "johndoe2", name: "John", surname: "Doe", pp_url: null, content: "I wont drink", created_at: "2017-07-01 16:08:02 +0000", participants: 123, failed: 1}
          ]
      }
  • Error Response:

    • Code: 401 UNAUTHORIZED
      Content: { error: true, error_msg : "You are unauthorized to make this request." }
  • Sample Call:

      $.ajax({
        url: "/api/v1/following/34",
        dataType: "json",
        data: { username: username, token: token},
        type : "POST",
        success : function(r) {
          console.log(r);
        }
      });

Show User's profile

Returns json data about a single user.

  • URL

    /api/v1/my_profile

  • Method:

    POST

  • URL Params

    None

  • Data Params

    {
        username : [string],
        token : [alphanumeric]
    }
  • Success Response:

    • Code: 200
      Content:
      { error: false,
          user: { id: 24, username: "okapi", name: "Okapi", surname: "Tech.", pp_url: "https://asd.com/i.jpg", bio: "wowow", followers: 23, followed: 245},
          participating: [
              {not2do_id: 1234, username: "johndoe", name: "John", surname: "Doe", pp_url: null, content: "I wont smoke", created_at: "2017-07-02 16:08:02 +0000", participants: 135, failed: 0},
              {not2do_id: 1235, username: "johndoe2", name: "John", surname: "Doe", pp_url: null, content: "I wont drink", created_at: "2017-07-01 16:08:02 +0000", participants: 123, failed: 1}
          ],
          owning: [
              {not2do_id: 12545, content: "I wont share picture on instagram", created_at: "2017-07-02 16:08:02 +0000", participants: 15, failed: 1},
              {not2do_id: 12548, content: "I wont send snap to Kerim", created_at: "2017-07-01 16:08:02 +0000", participants: 12, failed: 0}
          ],
          private: [
              {not2do_id: 12549, content: "I wont pee on myself", created_at: "2017-07-01 16:08:02 +0000", participants: 12, failed: 0}
          ],
          supervises: [
              {not2do_id: 1239, participant_username: "janedoe", username: "johndoe", name: "John", surname: "Doe", pp_url: null, content: "I wont smoke", created_at: "2017-07-02 16:08:02 +0000", participants: 135, failed: 0},
              {not2do_id: 1280, participant_username: "janedoe", username: "johndoe2", name: "John", surname: "Doe", pp_url: null, content: "I wont drink", created_at: "2017-07-01 16:08:02 +0000", participants: 123, failed: 1}
          ]
      }
  • Error Response:

    • Code: 404 NOT FOUND
      Content: { error: true, error_msg : "User doesn't exist" }

    OR

    • Code: 401 UNAUTHORIZED
      Content: { error: true, error_msg : "You are unauthorized to make this request." }
  • Sample Call:

      $.ajax({
        url: "/api/v1/my_profile",
        dataType: "json",
        data: { username: username, token: token},
        type : "POST",
        success : function(r) {
          console.log(r);
        }
      });

Create Not2Do

Creates a Not2Do

  • URL

    /api/v1/not2do

  • Method:

    POST

  • Data Params

    {
        username : [string],
        token : [alphanumeric],
        supervisor: [string],
        content: [string],
        privacy: [numeric]
    }
  • Success Response:

    • Code: 200
      Content: { message : "Success", id: 235, error: false }
  • Error Response:

    • Code: 404 NOT FOUND
      Content: { error: true, error_msg : "Supervisor doesn't exist." }

    OR

    • Code: 401 UNAUTHORIZED
      Content: { error: true, error_msg : "You are unauthorized to make this request." }

    OR

    • Code: 401 UNAUTHORIZED
      Content: { error: true, error_msg : "Supervisor is not following you." }
  • Sample Call:

      $.ajax({
        url: "/api/v1/not2do",
        dataType: "json",
        data: { username: username, token: token, supervisor: "blabla", content: "I wont smoke", privacy: 1},
        type : "POST",
        success : function(r) {
          console.log(r);
        }
      });

Show Participants

Gets participants of a given not2do

  • URL

    /api/v1/not2do/:not2do_id/participants

  • Method:

    POST

  • Data Params

    {
        username : [string],
        token : [alphanumeric],
    }
  • Success Response:

    • Code: 200
      Content: `
      { error: false,
          participants: [
              { id: 24, username: "okapi", name: "Okapi", surname: "Tech.", pp_url: "https://asd.com/i.jpg"},
              { id: 25, username: "okapi1", name: "Okapi", surname: "Tech.", pp_url: "https://asd.com/i.jpg"},
              { id: 26, username: "okapi2", name: "Okapi", surname: "Tech.", pp_url: "https://asd.com/i.jpg"},
              { id: 27, username: "okapi3", name: "Okapi", surname: "Tech.", pp_url: "https://asd.com/i.jpg"},
          ]
      }
  • Error Response:

    • Code: 404 NOT FOUND
      Content: { error: true, error_msg : "Not2Do doesn't exist." }

    OR

    • Code: 401 UNAUTHORIZED
      Content: { error: true, error_msg : "You are unauthorized to make this request." }

    OR

    • Code: 401 UNAUTHORIZED
      Content: { error: true, error_msg : "This not2do is private." }
  • Sample Call:

      $.ajax({
        url: "/api/v1/not2do/125/participants",
        dataType: "json",
        data: { username: username, token: token},
        type : "POST",
        success : function(r) {
          console.log(r);
        }
      });

New Participate

Participate given not2do_id

  • URL

    /api/v1/participate/:not2do_id

  • Method:

    POST

  • URL Params

    username=[alphanumeric]

  • Data Params

    {
        username : [string],
        token : [alphanumeric],
        supervisor: [string]
    }
  • Success Response:

    • Code: 200
      Content: { message : "Success", error: false }
  • Error Response:

    • Code: 404 NOT FOUND
      Content: { error: true, error_msg : "Not2Do doesn't exist" }

    OR

    • Code: 404 NOT FOUND
      Content: { error: true, error_msg : "Supervisor doesn't exist." }

    OR

    • Code: 401 UNAUTHORIZED
      Content: { error: true, error_msg : "You are unauthorized to make this request." }

    OR

    • Code: 401 UNAUTHORIZED
      Content: { error: true, error_msg : "This not2do is private." }

    OR

    • Code: 401 UNAUTHORIZED
      Content: { error: true, error_msg : "Supervisor is not following you." }
  • Sample Call:

      $.ajax({
        url: "/api/v1/participate/2564",
        dataType: "json",
        data: { username: username, token: token, supervisor: "blabla"},
        type : "POST",
        success : function(r) {
          console.log(r);
        }
      });

Report Participate

Participate given not2do_id

  • URL

    /api/v1/failed/:not2do_id/:username

  • Method:

    POST

  • URL Params

    username=[alphanumeric]

  • Data Params

    {
        username : [string],
        token : [alphanumeric]
    }
  • Success Response:

    • Code: 200
      Content: { message : "Success", error: false }
  • Error Response:

    • Code: 404 NOT FOUND
      Content: { error: true, error_msg : "Not2Do doesn't exist" }

    OR

    • Code: 404 NOT FOUND
      Content: { error: true, error_msg : "This user doesn't participate given Not2Do" }

    OR

    • Code: 401 UNAUTHORIZED
      Content: { error: true, error_msg : "You are unauthorized to make this request." }

    OR

    • Code: 401 UNAUTHORIZED
      Content: { error: true, error_msg : "This not2do is private." }

    OR

    • Code: 401 UNAUTHORIZED
      Content: { error: true, error_msg : "You are not supervising this user." }
  • Sample Call:

      $.ajax({
        url: "/api/v1/failed/2564/janedoe",
        dataType: "json",
        data: { username: username, token: token},
        type : "POST",
        success : function(r) {
          console.log(r);
        }
      });

Show Global Timeline

Returns json data about entire timeline

  • URL

    /api/v1/timeline/:less

  • Method:

    POST

  • URL Params

    less=[numeric]

  • Data Params

    {
        username : [string],
        token : [alphanumeric]
    }
  • Success Response:

    • Code: 200
      Content:
      { error: false,
          not2dos: [
              {not2do_id: 1234, username: "johndoe", name: "John", surname: "Doe", pp_url: null, content: "I wont smoke", created_at: "2017-07-02 16:08:02 +0000", participants: 135, failed: -1},
              {not2do_id: 1235, username: "johndoe2", name: "John", surname: "Doe", pp_url: null, content: "I wont drink", created_at: "2017-07-01 16:08:02 +0000", participants: 123, failed: 1}
          ]
      }
  • Error Response:

    • Code: 401 UNAUTHORIZED
      Content: { error: true, error_msg : "You are unauthorized to make this request." }
  • Sample Call:

      $.ajax({
        url: "/api/v1/timeline/28",
        dataType: "json",
        data: { username: username, token: token},
        type : "POST",
        success : function(r) {
          console.log(r);
        }
      });

Show User

Returns json data about a single user.

  • URL

    /api/v1/user/:username

  • Method:

    POST

  • URL Params

    Required:

    username=[alphanumeric]

  • Data Params

    {
        username : [string],
        token : [alphanumeric]
    }
  • Success Response:

    • Code: 200
      Content:
      { error: false,
          user: { id: 24, username: "okapi", name: "Okapi", surname: "Tech.", pp_url: "https://asd.com/i.jpg", bio: "wowow", followers: 23, followed: 245},
          participating: [
              {not2do_id: 1234, username: "johndoe", name: "John", surname: "Doe", pp_url: null, content: "I wont smoke", created_at: "2017-07-02 16:08:02 +0000", participants: 135, failed: 0},
              {not2do_id: 1235, username: "johndoe2", name: "John", surname: "Doe", pp_url: null, content: "I wont drink", created_at: "2017-07-01 16:08:02 +0000", participants: 123, failed: 1}
          ],
          owning: [
              {not2do_id: 12545, content: "I wont share picture on instagram", created_at: "2017-07-02 16:08:02 +0000", participants: 15, failed: 1},
              {not2do_id: 12548, content: "I wont send snap to Kerim", created_at: "2017-07-01 16:08:02 +0000", participants: 12, failed: 0}
          ]
      }
  • Error Response:

    • Code: 404 NOT FOUND
      Content: { error: true, error_msg : "User doesn't exist" }

    OR

    • Code: 401 UNAUTHORIZED
      Content: { error: true, error_msg : "You are unauthorized to make this request." }
  • Sample Call:

      $.ajax({
        url: "/api/v1/user/okapi",
        dataType: "json",
        data: { username: username, token: token},
        type : "GET",
        success : function(r) {
          console.log(r);
        }
      });