Skip to content

Commit baa4950

Browse files
nadavofirtocker
authored andcommitted
Add support for notification-url parameter to update API
1 parent 53b2350 commit baa4950

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/utils.coffee

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,7 @@ exports.updateable_resource_params = (options, params = {}) ->
429429
params.detection = options.detection if options.detection?
430430
params.face_coordinates = utils.encode_double_array(options.face_coordinates) if options.face_coordinates?
431431
params.headers = utils.build_custom_headers(options.headers) if options.headers?
432+
params.notification_url = options.notification_url if options.notification_url?
432433
params.ocr = options.ocr if options.ocr?
433434
params.raw_convert = options.raw_convert if options.raw_convert?
434435
params.similarity_search = options.similarity_search if options.similarity_search?

test/api_spec.coffee

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,20 @@ describe "api", ->
514514
done()
515515

516516
describe "update", ()->
517+
describe "notification url", ()->
518+
xhr = request = requestStub = requestSpy = writeSpy =undefined
519+
before ->
520+
xhr = sinon.useFakeXMLHttpRequest()
521+
writeSpy = sinon.spy(ClientRequest.prototype, 'write')
522+
after ->
523+
writeSpy.restore()
524+
xhr.restore()
525+
it "should support changing moderation status with notification-url", ()->
526+
cloudinary.v2.api.update "sample", moderation_status: "approved", notification_url: "http://example.com"
527+
if writeSpy.called
528+
sinon.assert.calledWith writeSpy, sinon.match(/notification_url=http%3A%2F%2Fexample.com/)
529+
sinon.assert.calledWith writeSpy, sinon.match(/moderation_status=approved/)
530+
517531
it "should support setting manual moderation status", (done) ->
518532
@timeout helper.TIMEOUT_MEDIUM
519533
cloudinary.v2.uploader.upload IMAGE_FILE, moderation: "manual", (error, upload_result) ->

0 commit comments

Comments
 (0)