Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Livechat extended REST APIs #4117

Merged
merged 7 commits into from
Oct 3, 2016
Merged

Livechat extended REST APIs #4117

merged 7 commits into from
Oct 3, 2016

Conversation

sampaiodiego
Copy link
Member

@sampaiodiego sampaiodiego commented Aug 25, 2016

@RocketChat/core

Closes #3957

New endpoints examples:

curl -H "X-Auth-Token: LOGIN_TOKEN" -H "X-User-Id: USER_ID" \
    http://localhost:3000/api/v1/settings/Livechat_enabled
curl -H "X-Auth-Token: LOGIN_TOKEN" -H "X-User-Id: USER_ID" \
    -H "Content-Type: application/json" \
    -X POST \
    -d '{ "value": true }' \
    http://localhost:3000/api/v1/settings/Livechat_enabled
curl -H "X-Auth-Token: LOGIN_TOKEN" -H "X-User-Id: USER_ID" \
    http://localhost:3000/api/v1/livechat/users/agent
curl -H "X-Auth-Token: LOGIN_TOKEN" -H "X-User-Id: USER_ID" \
    -X POST -H "Content-type:application/json" \
    -d '{"username":"diego.sampaio"}' \
    http://localhost:3000/api/v1/livechat/users/agent
curl -H "X-Auth-Token: LOGIN_TOKEN" -H "X-User-Id: USER_ID" \
    http://localhost:3000/api/v1/livechat/users/agent/EgbhyZi2cQe6AJXBG
curl -H "X-Auth-Token: LOGIN_TOKEN" -H "X-User-Id: USER_ID" \
    -X DELETE \
    http://localhost:3000/api/v1/livechat/users/agent/EgbhyZi2cQe6AJXBG
curl -H "X-Auth-Token: LOGIN_TOKEN" -H "X-User-Id: USER_ID" \
    http://localhost:3000/api/v1/livechat/users/manager
curl -H "X-Auth-Token: LOGIN_TOKEN" -H "X-User-Id: USER_ID" \
    -X POST -H "Content-type:application/json" \
    -d '{"username":"diego.sampaio"}' \
    http://localhost:3000/api/v1/livechat/users/manager
curl -H "X-Auth-Token: LOGIN_TOKEN" -H "X-User-Id: USER_ID" \
    http://localhost:3000/api/v1/livechat/users/manager/EgbhyZi2cQe6AJXBG
curl -H "X-Auth-Token: LOGIN_TOKEN" -H "X-User-Id: USER_ID" \
    -X DELETE \
    http://localhost:3000/api/v1/livechat/users/manager/EgbhyZi2cQe6AJXBG
curl -H "X-Auth-Token: LOGIN_TOKEN" -H "X-User-Id: USER_ID" \
    http://localhost:3000/api/v1/livechat/department
curl -H "X-Auth-Token: LOGIN_TOKEN" -H "X-User-Id: USER_ID" \
    http://localhost:3000/api/v1/livechat/department/zNh6q7Rw9JXFdGhMq
curl -H "X-Auth-Token: LOGIN_TOKEN" -H "X-User-Id: USER_ID" \
    -X POST -H "Content-type:application/json" \
    -d '{"department": {"enabled": false, "name": "new from api" }, "agents": [{ "agentId": "yhHvK7uhhXh9DqKWH", "username": "diego.sampaio" }] }' \
    http://localhost:3000/api/v1/livechat/department
curl -H "X-Auth-Token: LOGIN_TOKEN" -H "X-User-Id: USER_ID" \
    -X PUT -H "Content-type:application/json" \
    -d '{"department": {"enabled": false, "name": "update api 2"}, "agents": [{ "agentId": "yhHvK7uhhXh9DqKWH", "username": "diego.sampaio", "count": 2 }] }' \
    http://localhost:3000/api/v1/livechat/department/Cb6DH9r9b9ssYtAG9
curl -H "X-Auth-Token: LOGIN_TOKEN" -H "X-User-Id: USER_ID" \
    -X DELETE \
    http://localhost:3000/api/v1/livechat/department/Cb6DH9r9b9ssYtAG9

@engelgabriel engelgabriel temporarily deployed to rocket-chat-pr-4117 August 25, 2016 20:41 Inactive
@sampaiodiego
Copy link
Member Author

I'm not sure if this is the best way to create this APIs though 😞

@sampaiodiego
Copy link
Member Author

Ready for merge!

Should we start create some tests for REST APIs?

@sampaiodiego sampaiodiego changed the title [WIP] Livechat extended api Livechat extended REST APIs Sep 30, 2016
return RocketChat.API.v1.unauthorized();
}

return RocketChat.API.v1.success(_.pick(RocketChat.models.Settings.findOneNotHiddenById(this.urlParams._id), '_id', 'value'));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use RocketChat.settings.get?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because I don't want let users see settings hidden from the admin panel.

// REST endpoints
api.addFiles('server/rest/departments.js', 'server');
api.addFiles('server/rest/sms.js', 'server');
api.addFiles('server/rest/users.js', 'server');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can start using imports here. What do you think?
We can keep the server/api.js and just add the imports for each api file.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@engelgabriel engelgabriel merged commit 65d5ea3 into develop Oct 3, 2016
@engelgabriel engelgabriel deleted the livechat-extended-api branch October 3, 2016 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Request for additional REST API endpoint for LiveChat
3 participants