Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ zulip.callEndpoint('/messages', 'POST', params);
| `zulip.streams.retrieve()` | GET `/streams` | returns a promise that can be used to retrieve all streams. |
| `zulip.streams.getStreamId()` | GET `/get_stream_id` | returns a promise that can be used to retrieve a stream's id. |
| `zulip.streams.subscriptions.retrieve()` | GET `/users/me/subscriptions` | returns a promise that can be used to retrieve the user's subscriptions. |
| `zulip.streams.deleteById()` | DELETE `/streams/<stream_id>` | delete the stream with the provided stream id if the user has permission to do so. |
| `zulip.streams.topics.retrieve()` | GET `/users/me/<stream_id>/topics` | retrieves all the topics in a specific stream. |
| `zulip.typing.send()` | POST `/typing` | can be used to send a typing notification. The parameters required are `to` (either a username or a list of usernames) and `op` (either `start` or `stop`). |
| `zulip.users.retrieve()` | GET `/users` | retrieves all users for this realm. |
Expand Down
4 changes: 4 additions & 0 deletions src/resources/streams.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ function streams(config) {
return api(url, config, 'GET');
},
},
deleteById: (params) => {
const url = `${config.apiURL}/streams/${params.stream_id}`;
return api(url, config, 'DELETE', params);
},
};
}

Expand Down
22 changes: 22 additions & 0 deletions test/resources/streams.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,26 @@ describe('Streams', () => {
})
.catch(done);
});

it('should delete stream by stream id', (done) => {
const params = {
stream_id: 1,
};
const validator = (url, options) => {
url.should.contain(`${common.config.apiURL}/streams/${params.stream_id}`);
options.should.not.have.property('body');
options.method.should.be.equal('DELETE');
};
const output = {
msg: '',
result: 'success',
};
const stubs = common.getStubs(validator, output);
streams(common.config).deleteById(params)
.then((data) => {
data.should.have.property('result', 'success');
common.restoreStubs(stubs);
done();
}).catch(done);
});
});