Merge "Add a plugin.put() method"

This commit is contained in:
Viktar Donich
2017-09-30 14:04:56 +00:00
committed by Gerrit Code Review
2 changed files with 14 additions and 0 deletions

View File

@@ -120,6 +120,16 @@ limitations under the License.
});
});
test('put', () => {
const payload = {foo: 'foo'};
const response = {bar: 'bar'};
getResponseObjectStub.returns(Promise.resolve(response));
return plugin.put('/url', payload, r => {
assert.isTrue(sendStub.calledWith('PUT', '/url', payload));
assert.strictEqual(r, response);
});
});
test('delete works', () => {
const response = {status: 204};
sendStub.returns(Promise.resolve(response));

View File

@@ -157,6 +157,10 @@
return this._send('POST', url, opt_callback, payload);
},
Plugin.prototype.put = function(url, payload, opt_callback) {
return this._send('PUT', url, opt_callback, payload);
},
Plugin.prototype.delete = function(url, opt_callback) {
return getRestAPI().send('DELETE', url).then(response => {
if (response.status !== 204) {