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

feat: add new method to fetch enrollment requests #1200

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
233c040
feat: add new method fetchEnrollmentRequests() to AtClientImpl
srieteja Jan 10, 2024
07ef40f
test: add unit test
srieteja Jan 10, 2024
5a724a8
refactor: minor refactoring in RemoteSecondary
srieteja Jan 10, 2024
dfa6750
refactor: run dart formatter
srieteja Jan 11, 2024
d4bc099
Merge branch 'trunk' into enroll_list_client
srieteja Jan 11, 2024
bda846a
test: add functional test
srieteja Jan 11, 2024
d557101
Merge remote-tracking branch 'origin/enroll_list_client' into enroll_…
srieteja Jan 11, 2024
3d16f43
test: fix functional tests
srieteja Jan 11, 2024
3dfaaff
test: fix functional tests
srieteja Jan 11, 2024
d751c84
test: change the atsign used in the new test
srieteja Jan 11, 2024
68b5662
test: fix functional tests
srieteja Jan 11, 2024
c4cca0c
test: run dart formatter
srieteja Jan 11, 2024
17f342a
feat: introduced two classes for input and output of fetchEnrollmentR…
srieteja Jan 16, 2024
1816b39
tests: updated tests w.r.t. EnrollRequestParam and EnrollmentRequest …
srieteja Jan 16, 2024
3c669f7
Merge branch 'trunk' into enroll_list_client
srieteja Jan 16, 2024
17863da
fix: introduce toJson(), fromJson() and get enrollmentId for Enrollme…
srieteja Jan 17, 2024
3e01557
fix: make enrollRequestParams mandatory; and update tests
srieteja Jan 17, 2024
27081c1
Merge remote-tracking branch 'origin/enroll_list_client' into enroll_…
srieteja Jan 17, 2024
265f306
Merge branch 'trunk' into enroll_list_client
srieteja Jan 17, 2024
d6accd7
reformat: run the dart formatter
srieteja Jan 17, 2024
ff55915
Merge remote-tracking branch 'origin/enroll_list_client' into enroll_…
srieteja Jan 17, 2024
ffa9aec
reformat: address review comments
srieteja Jan 17, 2024
d0a0f0a
Merge branch 'trunk' into enroll_list_client
srieteja Jan 17, 2024
a6f3d28
reformat: run dart formatter
srieteja Jan 17, 2024
e20d2eb
Merge remote-tracking branch 'origin/enroll_list_client' into enroll_…
srieteja Jan 17, 2024
decb706
docs: updated changelog
srieteja Jan 18, 2024
adb23f2
Merge branch 'trunk' into enroll_list_client
srieteja Jan 22, 2024
8a17438
Merge branch 'trunk' into enroll_list_client
srieteja Jan 24, 2024
8f1b820
Merge branch 'trunk' into enroll_list_client
murali-shris Jan 24, 2024
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
2 changes: 2 additions & 0 deletions packages/at_client/lib/at_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export 'package:at_client/src/preference/at_client_preference.dart';
export 'package:at_client/src/response/at_notification.dart';
export 'package:at_client/src/util/at_client_util.dart';
export 'package:at_client/src/util/encryption_util.dart';
export 'package:at_client/src/util/enrollment_request.dart';
export 'package:at_client/src/util/enroll_list_request_param.dart';
export 'package:at_client/src/service/notification_service.dart';
export 'package:at_client/src/service/sync_service.dart';
export 'package:at_client/src/service/sync/sync_result.dart';
Expand Down
24 changes: 19 additions & 5 deletions packages/at_client/lib/src/client/at_client_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -674,18 +674,32 @@ class AtClientImpl implements AtClient, AtSignChangeListener {
}

@override
Future<Map<String, dynamic>> fetchEnrollmentRequests(
{String? appName, String? deviceName}) async {
Future<List<EnrollmentRequest>> fetchEnrollmentRequests(
{EnrollListRequestParam? enrollmentListRequest}) async {
EnrollVerbBuilder enrollBuilder = EnrollVerbBuilder()
..operation = EnrollOperationEnum.list
..appName = appName
..deviceName = deviceName;
..appName = enrollmentListRequest?.appName
..deviceName = enrollmentListRequest?.deviceName;

var response = await getRemoteSecondary()
?.executeCommand(enrollBuilder.buildCommand(), auth: true);
srieteja marked this conversation as resolved.
Show resolved Hide resolved
response = response?.replaceFirst('data:', '');
Map<String, dynamic> enrollRequests = jsonDecode(response!);
return enrollRequests;
stdout.writeln('enrollment lis req response: $response');
srieteja marked this conversation as resolved.
Show resolved Hide resolved
return _formatEnrollListResponse(enrollRequests);
}

List<EnrollmentRequest> _formatEnrollListResponse(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add fromJson and toJson to "EnrollmentRequest" class instead of setting in for loop.

EnrollmentRequest enrollmentRequest = EnrollmentRequest.fromJson(enrollRequest);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these methods have been introduced as part of 17863da

Map<String, dynamic> enrollRequests) {
List<EnrollmentRequest> enrollRequestsFormatted = [];
for (var request in enrollRequests.entries) {
enrollRequestsFormatted.add(EnrollmentRequest()
..enrollmentKey = request.key
..appName = request.value['appName']
..deviceName = request.value['deviceName']
..namespace = request.value['namespace']);
}
return enrollRequestsFormatted;
}

@override
Expand Down
11 changes: 8 additions & 3 deletions packages/at_client/lib/src/client/at_client_spec.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:io';

import 'package:at_client/at_client.dart';
import 'package:at_client/src/client/local_secondary.dart';
import 'package:at_client/src/client/remote_secondary.dart';
import 'package:at_client/src/manager/sync_manager.dart';
Expand Down Expand Up @@ -573,7 +574,11 @@ abstract class AtClient {

EncryptionService? get encryptionService;

/// Fetches all enrollment requests from the corresponding atServer
Future<Map<String, dynamic>> fetchEnrollmentRequests(
{String? appName, String? deviceName});
/// Fetches all enrollment requests from the corresponding atServer; Formats the requests into a
/// List<[EnrollmentResponse]>
///
/// The optional param [EnrollListRequestParam] is present to avoid future compatibility issues over backwards compatibility
/// [enrollListRequest] for now does not have any functionality
Future<List<EnrollmentRequest>> fetchEnrollmentRequests(
{EnrollListRequestParam? enrollmentListRequest});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/// class to store request parameters while fetching a list of enrollments
class EnrollListRequestParam {
String? appName;
String? deviceName;
String? namespace;
}
11 changes: 11 additions & 0 deletions packages/at_client/lib/src/util/enrollment_request.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class EnrollmentRequest {
late String enrollmentKey;
late String appName;
late String deviceName;
late Map<String, dynamic> namespace;

@override
String toString() {
return 'Enrollment Request: enrollmentKey: $enrollmentKey | appName: $appName | deviceName: $deviceName | namespace: ${namespace.toString()}';
}
}