permission function
Implementation
Future<Map> permission(
{required String app_id,
required String lang,
required String country}) async {
var dom = await post(
Formats.Permissions.build(lang: lang, country: country),
Formats.Permissions.build_body(app_id),
{"content-type": "application/x-www-form-urlencoded"},
);
var matches = json.decode(Regex.PERMISSIONS.allMatches(dom).first.group(1)!);
List container = json.decode(matches![0][2]);
var result = {};
for (var permission_items in container) {
if (permission_items is List) {
if (permission_items.length == 2) {
// rearrange layout to fit ElementSpecs
permission_items = [
["Uncategorized", null, permission_items, null]
];
}
for (var permission in permission_items) {
if (permission != null) {
result[ElementSpecs.Permission_Type.extract_content(permission)] =
ElementSpecs.Permission_List.extract_content(permission);
}
}
}
}
return result;
}