mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-08 00:51:20 +00:00
chore: Replace dynamic blobs with HetznerLocation
This commit is contained in:
parent
875a9e2e86
commit
f42e415633
|
@ -526,16 +526,15 @@ class HetznerApi extends ServerProviderApi with VolumeProviderApi {
|
|||
return GenericResult(data: servers, success: true);
|
||||
}
|
||||
|
||||
Future<GenericResult<List>> getAvailableLocations() async {
|
||||
List locations = [];
|
||||
Future<GenericResult<List<HetznerLocation>>> getAvailableLocations() async {
|
||||
final List<HetznerLocation> locations = [];
|
||||
|
||||
final Dio client = await getClient();
|
||||
try {
|
||||
final Response response = await client.get(
|
||||
'/locations',
|
||||
);
|
||||
|
||||
locations = response.data!['locations'];
|
||||
final Response response = await client.get('/locations');
|
||||
for (final location in response.data!['locations']) {
|
||||
locations.add(HetznerLocation.fromJson(location));
|
||||
}
|
||||
} catch (e) {
|
||||
print(e);
|
||||
return GenericResult(
|
||||
|
|
|
@ -118,7 +118,14 @@ class HetznerPriceInfo {
|
|||
|
||||
@JsonSerializable()
|
||||
class HetznerLocation {
|
||||
HetznerLocation(this.country, this.city, this.description, this.zone);
|
||||
HetznerLocation(
|
||||
this.country,
|
||||
this.city,
|
||||
this.description,
|
||||
this.zone,
|
||||
this.name,
|
||||
);
|
||||
final String name;
|
||||
final String country;
|
||||
final String city;
|
||||
final String description;
|
||||
|
|
|
@ -116,15 +116,15 @@ class HetznerServerProvider extends ServerProvider {
|
|||
);
|
||||
}
|
||||
|
||||
final List rawLocations = result.data;
|
||||
final List<HetznerLocation> rawLocations = result.data;
|
||||
for (final rawLocation in rawLocations) {
|
||||
ServerProviderLocation? location;
|
||||
try {
|
||||
location = ServerProviderLocation(
|
||||
title: rawLocation['city'],
|
||||
description: rawLocation['description'],
|
||||
flag: getEmojiFlag(rawLocation['country']),
|
||||
identifier: rawLocation['name'],
|
||||
title: rawLocation.city,
|
||||
description: rawLocation.description,
|
||||
flag: getEmojiFlag(rawLocation.country),
|
||||
identifier: rawLocation.name,
|
||||
);
|
||||
} catch (e) {
|
||||
continue;
|
||||
|
|
Loading…
Reference in a new issue