@@ -13,17 +13,24 @@ struct IterableAPICallRequest {
1313 let deviceMetadata : DeviceMetadata
1414 let iterableRequest : IterableRequest
1515
16- func convertToURLRequest( currentDate: Date ) -> URLRequest ? {
16+ enum ProcessorType {
17+ case offline
18+ case online
19+ }
20+
21+ func convertToURLRequest( currentDate: Date , processorType: ProcessorType = . online) -> URLRequest ? {
1722 switch iterableRequest {
1823 case let . get( getRequest) :
1924 return IterableRequestUtil . createGetRequest ( forApiEndPoint: endPoint,
2025 path: getRequest. path,
21- headers: createIterableHeaders ( currentDate: currentDate) ,
26+ headers: createIterableHeaders ( currentDate: currentDate,
27+ processorType: processorType) ,
2228 args: getRequest. args)
2329 case let . post( postRequest) :
2430 return IterableRequestUtil . createPostRequest ( forApiEndPoint: endPoint,
2531 path: postRequest. path,
26- headers: createIterableHeaders ( currentDate: currentDate) ,
32+ headers: createIterableHeaders ( currentDate: currentDate,
33+ processorType: processorType) ,
2734 args: postRequest. args,
2835 body: postRequest. body)
2936 }
@@ -46,12 +53,13 @@ struct IterableAPICallRequest {
4653 iterableRequest: iterableRequest. addingBodyField ( key: key, value: value) )
4754 }
4855
49- private func createIterableHeaders( currentDate: Date ) -> [ String : String ] {
56+ private func createIterableHeaders( currentDate: Date , processorType : ProcessorType ) -> [ String : String ] {
5057 var headers = [ JsonKey . contentType. jsonKey: JsonValue . applicationJson. jsonStringValue,
5158 JsonKey . Header. sdkPlatform: JsonValue . iOS. jsonStringValue,
5259 JsonKey . Header. sdkVersion: IterableAPI . sdkVersion,
5360 JsonKey . Header. apiKey: apiKey,
5461 JsonKey . Header. sentAt: Self . format ( sentAt: currentDate) ,
62+ JsonKey . Header. requestProcessor: Self . name ( for: processorType)
5563 ]
5664
5765 if let authToken = auth. authToken {
@@ -64,6 +72,15 @@ struct IterableAPICallRequest {
6472 private static func format( sentAt: Date ) -> String {
6573 return " \( IterableUtil . secondsFromEpoch ( for: sentAt) ) "
6674 }
75+
76+ private static func name( for processorType: ProcessorType ) -> String {
77+ switch processorType {
78+ case . online:
79+ return Const . ProcessorTypeName. online
80+ case . offline:
81+ return Const . ProcessorTypeName. offline
82+ }
83+ }
6784}
6885
6986extension IterableAPICallRequest : Codable { }
0 commit comments