Skip to content

Commit

Permalink
WIP: Fix vendor parsing and modify getter component
Browse files Browse the repository at this point in the history
  • Loading branch information
pmerlet-at-didomi committed Feb 26, 2024
1 parent 4cde791 commit 10ed441
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
6 changes: 5 additions & 1 deletion example/lib/widgets/get_vendor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,13 @@ class _GetVendorState
if (result == null) {
return "Vendor does not exist.";
} else {
Url url = result.urls?.find((element) => element.langId == "en") ?? result.urls![0];

return "Vendor: ${result.name}. Purposes: ${result.purposeIds.length} consent, "
"${result.legIntPurposeIds.length} LI, ${result.featureIds.length} features, "
"${result.specialPurposeIds.length} special purposes, ${result.specialFeatureIds.length} special features.";
"${result.specialPurposeIds.length} special purposes, ${result.specialFeatureIds.length} special features."
"URL 0: ${result.urls?[0].langId} -> ${result.urls?[0].privacy} - ${result.urls?[0].legIntClaim}."
"IAB2 = ${result.namespaces?.iab2}";
}
}
}
13 changes: 11 additions & 2 deletions lib/entities/vendor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ class Vendor implements Comparable<Vendor> {
: id = json["id"],
name = json["name"],
policyUrl = json["policyUrl"],
namespaces = json["namespaces"]?.cast<Namespaces>(),
namespaces = json["namespaces"] != null ? Namespaces.fromJson(json["namespaces"]) : null,
purposeIds = json["purposeIds"].cast<String>(),
legIntPurposeIds = json["legIntPurposeIds"].cast<String>(),
featureIds = json["featureIds"].cast<String>(),
flexiblePurposeIds = json["flexiblePurposeIds"].cast<String>(),
specialPurposeIds = json["specialPurposeIds"].cast<String>(),
specialFeatureIds = json["specialFeatureIds"].cast<String>(),
urls = json["urls"]?.cast<Url>();
urls = (json["urls"] as List?)?.map((json) => Url.fromJson(json)).toList();

@override
int compareTo(Vendor other) => (id ?? "").compareTo(other.id ?? "");
Expand All @@ -57,6 +57,10 @@ class Namespaces {
int num;

Namespaces(this.iab2, this.num);

Namespaces.fromJson(dynamic json)
: iab2 = json["iab2"],
num = json["num"];
}

class Url {
Expand All @@ -65,4 +69,9 @@ class Url {
String legIntClaim;

Url(this.langId, this.privacy, this.legIntClaim);

Url.fromJson(dynamic json)
: langId = json["langId"],
privacy = json["privacy"],
legIntClaim = json["legIntClaim"];
}

0 comments on commit 10ed441

Please sign in to comment.