@@ -461,135 +461,6 @@ class IterableAPIClient {
461461
462462 // MARK: - Embedded Message Management
463463
464- func getEmbeddedMessages( for userEmail: String , placementId: Int ? = nil , completion: @escaping ( Bool , [ [ String : Any ] ] ) -> Void ) {
465- let endpoint = " /api/embedded-messaging/messages "
466- recordAPICall ( endpoint: endpoint)
467-
468- var parameters : [ String : Any ] = [ " email " : userEmail]
469- if let placementId = placementId {
470- parameters [ " placementId " ] = placementId
471- }
472-
473- performAPIRequest (
474- endpoint: endpoint,
475- method: " GET " ,
476- parameters: parameters,
477- useServerKey: false
478- ) { result in
479- switch result {
480- case . success( let data) :
481- do {
482- if let json = try JSONSerialization . jsonObject ( with: data) as? [ String : Any ] ,
483- let messages = json [ " messages " ] as? [ [ String : Any ] ] {
484- completion ( true , messages)
485- } else {
486- completion ( true , [ ] )
487- }
488- } catch {
489- print ( " ❌ Error parsing embedded messages response: \( error) " )
490- completion ( false , [ ] )
491- }
492- case . failure( let error) :
493- print ( " ❌ Error getting embedded messages: \( error) " )
494- completion ( false , [ ] )
495- }
496- }
497- }
498-
499- func createEmbeddedCampaign(
500- name: String ,
501- placementId: Int ,
502- userListId: String ? = nil ,
503- userSegmentId: String ? = nil ,
504- dataFieldCriteria: [ String : Any ] ? = nil ,
505- messageContent: [ String : Any ] ,
506- completion: @escaping ( Bool , String ? ) -> Void
507- ) {
508- let endpoint = " /api/embedded-messaging/campaigns/create "
509- recordAPICall ( endpoint: endpoint)
510-
511- var payload : [ String : Any ] = [
512- " name " : name,
513- " placementId " : placementId,
514- " messageContent " : messageContent,
515- " state " : " Active "
516- ]
517-
518- // Add targeting criteria
519- var targeting : [ String : Any ] = [ : ]
520- if let userListId = userListId {
521- targeting [ " listIds " ] = [ userListId]
522- }
523- if let userSegmentId = userSegmentId {
524- targeting [ " segmentIds " ] = [ userSegmentId]
525- }
526- if let dataFieldCriteria = dataFieldCriteria {
527- targeting [ " dataFields " ] = dataFieldCriteria
528- }
529-
530- if !targeting. isEmpty {
531- payload [ " targeting " ] = targeting
532- }
533-
534- performAPIRequest (
535- endpoint: endpoint,
536- method: " POST " ,
537- body: payload,
538- useServerKey: true
539- ) { result in
540- switch result {
541- case . success( let data) :
542- do {
543- let json = try JSONSerialization . jsonObject ( with: data) as? [ String : Any ]
544- if let campaignId = json ? [ " campaignId " ] as? String {
545- completion ( true , campaignId)
546- } else if let campaignId = json ? [ " campaignId " ] as? Int {
547- completion ( true , String ( campaignId) )
548- } else {
549- completion ( false , nil )
550- }
551- } catch {
552- print ( " ❌ Error parsing embedded campaign creation response: \( error) " )
553- completion ( false , nil )
554- }
555- case . failure( let error) :
556- print ( " ❌ Error creating embedded campaign: \( error) " )
557- completion ( false , nil )
558- }
559- }
560- }
561-
562- func deleteEmbeddedCampaign( campaignId: String , completion: @escaping ( Bool ) -> Void ) {
563- let endpoint = " /api/embedded-messaging/campaigns/ \( campaignId) "
564- recordAPICall ( endpoint: endpoint)
565-
566- performAPIRequest (
567- endpoint: endpoint,
568- method: " DELETE " ,
569- body: nil ,
570- useServerKey: true
571- ) { result in
572- switch result {
573- case . success( _) :
574- completion ( true )
575- case . failure( let error) :
576- print ( " ⚠️ Warning: Error deleting embedded campaign: \( error) " )
577- completion ( true ) // Don't fail tests due to cleanup issues
578- }
579- }
580- }
581-
582- func validateEmbeddedMessageMetrics(
583- userEmail: String ,
584- metricType: String ,
585- timeWindow: TimeInterval = 300 ,
586- completion: @escaping ( Bool , Int ) -> Void
587- ) {
588- // Metrics for embedded messages are tracked as events
589- // Valid metric types: embeddedMessageReceived, embeddedClick, embeddedImpression, embeddedSession
590- validateEventExists ( userEmail: userEmail, eventType: metricType, timeWindow: timeWindow, completion: completion)
591- }
592-
593464 // MARK: - Network Request Helpers
594465
595466 private enum APIResult {
@@ -785,4 +656,4 @@ extension IterableAPIClient {
785656 completion ( allSucceeded)
786657 }
787658 }
788- }
659+ }
0 commit comments