-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(deriv_passkeys): moved fetch and fetchRaw calls to extended …
…response classes
- Loading branch information
1 parent
367d63a
commit 861009a
Showing
10 changed files
with
182 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import 'package:deriv_dependency_injector/dependency_injector.dart'; | ||
import 'package:flutter_deriv_api/api/exceptions/base_api_exception.dart'; | ||
import 'package:flutter_deriv_api/api/models/base_exception_model.dart'; | ||
import 'package:flutter_deriv_api/api/response/passkeys_list_response_result.dart'; | ||
import 'package:flutter_deriv_api/basic_api/generated/api.dart'; | ||
import 'package:flutter_deriv_api/helpers/helpers.dart'; | ||
import 'package:flutter_deriv_api/services/connection/api_manager/base_api.dart'; | ||
|
||
/// Extended functionality for [PasskeysListResponse] class. | ||
class PasskeysListResponseExtended extends PasskeysListResponse { | ||
static final BaseAPI _api = Injector()<BaseAPI>(); | ||
|
||
/// List all passkeys. | ||
static Future<PasskeysListResponse> fetch( | ||
PasskeysListRequest request, | ||
) async { | ||
final PasskeysListReceive response = await fetchRaw(request); | ||
|
||
return PasskeysListResponse.fromJson(response.toJson()); | ||
} | ||
|
||
/// Fetches raw passkeys list response. | ||
static Future<PasskeysListReceive> fetchRaw( | ||
PasskeysListRequest request, | ||
) async { | ||
final PasskeysListReceive response = await _api.call(request: request); | ||
|
||
checkException( | ||
response: response, | ||
exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => | ||
BaseAPIException(baseExceptionModel: baseExceptionModel), | ||
); | ||
|
||
return response; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
lib/api/response/passkeys_register_options_response_extended.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import 'package:deriv_dependency_injector/dependency_injector.dart'; | ||
import 'package:flutter_deriv_api/api/exceptions/base_api_exception.dart'; | ||
import 'package:flutter_deriv_api/api/models/base_exception_model.dart'; | ||
import 'package:flutter_deriv_api/api/response/passkeys_register_options_response_result.dart'; | ||
import 'package:flutter_deriv_api/basic_api/generated/api.dart'; | ||
import 'package:flutter_deriv_api/helpers/helpers.dart'; | ||
import 'package:flutter_deriv_api/services/connection/api_manager/base_api.dart'; | ||
|
||
/// Extended functionality for [PasskeysRegisterOptionsResponse] class. | ||
class PasskeysRegisterOptionsResponseExtended | ||
extends PasskeysRegisterOptionsResponse { | ||
static final BaseAPI _api = Injector()<BaseAPI>(); | ||
|
||
/// List all register passkeys options. | ||
static Future<PasskeysRegisterOptionsResponse> fetch( | ||
PasskeysRegisterOptionsRequest request, | ||
) async { | ||
final PasskeysRegisterOptionsReceive response = await fetchRaw(request); | ||
|
||
return PasskeysRegisterOptionsResponse.fromJson(response.toJson()); | ||
} | ||
|
||
/// Fetches raw register passkeys options response. | ||
static Future<PasskeysRegisterOptionsReceive> fetchRaw( | ||
PasskeysRegisterOptionsRequest request, | ||
) async { | ||
final PasskeysRegisterOptionsReceive response = | ||
await _api.call(request: request); | ||
|
||
checkException( | ||
response: response, | ||
exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => | ||
BaseAPIException(baseExceptionModel: baseExceptionModel), | ||
); | ||
|
||
return response; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import 'package:deriv_dependency_injector/dependency_injector.dart'; | ||
import 'package:flutter_deriv_api/api/exceptions/base_api_exception.dart'; | ||
import 'package:flutter_deriv_api/api/models/base_exception_model.dart'; | ||
import 'package:flutter_deriv_api/api/response/passkeys_register_response_result.dart'; | ||
import 'package:flutter_deriv_api/basic_api/generated/api.dart'; | ||
import 'package:flutter_deriv_api/helpers/helpers.dart'; | ||
import 'package:flutter_deriv_api/services/connection/api_manager/base_api.dart'; | ||
|
||
/// Extended functionality for [PasskeysRegisterResponse] class. | ||
class PasskeysRegisterResponseExtended extends PasskeysRegisterResponse { | ||
static final BaseAPI _api = Injector()<BaseAPI>(); | ||
|
||
/// register a new passkey. | ||
static Future<PasskeysRegisterResponse> fetch( | ||
PasskeysRegisterRequest request, | ||
) async { | ||
final PasskeysRegisterReceive response = await fetchRaw(request); | ||
|
||
return PasskeysRegisterResponse.fromJson(response.toJson()); | ||
} | ||
|
||
/// Fetches raw passkeys register response. | ||
static Future<PasskeysRegisterReceive> fetchRaw( | ||
PasskeysRegisterRequest request, | ||
) async { | ||
final PasskeysRegisterReceive response = await _api.call(request: request); | ||
|
||
checkException( | ||
response: response, | ||
exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => | ||
BaseAPIException(baseExceptionModel: baseExceptionModel), | ||
); | ||
|
||
return response; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import 'package:deriv_dependency_injector/dependency_injector.dart'; | ||
import 'package:flutter_deriv_api/api/exceptions/base_api_exception.dart'; | ||
import 'package:flutter_deriv_api/api/models/base_exception_model.dart'; | ||
import 'package:flutter_deriv_api/api/response/passkeys_rename_response_result.dart'; | ||
import 'package:flutter_deriv_api/basic_api/generated/api.dart'; | ||
import 'package:flutter_deriv_api/helpers/helpers.dart'; | ||
import 'package:flutter_deriv_api/services/connection/api_manager/base_api.dart'; | ||
|
||
/// Extended functionality for [PasskeysRenameResponse] class. | ||
class PasskeysRenameResponseExtended extends PasskeysRenameResponse { | ||
static final BaseAPI _api = Injector()<BaseAPI>(); | ||
|
||
/// rename a passkey. | ||
static Future<PasskeysRenameResponse> fetch( | ||
PasskeysRenameRequest request, | ||
) async { | ||
final PasskeysRenameReceive response = await fetchRaw(request); | ||
|
||
return PasskeysRenameResponse.fromJson(response.toJson()); | ||
} | ||
|
||
/// Fetches raw passkeys rename response. | ||
static Future<PasskeysRenameReceive> fetchRaw( | ||
PasskeysRenameRequest request, | ||
) async { | ||
final PasskeysRenameReceive response = await _api.call(request: request); | ||
|
||
checkException( | ||
response: response, | ||
exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => | ||
BaseAPIException(baseExceptionModel: baseExceptionModel), | ||
); | ||
|
||
return response; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import 'package:deriv_dependency_injector/dependency_injector.dart'; | ||
import 'package:flutter_deriv_api/api/exceptions/base_api_exception.dart'; | ||
import 'package:flutter_deriv_api/api/models/base_exception_model.dart'; | ||
import 'package:flutter_deriv_api/api/response/passkeys_revoke_response_result.dart'; | ||
import 'package:flutter_deriv_api/basic_api/generated/api.dart'; | ||
import 'package:flutter_deriv_api/helpers/helpers.dart'; | ||
import 'package:flutter_deriv_api/services/connection/api_manager/base_api.dart'; | ||
|
||
/// Extended functionality for [PasskeysRevokeReceive] class. | ||
class PasskeysRevokeReceiveExtended extends PasskeysRevokeReceive { | ||
static final BaseAPI _api = Injector()<BaseAPI>(); | ||
|
||
/// revoke a passkey. | ||
static Future<PasskeysRevokeResponse> fetch( | ||
PasskeysRevokeRequest request, | ||
) async { | ||
final PasskeysRevokeReceive response = await fetchRaw(request); | ||
|
||
return PasskeysRevokeResponse.fromJson(response.toJson()); | ||
} | ||
|
||
/// Fetches raw passkeys revoke response. | ||
static Future<PasskeysRevokeReceive> fetchRaw( | ||
PasskeysRevokeRequest request, | ||
) async { | ||
final PasskeysRevokeReceive response = await _api.call(request: request); | ||
|
||
checkException( | ||
response: response, | ||
exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => | ||
BaseAPIException(baseExceptionModel: baseExceptionModel), | ||
); | ||
|
||
return response; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters