Skip to content

Commit

Permalink
Merge pull request #579 from SourcePointUSA/DIA-4263_fix_pv-data_payload
Browse files Browse the repository at this point in the history
DIA-4263 fix `/pv-data` payload
  • Loading branch information
andresilveirah authored Aug 27, 2024
2 parents d2415f3 + 948d7f7 commit a12966d
Show file tree
Hide file tree
Showing 16 changed files with 245 additions and 182 deletions.
6 changes: 4 additions & 2 deletions ConsentViewController/Assets/javascript/SPJSReceiver.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ var getActionFromMessage = function (eventData) {
type: choiceData.type,
pmUrl: choiceData.pmUrl || choiceData.iframe_url,
consentLanguage: eventData.consentLanguage,
customActionId: choiceData.customAction
customActionId: choiceData.customAction,
messageId: eventData.messageId
};
};

Expand All @@ -67,7 +68,8 @@ var handleMessageEvent = function(SDK) {
payload: eventData.payload,
consentLanguage: eventData.consentLanguage,
customActionId: eventData.customAction,
pmUrl: eventData.pmUrl
pmUrl: eventData.pmUrl,
messageId: eventData.messageId
}) :
SDK.onAction(getActionFromMessage(eventData));
break;
Expand Down
24 changes: 0 additions & 24 deletions ConsentViewController/Classes/Consents/LastMessageData.swift

This file was deleted.

9 changes: 1 addition & 8 deletions ConsentViewController/Classes/Consents/SPCCPAConsent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,6 @@ extension SPUSPString {
/// In case `/getMessages` request was done with `groupPmId`, `childPmId` will be returned
var childPmId: String?

/// Required by SP endpoints
var lastMessage: LastMessageData?

/// Required by SP endpoints
var consentStatus: ConsentStatus

Expand Down Expand Up @@ -166,7 +163,6 @@ extension SPUSPString {
applies: Bool,
dateCreated: SPDate,
expirationDate: SPDate,
lastMessage: LastMessageData?,
consentStatus: ConsentStatus = ConsentStatus(),
webConsentPayload: SPWebConsentPayload? = nil,
GPPData: SPJson = SPJson()
Expand All @@ -183,7 +179,6 @@ extension SPUSPString {
self.applies = applies
self.dateCreated = dateCreated
self.expirationDate = expirationDate
self.lastMessage = lastMessage
}

public required init(from decoder: Decoder) throws {
Expand Down Expand Up @@ -211,8 +206,7 @@ extension SPUSPString {
signedLspa: false,
applies: false,
dateCreated: .now(),
expirationDate: .distantFuture(),
lastMessage: nil
expirationDate: .distantFuture()
)}

public func copy(with zone: NSZone? = nil) -> Any {
Expand All @@ -226,7 +220,6 @@ extension SPUSPString {
applies: applies,
dateCreated: dateCreated,
expirationDate: expirationDate,
lastMessage: lastMessage,
consentStatus: consentStatus,
webConsentPayload: webConsentPayload,
GPPData: GPPData
Expand Down
6 changes: 0 additions & 6 deletions ConsentViewController/Classes/Consents/SPGDPRConsent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,6 @@ public typealias SPGDPRPurposeId = String
/// Information required by Google's Firebase Analytics SDK, GCM 2.0
public var googleConsentMode: SPGCMData?

/// Required by SP endpoints
var lastMessage: LastMessageData?

/// Used by the rendering app
var webConsentPayload: SPWebConsentPayload?

Expand Down Expand Up @@ -158,7 +155,6 @@ public typealias SPGDPRPurposeId = String
expirationDate: SPDate,
applies: Bool,
consentStatus: ConsentStatus = ConsentStatus(),
lastMessage: LastMessageData? = nil,
webConsentPayload: SPWebConsentPayload? = nil,
googleConsentMode: SPGCMData? = nil,
acceptedLegIntCategories: [String] = [],
Expand All @@ -176,7 +172,6 @@ public typealias SPGDPRPurposeId = String
self.expirationDate = expirationDate
self.applies = applies
self.consentStatus = consentStatus
self.lastMessage = lastMessage
self.webConsentPayload = webConsentPayload
self.googleConsentMode = googleConsentMode
self.acceptedLegIntCategories = acceptedLegIntCategories
Expand Down Expand Up @@ -224,7 +219,6 @@ public typealias SPGDPRPurposeId = String
expirationDate: expirationDate,
applies: applies,
consentStatus: consentStatus,
lastMessage: lastMessage,
webConsentPayload: webConsentPayload,
googleConsentMode: googleConsentMode,
acceptedLegIntCategories: acceptedLegIntCategories,
Expand Down
7 changes: 0 additions & 7 deletions ConsentViewController/Classes/Consents/SPUSNatConsent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ import Foundation

var dateCreated, expirationDate: SPDate

/// Required by SP endpoints
var lastMessage: LastMessageData?

/// Used by the rendering app
let webConsentPayload: SPWebConsentPayload?

Expand All @@ -54,7 +51,6 @@ import Foundation
expirationDate: SPDate,
consentStrings: [ConsentString],
webConsentPayload: SPWebConsentPayload? = nil,
lastMessage: LastMessageData? = nil,
categories: [SPConsentable],
vendors: [SPConsentable],
consentStatus: ConsentStatus,
Expand All @@ -66,7 +62,6 @@ import Foundation
self.expirationDate = expirationDate
self.consentStrings = consentStrings
self.webConsentPayload = webConsentPayload
self.lastMessage = lastMessage
self.consentStatus = consentStatus
self.GPPData = GPPData
self.userConsents = UserConsents(vendors: vendors, categories: categories)
Expand All @@ -80,7 +75,6 @@ import Foundation
expirationDate = try container.decode(SPDate.self, forKey: .expirationDate)
consentStrings = try container.decode([ConsentString].self, forKey: .consentStrings)
webConsentPayload = try container.decodeIfPresent(SPWebConsentPayload.self, forKey: .webConsentPayload)
lastMessage = try container.decodeIfPresent(LastMessageData.self, forKey: .lastMessage)
consentStatus = try container.decode(ConsentStatus.self, forKey: .consentStatus)
GPPData = try container.decodeIfPresent(SPJson.self, forKey: .GPPData)
userConsents = try container.decodeIfPresent(UserConsents.self, forKey: .userConsents) ?? UserConsents(vendors: [], categories: [])
Expand Down Expand Up @@ -131,7 +125,6 @@ extension SPUSNatConsent {
expirationDate: expirationDate,
consentStrings: consentStrings,
webConsentPayload: webConsentPayload,
lastMessage: lastMessage,
categories: categories,
vendors: vendors,
consentStatus: consentStatus,
Expand Down
14 changes: 9 additions & 5 deletions ConsentViewController/Classes/SPAction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import Foundation
/// This property will be renamed to `publisherData` in the next major release
public var encodablePubData: SPPublisherData = [:]
public var customActionId: String?
public var messageId: String?

override public var description: String {
"""
Expand All @@ -78,7 +79,8 @@ import Foundation
consentLanguage: String? = nil,
pmPayload: SPJson = SPJson(),
pmurl: URL? = nil,
customActionId: String? = nil
customActionId: String? = nil,
messageId: String? = nil
) {
self.type = type
self.campaignType = campaignType
Expand All @@ -87,16 +89,18 @@ import Foundation
self.pmPayload = pmPayload
self.pmURL = pmurl
self.customActionId = customActionId
self.messageId = messageId
}

override public func isEqual(_ object: Any?) -> Bool {
guard let other = object as? SPAction else {
return false
}
return other.type == type &&
other.consentLanguage == consentLanguage &&
other.pmURL == pmURL &&
other.pmPayload == pmPayload &&
other.publisherData == publisherData
other.consentLanguage == consentLanguage &&
other.pmURL == pmURL &&
other.pmPayload == pmPayload &&
other.publisherData == publisherData &&
other.messageId == messageId
}
}
16 changes: 14 additions & 2 deletions ConsentViewController/Classes/SPConsentManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -575,9 +575,21 @@ extension SPConsentManager: SPMessageUIDelegate {
osVersion: self?.deviceManager.osVersion ?? ""
)
if status == .accepted {
self?.onAction(SPAction(type: .IDFAAccepted, campaignType: .ios14), from: controller)
self?.onAction(
SPAction(
type: .IDFAAccepted,
campaignType: .ios14,
messageId: action.messageId
),
from: controller
)
} else if status == .denied {
self?.onAction(SPAction(type: .IDFADenied, campaignType: .ios14), from: controller)
self?.onAction(
SPAction(
type: .IDFADenied,
campaignType: .ios14,
messageId: action.messageId
), from: controller)
}
self?.nextMessageIfAny(controller)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ extension Consent: Codable {
}
}

func toConsent(defaults: SPUSNatConsent?, messageMetaData: MessageMetaData?) -> SPUSNatConsent? {
func toConsent(defaults: SPUSNatConsent?) -> SPUSNatConsent? {
switch self {
case .usnat(let consents):
return SPUSNatConsent(
Expand All @@ -162,7 +162,6 @@ extension Consent: Codable {
expirationDate: consents.expirationDate,
consentStrings: consents.consentStrings,
webConsentPayload: consents.webConsentPayload,
lastMessage: LastMessageData(from: messageMetaData),
categories: consents.categories,
vendors: consents.vendors,
consentStatus: consents.consentStatus,
Expand All @@ -174,7 +173,7 @@ extension Consent: Codable {
}
}

func toConsent(defaults: SPCCPAConsent?, messageMetaData: MessageMetaData?) -> SPCCPAConsent? {
func toConsent(defaults: SPCCPAConsent?) -> SPCCPAConsent? {
switch self {
case .ccpa(let consents):
return SPCCPAConsent(
Expand All @@ -187,7 +186,6 @@ extension Consent: Codable {
applies: defaults?.applies ?? false,
dateCreated: consents.dateCreated,
expirationDate: consents.expirationDate,
lastMessage: LastMessageData(from: messageMetaData),
consentStatus: consents.consentStatus,
webConsentPayload: consents.webConsentPayload,
GPPData: consents.GPPData
Expand All @@ -198,7 +196,7 @@ extension Consent: Codable {
}
}

func toConsent(defaults: SPGDPRConsent?, messageMetaData: MessageMetaData?) -> SPGDPRConsent? {
func toConsent(defaults: SPGDPRConsent?) -> SPGDPRConsent? {
switch self {
case .gdpr(let consents):
return SPGDPRConsent(
Expand All @@ -211,7 +209,6 @@ extension Consent: Codable {
expirationDate: consents.expirationDate,
applies: defaults?.applies ?? false,
consentStatus: consents.consentStatus,
lastMessage: LastMessageData(from: messageMetaData),
webConsentPayload: consents.webConsentPayload,
acceptedLegIntCategories: consents.acceptedLegIntCategories,
acceptedLegIntVendors: consents.acceptedLegIntVendors,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

import Foundation

struct MetaDataResponse: Decodable, Equatable {
struct CCPA: Decodable, Equatable {
struct MetaDataResponse: Equatable {
struct CCPA: Equatable {
let applies: Bool
let sampleRate: Float
}
struct GDPR: Decodable, Equatable {
struct GDPR: Equatable {
let additionsChangeDate: SPDate
let legalBasisChangeDate: SPDate?
let vendorListId: String
Expand All @@ -25,7 +25,7 @@ struct MetaDataResponse: Decodable, Equatable {
case vendorListId = "_id"
}
}
struct USNat: Decodable, Equatable {
struct USNat: Equatable {
let vendorListId: String
let additionsChangeDate: SPDate
let applies: Bool
Expand All @@ -43,6 +43,11 @@ struct MetaDataResponse: Decodable, Equatable {
let usnat: USNat?
}

extension MetaDataResponse: Decodable {}
extension MetaDataResponse.GDPR: Decodable {}
extension MetaDataResponse.CCPA: Decodable {}
extension MetaDataResponse.USNat: Decodable {}

struct MetaDataQueryParam: QueryParamEncodable {
struct Campaign: Encodable {
let groupPmId: String?
Expand Down
Loading

0 comments on commit a12966d

Please sign in to comment.