Skip to content

Commit

Permalink
Added user_segments Help Center API methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
petr-sereda committed Feb 11, 2021
1 parent ca6de4d commit 786b456
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 2 deletions.
15 changes: 15 additions & 0 deletions docs/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,21 @@ create(section, cb)
update(sectionID, section, cb)
delete(sectionID, cb)
```
### usersegments
```js
list(cb)
listApplicable(cb)
listByUser(userID, cb)
show(sectionID, cb)
listSections(userSegmentID, cb)
listTopics(userSegmentID, cb)
create(userSegment, cb)
update(userSegmentID, userSegment, cb)
delete(userSegmentID, cb)
```
### subscriptions
```js
Expand Down
5 changes: 3 additions & 2 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ var parts = [
'Votes',
'Search',
'AccessPolicies',
'Subscriptions'
'Subscriptions',
'UserSegments'
],
voiceParts = [
'PhoneNumbers',
Expand Down Expand Up @@ -108,7 +109,7 @@ exports.createClient = function(options) {
alias: 'customHeaders'
},
'serv': {
alias: 'services'
alias: 'services'
}
});
}
Expand Down
61 changes: 61 additions & 0 deletions lib/client/helpcenter/usersegments.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// usersegments.js: Client for the zendesk help center API..


var util = require('util'),
Client = require('../client').Client;


var UserSegments = exports.UserSegments = function (options) {
this.jsonAPINames = ['usersegments', 'usersegment'];

Client.call(this, options);
};

// Inherit from Client base object
util.inherits(UserSegments, Client);

// ######################################################## UserSegments
// ====================================== Listing User Segments
UserSegments.prototype.list = function (cb) {
return this.requestAll('GET', ['user_segments'], cb); //all
};

// ====================================== Listing only User Segments applicable to the current account
UserSegments.prototype.listApplicable = function (cb) {
return this.requestAll('GET', ['user_segments', 'applicable'], cb); //all
};

// ====================================== Listing Segment accessible for the specified user
UserSegments.prototype.listByUser = function (userID, cb) {
return this.requestAll('GET', ['users', userID, 'user_segments'], cb);//all
};

// ====================================== Get User Segment By Id
UserSegments.prototype.show = function (userSegmentID, cb) {
return this.request('GET', ['user_segments', userSegmentID], cb);
};

// ====================================== List Sections using a User Segment
UserSegments.prototype.listSections = function (userSegmentID, cb) {
return this.requestAll('GET', ['user_segments', userSegmentID, 'sections'], cb); // all
};

// ====================================== List Sections using a User Segment
UserSegments.prototype.listTopics = function (userSegmentID, cb) {
return this.requestAll('GET', ['user_segments', userSegmentID, 'topics'], cb); // all
};

// ====================================== Creating User Segment
UserSegments.prototype.create = function (userSegment, cb) {
return this.request('POST', ['user_segments'], userSegment, cb);
};

// ====================================== Updating User Segment
UserSegments.prototype.update = function (userSegmentID, userSegment, cb) {
return this.request('PUT', ['user_segments', userSegmentID], userSegment, cb);
};

// ====================================== Deleting User Segment
UserSegments.prototype.delete = function (userSegmentID, cb) {
return this.request('DELETE', ['user_segments', userSegmentID], cb);
};

0 comments on commit 786b456

Please sign in to comment.