Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CONSULT-940] add listMachineSummaries to flutter sdk #359

Merged
merged 6 commits into from
Mar 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion lib/src/app/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ class AppClient {

AppClient(this._client);

/// List all [MachineSummary]s for an organization grouped by Location
///
/// For more information, see [Fleet Management API] ](https://docs.viam.com/appendix/apis/fleet/).
Future<List<LocationSummary>> listMachineSummaries(String organizationId) async {
final request = ListMachineSummariesRequest()..organizationId = organizationId;
final ListMachineSummariesResponse response = await _client.listMachineSummaries(request);
return response.locationSummaries;
}

/// Get the id of the user with the email provided
///
/// For more information, see [Fleet Management API](https://docs.viam.com/appendix/apis/fleet/).
Expand All @@ -29,7 +38,7 @@ class AppClient {

/// Create a new [Organization]
///
/// For more information, see [Fleet Management API](https://docs.viam.com/appendix/apis/fleet/). Future<Organization> createOrganization(String name) async {
/// For more information, see [Fleet Management API](https://docs.viam.com/appendix/apis/fleet/).
Future<Organization> createOrganization(String name) async {
final request = CreateOrganizationRequest()..name = name;
final CreateOrganizationResponse response = await _client.createOrganization(request);
Expand Down
32 changes: 32 additions & 0 deletions test/unit_test/app/app_client_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,38 @@ void main() {
});

group('App RPC Client Tests', () {
test('listMachineSummaries', () async {
final expected = [
LocationSummary()
..locationId = 'id'
..locationName = 'name'
..machineSummaries.addAll([
MachineSummary()
..machineId = 'machineId'
..machineName = 'machineName'
..partSummaries.addAll([
PartSummary()
..partId = 'partId'
..partName = 'partName'
..lastOnline = Timestamp.create()
..viamServerVersion = ViamServerVersion.create()
..viamAgentVersion = ViamAgentVersion.create()
..os = 'os'
..platform = 'platform'
..publicIpAddress = 'publicIpAddress'
..fragments.addAll([
FragmentSummary()
..id = 'fragmentId'
..name = 'name'
])
])
])
];
when(serviceClient.listMachineSummaries(any))
.thenAnswer((_) => MockResponseFuture.value(ListMachineSummariesResponse()..locationSummaries.addAll(expected)));
final response = await appClient.listMachineSummaries('organizationId');
expect(response, equals(expected));
});
test('getUserIDByEmail', () async {
when(serviceClient.getUserIDByEmail(any)).thenAnswer((_) => MockResponseFuture.value(GetUserIDByEmailResponse()..userId = 'userId'));
final response = await appClient.getUserIdByEmail('email');
Expand Down
Loading