Skip to content

Commit 8f73000

Browse files
authored
Merge pull request #4 from threefoldtech/development_add_stellar
Add stellar address to farm model
2 parents f75962b + d782b3f commit 8f73000

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

packages/registrar_client/lib/models/farm.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class Farm {
88
final List<Node>? nodes;
99
final int twinID;
1010
final String? updatedAt;
11+
final String? stellarAddress;
1112

1213
Farm({
1314
this.createdAt,
@@ -16,6 +17,7 @@ class Farm {
1617
required farmName,
1718
this.nodes,
1819
required twinID,
20+
this.stellarAddress,
1921
this.updatedAt,
2022
}) : farmName = _validateFarmName(farmName),
2123
twinID = _validateTwinId(twinID);
@@ -30,6 +32,7 @@ class Farm {
3032
? (json['nodes'] as List).map((node) => Node.fromJson(node)).toList()
3133
: null,
3234
twinID: json['twin_id'],
35+
stellarAddress: json['stellar_address'],
3336
updatedAt: json['updated_at'],
3437
);
3538
}
@@ -42,6 +45,7 @@ class Farm {
4245
'farm_name': farmName,
4346
'nodes': nodes ?? [],
4447
'twin_id': twinID,
48+
'stellar_address': stellarAddress,
4549
'updated_at': updatedAt,
4650
};
4751
}

packages/registrar_client/lib/src/farms.dart

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,18 @@ class Farms {
2727
return List<Farm>.from(response.map((farm) => Farm.fromJson(farm)));
2828
}
2929

30-
Future<dynamic> update(int twinID, int farmID, String farmName) async {
30+
Future<dynamic> update(int twinID, int farmID,
31+
{String? farmName, String? stellarAddress}) async {
32+
if (farmName == null && stellarAddress == null) {
33+
return;
34+
}
3135
final header = createAuthHeader(twinID, _client.privateKey);
32-
final response = await _client.patch(
33-
path: '$path/$farmID', body: {'farm_name': farmName}, headers: header);
36+
final body = {
37+
if (farmName != null) 'farm_name': farmName,
38+
if (stellarAddress != null) 'stellar_address': stellarAddress
39+
};
40+
final response =
41+
await _client.patch(path: '$path/$farmID', body: body, headers: header);
3442
return response;
3543
}
3644
}

0 commit comments

Comments
 (0)