Skip to content

[NEW] Add Livechat inquiries endpoints#14779

Merged
renatobecker-zz merged 3 commits intodevelopfrom
rest-inquiries
Jun 11, 2019
Merged

[NEW] Add Livechat inquiries endpoints#14779
renatobecker-zz merged 3 commits intodevelopfrom
rest-inquiries

Conversation

@MarcosSpessatto
Copy link
Copy Markdown
Contributor

No description provided.

Copy link
Copy Markdown

@renatobecker-zz renatobecker-zz left a comment

Choose a reason for hiding this comment

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

Hey!
I left just some comments here...
Thanks!

}
const { offset, count } = this.getPaginationItems();
const { sort } = this.parseJsonQuery();
const cursor = LivechatInquiry.find({ status: 'open' }, {
Copy link
Copy Markdown

@renatobecker-zz renatobecker-zz Jun 11, 2019

Choose a reason for hiding this comment

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

I know we decided to return the entire inquiry object, but due to the large number of agents available, it would be better to return only a few fields, such as:

   {
            "_id": "jz9WE69S9zmvpW2Fd",
            "rid": "Q3ZLHdXYmPk8PxfPm",
            "name": "Renato Becker",
            "ts": "2019-06-11T02:15:54.761Z",
            "status": "open"
    }

if (!hasPermission(this.userId, 'view-livechat-manager')) {
return API.v1.unauthorized();
}
const { inquiryId, userId } = this.bodyParams;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What do you think about using the check approach? Like this:

{
    try {
	check(this.bodyParams, {
		inquiriId: string,
		userId: Match.Maybe(String),
	});
     ...
     } catch (e) {
	  return API.v1.failure(e);
     }
}

},
});

API.v1.addRoute('livechat/inquiry.take', { authRequired: true }, {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think it would be better renaming this route to livechat/inquiries.take, ok?

import { Users } from '../../../../models';
import { LivechatInquiry } from '../../../lib/LivechatInquiry';

API.v1.addRoute('livechat/inquiries', { authRequired: true }, {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think it would be better renaming this route to livechat/inquiries.list, ok?

@renatobecker-zz renatobecker-zz merged commit ab6a0f3 into develop Jun 11, 2019
@renatobecker-zz renatobecker-zz deleted the rest-inquiries branch June 11, 2019 19:21
@renatobecker-zz renatobecker-zz changed the title [NEW] Add endpoints to list inquiries and take a inquiry [NEW] Add Livechat inquiries endpoints Jun 11, 2019
@sampaiodiego sampaiodiego mentioned this pull request Jun 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants