Skip to content

Commit d6372be

Browse files
Milind712000aero31aero
authored andcommitted
implement zulip.streams.deleteById( { stream_id : ?? } )
1 parent 7afd95c commit d6372be

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ zulip.callEndpoint('/messages', 'POST', params);
115115
| `zulip.streams.retrieve()` | GET `/streams` | returns a promise that can be used to retrieve all streams. |
116116
| `zulip.streams.getStreamId()` | GET `/get_stream_id` | returns a promise that can be used to retrieve a stream's id. |
117117
| `zulip.streams.subscriptions.retrieve()` | GET `/users/me/subscriptions` | returns a promise that can be used to retrieve the user's subscriptions. |
118+
| `zulip.streams.deleteById()` | DELETE `/streams/<stream_id>` | delete the stream with the provided stream id if the user has permission to do so. |
118119
| `zulip.streams.topics.retrieve()` | GET `/users/me/<stream_id>/topics` | retrieves all the topics in a specific stream. |
119120
| `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`). |
120121
| `zulip.users.retrieve()` | GET `/users` | retrieves all users for this realm. |

src/resources/streams.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ function streams(config) {
2828
return api(url, config, 'GET');
2929
},
3030
},
31+
deleteById: (params) => {
32+
const url = `${config.apiURL}/streams/${params.stream_id}`;
33+
return api(url, config, 'DELETE', params);
34+
},
3135
};
3236
}
3337

test/resources/streams.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,4 +170,26 @@ describe('Streams', () => {
170170
})
171171
.catch(done);
172172
});
173+
174+
it('should delete stream by stream id', (done) => {
175+
const params = {
176+
stream_id: 1,
177+
};
178+
const validator = (url, options) => {
179+
url.should.contain(`${common.config.apiURL}/streams/${params.stream_id}`);
180+
options.should.not.have.property('body');
181+
options.method.should.be.equal('DELETE');
182+
};
183+
const output = {
184+
msg: '',
185+
result: 'success',
186+
};
187+
const stubs = common.getStubs(validator, output);
188+
streams(common.config).deleteById(params)
189+
.then((data) => {
190+
data.should.have.property('result', 'success');
191+
common.restoreStubs(stubs);
192+
done();
193+
}).catch(done);
194+
});
173195
});

0 commit comments

Comments
 (0)