mirror of
https://github.com/foss42/apidash.git
synced 2025-06-21 14:57:07 +08:00
Update insomnia_utils.dart
This commit is contained in:
@ -1,47 +1,25 @@
|
|||||||
|
import '../models/models.dart';
|
||||||
|
|
||||||
|
|
||||||
import 'package:insomnia_collection/models/insomnia_collection.dart';
|
|
||||||
import 'package:insomnia_collection/models/insomnia_environment.dart';
|
|
||||||
|
|
||||||
List<(String?, Resource)> getRequestsFromInsomniaCollection(
|
List<(String?, Resource)> getRequestsFromInsomniaCollection(
|
||||||
InsomniaCollection? ic) {
|
InsomniaCollection? ic) =>
|
||||||
if (ic == null || ic.resources == null) {
|
getItemByTypeFromInsomniaCollection(ic, ResourceType.request.name);
|
||||||
|
|
||||||
|
List<(String?, Resource)> getEnvironmentsFromInsomniaCollection(
|
||||||
|
InsomniaCollection? ic) =>
|
||||||
|
getItemByTypeFromInsomniaCollection(ic, ResourceType.environment.name);
|
||||||
|
|
||||||
|
List<(String?, Resource)> getItemByTypeFromInsomniaCollection(
|
||||||
|
InsomniaCollection? ic,
|
||||||
|
String type,
|
||||||
|
) {
|
||||||
|
if (ic?.resources == null || ic!.resources!.length > 0) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
List<(String?, Resource)> requests = [];
|
List<(String?, Resource)> requests = [];
|
||||||
if (ic.resources!.length > 0) {
|
for (var item in ic.resources!) {
|
||||||
for (var i in ic.resources!) {
|
if (item.type != null || item.type == type) {
|
||||||
requests.addAll(getRequestsFromInsomniaResource(i));
|
requests.add((item.name, item));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return requests;
|
return requests;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<EnvironmentVariable> getEnvironmentVariablesFromInsomniaEnvironment(
|
|
||||||
InsomniaEnvironment? ev) {
|
|
||||||
if (ev == null || ev.resources == null) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
List<EnvironmentVariable> envVariables = [];
|
|
||||||
if (ev.resources!.length > 0) {
|
|
||||||
for (var envvar in ev.resources!) {
|
|
||||||
envVariables.add(envvar);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return envVariables;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<(String?, Resource)> getRequestsFromInsomniaResource(Resource? resource) {
|
|
||||||
if (resource == null) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
List<(String?, Resource)> requests = [];
|
|
||||||
if (resource.type != null || resource.type == 'request') {
|
|
||||||
requests.add((resource.name, resource));
|
|
||||||
} else {
|
|
||||||
print('Resource type is not request');
|
|
||||||
}
|
|
||||||
return requests;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user