From 06228e828c3d92b6f16e84d65ffda7f5c6c732b3 Mon Sep 17 00:00:00 2001 From: akhil-deriv Date: Thu, 16 May 2024 14:16:47 +0400 Subject: [PATCH 1/6] added loginId for account status --- .../get_account_status_response_result.dart | 181 +++++++++++++++++- 1 file changed, 177 insertions(+), 4 deletions(-) diff --git a/lib/api/response/get_account_status_response_result.dart b/lib/api/response/get_account_status_response_result.dart index ff9472e4cb..4995ce6add 100644 --- a/lib/api/response/get_account_status_response_result.dart +++ b/lib/api/response/get_account_status_response_result.dart @@ -55,9 +55,10 @@ class GetAccountStatusResponse extends GetAccountStatusResponseModel { /// /// For parameters information refer to [GetAccountStatusRequest]. /// Throws an [BaseAPIException] if API response contains an error. - static Future fetchAccountStatusRaw() async { + static Future fetchAccountStatusRaw( + {required String loginId}) async { final GetAccountStatusReceive response = await _api.call( - request: const GetAccountStatusRequest(), + request: GetAccountStatusRequest(loginid: loginId), ); checkException( @@ -73,8 +74,10 @@ class GetAccountStatusResponse extends GetAccountStatusResponseModel { /// /// For parameters information refer to [GetAccountStatusRequest]. /// Throws an [BaseAPIException] if API response contains an error. - static Future fetchAccountStatus() async { - final GetAccountStatusReceive response = await fetchAccountStatusRaw(); + static Future fetchAccountStatus( + {required String loginId}) async { + final GetAccountStatusReceive response = + await fetchAccountStatusRaw(loginId: loginId); return GetAccountStatusResponse.fromJson(response.getAccountStatus); } @@ -268,6 +271,7 @@ enum SocialIdentityProviderEnum { /// apple. apple, } + /// Get account status model class. abstract class GetAccountStatusModel { /// Initializes Get account status model class . @@ -329,6 +333,7 @@ abstract class GetAccountStatusModel { /// - `mt5_additional_kyc_required`: client tax information, place of birth and account opening reason is missing. /// - `poi_expiring_soon`: the POI documents of the client will get expired soon, allow them to reupload POI documents. /// - `poa_expiring_soon`: the POA documents of the client will get outdated soon, allow them to reupload POA documents. + /// - `tin_manually_approved`: the client's tax_identification_number has been manually approved as client is not applicable for tax_identification_number final List status; /// Client risk classification: `low`, `standard`, `high`. @@ -490,6 +495,7 @@ class GetAccountStatus extends GetAccountStatusModel { socialIdentityProvider ?? this.socialIdentityProvider, ); } + /// Currency config property model class. abstract class CurrencyConfigPropertyModel { /// Initializes Currency config property model class . @@ -541,6 +547,7 @@ class CurrencyConfigProperty extends CurrencyConfigPropertyModel { isWithdrawalSuspended ?? this.isWithdrawalSuspended, ); } + /// Authentication model class. abstract class AuthenticationModel { /// Initializes Authentication model class . @@ -653,6 +660,7 @@ class Authentication extends AuthenticationModel { ownership: ownership ?? this.ownership, ); } + /// Attempts model class. abstract class AttemptsModel { /// Initializes Attempts model class . @@ -723,6 +731,7 @@ class Attempts extends AttemptsModel { latest: latest ?? this.latest, ); } + /// History item model class. abstract class HistoryItemModel { /// Initializes History item model class . @@ -812,6 +821,7 @@ class HistoryItem extends HistoryItemModel { timestamp: timestamp ?? this.timestamp, ); } + /// Document model class. abstract class DocumentModel { /// Initializes Document model class . @@ -819,6 +829,7 @@ abstract class DocumentModel { this.authenticatedWithIdv, this.expiryDate, this.status, + this.verifiedJurisdiction, }); /// This represents the current status of idv authentication for each mt5 jurisdiction. @@ -829,6 +840,9 @@ abstract class DocumentModel { /// This represents the current status of the proof of address document submitted for authentication. final DocumentStatusEnum? status; + + /// This represents the current status of authentication for each mt5 jurisdiction. + final VerifiedJurisdiction? verifiedJurisdiction; } /// Document class. @@ -838,6 +852,7 @@ class Document extends DocumentModel { super.authenticatedWithIdv, super.expiryDate, super.status, + super.verifiedJurisdiction, }); /// Creates an instance from JSON. @@ -849,6 +864,9 @@ class Document extends DocumentModel { status: json['status'] == null ? null : documentStatusEnumMapper[json['status']], + verifiedJurisdiction: json['verified_jurisdiction'] == null + ? null + : VerifiedJurisdiction.fromJson(json['verified_jurisdiction']), ); /// Converts an instance to JSON. @@ -863,6 +881,9 @@ class Document extends DocumentModel { .firstWhere((MapEntry entry) => entry.value == status) .key; + if (verifiedJurisdiction != null) { + resultMap['verified_jurisdiction'] = verifiedJurisdiction!.toJson(); + } return resultMap; } @@ -872,13 +893,16 @@ class Document extends DocumentModel { AuthenticatedWithIdv? authenticatedWithIdv, DateTime? expiryDate, DocumentStatusEnum? status, + VerifiedJurisdiction? verifiedJurisdiction, }) => Document( authenticatedWithIdv: authenticatedWithIdv ?? this.authenticatedWithIdv, expiryDate: expiryDate ?? this.expiryDate, status: status ?? this.status, + verifiedJurisdiction: verifiedJurisdiction ?? this.verifiedJurisdiction, ); } + /// Authenticated with idv model class. abstract class AuthenticatedWithIdvModel { /// Initializes Authenticated with idv model class . @@ -1010,6 +1034,139 @@ class AuthenticatedWithIdv extends AuthenticatedWithIdvModel { virtual: virtual ?? this.virtual, ); } + +/// Verified jurisdiction model class. +abstract class VerifiedJurisdictionModel { + /// Initializes Verified jurisdiction model class . + const VerifiedJurisdictionModel({ + this.bvi, + this.dsl, + this.iom, + this.labuan, + this.malta, + this.maltainvest, + this.samoa, + this.samoaVirtual, + this.svg, + this.vanuatu, + this.virtual, + }); + + /// This represents whether the client is allowed or not to create an account under this jurisdiction + final bool? bvi; + + /// This represents whether the client is allowed or not to create an account under this jurisdiction + final bool? dsl; + + /// This represents whether the client is allowed or not to create an account under this jurisdiction + final bool? iom; + + /// This represents whether the client is allowed or not to create an account under this jurisdiction + final bool? labuan; + + /// This represents whether the client is allowed or not to create an account under this jurisdiction + final bool? malta; + + /// This represents whether the client is allowed or not to create an account under this jurisdiction + final bool? maltainvest; + + /// This represents whether the client is allowed or not to create an account under this jurisdiction + final bool? samoa; + + /// This represents whether the client is allowed or not to create an account under this jurisdiction + final bool? samoaVirtual; + + /// This represents whether the client is allowed or not to create an account under this jurisdiction + final bool? svg; + + /// This represents whether the client is allowed or not to create an account under this jurisdiction + final bool? vanuatu; + + /// This represents whether the client is allowed or not to create an account under this jurisdiction + final bool? virtual; +} + +/// Verified jurisdiction class. +class VerifiedJurisdiction extends VerifiedJurisdictionModel { + /// Initializes Verified jurisdiction class. + const VerifiedJurisdiction({ + super.bvi, + super.dsl, + super.iom, + super.labuan, + super.malta, + super.maltainvest, + super.samoa, + super.samoaVirtual, + super.svg, + super.vanuatu, + super.virtual, + }); + + /// Creates an instance from JSON. + factory VerifiedJurisdiction.fromJson(Map json) => + VerifiedJurisdiction( + bvi: getBool(json['bvi']), + dsl: getBool(json['dsl']), + iom: getBool(json['iom']), + labuan: getBool(json['labuan']), + malta: getBool(json['malta']), + maltainvest: getBool(json['maltainvest']), + samoa: getBool(json['samoa']), + samoaVirtual: getBool(json['samoa-virtual']), + svg: getBool(json['svg']), + vanuatu: getBool(json['vanuatu']), + virtual: getBool(json['virtual']), + ); + + /// Converts an instance to JSON. + Map toJson() { + final Map resultMap = {}; + + resultMap['bvi'] = bvi; + resultMap['dsl'] = dsl; + resultMap['iom'] = iom; + resultMap['labuan'] = labuan; + resultMap['malta'] = malta; + resultMap['maltainvest'] = maltainvest; + resultMap['samoa'] = samoa; + resultMap['samoa-virtual'] = samoaVirtual; + resultMap['svg'] = svg; + resultMap['vanuatu'] = vanuatu; + resultMap['virtual'] = virtual; + + return resultMap; + } + + /// Creates a copy of instance with given parameters. + VerifiedJurisdiction copyWith({ + bool? bvi, + bool? dsl, + bool? iom, + bool? labuan, + bool? malta, + bool? maltainvest, + bool? samoa, + bool? samoaVirtual, + bool? svg, + bool? vanuatu, + bool? virtual, + }) => + VerifiedJurisdiction( + bvi: bvi ?? this.bvi, + dsl: dsl ?? this.dsl, + iom: iom ?? this.iom, + labuan: labuan ?? this.labuan, + malta: malta ?? this.malta, + maltainvest: maltainvest ?? this.maltainvest, + samoa: samoa ?? this.samoa, + samoaVirtual: samoaVirtual ?? this.samoaVirtual, + svg: svg ?? this.svg, + vanuatu: vanuatu ?? this.vanuatu, + virtual: virtual ?? this.virtual, + ); +} + /// Identity model class. abstract class IdentityModel { /// Initializes Identity model class . @@ -1077,6 +1234,7 @@ class Identity extends IdentityModel { status: status ?? this.status, ); } + /// Services model class. abstract class ServicesModel { /// Initializes Services model class . @@ -1141,12 +1299,14 @@ class Services extends ServicesModel { onfido: onfido ?? this.onfido, ); } + /// Idv model class. abstract class IdvModel { /// Initializes Idv model class . const IdvModel({ this.expiryDate, this.lastRejected, + this.reportAvailable, this.reportedProperties, this.status, this.submissionsLeft, @@ -1158,6 +1318,9 @@ abstract class IdvModel { /// Show the last IDV reported reasons for the rejected cases final List? lastRejected; + /// Indicate if the verification report was returned by the provider + final bool? reportAvailable; + /// Shows the latest document properties detected and reported by IDVS final Map? reportedProperties; @@ -1174,6 +1337,7 @@ class Idv extends IdvModel { const Idv({ super.expiryDate, super.lastRejected, + super.reportAvailable, super.reportedProperties, super.status, super.submissionsLeft, @@ -1189,6 +1353,7 @@ class Idv extends IdvModel { (dynamic item) => item, ), ), + reportAvailable: getBool(json['report_available']), reportedProperties: json['reported_properties'], status: json['status'] == null ? null : idvStatusEnumMapper[json['status']], @@ -1207,6 +1372,7 @@ class Idv extends IdvModel { ) .toList(); } + resultMap['report_available'] = reportAvailable; resultMap['reported_properties'] = reportedProperties; resultMap['status'] = idvStatusEnumMapper.entries .firstWhere( @@ -1221,6 +1387,7 @@ class Idv extends IdvModel { Idv copyWith({ DateTime? expiryDate, List? lastRejected, + bool? reportAvailable, Map? reportedProperties, IdvStatusEnum? status, int? submissionsLeft, @@ -1228,11 +1395,13 @@ class Idv extends IdvModel { Idv( expiryDate: expiryDate ?? this.expiryDate, lastRejected: lastRejected ?? this.lastRejected, + reportAvailable: reportAvailable ?? this.reportAvailable, reportedProperties: reportedProperties ?? this.reportedProperties, status: status ?? this.status, submissionsLeft: submissionsLeft ?? this.submissionsLeft, ); } + /// Manual model class. abstract class ManualModel { /// Initializes Manual model class . @@ -1278,6 +1447,7 @@ class Manual extends ManualModel { status: status ?? this.status, ); } + /// Onfido model class. abstract class OnfidoModel { /// Initializes Onfido model class . @@ -1422,6 +1592,7 @@ class Onfido extends OnfidoModel { submissionsLeft: submissionsLeft ?? this.submissionsLeft, ); } + /// Income model class. abstract class IncomeModel { /// Initializes Income model class . @@ -1476,6 +1647,7 @@ class Income extends IncomeModel { status: status ?? this.status, ); } + /// Ownership model class. abstract class OwnershipModel { /// Initializes Ownership model class . @@ -1542,6 +1714,7 @@ class Ownership extends OwnershipModel { status: status ?? this.status, ); } + /// Requests item model class. abstract class RequestsItemModel { /// Initializes Requests item model class . From 5d810beb86a116db08c177f96d11c7403c3c3d98 Mon Sep 17 00:00:00 2001 From: akhil-deriv Date: Thu, 16 May 2024 14:17:44 +0400 Subject: [PATCH 2/6] fixed the test case for account status --- test/api/account/account_status/account_status_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/api/account/account_status/account_status_test.dart b/test/api/account/account_status/account_status_test.dart index 3a7694bf0e..508df18eba 100644 --- a/test/api/account/account_status/account_status_test.dart +++ b/test/api/account/account_status/account_status_test.dart @@ -11,7 +11,7 @@ void main() { test('Account Status Test', () async { final GetAccountStatusResponse accountStatus = - await GetAccountStatusResponse.fetchAccountStatus(); + await GetAccountStatusResponse.fetchAccountStatus(loginId: 'CR12345'); expect(accountStatus.getAccountStatus?.currencyConfig.length, 1); expect(accountStatus.getAccountStatus?.currencyConfig.keys.first, 'USD'); From 30f3736e7838aae960cd1ead9e19456159bd66bd Mon Sep 17 00:00:00 2001 From: akhil-deriv Date: Thu, 16 May 2024 17:29:57 +0400 Subject: [PATCH 3/6] reverted previous changes --- .../response/get_account_status_response_result.dart | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/api/response/get_account_status_response_result.dart b/lib/api/response/get_account_status_response_result.dart index 4995ce6add..d6b31c9dbc 100644 --- a/lib/api/response/get_account_status_response_result.dart +++ b/lib/api/response/get_account_status_response_result.dart @@ -55,10 +55,9 @@ class GetAccountStatusResponse extends GetAccountStatusResponseModel { /// /// For parameters information refer to [GetAccountStatusRequest]. /// Throws an [BaseAPIException] if API response contains an error. - static Future fetchAccountStatusRaw( - {required String loginId}) async { + static Future fetchAccountStatusRaw() async { final GetAccountStatusReceive response = await _api.call( - request: GetAccountStatusRequest(loginid: loginId), + request: const GetAccountStatusRequest(), ); checkException( @@ -74,10 +73,8 @@ class GetAccountStatusResponse extends GetAccountStatusResponseModel { /// /// For parameters information refer to [GetAccountStatusRequest]. /// Throws an [BaseAPIException] if API response contains an error. - static Future fetchAccountStatus( - {required String loginId}) async { - final GetAccountStatusReceive response = - await fetchAccountStatusRaw(loginId: loginId); + static Future fetchAccountStatus() async { + final GetAccountStatusReceive response = await fetchAccountStatusRaw(); return GetAccountStatusResponse.fromJson(response.getAccountStatus); } From 73d320aeea2a61ca3f45cc6227c29d75dbe5d51b Mon Sep 17 00:00:00 2001 From: akhil-deriv Date: Wed, 5 Jun 2024 14:56:53 +0400 Subject: [PATCH 4/6] updated topup functionality --- lib/api/response/topup_virtual_response_result.dart | 10 +++++++--- .../methods/topup_virtual_receive_methods.json | 2 +- .../account/account_status/account_status_test.dart | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/api/response/topup_virtual_response_result.dart b/lib/api/response/topup_virtual_response_result.dart index 30734ab493..156329069d 100644 --- a/lib/api/response/topup_virtual_response_result.dart +++ b/lib/api/response/topup_virtual_response_result.dart @@ -1,5 +1,6 @@ // ignore_for_file: prefer_single_quotes, unnecessary_import, unused_import +import 'package:build/build.dart'; import 'package:equatable/equatable.dart'; import 'package:flutter_deriv_api/api/exceptions/exceptions.dart'; @@ -55,11 +56,13 @@ class TopupVirtualResponse extends TopupVirtualResponseModel { /// /// For parameters information refer to [TopupVirtualRequest]. /// Throws a [BaseAPIException] if API response contains an error - static Future topUp([ + static Future topUp({ TopupVirtualRequest? request, - ]) async { + String? loginId, + }) async { final TopupVirtualReceive response = await _api.call( - request: request ?? const TopupVirtualRequest(), + request: request?.copyWith(loginid: loginId) ?? + TopupVirtualRequest(loginid: loginId), ); checkException( @@ -79,6 +82,7 @@ class TopupVirtualResponse extends TopupVirtualResponseModel { topupVirtual: topupVirtual ?? this.topupVirtual, ); } + /// Topup virtual model class. abstract class TopupVirtualModel { /// Initializes Topup virtual model class . diff --git a/lib/basic_api/generated/methods/topup_virtual_receive_methods.json b/lib/basic_api/generated/methods/topup_virtual_receive_methods.json index be41a59d85..7f44e71a7c 100644 --- a/lib/basic_api/generated/methods/topup_virtual_receive_methods.json +++ b/lib/basic_api/generated/methods/topup_virtual_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Topes up the virtual-money's account balance becomes when it becomes low.\n ///\n /// For parameters information refer to [TopupVirtualRequest].\n /// Throws a [BaseAPIException] if API response contains an error\n static Future topUp([\n TopupVirtualRequest? request,\n ]) async {\n final TopupVirtualReceive response = await _api.call(\n request: request ?? const TopupVirtualRequest(),\n );\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return TopupVirtualResponse.fromJson(response.topupVirtual);\n }", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Topes up the virtual-money's account balance becomes when it becomes low.\n ///\n /// For parameters information refer to [TopupVirtualRequest].\n /// Throws a [BaseAPIException] if API response contains an error\n static Future topUp({\n TopupVirtualRequest? request,\n String? loginId, \n}) async {\n final TopupVirtualReceive response = await _api.call(\n request: request?.copyWith(loginid: loginId) ?? TopupVirtualRequest(loginid: loginId),\n );\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return TopupVirtualResponse.fromJson(response.topupVirtual);\n }", "imports": "import 'package:flutter_deriv_api/api/exceptions/exceptions.dart';\nimport 'package:flutter_deriv_api/api/models/base_exception_model.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/topup_virtual_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/topup_virtual_send.dart';\nimport 'package:flutter_deriv_api/helpers/helpers.dart';\nimport 'package:flutter_deriv_api/services/connection/api_manager/base_api.dart';\nimport 'package:deriv_dependency_injector/dependency_injector.dart';\n" } diff --git a/test/api/account/account_status/account_status_test.dart b/test/api/account/account_status/account_status_test.dart index 508df18eba..3a7694bf0e 100644 --- a/test/api/account/account_status/account_status_test.dart +++ b/test/api/account/account_status/account_status_test.dart @@ -11,7 +11,7 @@ void main() { test('Account Status Test', () async { final GetAccountStatusResponse accountStatus = - await GetAccountStatusResponse.fetchAccountStatus(loginId: 'CR12345'); + await GetAccountStatusResponse.fetchAccountStatus(); expect(accountStatus.getAccountStatus?.currencyConfig.length, 1); expect(accountStatus.getAccountStatus?.currencyConfig.keys.first, 'USD'); From 511c5cde9bb4f007bbe3b5485eff8c33800e6c2c Mon Sep 17 00:00:00 2001 From: akhil-deriv Date: Mon, 1 Jul 2024 12:46:56 +0400 Subject: [PATCH 5/6] updated contract details API calls --- .../proposal_open_contract_response_result.dart | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/api/response/proposal_open_contract_response_result.dart b/lib/api/response/proposal_open_contract_response_result.dart index 99e37ca790..56951c50fa 100644 --- a/lib/api/response/proposal_open_contract_response_result.dart +++ b/lib/api/response/proposal_open_contract_response_result.dart @@ -1,5 +1,6 @@ // ignore_for_file: prefer_single_quotes, unnecessary_import, unused_import +import 'package:build/build.dart'; import 'package:equatable/equatable.dart'; import 'package:flutter_deriv_api/api/exceptions/exceptions.dart'; @@ -163,14 +164,21 @@ class ProposalOpenContractResponse extends ProposalOpenContractResponseModel { /// Default be 0 for 'sell at market'. /// Throws a [BaseAPIException] if API response contains an error static Future sell( - {required int contractId, double price = 0}) => - SellResponse.sellContract(SellRequest(sell: contractId, price: price)); + {required int contractId, double price = 0, String? loginId}) => + SellResponse.sellContract(SellRequest( + sell: contractId, + price: price, + loginid: loginId, + )); /// Cancels this contract /// /// Throws a [BaseAPIException] if API response contains an error - static Future cancel(int contractId) => - CancelResponse.cancelContract(CancelRequest(cancel: contractId)); + static Future cancel(int contractId, {String? loginId}) => + CancelResponse.cancelContract(CancelRequest( + cancel: contractId, + loginid: loginId, + )); /// Creates a copy of instance with given parameters. ProposalOpenContractResponse copyWith({ From 17e59cb58a461f8fe4dbaa92dde884f651e7072b Mon Sep 17 00:00:00 2001 From: akhil-deriv Date: Fri, 5 Jul 2024 00:01:22 +0400 Subject: [PATCH 6/6] removed unnecessary import --- lib/api/response/proposal_open_contract_response_result.dart | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/api/response/proposal_open_contract_response_result.dart b/lib/api/response/proposal_open_contract_response_result.dart index 56951c50fa..b54825f943 100644 --- a/lib/api/response/proposal_open_contract_response_result.dart +++ b/lib/api/response/proposal_open_contract_response_result.dart @@ -1,8 +1,5 @@ // ignore_for_file: prefer_single_quotes, unnecessary_import, unused_import - -import 'package:build/build.dart'; import 'package:equatable/equatable.dart'; - import 'package:flutter_deriv_api/api/exceptions/exceptions.dart'; import 'package:flutter_deriv_api/api/models/base_exception_model.dart'; import 'package:flutter_deriv_api/api/models/enums.dart';