Skip to content

Commit 5d9d409

Browse files
jckrasstuqdog
andauthored
[CONSULT-940] add listMachineSummaries to flutter sdk (#359)
* trigger test * add listMachineSummaries to flutter sdk * change to list * remove comment * change comment * format --------- Co-authored-by: Ethan Rodkin <[email protected]>
1 parent 915ee88 commit 5d9d409

File tree

3 files changed

+487
-1
lines changed

3 files changed

+487
-1
lines changed

lib/src/app/app.dart

+10-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ class AppClient {
1818

1919
AppClient(this._client);
2020

21+
/// List all [MachineSummary]s for an organization grouped by Location
22+
///
23+
/// For more information, see [Fleet Management API] ](https://docs.viam.com/appendix/apis/fleet/).
24+
Future<List<LocationSummary>> listMachineSummaries(String organizationId) async {
25+
final request = ListMachineSummariesRequest()..organizationId = organizationId;
26+
final ListMachineSummariesResponse response = await _client.listMachineSummaries(request);
27+
return response.locationSummaries;
28+
}
29+
2130
/// Get the id of the user with the email provided
2231
///
2332
/// For more information, see [Fleet Management API](https://docs.viam.com/appendix/apis/fleet/).
@@ -29,7 +38,7 @@ class AppClient {
2938

3039
/// Create a new [Organization]
3140
///
32-
/// For more information, see [Fleet Management API](https://docs.viam.com/appendix/apis/fleet/). Future<Organization> createOrganization(String name) async {
41+
/// For more information, see [Fleet Management API](https://docs.viam.com/appendix/apis/fleet/).
3342
Future<Organization> createOrganization(String name) async {
3443
final request = CreateOrganizationRequest()..name = name;
3544
final CreateOrganizationResponse response = await _client.createOrganization(request);

test/unit_test/app/app_client_test.dart

+32
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,38 @@ void main() {
2323
});
2424

2525
group('App RPC Client Tests', () {
26+
test('listMachineSummaries', () async {
27+
final expected = [
28+
LocationSummary()
29+
..locationId = 'id'
30+
..locationName = 'name'
31+
..machineSummaries.addAll([
32+
MachineSummary()
33+
..machineId = 'machineId'
34+
..machineName = 'machineName'
35+
..partSummaries.addAll([
36+
PartSummary()
37+
..partId = 'partId'
38+
..partName = 'partName'
39+
..lastOnline = Timestamp.create()
40+
..viamServerVersion = ViamServerVersion.create()
41+
..viamAgentVersion = ViamAgentVersion.create()
42+
..os = 'os'
43+
..platform = 'platform'
44+
..publicIpAddress = 'publicIpAddress'
45+
..fragments.addAll([
46+
FragmentSummary()
47+
..id = 'fragmentId'
48+
..name = 'name'
49+
])
50+
])
51+
])
52+
];
53+
when(serviceClient.listMachineSummaries(any))
54+
.thenAnswer((_) => MockResponseFuture.value(ListMachineSummariesResponse()..locationSummaries.addAll(expected)));
55+
final response = await appClient.listMachineSummaries('organizationId');
56+
expect(response, equals(expected));
57+
});
2658
test('getUserIDByEmail', () async {
2759
when(serviceClient.getUserIDByEmail(any)).thenAnswer((_) => MockResponseFuture.value(GetUserIDByEmailResponse()..userId = 'userId'));
2860
final response = await appClient.getUserIdByEmail('email');

0 commit comments

Comments
 (0)