Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SP-8288 ott unexpected response message endpoint #353

Merged
merged 8 commits into from
Jan 26, 2022
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,35 @@ struct GDPRVendor: Decodable {
let vendorType: VendorType
let consentCategories, legIntCategories: [Category]
let iabSpecialPurposes, iabFeatures, iabSpecialFeatures: [String]

enum Keys: String, CodingKey {
case policyUrl, vendorId, name
case iabId
case iabSpecialPurposes, iabFeatures, iabSpecialFeatures
case description, cookieHeader
case vendorType
case consentCategories, legIntCategories
}

init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: Keys.self)
do {
policyUrl = try container.decodeIfPresent(URL.self, forKey: .policyUrl)
} catch {
policyUrl = nil
}
iabId = try container.decodeIfPresent(Int.self, forKey: .iabId)
vendorId = try container.decode(String.self, forKey: .vendorId)
name = try container.decode(String.self, forKey: .name)
iabSpecialPurposes = try container.decode([String].self, forKey: .iabSpecialPurposes)
iabFeatures = try container.decode([String].self, forKey: .iabFeatures)
iabSpecialFeatures = try container.decode([String].self, forKey: .iabSpecialFeatures)
description = try container.decodeIfPresent(String.self, forKey: .description)
cookieHeader = try container.decodeIfPresent(String.self, forKey: .cookieHeader)
vendorType = try container.decode(VendorType.self, forKey: .vendorType)
consentCategories = try container.decode([Category].self, forKey: .consentCategories)
legIntCategories = try container.decode([Category].self, forKey: .legIntCategories)
}
}

extension GDPRVendor: Identifiable, Equatable, Hashable {
Expand Down Expand Up @@ -81,7 +110,11 @@ extension CCPAVendor: Decodable {
let container = try decoder.container(keyedBy: Keys.self)
_id = try container.decode(String.self, forKey: ._id)
name = try container.decode(String.self, forKey: .name)
policyUrl = try container.decodeIfPresent(URL.self, forKey: .policyUrl)
do {
policyUrl = try container.decodeIfPresent(URL.self, forKey: .policyUrl)
} catch {
policyUrl = nil
}
nullablePurposes = try container.decodeIfPresent([String?].self, forKey: .nullablePurposes)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,24 @@ import Foundation
let vendorId: String?
let policyUrl: URL?
let vendorType: GDPRVendor.VendorType?

enum Keys: String, CodingKey {
case name
case vendorId
case policyUrl
case vendorType
}

init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: Keys.self)
do {
policyUrl = try container.decodeIfPresent(URL.self, forKey: .policyUrl)
} catch {
policyUrl = nil
}
vendorId = try container.decodeIfPresent(String.self, forKey: .vendorId)
name = try container.decode(String.self, forKey: .name)
vendorType = try container.decodeIfPresent(GDPRVendor.VendorType.self, forKey: .vendorType) }
}

let iabId: Int?
Expand Down