@@ -386,4 +386,102 @@ public async Task GetCallbacksAsync_WithNullRequestHeaders_ShouldHandleGracefull
386386 Assert . IsNotNull ( callback . RequestContent ) ;
387387 Assert . IsNotNull ( callback . RequestContent . Content ) ;
388388 }
389- } }
389+
390+ [ TestMethod ]
391+ public async Task GetCallbacksBySubscriptionIdAsync_WithValidSubscriptionId_ShouldReturnCallbacks ( )
392+ {
393+ var subscriptionId = "8a49e32e267e42a18e4a3967669f347e06e3b71e" ;
394+ var mockResponse = TestUtils . SerializeToJsonFormatted ( new
395+ {
396+ data = new [ ]
397+ {
398+ new
399+ {
400+ id = "callback_123" ,
401+ application_name = "TestApp" ,
402+ entity_id = "doc_456" ,
403+ event_subscription_id = subscriptionId ,
404+ event_subscription_active = true ,
405+ entity_type = "document" ,
406+ event_name = "document.complete" ,
407+ callback_url = "https://example.com/webhook" ,
408+ request_method = "POST" ,
409+ duration = 1.5 ,
410+ request_start_time = 1609459200 ,
411+ request_end_time = 1609459205 ,
412+ request_headers = new
413+ {
414+ string_head = "test_value" ,
415+ int_head = 42 ,
416+ bool_head = true ,
417+ float_head = 3.14f
418+ } ,
419+ response_content = "OK" ,
420+ response_status_code = 200 ,
421+ event_subscription_owner_email = "owner@example.com" ,
422+ request_content = new
423+ {
424+ meta = new
425+ {
426+ timestamp = 1609459200 ,
427+ @event = "document.complete" ,
428+ environment = "https://api.signnow.com/" ,
429+ initiator_id = "user_789" ,
430+ callback_url = "https://example.com/webhook" ,
431+ access_token = "***masked***"
432+ } ,
433+ content = new
434+ {
435+ document_id = "doc_456" ,
436+ document_name = "Test Document.pdf" ,
437+ user_id = "user_789" ,
438+ initiator_id = "user_789" ,
439+ initiator_email = "initiator@example.com"
440+ }
441+ }
442+ }
443+ } ,
444+ meta = new
445+ {
446+ pagination = new
447+ {
448+ total = 1 ,
449+ count = 1 ,
450+ per_page = 50 ,
451+ current_page = 1 ,
452+ total_pages = 1
453+ }
454+ }
455+ } ) ;
456+
457+ var service = new EventSubscriptionService ( ApiBaseUrl , new Token ( ) , SignNowClientMock ( mockResponse ) ) ;
458+ var options = new GetCallbacksOptions
459+ {
460+ Page = 1 ,
461+ PerPage = 50
462+ } ;
463+
464+ var response = await service . GetCallbacksBySubscriptionIdAsync ( subscriptionId , options ) . ConfigureAwait ( false ) ;
465+
466+ Assert . IsNotNull ( response ) ;
467+ Assert . IsNotNull ( response . Data ) ;
468+ Assert . IsNotNull ( response . Meta ) ;
469+ Assert . AreEqual ( 1 , response . Data . Count ) ;
470+
471+ var callback = response . Data [ 0 ] ;
472+ Assert . AreEqual ( "callback_123" , callback . Id ) ;
473+ Assert . AreEqual ( "TestApp" , callback . ApplicationName ) ;
474+ Assert . AreEqual ( "doc_456" , callback . EntityId ) ;
475+ Assert . AreEqual ( subscriptionId , callback . EventSubscriptionId ) ;
476+ Assert . IsTrue ( callback . EventSubscriptionActive ) ;
477+ Assert . AreEqual ( EventSubscriptionEntityType . Document , callback . EntityType ) ;
478+ Assert . AreEqual ( EventType . DocumentComplete , callback . EventName ) ;
479+ Assert . AreEqual ( "https://example.com/webhook" , callback . CallbackUrl . ToString ( ) ) ;
480+ Assert . AreEqual ( 200 , callback . ResponseStatusCode ) ;
481+
482+ Assert . AreEqual ( 1 , response . Meta . Pagination . Total ) ;
483+ Assert . AreEqual ( 1 , response . Meta . Pagination . Count ) ;
484+ Assert . AreEqual ( 50 , response . Meta . Pagination . PerPage ) ;
485+ }
486+ }
487+ }
0 commit comments