@@ -15,12 +15,36 @@ public struct ReplicatorHelper {
1515 guard let target = data [ " target " ] as? [ String : Any ] ,
1616 let url = target [ " url " ] as? String ,
1717 let replicatorType = data [ " replicatorType " ] as? String ,
18- let continuous = data [ " continuous " ] as? Bool else {
18+ let continuous = data [ " continuous " ] as? Bool ,
19+ let acceptParentDomainCookies = data [ " acceptParentDomainCookies " ] as? Bool ,
20+ let acceptSelfSignedCerts = data [ " acceptSelfSignedCerts " ] as? Bool ,
21+ let allowReplicationInBackground = data [ " allowReplicationInBackground " ] as? Bool ,
22+ let autoPurgeEnabled = data [ " autoPurgeEnabled " ] as? Bool ,
23+ let heartbeat = data [ " heartbeat " ] as? NSNumber ,
24+ let maxAttempts = data [ " maxAttempts " ] as? NSNumber ,
25+ let maxAttemptWaitTime = data [ " maxAttemptWaitTime " ] as? NSNumber
26+ else {
1927 throw ReplicatorError . fatalError ( message: " Invalid JSON data " )
2028 }
2129
2230 let endpoint = URLEndpoint ( url: URL ( string: url) !)
31+
32+ //set values from data
2333 var replConfig = ReplicatorConfiguration ( target: endpoint)
34+ replConfig. acceptParentDomainCookie = acceptSelfSignedCerts
35+ replConfig. acceptParentDomainCookie = acceptParentDomainCookies
36+ replConfig. allowReplicatingInBackground = allowReplicationInBackground
37+ replConfig. continuous = continuous
38+ replConfig. enableAutoPurge = autoPurgeEnabled
39+
40+ replConfig. heartbeat = TimeInterval ( exactly: heartbeat. int64Value) ?? 300
41+ replConfig. maxAttemptWaitTime = TimeInterval ( exactly: maxAttemptWaitTime. int64Value) ?? 0
42+ replConfig. maxAttempts = maxAttempts. uintValue
43+
44+ //check for headers
45+ if let headers = data [ " headers " ] as? [ String : String ] {
46+ replConfig. headers = headers
47+ }
2448
2549 if let authenticatorData = data [ " authenticator " ] , !( authenticatorData is String && authenticatorData as! String == " " ) {
2650 if let authenticatorConfig = authenticatorData as? [ String : Any ] {
@@ -43,10 +67,6 @@ public struct ReplicatorHelper {
4367 default :
4468 throw ReplicatorError . fatalError ( message: " Invalid replicatorType " )
4569 }
46-
47- replConfig. continuous = continuous
48-
49-
5070 return replConfig
5171 }
5272
0 commit comments