mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2024-11-16 05:33:17 +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);
|
return GenericResult(data: servers, success: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<GenericResult<List>> getAvailableLocations() async {
|
Future<GenericResult<List<HetznerLocation>>> getAvailableLocations() async {
|
||||||
List locations = [];
|
final List<HetznerLocation> locations = [];
|
||||||
|
|
||||||
final Dio client = await getClient();
|
final Dio client = await getClient();
|
||||||
try {
|
try {
|
||||||
final Response response = await client.get(
|
final Response response = await client.get('/locations');
|
||||||
'/locations',
|
for (final location in response.data!['locations']) {
|
||||||
);
|
locations.add(HetznerLocation.fromJson(location));
|
||||||
|
}
|
||||||
locations = response.data!['locations'];
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print(e);
|
print(e);
|
||||||
return GenericResult(
|
return GenericResult(
|
||||||
|
|
|
@ -118,7 +118,14 @@ class HetznerPriceInfo {
|
||||||
|
|
||||||
@JsonSerializable()
|
@JsonSerializable()
|
||||||
class HetznerLocation {
|
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 country;
|
||||||
final String city;
|
final String city;
|
||||||
final String description;
|
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) {
|
for (final rawLocation in rawLocations) {
|
||||||
ServerProviderLocation? location;
|
ServerProviderLocation? location;
|
||||||
try {
|
try {
|
||||||
location = ServerProviderLocation(
|
location = ServerProviderLocation(
|
||||||
title: rawLocation['city'],
|
title: rawLocation.city,
|
||||||
description: rawLocation['description'],
|
description: rawLocation.description,
|
||||||
flag: getEmojiFlag(rawLocation['country']),
|
flag: getEmojiFlag(rawLocation.country),
|
||||||
identifier: rawLocation['name'],
|
identifier: rawLocation.name,
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Reference in a new issue