项目作者: LuizHAssuncao

项目描述 :
Referral API (sample app)
高级语言: Ruby
项目地址: git://github.com/LuizHAssuncao/referral-app.git
创建时间: 2018-08-09T16:59:04Z
项目社区:https://github.com/LuizHAssuncao/referral-app

开源协议:

下载


API Documentation

References

Create a contact

  • URL

    /contacts

  • Method:

    POST

  • URL Params

    None

  • Data Params

    1. {
    2. "name": "Luiz",
    3. "email": "test@test.tech"
    4. }
  • Success Response:

    • Code: 201

      Content: { "id": 1, "name": "Luiz", "email": "test@test.tech", "points": 0, "created_at": "2018-08-10T05:22:30.330Z", "updated_at": "2018-08-10T05:22:30.330Z" }
  • Sample Call:

    1. curl -X POST https://influitive-referral-app.herokuapp.com/contacts -H 'content-type: application/json' -d '{ "name": "Luiz", "email": "test@test.tech"}'

Show all contacts

  • URL

    /contacts

  • Method:

    GET

  • URL Params

    None

  • Data Params

    None

  • Success Response:

    • Code: 200

      Content: [ { "id": 1, "name": "Luiz", "email": "test@test.tech", "contact_id": 1, "created_at": "2018-08-10T05:09:34.853Z", "updated_at": "2018-08-10T05:09:34.853Z" } ]
  • Sample Call:

    1. curl -X GET https://influitive-referral-app.herokuapp.com/contacts

Show specific contact

  • URL

    /contacts/:id

  • Method:

    GET

  • URL Params

    id=[integer]

  • Data Params

    None

  • Success Response:

    • Code: 200

      Content: { "id": 1, "name": "Luiz", "email": "test@test.tech", "contact_id": 1, "created_at": "2018-08-10T05:09:34.853Z", "updated_at": "2018-08-10T05:09:34.853Z" }
  • Error Response:

    • Code: 404 NOT FOUND

      Content: {"message":"Couldn't find Contact with 'id'=123"}
  • Sample Call:

    1. curl -X GET https://influitive-referral-app.herokuapp.com/contacts

    Create a referral


  • URL

    /contacts/:id/referrals

  • Method:

    POST

  • URL Params

    id=[integer]

  • Data Params

    1. {
    2. "name": "Fernando",
    3. "email": "test2@test.tech"
    4. }
  • Success Response:

    • Code: 201

      Content: { "id": 9, "name": "Fernando", "email": "test2@test.tech", "contact_id": 1, "created_at": "2018-08-10T05:30:28.836Z", "updated_at": "2018-08-10T05:30:28.836Z" }
  • Sample Call:

    1. curl -X POST https://influitive-referral-app.herokuapp.com/contacts/1/referrals -H 'content-type: application/json' -d '{ "name": "Fernando", "email": "test2@test.tech" }'

Show all referrals

  • URL

    /contacts/:id/referrals

  • Method:

    GET

  • URL Params

    id=[integer]

  • Data Params

    None

  • Success Response:

    • Code: 200

      Content: [ { "id": 1, "name": "Luiz", "email": "test@test.tech", "contact_id": 1, "created_at": "2018-08-10T05:09:34.853Z", "updated_at": "2018-08-10T05:09:34.853Z" }, { "id": 9, "name": "Luiz", "email": "test@test.tech", "contact_id": 1, "created_at": "2018-08-10T05:30:28.836Z", "updated_at": "2018-08-10T05:30:28.836Z" } ]
  • Error Response:

    • Code: 404 NOT FOUND

      Content: {"message":"Couldn't find Contact with 'id'=123"}
  • Sample Call:

    1. curl -X GET https://influitive-referral-app.herokuapp.com/contacts/1/referrals

Show leaderboard

Show all contacts sorted by amount of referrals

  • URL

    /leaderboard

  • Method:

    GET

  • URL Params

    None

  • Data Params

    None

  • Success Response:

    • Code: 200

      Content: [ { "id": 1, "name": "Luiz", "email": "test@test.tech", "points": 200, "created_at": "2018-08-10T05:09:26.215Z", "updated_at": "2018-08-10T05:30:28.843Z" }, { "id": 2, "name": "Luiz", "email": "test@test.tech", "points": 0, "created_at": "2018-08-10T18:29:47.844Z", "updated_at": "2018-08-10T18:29:47.844Z" }, { "id": 3, "name": "Luiz", "email": "test@test.tech", "points": 0, "created_at": "2018-08-10T18:30:49.075Z", "updated_at": "2018-08-10T18:30:49.075Z" } ]
  • Sample Call:

    1. curl -X GET https://influitive-referral-app.herokuapp.com/leaderboard

    Show all events


  • URL

    /events

  • Method:

    GET

  • URL Params

    None

  • Data Params

    None

  • Success Response:

    • Code: 200

      Content: [ { "id": 1, "points": 100, "descriptions": "Referral awarded to contact id: 1. New score: 100", "event_type": "referral_awarded", "created_at": "2018-08-10T05:09:35.164Z", "updated_at": "2018-08-10T05:09:35.164Z" }, { "id": 2, "points": 100, "descriptions": "Referral awarded to contact id: 1. New score: 200", "event_type": "referral_awarded", "created_at": "2018-08-10T05:30:28.867Z", "updated_at": "2018-08-10T05:30:28.867Z" } ]
  • Sample Call:

    1. curl -X GET https://influitive-referral-app.herokuapp.com/events