@@ -487,6 +487,119 @@ class ContactAPIClientTest: XCTestCase {
487
487
}
488
488
}
489
489
490
+ func testDisassociate( ) async throws {
491
+ let expectedChannelType : ChannelType = . email
492
+ let expectedChannelID : String = " some channel "
493
+ let expectedContactID : String = " contact "
494
+
495
+ let response = try await contactAPIClient. disassociateChannel ( contactID: expectedContactID, channelID: expectedChannelID, type: expectedChannelType)
496
+ XCTAssertTrue ( response. isSuccess)
497
+
498
+ let request = self . session. lastRequest!
499
+ XCTAssertEqual (
500
+ " https://example.com/api/contacts/disassociate/ \( expectedContactID) " ,
501
+ request. url!. absoluteString
502
+ )
503
+
504
+ let body = try JSONSerialization . jsonObject (
505
+ with: request. body!,
506
+ options: [ ]
507
+ ) as! [ String : Any ]
508
+
509
+ let expectedBody = [
510
+ " channel_type " : expectedChannelType. stringValue,
511
+ " channel_id " : expectedChannelID,
512
+ " opt_out " : true
513
+ ] as [ String : Any ]
514
+
515
+ XCTAssertEqual ( body as NSDictionary , expectedBody as NSDictionary )
516
+ }
517
+
518
+ func testResendEmail( ) async throws {
519
+ let expectedChannelType : ChannelType = . email
520
+ let expectedEmail : String = " [email protected] "
521
+
522
+ let expectedResendOptions = ResendOptions ( address: expectedEmail)
523
+
524
+ let response = try await contactAPIClient. resend ( resendOptions: expectedResendOptions)
525
+ XCTAssertTrue ( response. isSuccess)
526
+
527
+ let request = self . session. lastRequest!
528
+ XCTAssertEqual (
529
+ " https://example.com/api/channels/resend " ,
530
+ request. url!. absoluteString
531
+ )
532
+
533
+ let body = try JSONSerialization . jsonObject (
534
+ with: request. body!,
535
+ options: [ ]
536
+ ) as! [ String : Any ]
537
+
538
+ let expectedBody = [
539
+ " channel_type " : expectedChannelType. stringValue,
540
+ " email_address " : expectedEmail
541
+ ] as [ String : Any ]
542
+
543
+ XCTAssertEqual ( body as NSDictionary , expectedBody as NSDictionary )
544
+ }
545
+
546
+ func testResendSMS( ) async throws {
547
+ let expectedChannelType : ChannelType = . sms
548
+ let expectedMSISDN : String = " 1234 "
549
+ let expectedSenderID : String = " 1234 "
550
+
551
+ let expectedResendOptions = ResendOptions ( msisdn: expectedMSISDN, senderID: expectedSenderID)
552
+
553
+ let response = try await contactAPIClient. resend ( resendOptions: expectedResendOptions)
554
+ XCTAssertTrue ( response. isSuccess)
555
+
556
+ let request = self . session. lastRequest!
557
+ XCTAssertEqual (
558
+ " https://example.com/api/channels/resend " ,
559
+ request. url!. absoluteString
560
+ )
561
+
562
+ let body = try JSONSerialization . jsonObject (
563
+ with: request. body!,
564
+ options: [ ]
565
+ ) as! [ String : Any ]
566
+
567
+ let expectedBody = [
568
+ " channel_type " : expectedChannelType. stringValue,
569
+ " sender " : expectedSenderID,
570
+ " msisdn " : expectedMSISDN
571
+ ] as [ String : Any ]
572
+
573
+ XCTAssertEqual ( body as NSDictionary , expectedBody as NSDictionary )
574
+ }
575
+
576
+ func testResendChannel( ) async throws {
577
+ let expectedChannelType : ChannelType = . email
578
+ let expectedChannelID : String = " some channel "
579
+ let expectedResendOptions = ResendOptions ( channelID: expectedChannelID, channelType: expectedChannelType)
580
+
581
+ let response = try await contactAPIClient. resend ( resendOptions: expectedResendOptions)
582
+ XCTAssertTrue ( response. isSuccess)
583
+
584
+ let request = self . session. lastRequest!
585
+ XCTAssertEqual (
586
+ " https://example.com/api/channels/resend " ,
587
+ request. url!. absoluteString
588
+ )
589
+
590
+ let body = try JSONSerialization . jsonObject (
591
+ with: request. body!,
592
+ options: [ ]
593
+ ) as! [ String : Any ]
594
+
595
+ let expectedBody = [
596
+ " channel_type " : expectedChannelType. stringValue,
597
+ " channel_id " : expectedChannelID
598
+ ] as [ String : Any ]
599
+
600
+ XCTAssertEqual ( body as NSDictionary , expectedBody as NSDictionary )
601
+ }
602
+
490
603
func testUpdate( ) async throws {
491
604
let tagUpdates = [
492
605
TagGroupUpdate ( group: " tag-set " , tags: [ ] , type: . set) ,
0 commit comments