diff --git a/Example/ConsentViewController_ExampleTests/Helpers/SourcePointClientMock.swift b/Example/ConsentViewController_ExampleTests/Helpers/SourcePointClientMock.swift index 72c7a505c..96618497d 100644 --- a/Example/ConsentViewController_ExampleTests/Helpers/SourcePointClientMock.swift +++ b/Example/ConsentViewController_ExampleTests/Helpers/SourcePointClientMock.swift @@ -122,19 +122,19 @@ class SourcePointClientMock: SourcePointProtocol { func ccpaPrivacyManagerView(propertyId: Int, consentLanguage: SPMessageLanguage, handler: @escaping CCPAPrivacyManagerViewHandler) { } - func postCCPAAction(actionType: SPActionType, body: CCPAChoiceBody, handler: @escaping CCPAConsentHandler) { + func postCCPAAction(actionType: ConsentViewController.SPActionType, request: CCPAChoiceRequest, handler: @escaping ConsentViewController.CCPAConsentHandler) { postCCPAActionCalled = true postCCPAActionCalledWith = [ "actionType": actionType, - "body": body, + "request": request, "handler": handler ] if let error = error { handler(.failure(error)) } else { - handler(.success(CCPAChoiceResponse( + handler(.success(SPMobileCore.CCPAChoiceResponse( uuid: "", - dateCreated: .now(), + dateCreated: SPDate.format.string(from: SPDate.now().date), consentedAll: nil, rejectedAll: nil, status: nil, @@ -143,26 +143,26 @@ class SourcePointClientMock: SourcePointProtocol { rejectedVendors: nil, rejectedCategories: nil, webConsentPayload: nil, - GPPData: SPJson() + gppData: [:] as [String : Kotlinx_serialization_jsonJsonPrimitive] ))) } } - func postGDPRAction(actionType: SPActionType, body: GDPRChoiceBody, handler: @escaping GDPRConsentHandler) { + func postGDPRAction(actionType: ConsentViewController.SPActionType, request: GDPRChoiceRequest, handler: @escaping ConsentViewController.GDPRConsentHandler) { postGDPRActionCalled = true postGDPRActionCalledWith = [ "actionType": actionType, - "body": body, + "request": request, "handler": handler ] if let error = error { handler(.failure(error)) } else { - handler(.success(GDPRChoiceResponse( + handler(.success(SPMobileCore.GDPRChoiceResponse( uuid: "", - dateCreated: .now(), - expirationDate: .distantFuture(), - TCData: nil, + dateCreated: SPDate.format.string(from: SPDate.now().date), + expirationDate: SPDate.format.string(from: SPDate.distantFuture().date), + tcData: nil, euconsent: nil, consentStatus: nil, grants: nil, @@ -178,19 +178,30 @@ class SourcePointClientMock: SourcePointProtocol { } func postUSNatAction( - actionType: SPActionType, - body: USNatChoiceBody, - handler: @escaping USNatConsentHandler + actionType: ConsentViewController.SPActionType, + request: USNatChoiceRequest, + handler: @escaping ConsentViewController.USNatConsentHandler ) { postUSNatActionCalledWith = [ "actionType": actionType, - "body": body, + "request": request, "handler": handler ] if let error = error { handler(.failure(error)) } else { - handler(.success(SPUSNatConsent.empty())) + handler(.success(SPMobileCore.USNatChoiceResponse( + uuid: nil, + categories: [], + consentStatus: SPMobileCore.ConsentStatus(rejectedAny: nil, rejectedLI: nil, rejectedAll: nil, consentedAll: nil, consentedToAll: nil, consentedToAny: nil, hasConsentData: nil, vendorListAdditions: nil, legalBasisChanges: nil, granularStatus: nil, rejectedVendors: nil, rejectedCategories: nil), + consentStrings: [], + dateCreated: SPDate.format.string(from: SPDate.now().date), + expirationDate: SPDate.format.string(from: SPDate.distantFuture().date), + gpcEnabled: nil, + webConsentPayload: nil, + gppData: [:] as [String : Kotlinx_serialization_jsonJsonPrimitive], + userConsents: USNatConsent.USNatUserConsents(vendors: [], categories: []) + ))) } } @@ -267,14 +278,13 @@ class SourcePointClientMock: SourcePointProtocol { } func choiceAll( - actionType: SPActionType, + actionType: SPMobileCore.SPActionType, accountId: Int, propertyId: Int, - idfaStatus: SPIDFAStatus, - metadata: ChoiceAllMetaDataParam, - includeData: IncludeData, - handler: @escaping ChoiceHandler - ) { + idfaStatus: SPMobileCore.SPIDFAStatus, + metadata: ChoiceAllMetaDataRequest, + includeData: SPMobileCore.IncludeData, + handler: @escaping ConsentViewController.ChoiceHandler) { handler(.success(ChoiceAllResponse(gdpr: nil, ccpa: nil, usnat: nil))) } } diff --git a/Example/ConsentViewController_ExampleTests/SPClientCoordinator/SPClientCoordinatorSpec.swift b/Example/ConsentViewController_ExampleTests/SPClientCoordinator/SPClientCoordinatorSpec.swift index e7245d108..93ebeb966 100644 --- a/Example/ConsentViewController_ExampleTests/SPClientCoordinator/SPClientCoordinatorSpec.swift +++ b/Example/ConsentViewController_ExampleTests/SPClientCoordinator/SPClientCoordinatorSpec.swift @@ -186,6 +186,7 @@ class SPClientCoordinatorSpec: QuickSpec { messageId: "1234" ) gdprAction.encodablePubData = ["foo": .init("gdpr")] + let publisherData = JsonKt.encodeToJsonObject(gdprAction.encodablePubData.toCore()) waitUntil { done in coordinator.reportAction(gdprAction) { response in @@ -194,9 +195,9 @@ class SPClientCoordinatorSpec: QuickSpec { case .success: expect(spClientMock.postGDPRActionCalled).to(beTrue()) - let body = spClientMock.postGDPRActionCalledWith?["body"] as? GDPRChoiceBody - expect(body?.pubData).to(equal(gdprAction.encodablePubData)) - expect(body?.messageId).to(equal("1234")) + let request = spClientMock.postGDPRActionCalledWith?["request"] as? GDPRChoiceRequest + expect(request?.pubData).to(equal(publisherData)) + expect(request?.messageId).to(equal("1234")) } done() } @@ -210,6 +211,7 @@ class SPClientCoordinatorSpec: QuickSpec { messageId: "321" ) ccpaAction.encodablePubData = ["foo": .init("ccpa")] + let publisherData = JsonKt.encodeToJsonObject(ccpaAction.encodablePubData.toCore()) waitUntil { done in coordinator.reportAction(ccpaAction) { response in @@ -218,9 +220,9 @@ class SPClientCoordinatorSpec: QuickSpec { case .success: expect(spClientMock.postCCPAActionCalled).to(beTrue()) - let body = spClientMock.postCCPAActionCalledWith?["body"] as? CCPAChoiceBody - expect(body?.pubData).to(equal(ccpaAction.encodablePubData)) - expect(body?.messageId).to(equal("321")) + let request = spClientMock.postCCPAActionCalledWith?["request"] as? CCPAChoiceRequest + expect(request?.pubData).to(equal(publisherData)) + expect(request?.messageId).to(equal("321")) } done() } diff --git a/Example/ConsentViewController_ExampleTests/SPClientCoordinator/SourcePointClient/UnmockedSourcepointClientSpec.swift b/Example/ConsentViewController_ExampleTests/SPClientCoordinator/SourcePointClient/UnmockedSourcepointClientSpec.swift index 74e69d8e3..384fe5fa5 100644 --- a/Example/ConsentViewController_ExampleTests/SPClientCoordinator/SourcePointClient/UnmockedSourcepointClientSpec.swift +++ b/Example/ConsentViewController_ExampleTests/SPClientCoordinator/SourcePointClient/UnmockedSourcepointClientSpec.swift @@ -229,7 +229,7 @@ class UnmockedSourcepointClientSpec: QuickSpec { it("should call the endpoint and parse the response into ChoiceAllResponse") { waitUntil { done in client.choiceAll( - actionType: .RejectAll, + actionType: .rejectall, accountId: accountId, propertyId: propertyId, idfaStatus: .accepted, @@ -238,7 +238,7 @@ class UnmockedSourcepointClientSpec: QuickSpec { ccpa: .init(applies: true), usnat: .init(applies: true) ), - includeData: .standard + includeData: IncludeData.standard.toCore() ) { result in switch result { case .success(let response): @@ -261,7 +261,7 @@ class UnmockedSourcepointClientSpec: QuickSpec { it("should call the endpoint and parse the response into ChoiceAllResponse") { waitUntil { done in client.choiceAll( - actionType: .AcceptAll, + actionType: .acceptall, accountId: accountId, propertyId: propertyId, idfaStatus: .accepted, @@ -270,7 +270,7 @@ class UnmockedSourcepointClientSpec: QuickSpec { ccpa: .init(applies: true), usnat: .init(applies: true) ), - includeData: .standard + includeData: IncludeData.standard.toCore() ) { result in switch result { case .success(let response):