Referral API (sample app)
References
URL
/contacts
Method:
POST
URL Params
None
Data Params
{
"name": "Luiz",
"email": "test@test.tech"
}
Success Response:
{ "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:
curl -X POST https://influitive-referral-app.herokuapp.com/contacts -H 'content-type: application/json' -d '{ "name": "Luiz", "email": "test@test.tech"}'
URL
/contacts
Method:
GET
URL Params
None
Data Params
None
Success Response:
[ { "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:
curl -X GET https://influitive-referral-app.herokuapp.com/contacts
URL
/contacts/:id
Method:
GET
URL Params
id=[integer]
Data Params
None
Success Response:
{ "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:
{"message":"Couldn't find Contact with 'id'=123"}
Sample Call:
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
{
"name": "Fernando",
"email": "test2@test.tech"
}
Success Response:
{ "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:
curl -X POST https://influitive-referral-app.herokuapp.com/contacts/1/referrals -H 'content-type: application/json' -d '{ "name": "Fernando", "email": "test2@test.tech" }'
URL
/contacts/:id/referrals
Method:
GET
URL Params
id=[integer]
Data Params
None
Success Response:
[ { "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:
{"message":"Couldn't find Contact with 'id'=123"}
Sample Call:
curl -X GET https://influitive-referral-app.herokuapp.com/contacts/1/referrals
Show all contacts sorted by amount of referrals
URL
/leaderboard
Method:
GET
URL Params
None
Data Params
None
Success Response:
[ { "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:
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:
[ { "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:
curl -X GET https://influitive-referral-app.herokuapp.com/events