diff --git a/analysis_options.yaml b/analysis_options.yaml index b949a79255..b8565f8cb7 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -2,9 +2,9 @@ analyzer: exclude: - lib/basic_api/generated/api.dart - strong-mode: - implicit-dynamic: false - + language: + strict-raw-types: true + errors: todo: ignore missing_required_param: warning @@ -92,7 +92,6 @@ linter: - prefer_const_literals_to_create_immutables - prefer_constructors_over_static_methods - prefer_contains - - prefer_equal_for_default_values - prefer_expression_function_bodies # https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#consider-using--for-short-functions-and-methods - prefer_final_fields - prefer_final_in_for_each diff --git a/android/build.gradle b/android/build.gradle index a1d9341b0f..aa8bae7a4b 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -2,14 +2,14 @@ group 'com.deriv.flutter_deriv_api' version '1.0-SNAPSHOT' buildscript { - ext.kotlin_version = '1.3.50' + ext.kotlin_version = '1.7.10' repositories { google() jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.5.0' + classpath 'com.android.tools.build:gradle:7.3.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index 019065d1d6..ceccc3a854 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip diff --git a/api_builder.dart b/api_builder.dart index 8871a141b5..d6fe0154b4 100644 --- a/api_builder.dart +++ b/api_builder.dart @@ -122,8 +122,8 @@ class APIBuilder extends Builder { /// Initialize $classFullName. const $classFullName({ ${_getConstructorParameters(methodName, schema, schemaType, properties)} - ${_getSuperClassParameters(schemaType)}, - }): super(${_getSuperClassCallParameters(schemaType, methodName)},); + ${_getSuperClassConstructorParameters(schemaType, methodName)}, + }); ${_getFromJsonMethod(classFullName, schema, schemaType, properties)} @@ -169,6 +169,7 @@ class APIBuilder extends Builder { return '${_isFieldRequired(key, schemaType, property) ? 'required ' : ''} this.${ReCase(key).camelCase}'; }, ).join(', '); + return fields.isEmpty ? result : '$result , '; } @@ -380,6 +381,7 @@ class APIBuilder extends Builder { fields.map( (String key) { final String name = ReCase(key).camelCase; + return '$name: $name ?? this.$name'; }, ).join(', '), @@ -388,40 +390,45 @@ class APIBuilder extends Builder { ..write('${_getSupperClassAssignments(schemaType)},);'); } - static String _getSuperClassParameters(String? schemaType) { + static String _getSuperClassParameters(String schemaType) { final Map superClassFields = _getSuperClassFields(schemaType); - return superClassFields.keys - .map((String key) => - '${typeMap[superClassFields[key]!]} ${ReCase(key).camelCase}') - .join(', '); + final Iterable parameters = superClassFields.keys.map((String key) { + final String type = typeMap[superClassFields[key]!] ?? 'dynamic'; + final String parameterName = ReCase(key).camelCase; + + return '$type $parameterName'; + }); + + return parameters.join(', '); } - static String _getSuperClassCallParameters( + static String _getSuperClassConstructorParameters( String schemaType, String methodName, ) { - final StringBuffer superCallParameters = StringBuffer(); + final Map superClassFields = + _getSuperClassFields(schemaType); + final StringBuffer superClassParameters = StringBuffer(); if (schemaType == 'send') { - superCallParameters.write('msgType: \'$methodName\','); + superClassParameters.write('super.msgType = \'$methodName\', '); } - superCallParameters.write(_getSuperClassFields(schemaType).keys.map( - (String key) { - final String parameterName = ReCase(key).camelCase; - return '$parameterName: $parameterName'; - }, - ).join(', ')); + final Iterable parameters = superClassFields.keys + .map((String key) => 'super.${ReCase(key).camelCase}'); - return superCallParameters.toString(); + superClassParameters.write(parameters.join(', ')); + + return superClassParameters.toString(); } static String _getSupperClassAssignments(String schemaType) => _getSuperClassFields(schemaType).keys.map( (String key) { final String propertyName = ReCase(key).camelCase; + return '$propertyName: $propertyName ?? this.$propertyName'; }, ).join(', '); @@ -458,7 +465,7 @@ class APIBuilder extends Builder { } } -class GeneratedResponseJson extends Comparable { +class GeneratedResponseJson implements Comparable { GeneratedResponseJson({ this.msgType, this.fileName, diff --git a/binary-websocket-api b/binary-websocket-api index 815af08a17..4a2ead83f9 160000 --- a/binary-websocket-api +++ b/binary-websocket-api @@ -1 +1 @@ -Subproject commit 815af08a17a6f3933923fc45d2f0f125721d57ed +Subproject commit 4a2ead83f9323d0b8bfe762710b2898060a9c98f diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index fad92a4f20..94759d7825 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -26,7 +26,7 @@ apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion 28 + compileSdkVersion 33 sourceSets { main.java.srcDirs += 'src/main/kotlin' diff --git a/example/android/build.gradle b/example/android/build.gradle index 3100ad2d55..e0e4f0a765 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -1,12 +1,12 @@ buildscript { - ext.kotlin_version = '1.3.50' + ext.kotlin_version = '1.7.10' repositories { google() jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.5.0' + classpath 'com.android.tools.build:gradle:7.3.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } @@ -26,6 +26,6 @@ subprojects { project.evaluationDependsOn(':app') } -task clean(type: Delete) { +tasks.register("clean", Delete) { delete rootProject.buildDir } diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties index 296b146b73..cfe88f6904 100644 --- a/example/android/gradle/wrapper/gradle-wrapper.properties +++ b/example/android/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip diff --git a/example/lib/blocs/active_symbols/active_symbols_bloc.dart b/example/lib/blocs/active_symbols/active_symbols_bloc.dart index 10201adfb5..0d28ae0db2 100644 --- a/example/lib/blocs/active_symbols/active_symbols_bloc.dart +++ b/example/lib/blocs/active_symbols/active_symbols_bloc.dart @@ -11,31 +11,40 @@ part 'active_symbols_state.dart'; /// ActiveSymbolsBloc class ActiveSymbolsBloc extends Bloc { /// ActiveSymbolsBloc initializer - ActiveSymbolsBloc() : super(ActiveSymbolsLoading()); - - @override - Stream mapEventToState(ActiveSymbolsEvent event) async* { - if (event is FetchActiveSymbols) { - yield ActiveSymbolsLoading(); - - try { - final ActiveSymbolsResponse symbols = await _fetchActiveSymbols(); - yield ActiveSymbolsLoaded(activeSymbols: symbols.activeSymbols!); - } on ActiveSymbolsException catch (error) { - yield ActiveSymbolsError(error.message); - } - } else if (event is SelectActiveSymbol) { - if (state is ActiveSymbolsLoaded) { - final ActiveSymbolsLoaded loadedState = state as ActiveSymbolsLoaded; - - yield ActiveSymbolsLoaded( - activeSymbols: loadedState.activeSymbols, - selectedSymbol: loadedState.activeSymbols[event.index], - ); - } else { - yield ActiveSymbolsLoading(); - add(FetchActiveSymbols()); - } + ActiveSymbolsBloc() : super(ActiveSymbolsLoading()) { + on( + (FetchActiveSymbols event, Emitter emit) => + _handleFetchActiveSymbols(event, emit)); + + on( + (SelectActiveSymbol event, Emitter emit) => + _handleSelectActiveSymbol(event, emit)); + } + + Future _handleFetchActiveSymbols( + FetchActiveSymbols event, Emitter emit) async { + emit(ActiveSymbolsLoading()); + + try { + final ActiveSymbolsResponse symbols = await _fetchActiveSymbols(); + emit(ActiveSymbolsLoaded(activeSymbols: symbols.activeSymbols!)); + } on BaseAPIException catch (error) { + emit(ActiveSymbolsError(error.message)); + } + } + + Future _handleSelectActiveSymbol( + SelectActiveSymbol event, Emitter emit) async { + if (state is ActiveSymbolsLoaded) { + final ActiveSymbolsLoaded loadedState = state as ActiveSymbolsLoaded; + + emit(ActiveSymbolsLoaded( + activeSymbols: loadedState.activeSymbols, + selectedSymbol: loadedState.activeSymbols[event.index], + )); + } else { + emit(ActiveSymbolsLoading()); + add(FetchActiveSymbols()); } } diff --git a/example/lib/blocs/available_contracts/available_contracts_bloc.dart b/example/lib/blocs/available_contracts/available_contracts_bloc.dart index a9a4dfc211..47e631784a 100644 --- a/example/lib/blocs/available_contracts/available_contracts_bloc.dart +++ b/example/lib/blocs/available_contracts/available_contracts_bloc.dart @@ -26,36 +26,47 @@ class AvailableContractsBloc ); } }); + + on((FetchAvailableContracts event, + Emitter emit) => + _handleFetchAvailableContracts(event, emit)); + + on( + (SelectContract event, Emitter emit) => + _handleSelectContract(event, emit)); } - @override - Stream mapEventToState( - AvailableContractsEvent event, - ) async* { - if (event is FetchAvailableContracts) { - yield AvailableContractsLoading(); + Future _handleFetchAvailableContracts( + FetchAvailableContracts event, + Emitter emit, + ) async { + emit(AvailableContractsLoading()); - try { - final ContractsForResponse contracts = - await _fetchAvailableContracts(event.activeSymbol); + try { + final ContractsForResponse contracts = + await _fetchAvailableContracts(event.activeSymbol); - yield AvailableContractsLoaded(contracts: contracts.contractsFor!); - } on ContractsForSymbolException catch (error) { - yield AvailableContractsError(error.message); - } - } else if (event is SelectContract) { - if (state is AvailableContractsLoaded) { - final AvailableContractsLoaded loadedState = - state as AvailableContractsLoaded; + emit(AvailableContractsLoaded(contracts: contracts.contractsFor!)); + } on BaseAPIException catch (error) { + emit(AvailableContractsError(error.message)); + } + } - yield AvailableContractsLoaded( - contracts: loadedState.contracts, - selectedContract: loadedState.contracts.available[event.index], - ); - } else { - yield AvailableContractsLoading(); - add(FetchAvailableContracts()); - } + void _handleSelectContract( + SelectContract event, + Emitter emit, + ) { + if (state is AvailableContractsLoaded) { + final AvailableContractsLoaded loadedState = + state as AvailableContractsLoaded; + + emit(AvailableContractsLoaded( + contracts: loadedState.contracts, + selectedContract: loadedState.contracts.available[event.index], + )); + } else { + emit(AvailableContractsLoading()); + add(FetchAvailableContracts()); } } diff --git a/example/lib/blocs/price_proposal/price_proposal_bloc.dart b/example/lib/blocs/price_proposal/price_proposal_bloc.dart index 60320abc7e..485478b58c 100644 --- a/example/lib/blocs/price_proposal/price_proposal_bloc.dart +++ b/example/lib/blocs/price_proposal/price_proposal_bloc.dart @@ -22,28 +22,33 @@ class PriceProposalBloc extends Bloc { add(SubscribeProposal(state.selectedContract)); } }); + + on( + (SubscribeProposal event, Emitter emit) => + _handleSubscribeProposal(event, emit)); + + on( + (YieldProposalLoaded event, Emitter emit) => + emit(PriceProposalLoaded(event.proposal.proposal))); + + on((YieldError event, Emitter emit) => + emit(PriceProposalError(event.message))); } - @override - Stream mapEventToState( - PriceProposalEvent event, - ) async* { - if (event is SubscribeProposal) { - yield PriceProposalLoading(); + Future _handleSubscribeProposal( + SubscribeProposal event, + Emitter emit, + ) async { + emit(PriceProposalLoading()); - await _unsubscribeProposal(); + await _unsubscribeProposal(); - _subscribeProposal(event) - .handleError((dynamic error) => error is ContractOperationException - ? add(YieldError(error.message)) - : add(YieldError(error.toString()))) - .listen((ProposalResponse? proposal) => - add(YieldProposalLoaded(proposal!))); - } else if (event is YieldProposalLoaded) { - yield PriceProposalLoaded(event.proposal.proposal); - } else if (event is YieldError) { - yield PriceProposalError(event.message); - } + _subscribeProposal(event) + .handleError((dynamic error) => error is BaseAPIException + ? add(YieldError(error.message)) + : add(YieldError(error.toString()))) + .listen((ProposalResponse? proposal) => + add(YieldProposalLoaded(proposal!))); } Stream _subscribeProposal(SubscribeProposal event) => diff --git a/example/lib/blocs/ticks/ticks_bloc.dart b/example/lib/blocs/ticks/ticks_bloc.dart index 14b4b067da..742dcdbc06 100644 --- a/example/lib/blocs/ticks/ticks_bloc.dart +++ b/example/lib/blocs/ticks/ticks_bloc.dart @@ -22,27 +22,28 @@ class TicksBloc extends Bloc { add(SubscribeTicks(activeSymbolsState.selectedSymbol)); } }); + + on((SubscribeTicks event, Emitter emit) => + _handleSubscribeTicks(event, emit)); + + on((YieldTick event, Emitter emit) => + emit(TicksLoaded(event.tick?.tick))); + + on((YieldError event, Emitter emit) => + emit(TicksError(event.message))); } - @override - Stream mapEventToState( - TicksEvent event, - ) async* { - if (event is SubscribeTicks) { - yield TicksLoading(); - - await _unsubscribeTick(); - - _subscribeTick(event.selectedSymbol!) - .handleError((dynamic error) => error is TickException - ? add(YieldError(error.message)) - : add(YieldError(error.toString()))) - .listen((TicksResponse? tick) => add(YieldTick(tick))); - } else if (event is YieldTick) { - yield TicksLoaded(event.tick?.tick); - } else if (event is YieldError) { - yield TicksError(event.message); - } + Future _handleSubscribeTicks( + SubscribeTicks event, Emitter emit) async { + emit(TicksLoading()); + + await _unsubscribeTick(); + + _subscribeTick(event.selectedSymbol!) + .handleError((dynamic error) => error is BaseAPIException + ? add(YieldError(error.message)) + : add(YieldError(error.toString()))) + .listen((TicksResponse? tick) => add(YieldTick(tick))); } Stream _subscribeTick(ActiveSymbolsItem selectedSymbol) => diff --git a/example/lib/sample_app.dart b/example/lib/sample_app.dart index 19286bf8e3..a3799bfe71 100644 --- a/example/lib/sample_app.dart +++ b/example/lib/sample_app.dart @@ -24,6 +24,7 @@ class _SampleAppState extends State { appId: '1089', brand: 'binary', endpoint: 'frontend.binaryws.com', + authEndpoint: '', ), ); } diff --git a/example/pubspec.yaml b/example/pubspec.yaml index e3f31c3d38..7839397ea0 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -3,14 +3,15 @@ description: Demonstrates how to use the flutter_deriv_api plugin. publish_to: "none" environment: - sdk: ">=2.12.0 <3.0.0" + sdk: ">=3.0.0" + flutter: "3.10.2" dependencies: flutter: sdk: flutter - rxdart: ^0.27.4 - flutter_bloc: ^7.0.0 + rxdart: ^0.27.7 + flutter_bloc: ^8.1.2 dev_dependencies: flutter_test: diff --git a/lib/api/exceptions/account_currency_exception.dart b/lib/api/exceptions/account_currency_exception.dart deleted file mode 100644 index db459fb8ee..0000000000 --- a/lib/api/exceptions/account_currency_exception.dart +++ /dev/null @@ -1,11 +0,0 @@ -import 'package:flutter_deriv_api/api/models/base_exception_model.dart'; - -import 'account_exception.dart'; - -/// Account currency exception class -class AccountCurrencyException extends AccountException { - /// Initializes - AccountCurrencyException({ - BaseExceptionModel? baseExceptionModel, - }) : super(baseExceptionModel: baseExceptionModel); -} diff --git a/lib/api/exceptions/account_exception.dart b/lib/api/exceptions/account_exception.dart deleted file mode 100644 index 3086fc8bd8..0000000000 --- a/lib/api/exceptions/account_exception.dart +++ /dev/null @@ -1,10 +0,0 @@ -import 'package:flutter_deriv_api/api/exceptions/api_base_exception.dart'; -import 'package:flutter_deriv_api/api/models/base_exception_model.dart'; - -/// Account exception -class AccountException extends APIBaseException { - /// Initializes - AccountException({ - BaseExceptionModel? baseExceptionModel, - }) : super(baseExceptionModel: baseExceptionModel); -} diff --git a/lib/api/exceptions/account_limits_exception.dart b/lib/api/exceptions/account_limits_exception.dart deleted file mode 100644 index 57d2b5d937..0000000000 --- a/lib/api/exceptions/account_limits_exception.dart +++ /dev/null @@ -1,11 +0,0 @@ -import 'package:flutter_deriv_api/api/models/base_exception_model.dart'; - -import 'account_exception.dart'; - -/// Account limits exception class -class AccountLimitsException extends AccountException { - /// Initializes - AccountLimitsException({ - BaseExceptionModel? baseExceptionModel, - }) : super(baseExceptionModel: baseExceptionModel); -} diff --git a/lib/api/exceptions/account_settings_exception.dart b/lib/api/exceptions/account_settings_exception.dart deleted file mode 100644 index 1c889a4d16..0000000000 --- a/lib/api/exceptions/account_settings_exception.dart +++ /dev/null @@ -1,11 +0,0 @@ -import 'package:flutter_deriv_api/api/models/base_exception_model.dart'; - -import 'account_exception.dart'; - -/// Account settings exception class -class AccountSettingsException extends AccountException { - /// Initializes - AccountSettingsException({ - BaseExceptionModel? baseExceptionModel, - }) : super(baseExceptionModel: baseExceptionModel); -} diff --git a/lib/api/exceptions/account_status_exception.dart b/lib/api/exceptions/account_status_exception.dart deleted file mode 100644 index 9ef720b435..0000000000 --- a/lib/api/exceptions/account_status_exception.dart +++ /dev/null @@ -1,11 +0,0 @@ -import 'package:flutter_deriv_api/api/models/base_exception_model.dart'; - -import 'account_exception.dart'; - -/// Exception class for account status calls -class AccountStatusException extends AccountException { - /// Initializes - AccountStatusException({ - BaseExceptionModel? baseExceptionModel, - }) : super(baseExceptionModel: baseExceptionModel); -} diff --git a/lib/api/exceptions/active_symbols_exception.dart b/lib/api/exceptions/active_symbols_exception.dart deleted file mode 100644 index f2477da035..0000000000 --- a/lib/api/exceptions/active_symbols_exception.dart +++ /dev/null @@ -1,11 +0,0 @@ -import 'package:flutter_deriv_api/api/models/base_exception_model.dart'; - -import 'common_exception.dart'; - -/// Exception for active symbols request call -class ActiveSymbolsException extends CommonException { - /// Initializes - ActiveSymbolsException({ - BaseExceptionModel? baseExceptionModel, - }) : super(baseExceptionModel: baseExceptionModel); -} diff --git a/lib/api/exceptions/api_token_exception.dart b/lib/api/exceptions/api_token_exception.dart deleted file mode 100644 index 8798f6c162..0000000000 --- a/lib/api/exceptions/api_token_exception.dart +++ /dev/null @@ -1,11 +0,0 @@ -import 'package:flutter_deriv_api/api/models/base_exception_model.dart'; - -import 'account_exception.dart'; - -/// Api token exception class -class APITokenException extends AccountException { - /// Initializes - APITokenException({ - BaseExceptionModel? baseExceptionModel, - }) : super(baseExceptionModel: baseExceptionModel); -} diff --git a/lib/api/exceptions/app_exception.dart b/lib/api/exceptions/app_exception.dart deleted file mode 100644 index 8544e702e4..0000000000 --- a/lib/api/exceptions/app_exception.dart +++ /dev/null @@ -1,10 +0,0 @@ -import 'package:flutter_deriv_api/api/exceptions/api_base_exception.dart'; -import 'package:flutter_deriv_api/api/models/base_exception_model.dart'; - -/// App exception -class AppException extends APIBaseException { - /// Initializes - AppException({ - BaseExceptionModel? baseExceptionModel, - }) : super(baseExceptionModel: baseExceptionModel); -} diff --git a/lib/api/exceptions/asset_index_exception.dart b/lib/api/exceptions/asset_index_exception.dart deleted file mode 100644 index b274275b31..0000000000 --- a/lib/api/exceptions/asset_index_exception.dart +++ /dev/null @@ -1,11 +0,0 @@ -import 'package:flutter_deriv_api/api/models/base_exception_model.dart'; - -import 'common_exception.dart'; - -/// Exception class for asset index -class AssetIndexException extends CommonException { - /// Initializes - AssetIndexException({ - BaseExceptionModel? baseExceptionModel, - }) : super(baseExceptionModel: baseExceptionModel); -} diff --git a/lib/api/exceptions/authorize_exception.dart b/lib/api/exceptions/authorize_exception.dart deleted file mode 100644 index a2f05241f4..0000000000 --- a/lib/api/exceptions/authorize_exception.dart +++ /dev/null @@ -1,11 +0,0 @@ -import 'package:flutter_deriv_api/api/models/base_exception_model.dart'; - -import 'account_exception.dart'; - -/// Authorize exception class -class AuthorizeException extends AccountException { - /// Initializes - AuthorizeException({ - BaseExceptionModel? baseExceptionModel, - }) : super(baseExceptionModel: baseExceptionModel); -} diff --git a/lib/api/exceptions/balance_exception.dart b/lib/api/exceptions/balance_exception.dart deleted file mode 100644 index e53535ed79..0000000000 --- a/lib/api/exceptions/balance_exception.dart +++ /dev/null @@ -1,11 +0,0 @@ -import 'package:flutter_deriv_api/api/models/base_exception_model.dart'; - -import 'account_exception.dart'; - -/// Balance exception class -class BalanceException extends AccountException { - /// Initializes - BalanceException({ - BaseExceptionModel? baseExceptionModel, - }) : super(baseExceptionModel: baseExceptionModel); -} diff --git a/lib/api/exceptions/api_base_exception.dart b/lib/api/exceptions/base_api_exception.dart similarity index 73% rename from lib/api/exceptions/api_base_exception.dart rename to lib/api/exceptions/base_api_exception.dart index 36f6508ddf..3883ef6e44 100644 --- a/lib/api/exceptions/api_base_exception.dart +++ b/lib/api/exceptions/base_api_exception.dart @@ -3,11 +3,9 @@ import 'dart:developer' as dev; import 'package:flutter_deriv_api/api/models/base_exception_model.dart'; /// Base exception class for all API exceptions. -class APIBaseException implements Exception { - /// Initializes - APIBaseException({ - required this.baseExceptionModel, - }); +class BaseAPIException implements Exception { + /// Initializes an exception with the given [baseExceptionModel]. + BaseAPIException({required this.baseExceptionModel}); /// Exception code and message model from API response. final BaseExceptionModel? baseExceptionModel; @@ -23,9 +21,7 @@ class APIBaseException implements Exception { @override String toString() { - dev.log( - '$runtimeType(code: $code, message: $message)', - ); + dev.log('$runtimeType(code: $code, message: $message)'); return message ?? '$runtimeType: API unknown error.'; } diff --git a/lib/api/exceptions/cashier_exception.dart b/lib/api/exceptions/cashier_exception.dart deleted file mode 100644 index 8391a2c276..0000000000 --- a/lib/api/exceptions/cashier_exception.dart +++ /dev/null @@ -1,10 +0,0 @@ -import 'package:flutter_deriv_api/api/exceptions/api_base_exception.dart'; -import 'package:flutter_deriv_api/api/models/base_exception_model.dart'; - -/// Cashier exception -class CashierException extends APIBaseException { - /// Initializes - CashierException({ - BaseExceptionModel? baseExceptionModel, - }) : super(baseExceptionModel: baseExceptionModel); -} diff --git a/lib/api/exceptions/common_exception.dart b/lib/api/exceptions/common_exception.dart deleted file mode 100644 index 8d73514a82..0000000000 --- a/lib/api/exceptions/common_exception.dart +++ /dev/null @@ -1,10 +0,0 @@ -import 'package:flutter_deriv_api/api/exceptions/api_base_exception.dart'; -import 'package:flutter_deriv_api/api/models/base_exception_model.dart'; - -/// Common exception -class CommonException extends APIBaseException { - /// Initializes - CommonException({ - BaseExceptionModel? baseExceptionModel, - }) : super(baseExceptionModel: baseExceptionModel); -} diff --git a/lib/api/exceptions/contract_exception.dart b/lib/api/exceptions/contract_exception.dart deleted file mode 100644 index 9e25eb8559..0000000000 --- a/lib/api/exceptions/contract_exception.dart +++ /dev/null @@ -1,10 +0,0 @@ -import 'package:flutter_deriv_api/api/exceptions/api_base_exception.dart'; -import 'package:flutter_deriv_api/api/models/base_exception_model.dart'; - -/// Contract exception class -class ContractException extends APIBaseException { - /// Initializes - ContractException({ - BaseExceptionModel? baseExceptionModel, - }) : super(baseExceptionModel: baseExceptionModel); -} diff --git a/lib/api/exceptions/contract_for_symbol_exception.dart b/lib/api/exceptions/contract_for_symbol_exception.dart deleted file mode 100644 index d193b58930..0000000000 --- a/lib/api/exceptions/contract_for_symbol_exception.dart +++ /dev/null @@ -1,10 +0,0 @@ -import 'package:flutter_deriv_api/api/exceptions/contract_exception.dart'; -import 'package:flutter_deriv_api/api/models/base_exception_model.dart'; - -/// Exception for contract for symbol request call -class ContractsForSymbolException extends ContractException { - /// Initializes - ContractsForSymbolException({ - BaseExceptionModel? baseExceptionModel, - }) : super(baseExceptionModel: baseExceptionModel); -} diff --git a/lib/api/exceptions/contract_operations_exception.dart b/lib/api/exceptions/contract_operations_exception.dart deleted file mode 100644 index bdcd3a3285..0000000000 --- a/lib/api/exceptions/contract_operations_exception.dart +++ /dev/null @@ -1,10 +0,0 @@ -import 'package:flutter_deriv_api/api/exceptions/contract_exception.dart'; -import 'package:flutter_deriv_api/api/models/base_exception_model.dart'; - -/// Exception for price proposal request calls -class ContractOperationException extends ContractException { - /// Initializes - ContractOperationException({ - BaseExceptionModel? baseExceptionModel, - }) : super(baseExceptionModel: baseExceptionModel); -} diff --git a/lib/api/exceptions/copy_trading_exception.dart b/lib/api/exceptions/copy_trading_exception.dart deleted file mode 100644 index 970e2dbb2d..0000000000 --- a/lib/api/exceptions/copy_trading_exception.dart +++ /dev/null @@ -1,11 +0,0 @@ -import 'package:flutter_deriv_api/api/models/base_exception_model.dart'; - -import 'account_exception.dart'; - -/// Exception for CopyTrading -class CopyTradingException extends AccountException { - /// Initializes - CopyTradingException({ - BaseExceptionModel? baseExceptionModel, - }) : super(baseExceptionModel: baseExceptionModel); -} diff --git a/lib/api/exceptions/exceptions.dart b/lib/api/exceptions/exceptions.dart index 82d3e82e47..805351f3c9 100644 --- a/lib/api/exceptions/exceptions.dart +++ b/lib/api/exceptions/exceptions.dart @@ -1,52 +1,2 @@ export '../models/base_exception_model.dart'; -export 'account_currency_exception.dart'; -export 'account_exception.dart'; -export 'account_limits_exception.dart'; -export 'account_settings_exception.dart'; -export 'account_status_exception.dart'; -export 'active_symbols_exception.dart'; -export 'api_base_exception.dart'; -export 'api_token_exception.dart'; -export 'app_exception.dart'; -export 'asset_index_exception.dart'; -export 'authorize_exception.dart'; -export 'balance_exception.dart'; -export 'cashier_exception.dart'; -export 'common_exception.dart'; -export 'contract_exception.dart'; -export 'contract_for_symbol_exception.dart'; -export 'contract_operations_exception.dart'; -export 'copy_trading_exception.dart'; -export 'exchange_exception.dart'; -export 'financial_assessment_exception.dart'; -export 'forget_exception.dart'; -export 'landing_company_exception.dart'; -export 'mt5_exception.dart'; -export 'new_account_exception.dart'; -export 'p2p_advert_exception.dart'; -export 'p2p_advert_exception.dart'; -export 'p2p_advertiser_exception.dart'; -export 'p2p_advertiser_stats_exception.dart'; -export 'p2p_chat_exception.dart'; -export 'p2p_exception.dart'; -export 'p2p_order_exception.dart'; -export 'payment_agent_exception.dart'; -export 'payment_exception.dart'; -export 'payout_currency_exception.dart'; -export 'ping_exception.dart'; -export 'portfolio_exception.dart'; -export 'profit_table_exception.dart'; -export 'reality_check_exception.dart'; -export 'residence_exception.dart'; -export 'self_exclusion_exception.dart'; -export 'server_time_exception.dart'; -export 'state_exception.dart'; -export 'statement_exception.dart'; -export 'tick_exception.dart'; -export 'top_up_virtual_exception.dart'; -export 'trading_exception.dart'; -export 'trading_platform_exception.dart'; -export 'transactions_exception.dart'; -export 'transfer_exception.dart'; -export 'user_exception.dart'; -export 'website_status_exception.dart'; +export 'base_api_exception.dart'; diff --git a/lib/api/exceptions/exchange_exception.dart b/lib/api/exceptions/exchange_exception.dart deleted file mode 100644 index 975800095c..0000000000 --- a/lib/api/exceptions/exchange_exception.dart +++ /dev/null @@ -1,11 +0,0 @@ -import 'package:flutter_deriv_api/api/models/base_exception_model.dart'; - -import 'common_exception.dart'; - -/// Exchange exception class -class ExchangeException extends CommonException { - /// Initializes - ExchangeException({ - BaseExceptionModel? baseExceptionModel, - }) : super(baseExceptionModel: baseExceptionModel); -} diff --git a/lib/api/exceptions/financial_assessment_exception.dart b/lib/api/exceptions/financial_assessment_exception.dart deleted file mode 100644 index 256b0fa4e7..0000000000 --- a/lib/api/exceptions/financial_assessment_exception.dart +++ /dev/null @@ -1,11 +0,0 @@ -import 'package:flutter_deriv_api/api/models/base_exception_model.dart'; - -import 'user_exception.dart'; - -/// Financial assessment exception class -class FinancialAssessmentException extends UserException { - /// Initializes - FinancialAssessmentException({ - BaseExceptionModel? baseExceptionModel, - }) : super(baseExceptionModel: baseExceptionModel); -} diff --git a/lib/api/exceptions/forget_exception.dart b/lib/api/exceptions/forget_exception.dart deleted file mode 100644 index 4f0ee63bb7..0000000000 --- a/lib/api/exceptions/forget_exception.dart +++ /dev/null @@ -1,11 +0,0 @@ -import 'package:flutter_deriv_api/api/models/base_exception_model.dart'; - -import 'common_exception.dart'; - -/// Forget exception class -class ForgetException extends CommonException { - /// Initializes - ForgetException({ - BaseExceptionModel? baseExceptionModel, - }) : super(baseExceptionModel: baseExceptionModel); -} diff --git a/lib/api/exceptions/landing_company_exception.dart b/lib/api/exceptions/landing_company_exception.dart deleted file mode 100644 index 3afb5e6b12..0000000000 --- a/lib/api/exceptions/landing_company_exception.dart +++ /dev/null @@ -1,11 +0,0 @@ -import 'package:flutter_deriv_api/api/models/base_exception_model.dart'; - -import 'common_exception.dart'; - -/// Exception class for Landing company -class LandingCompanyException extends CommonException { - /// Initializes - LandingCompanyException({ - BaseExceptionModel? baseExceptionModel, - }) : super(baseExceptionModel: baseExceptionModel); -} diff --git a/lib/api/exceptions/mt5_exception.dart b/lib/api/exceptions/mt5_exception.dart deleted file mode 100644 index 0885e8abfd..0000000000 --- a/lib/api/exceptions/mt5_exception.dart +++ /dev/null @@ -1,10 +0,0 @@ -import 'package:flutter_deriv_api/api/exceptions/api_base_exception.dart'; -import 'package:flutter_deriv_api/api/models/base_exception_model.dart'; - -/// MT5 exception class -class MT5Exception extends APIBaseException { - /// Initializes - MT5Exception({ - BaseExceptionModel? baseExceptionModel, - }) : super(baseExceptionModel: baseExceptionModel); -} diff --git a/lib/api/exceptions/new_account_exception.dart b/lib/api/exceptions/new_account_exception.dart deleted file mode 100644 index 4fc47a5760..0000000000 --- a/lib/api/exceptions/new_account_exception.dart +++ /dev/null @@ -1,11 +0,0 @@ -import 'package:flutter_deriv_api/api/models/base_exception_model.dart'; - -import 'app_exception.dart'; - -/// New account exception -class NewAccountException extends AppException { - /// Initializes - NewAccountException({ - BaseExceptionModel? baseExceptionModel, - }) : super(baseExceptionModel: baseExceptionModel); -} diff --git a/lib/api/exceptions/p2p_advert_exception.dart b/lib/api/exceptions/p2p_advert_exception.dart deleted file mode 100644 index 9333868d67..0000000000 --- a/lib/api/exceptions/p2p_advert_exception.dart +++ /dev/null @@ -1,11 +0,0 @@ -import 'package:flutter_deriv_api/api/models/base_exception_model.dart'; - -import 'p2p_exception.dart'; - -/// P2P advert exception class -class P2PAdvertException extends P2PException { - /// Initializes - P2PAdvertException({ - BaseExceptionModel? baseExceptionModel, - }) : super(baseExceptionModel: baseExceptionModel); -} diff --git a/lib/api/exceptions/p2p_advertiser_exception.dart b/lib/api/exceptions/p2p_advertiser_exception.dart deleted file mode 100644 index 4be8f458dc..0000000000 --- a/lib/api/exceptions/p2p_advertiser_exception.dart +++ /dev/null @@ -1,11 +0,0 @@ -import 'package:flutter_deriv_api/api/models/base_exception_model.dart'; - -import 'p2p_exception.dart'; - -/// P2P advertiser exception class -class P2PAdvertiserException extends P2PException { - /// Initializes - P2PAdvertiserException({ - BaseExceptionModel? baseExceptionModel, - }) : super(baseExceptionModel: baseExceptionModel); -} diff --git a/lib/api/exceptions/p2p_advertiser_stats_exception.dart b/lib/api/exceptions/p2p_advertiser_stats_exception.dart deleted file mode 100644 index 421d8a8be2..0000000000 --- a/lib/api/exceptions/p2p_advertiser_stats_exception.dart +++ /dev/null @@ -1,11 +0,0 @@ -import 'package:flutter_deriv_api/api/models/base_exception_model.dart'; - -import 'p2p_exception.dart'; - -/// P2P advertiser stats exception class -class P2PAdvertiserStatsException extends P2PException { - /// Initializes - P2PAdvertiserStatsException({ - BaseExceptionModel? baseExceptionModel, - }) : super(baseExceptionModel: baseExceptionModel); -} diff --git a/lib/api/exceptions/p2p_chat_exception.dart b/lib/api/exceptions/p2p_chat_exception.dart deleted file mode 100644 index 193acebf5e..0000000000 --- a/lib/api/exceptions/p2p_chat_exception.dart +++ /dev/null @@ -1,11 +0,0 @@ -import 'package:flutter_deriv_api/api/models/base_exception_model.dart'; - -import 'p2p_exception.dart'; - -/// P2P chat exception -class P2PChatException extends P2PException { - /// Initializes - P2PChatException({ - BaseExceptionModel? baseExceptionModel, - }) : super(baseExceptionModel: baseExceptionModel); -} diff --git a/lib/api/exceptions/p2p_exception.dart b/lib/api/exceptions/p2p_exception.dart deleted file mode 100644 index 3f10f0dff0..0000000000 --- a/lib/api/exceptions/p2p_exception.dart +++ /dev/null @@ -1,10 +0,0 @@ -import 'package:flutter_deriv_api/api/exceptions/api_base_exception.dart'; -import 'package:flutter_deriv_api/api/models/base_exception_model.dart'; - -/// P2P exception -class P2PException extends APIBaseException { - /// Initializes - P2PException({ - BaseExceptionModel? baseExceptionModel, - }) : super(baseExceptionModel: baseExceptionModel); -} diff --git a/lib/api/exceptions/p2p_order_exception.dart b/lib/api/exceptions/p2p_order_exception.dart deleted file mode 100644 index 925a14427d..0000000000 --- a/lib/api/exceptions/p2p_order_exception.dart +++ /dev/null @@ -1,11 +0,0 @@ -import 'package:flutter_deriv_api/api/models/base_exception_model.dart'; - -import 'p2p_exception.dart'; - -/// P2P Order exception class -class P2POrderException extends P2PException { - /// Initializes - P2POrderException({ - BaseExceptionModel? baseExceptionModel, - }) : super(baseExceptionModel: baseExceptionModel); -} diff --git a/lib/api/exceptions/payment_agent_exception.dart b/lib/api/exceptions/payment_agent_exception.dart deleted file mode 100644 index 7a2bb7ddc0..0000000000 --- a/lib/api/exceptions/payment_agent_exception.dart +++ /dev/null @@ -1,11 +0,0 @@ -import 'package:flutter_deriv_api/api/models/base_exception_model.dart'; - -import 'common_exception.dart'; - -/// Payment agent exception -class PaymentAgentException extends CommonException { - /// Initializes - PaymentAgentException({ - BaseExceptionModel? baseExceptionModel, - }) : super(baseExceptionModel: baseExceptionModel); -} diff --git a/lib/api/exceptions/payment_exception.dart b/lib/api/exceptions/payment_exception.dart deleted file mode 100644 index 26e83ba931..0000000000 --- a/lib/api/exceptions/payment_exception.dart +++ /dev/null @@ -1,11 +0,0 @@ -import 'package:flutter_deriv_api/api/models/base_exception_model.dart'; - -import 'common_exception.dart'; - -/// Payment exception -class PaymentException extends CommonException { - /// Initializes - PaymentException({ - BaseExceptionModel? baseExceptionModel, - }) : super(baseExceptionModel: baseExceptionModel); -} diff --git a/lib/api/exceptions/payout_currency_exception.dart b/lib/api/exceptions/payout_currency_exception.dart deleted file mode 100644 index ca3c675ba8..0000000000 --- a/lib/api/exceptions/payout_currency_exception.dart +++ /dev/null @@ -1,12 +0,0 @@ -import 'package:flutter_deriv_api/api/models/base_exception_model.dart'; - -import 'common_exception.dart'; - - -/// Payout currency exception class -class PayoutCurrencyException extends CommonException { - /// Initializes - PayoutCurrencyException({ - BaseExceptionModel? baseExceptionModel, - }) : super(baseExceptionModel: baseExceptionModel); -} diff --git a/lib/api/exceptions/ping_exception.dart b/lib/api/exceptions/ping_exception.dart deleted file mode 100644 index 6bdeb9abee..0000000000 --- a/lib/api/exceptions/ping_exception.dart +++ /dev/null @@ -1,11 +0,0 @@ -import 'package:flutter_deriv_api/api/models/base_exception_model.dart'; - -import 'common_exception.dart'; - -/// Ping exception class -class PingException extends CommonException { - /// Initializes - PingException({ - BaseExceptionModel? baseExceptionModel, - }) : super(baseExceptionModel: baseExceptionModel); -} diff --git a/lib/api/exceptions/portfolio_exception.dart b/lib/api/exceptions/portfolio_exception.dart deleted file mode 100644 index 08438c5526..0000000000 --- a/lib/api/exceptions/portfolio_exception.dart +++ /dev/null @@ -1,11 +0,0 @@ -import 'package:flutter_deriv_api/api/models/base_exception_model.dart'; - -import 'account_exception.dart'; - -/// Exception for portfolio -class PortfolioException extends AccountException { - /// Initializes - PortfolioException({ - BaseExceptionModel? baseExceptionModel, - }) : super(baseExceptionModel: baseExceptionModel); -} diff --git a/lib/api/exceptions/profit_table_exception.dart b/lib/api/exceptions/profit_table_exception.dart deleted file mode 100644 index 9a2053d792..0000000000 --- a/lib/api/exceptions/profit_table_exception.dart +++ /dev/null @@ -1,11 +0,0 @@ -import 'package:flutter_deriv_api/api/models/base_exception_model.dart'; - -import 'account_exception.dart'; - -/// Profit table exception -class ProfitTableException extends AccountException { - /// Initializes - ProfitTableException({ - BaseExceptionModel? baseExceptionModel, - }) : super(baseExceptionModel: baseExceptionModel); -} diff --git a/lib/api/exceptions/reality_check_exception.dart b/lib/api/exceptions/reality_check_exception.dart deleted file mode 100644 index e7deb56020..0000000000 --- a/lib/api/exceptions/reality_check_exception.dart +++ /dev/null @@ -1,11 +0,0 @@ -import 'package:flutter_deriv_api/api/models/base_exception_model.dart'; - -import 'account_exception.dart'; - -/// Reality check exception -class RealityCheckException extends AccountException { - /// Initializes - RealityCheckException({ - BaseExceptionModel? baseExceptionModel, - }) : super(baseExceptionModel: baseExceptionModel); -} diff --git a/lib/api/exceptions/residence_exception.dart b/lib/api/exceptions/residence_exception.dart deleted file mode 100644 index bc7fabffc0..0000000000 --- a/lib/api/exceptions/residence_exception.dart +++ /dev/null @@ -1,11 +0,0 @@ -import 'package:flutter_deriv_api/api/models/base_exception_model.dart'; - -import 'common_exception.dart'; - -/// Exception for residence calls -class ResidenceException extends CommonException { - /// Initializes - ResidenceException({ - BaseExceptionModel? baseExceptionModel, - }) : super(baseExceptionModel: baseExceptionModel); -} diff --git a/lib/api/exceptions/self_exclusion_exception.dart b/lib/api/exceptions/self_exclusion_exception.dart deleted file mode 100644 index 5746024f20..0000000000 --- a/lib/api/exceptions/self_exclusion_exception.dart +++ /dev/null @@ -1,11 +0,0 @@ -import 'package:flutter_deriv_api/api/models/base_exception_model.dart'; - -import 'account_exception.dart'; - -/// Self exclusion exception -class SelfExclusionException extends AccountException { - /// Initializes - SelfExclusionException({ - BaseExceptionModel? baseExceptionModel, - }) : super(baseExceptionModel: baseExceptionModel); -} diff --git a/lib/api/exceptions/server_time_exception.dart b/lib/api/exceptions/server_time_exception.dart deleted file mode 100644 index 9ed0d057b0..0000000000 --- a/lib/api/exceptions/server_time_exception.dart +++ /dev/null @@ -1,11 +0,0 @@ -import 'package:flutter_deriv_api/api/models/base_exception_model.dart'; - -import 'common_exception.dart'; - -/// Server time exception -class ServerTimeException extends CommonException { - /// Initializes - ServerTimeException({ - BaseExceptionModel? baseExceptionModel, - }) : super(baseExceptionModel: baseExceptionModel); -} diff --git a/lib/api/exceptions/state_exception.dart b/lib/api/exceptions/state_exception.dart deleted file mode 100644 index bd9e767ec8..0000000000 --- a/lib/api/exceptions/state_exception.dart +++ /dev/null @@ -1,11 +0,0 @@ -import 'package:flutter_deriv_api/api/models/base_exception_model.dart'; - -import 'common_exception.dart'; - -/// Exception for state call -class StateException extends CommonException { - /// Initializes - StateException({ - BaseExceptionModel? baseExceptionModel, - }) : super(baseExceptionModel: baseExceptionModel); -} diff --git a/lib/api/exceptions/statement_exception.dart b/lib/api/exceptions/statement_exception.dart deleted file mode 100644 index 931df56509..0000000000 --- a/lib/api/exceptions/statement_exception.dart +++ /dev/null @@ -1,11 +0,0 @@ -import 'package:flutter_deriv_api/api/models/base_exception_model.dart'; - -import 'account_exception.dart'; - -/// Statement exception -class StatementException extends AccountException { - /// Initializes - StatementException({ - BaseExceptionModel? baseExceptionModel, - }) : super(baseExceptionModel: baseExceptionModel); -} diff --git a/lib/api/exceptions/tick_exception.dart b/lib/api/exceptions/tick_exception.dart deleted file mode 100644 index 6bcfa8a20e..0000000000 --- a/lib/api/exceptions/tick_exception.dart +++ /dev/null @@ -1,11 +0,0 @@ -import 'package:flutter_deriv_api/api/models/base_exception_model.dart'; - -import 'common_exception.dart'; - -/// Exception class for Tick calls -class TickException extends CommonException { - /// Initializes - TickException({ - BaseExceptionModel? baseExceptionModel, - }) : super(baseExceptionModel: baseExceptionModel); -} diff --git a/lib/api/exceptions/top_up_virtual_exception.dart b/lib/api/exceptions/top_up_virtual_exception.dart deleted file mode 100644 index 1ae8288bb2..0000000000 --- a/lib/api/exceptions/top_up_virtual_exception.dart +++ /dev/null @@ -1,11 +0,0 @@ -import 'package:flutter_deriv_api/api/models/base_exception_model.dart'; - -import 'account_exception.dart'; - -/// Top-Up virtual exception class -class TopUpVirtualException extends AccountException { - /// Initializes - TopUpVirtualException({ - BaseExceptionModel? baseExceptionModel, - }) : super(baseExceptionModel: baseExceptionModel); -} diff --git a/lib/api/exceptions/trading_exception.dart b/lib/api/exceptions/trading_exception.dart deleted file mode 100644 index 4539acb232..0000000000 --- a/lib/api/exceptions/trading_exception.dart +++ /dev/null @@ -1,11 +0,0 @@ -import 'package:flutter_deriv_api/api/models/base_exception_model.dart'; - -import 'common_exception.dart'; - -/// Trading exception -class TradingException extends CommonException { - /// Initializes - TradingException({ - BaseExceptionModel? baseExceptionModel, - }) : super(baseExceptionModel: baseExceptionModel); -} diff --git a/lib/api/exceptions/trading_platform_exception.dart b/lib/api/exceptions/trading_platform_exception.dart deleted file mode 100644 index b90f5ef84a..0000000000 --- a/lib/api/exceptions/trading_platform_exception.dart +++ /dev/null @@ -1,11 +0,0 @@ -import 'package:flutter_deriv_api/api/models/base_exception_model.dart'; - -import 'account_exception.dart'; - -/// Trading platform exception class. -class TradingPlatformException extends AccountException { - /// Initializes [TradingPlatformException]. - TradingPlatformException({ - BaseExceptionModel? baseExceptionModel, - }) : super(baseExceptionModel: baseExceptionModel); -} diff --git a/lib/api/exceptions/transactions_exception.dart b/lib/api/exceptions/transactions_exception.dart deleted file mode 100644 index 0d56f7a8ea..0000000000 --- a/lib/api/exceptions/transactions_exception.dart +++ /dev/null @@ -1,10 +0,0 @@ -import 'package:flutter_deriv_api/api/exceptions/contract_exception.dart'; -import 'package:flutter_deriv_api/api/models/base_exception_model.dart'; - -/// Exceptions for transaction call -class TransactionsException extends ContractException { - /// Initializes - TransactionsException({ - BaseExceptionModel? baseExceptionModel, - }) : super(baseExceptionModel: baseExceptionModel); -} diff --git a/lib/api/exceptions/transfer_exception.dart b/lib/api/exceptions/transfer_exception.dart deleted file mode 100644 index 5b5ede3fad..0000000000 --- a/lib/api/exceptions/transfer_exception.dart +++ /dev/null @@ -1,11 +0,0 @@ -import 'package:flutter_deriv_api/api/models/base_exception_model.dart'; - -import 'user_exception.dart'; - -/// Transfer exception -class TransferException extends UserException { - /// Initializes - TransferException({ - BaseExceptionModel? baseExceptionModel, - }) : super(baseExceptionModel: baseExceptionModel); -} diff --git a/lib/api/exceptions/user_exception.dart b/lib/api/exceptions/user_exception.dart deleted file mode 100644 index a097571e89..0000000000 --- a/lib/api/exceptions/user_exception.dart +++ /dev/null @@ -1,10 +0,0 @@ -import 'package:flutter_deriv_api/api/exceptions/api_base_exception.dart'; -import 'package:flutter_deriv_api/api/models/base_exception_model.dart'; - -/// User exception -class UserException extends APIBaseException { - /// Initializes - UserException({ - BaseExceptionModel? baseExceptionModel, - }) : super(baseExceptionModel: baseExceptionModel); -} diff --git a/lib/api/exceptions/website_status_exception.dart b/lib/api/exceptions/website_status_exception.dart deleted file mode 100644 index 7d27dac6b4..0000000000 --- a/lib/api/exceptions/website_status_exception.dart +++ /dev/null @@ -1,11 +0,0 @@ -import 'package:flutter_deriv_api/api/models/base_exception_model.dart'; - -import 'common_exception.dart'; - -/// Exception class for website status -class WebsiteStatusException extends CommonException { - /// Initializes - WebsiteStatusException({ - BaseExceptionModel? baseExceptionModel, - }) : super(baseExceptionModel: baseExceptionModel); -} diff --git a/lib/api/manually/ohlc_response_result.dart b/lib/api/manually/ohlc_response_result.dart index 0d83ea8e19..a1bac6734a 100644 --- a/lib/api/manually/ohlc_response_result.dart +++ b/lib/api/manually/ohlc_response_result.dart @@ -81,7 +81,7 @@ class OHLC extends TickBase { /// Unsubscribes all OHLC. /// - /// Throws a [TickException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future unsubscribeAllOHLC() async { final ForgetAllReceive response = await _api.unsubscribeAll(method: ForgetStreamType.candles); @@ -89,7 +89,7 @@ class OHLC extends TickBase { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - TickException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return ForgetAllResponse.fromJson(response.forgetAll); diff --git a/lib/api/manually/tick.dart b/lib/api/manually/tick.dart index db92b083ed..f6aa7d3c29 100644 --- a/lib/api/manually/tick.dart +++ b/lib/api/manually/tick.dart @@ -60,7 +60,7 @@ class Tick extends TickBase { /// Subscribes to a tick for given [TickRequest] /// - /// Throws [TickException] if API response contains an error + /// Throws [BaseAPIException] if API response contains an error static Stream subscribeTick( TicksRequest tickRequest, { RequestCompareFunction? comparePredicate, @@ -72,7 +72,7 @@ class Tick extends TickBase { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - TickException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return response is TicksReceive @@ -86,7 +86,7 @@ class Tick extends TickBase { /// Unsubscribes all ticks. /// - /// Throws a [TickException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future unsubscribeAllTicks() async { final ForgetAllReceive response = await _api.unsubscribeAll(method: ForgetStreamType.ticks); @@ -94,7 +94,7 @@ class Tick extends TickBase { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - TickException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return ForgetAllResponse.fromJson(response); diff --git a/lib/api/manually/tick_base.dart b/lib/api/manually/tick_base.dart index 930e1a540a..3e30f9a367 100644 --- a/lib/api/manually/tick_base.dart +++ b/lib/api/manually/tick_base.dart @@ -68,7 +68,7 @@ class TickBase extends TickBaseModel { /// Unsubscribes from tick stream /// - /// Throws a [TickException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error Future unsubscribe() async { if (subscriptionInformation?.id == null) { return null; @@ -80,7 +80,7 @@ class TickBase extends TickBaseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - TickException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return ForgetResponse.fromJson(response.forget); diff --git a/lib/api/manually/tick_history_subscription.dart b/lib/api/manually/tick_history_subscription.dart index 84476bc2d7..4ca904928c 100644 --- a/lib/api/manually/tick_history_subscription.dart +++ b/lib/api/manually/tick_history_subscription.dart @@ -23,7 +23,7 @@ class TickHistorySubscription { /// Unsubscribes from tick history stream /// - /// Throws a [TickException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error Future unsubscribe() async { if (tickHistory?.subscription == null) { return null; @@ -36,7 +36,7 @@ class TickHistorySubscription { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - TickException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return ForgetResponse.fromJson(response.forget); diff --git a/lib/api/models/enums.dart b/lib/api/models/enums.dart index 388a6e1a2f..9e5ee5b304 100644 --- a/lib/api/models/enums.dart +++ b/lib/api/models/enums.dart @@ -319,7 +319,10 @@ enum ForgetStreamType { transaction, /// Website status - websiteStatus + websiteStatus, + + /// Cashier payments. + cashierPayments, } /// Contract types diff --git a/lib/api/response/active_symbols_response_result.dart b/lib/api/response/active_symbols_response_result.dart index 08fd25d55f..d646bdf460 100644 --- a/lib/api/response/active_symbols_response_result.dart +++ b/lib/api/response/active_symbols_response_result.dart @@ -63,7 +63,7 @@ class ActiveSymbolsResponse extends ActiveSymbolsResponseModel { /// Gets the list of active symbols. /// /// For parameters information refer to [ActiveSymbolsRequest]. - /// Throws an [ActiveSymbolsException] if API response contains an error + /// Throws an [BaseAPIException] if API response contains an error static Future fetchActiveSymbols( ActiveSymbolsRequest request, ) async { @@ -74,7 +74,7 @@ class ActiveSymbolsResponse extends ActiveSymbolsResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - ActiveSymbolsException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return ActiveSymbolsResponse.fromJson(response.activeSymbols); diff --git a/lib/api/response/api_token_response_result.dart b/lib/api/response/api_token_response_result.dart index 58ed812c6d..9a665700e3 100644 --- a/lib/api/response/api_token_response_result.dart +++ b/lib/api/response/api_token_response_result.dart @@ -56,7 +56,7 @@ class ApiTokenResponse extends ApiTokenResponseModel { /// [scopes] is a list of permission scopes to provide with the token. /// [validForCurrentIPOnly] is optional and if you set this parameter during token creation, /// then the token created will only work for the IP address that was used to create the token - /// Throws an [APITokenException] if API response contains an error. + /// Throws an [BaseAPIException] if API response contains an error. static Future create({ required String name, required List scopes, @@ -73,7 +73,7 @@ class ApiTokenResponse extends ApiTokenResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - APITokenException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return ApiTokenResponse.fromJson(response.apiToken); @@ -81,7 +81,7 @@ class ApiTokenResponse extends ApiTokenResponseModel { /// Deletes the [token] /// - /// Throws an [APITokenException] if API response contains an error + /// Throws an [BaseAPIException] if API response contains an error static Future delete({ required String token, }) async { @@ -92,7 +92,7 @@ class ApiTokenResponse extends ApiTokenResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - APITokenException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return ApiTokenResponse.fromJson(response.apiToken); diff --git a/lib/api/response/app_delete_response_result.dart b/lib/api/response/app_delete_response_result.dart index 3ddbcf61b7..c5945ec156 100644 --- a/lib/api/response/app_delete_response_result.dart +++ b/lib/api/response/app_delete_response_result.dart @@ -51,7 +51,7 @@ class AppDeleteResponse extends AppDeleteResponseModel { /// Deletes the application by appId specified in [AppDeleteRequest.appDelete]. /// /// For parameters information refer to [AppDeleteRequest]. - /// Throws an [AppException] if API response contains an error + /// Throws an [BaseAPIException] if API response contains an error static Future deleteApplication( AppDeleteRequest request) async { final AppDeleteReceive response = await _api.call(request: request); @@ -59,7 +59,7 @@ class AppDeleteResponse extends AppDeleteResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - AppException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return AppDeleteResponse.fromJson(response.appDelete); diff --git a/lib/api/response/app_get_response_result.dart b/lib/api/response/app_get_response_result.dart index a54dd01b45..a914b47eb2 100644 --- a/lib/api/response/app_get_response_result.dart +++ b/lib/api/response/app_get_response_result.dart @@ -66,7 +66,7 @@ class AppGetResponse extends AppGetResponseModel { /// Gets the information of the OAuth application specified by [appId] in [request] /// /// For parameters information refer to [AppGetRequest]. - /// Throws an [AppException] if API response contains an error + /// Throws an [BaseAPIException] if API response contains an error static Future fetchApplicationDetails( AppGetRequest request, ) async { @@ -75,7 +75,7 @@ class AppGetResponse extends AppGetResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - AppException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return AppGetResponse.fromJson(response.appGet); @@ -84,7 +84,7 @@ class AppGetResponse extends AppGetResponseModel { /// Gets all of the account's OAuth applications. /// /// For parameters information refer to [AppListRequest]. - /// Throws an [AppException] if API response contains an error + /// Throws an [BaseAPIException] if API response contains an error static Future?> fetchApplicationList( AppListRequest request, ) async { @@ -93,7 +93,7 @@ class AppGetResponse extends AppGetResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - AppException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return getListFromMap( diff --git a/lib/api/response/app_list_response_result.dart b/lib/api/response/app_list_response_result.dart index c2b93a1b6b..7cb8fbe1b5 100644 --- a/lib/api/response/app_list_response_result.dart +++ b/lib/api/response/app_list_response_result.dart @@ -64,7 +64,7 @@ class AppListResponse extends AppListResponseModel { /// Gets all of the account's OAuth applications. /// /// For parameters information refer to [AppListRequest]. - /// Throws an [AppException] if API response contains an error + /// Throws an [BaseAPIException] if API response contains an error static Future fetchApplicationList( AppListRequest request, ) async { @@ -73,7 +73,7 @@ class AppListResponse extends AppListResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - AppException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return AppListResponse.fromJson(response.appList); diff --git a/lib/api/response/app_markup_details_response_result.dart b/lib/api/response/app_markup_details_response_result.dart index bfb45c2864..3e7075aa59 100644 --- a/lib/api/response/app_markup_details_response_result.dart +++ b/lib/api/response/app_markup_details_response_result.dart @@ -55,7 +55,7 @@ class AppMarkupDetailsResponse extends AppMarkupDetailsResponseModel { /// Retrieve details of app markup according to criteria specified. /// /// For parameters information refer to [AppMarkupDetailsRequest]. - /// Throws an [AppException] if API response contains an error + /// Throws an [BaseAPIException] if API response contains an error static Future fetchApplicationMarkupDetails( AppMarkupDetailsRequest request, ) async { @@ -64,7 +64,7 @@ class AppMarkupDetailsResponse extends AppMarkupDetailsResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - AppException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return AppMarkupDetailsResponse.fromJson(response.appMarkupDetails); diff --git a/lib/api/response/app_register_response_result.dart b/lib/api/response/app_register_response_result.dart index d1d5b2f837..082f4616cb 100644 --- a/lib/api/response/app_register_response_result.dart +++ b/lib/api/response/app_register_response_result.dart @@ -56,7 +56,7 @@ class AppRegisterResponse extends AppRegisterResponseModel { /// Registers a new OAuth application. /// /// For parameters information refer to [AppRegisterRequest]. - /// Throws an [AppException] if API response contains an error + /// Throws an [BaseAPIException] if API response contains an error static Future registerApplication( AppRegisterRequest request, ) async { @@ -65,7 +65,7 @@ class AppRegisterResponse extends AppRegisterResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - AppException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return AppRegisterResponse.fromJson(response.appRegister); diff --git a/lib/api/response/app_update_response_result.dart b/lib/api/response/app_update_response_result.dart index 439871bffa..158ca4dcd9 100644 --- a/lib/api/response/app_update_response_result.dart +++ b/lib/api/response/app_update_response_result.dart @@ -55,7 +55,7 @@ class AppUpdateResponse extends AppUpdateResponseModel { /// Updates the application specified in [request]. /// /// For parameters information refer to [AppUpdateRequest]. - /// Throws an [AppException] if API response contains an error + /// Throws an [BaseAPIException] if API response contains an error static Future updateApplication( AppUpdateRequest request) async { final AppUpdateReceive response = await _api.call(request: request); @@ -63,7 +63,7 @@ class AppUpdateResponse extends AppUpdateResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - AppException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return AppUpdateResponse.fromJson(response.appUpdate); diff --git a/lib/api/response/asset_index_response_result.dart b/lib/api/response/asset_index_response_result.dart index 31c8c16276..3747bd71b2 100644 --- a/lib/api/response/asset_index_response_result.dart +++ b/lib/api/response/asset_index_response_result.dart @@ -64,7 +64,7 @@ class AssetIndexResponse extends AssetIndexResponseModel { /// Retrieves a list of all available underlyings and the corresponding contract types and duration boundaries. /// /// If the user is logged in, only the assets available for that user's landing company will be returned. - /// Throws an [AssetIndexException] if API response contains an error + /// Throws an [BaseAPIException] if API response contains an error static Future fetchAssetIndices( AssetIndexRequest request, ) async { @@ -75,7 +75,7 @@ class AssetIndexResponse extends AssetIndexResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - AssetIndexException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return AssetIndexResponse.fromJson(response.assetIndex); diff --git a/lib/api/response/authorize_response_result.dart b/lib/api/response/authorize_response_result.dart index d73633e0b0..555276e7f6 100644 --- a/lib/api/response/authorize_response_result.dart +++ b/lib/api/response/authorize_response_result.dart @@ -25,10 +25,8 @@ abstract class AuthorizeResponseModel { class AuthorizeResponse extends AuthorizeResponseModel { /// Initializes Authorize response class. const AuthorizeResponse({ - Authorize? authorize, - }) : super( - authorize: authorize, - ); + super.authorize, + }); /// Creates an instance from JSON. factory AuthorizeResponse.fromJson( @@ -55,7 +53,7 @@ class AuthorizeResponse extends AuthorizeResponseModel { /// Authorizes current WebSocket session to act on behalf of the owner of a given token. /// /// For parameters information refer to [AuthorizeRequest]. - /// Throws an [AuthorizeException] if API response contains an error. + /// Throws an [BaseAPIException] if API response contains an error. static Future authorizeMethodRaw( AuthorizeRequest request, ) async { @@ -66,7 +64,7 @@ class AuthorizeResponse extends AuthorizeResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - AuthorizeException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return response; @@ -75,7 +73,7 @@ class AuthorizeResponse extends AuthorizeResponseModel { /// Authorizes current WebSocket session to act on behalf of the owner of a given token. /// /// For parameters information refer to [AuthorizeRequest]. - /// Throws an [AuthorizeException] if API response contains an error. + /// Throws an [BaseAPIException] if API response contains an error. static Future authorizeMethod( AuthorizeRequest request, ) async { @@ -93,17 +91,41 @@ class AuthorizeResponse extends AuthorizeResponseModel { ); } +/// AccountCategoryEnum mapper. +final Map accountCategoryEnumMapper = + { + "trading": AccountCategoryEnum.trading, + "wallet": AccountCategoryEnum.wallet, +}; + +/// AccountCategory Enum. +enum AccountCategoryEnum { + /// trading. + trading, + + /// wallet. + wallet, +} + /// PlatformEnum mapper. final Map platformEnumMapper = { - "deriv": PlatformEnum.deriv, + "derivez": PlatformEnum.derivez, + "dtrade": PlatformEnum.dtrade, + "dwallet": PlatformEnum.dwallet, "dxtrade": PlatformEnum.dxtrade, "mt5": PlatformEnum.mt5, }; /// Platform Enum. enum PlatformEnum { - /// deriv. - deriv, + /// derivez. + derivez, + + /// dtrade. + dtrade, + + /// dwallet. + dwallet, /// dxtrade. dxtrade, @@ -124,14 +146,13 @@ abstract class AuthorizeModel { this.isVirtual, this.landingCompanyFullname, this.landingCompanyName, + this.linkedTo, this.localCurrencies, this.loginid, this.preferredLanguage, this.scopes, - this.trading, this.upgradeableLandingCompanies, this.userId, - this.wallet, }); /// List of accounts for current user. @@ -161,6 +182,9 @@ abstract class AuthorizeModel { /// Landing company shortcode the account belongs to. final String? landingCompanyName; + /// Details of the list of Trading accounts linked to the Wallet account. + final List? linkedTo; + /// Currencies in client's residence country final Map? localCurrencies; @@ -173,59 +197,34 @@ abstract class AuthorizeModel { /// Scopes available to the token. final List? scopes; - /// Details of the Trading account. - final AuthorizeTrading? trading; - /// List of landing company shortcodes the account can upgrade to. final List? upgradeableLandingCompanies; /// The internal user ID for this account. final int? userId; - - /// Details of the Wallet account. - final AuthorizeWallet? wallet; } /// Authorize class. class Authorize extends AuthorizeModel { /// Initializes Authorize class. const Authorize({ - List? accountList, - double? balance, - String? country, - String? currency, - String? email, - String? fullname, - bool? isVirtual, - String? landingCompanyFullname, - String? landingCompanyName, - Map? localCurrencies, - String? loginid, - String? preferredLanguage, - List? scopes, - AuthorizeTrading? trading, - List? upgradeableLandingCompanies, - int? userId, - AuthorizeWallet? wallet, - }) : super( - accountList: accountList, - balance: balance, - country: country, - currency: currency, - email: email, - fullname: fullname, - isVirtual: isVirtual, - landingCompanyFullname: landingCompanyFullname, - landingCompanyName: landingCompanyName, - localCurrencies: localCurrencies, - loginid: loginid, - preferredLanguage: preferredLanguage, - scopes: scopes, - trading: trading, - upgradeableLandingCompanies: upgradeableLandingCompanies, - userId: userId, - wallet: wallet, - ); + super.accountList, + super.balance, + super.country, + super.currency, + super.email, + super.fullname, + super.isVirtual, + super.landingCompanyFullname, + super.landingCompanyName, + super.linkedTo, + super.localCurrencies, + super.loginid, + super.preferredLanguage, + super.scopes, + super.upgradeableLandingCompanies, + super.userId, + }); /// Creates an instance from JSON. factory Authorize.fromJson(Map json) => Authorize( @@ -244,6 +243,13 @@ class Authorize extends AuthorizeModel { isVirtual: getBool(json['is_virtual']), landingCompanyFullname: json['landing_company_fullname'], landingCompanyName: json['landing_company_name'], + linkedTo: json['linked_to'] == null + ? null + : List.from( + json['linked_to']?.map( + (dynamic item) => AuthorizeLinkedToItem.fromJson(item), + ), + ), localCurrencies: json['local_currencies'] == null ? null : Map.fromEntries(json[ @@ -262,9 +268,6 @@ class Authorize extends AuthorizeModel { (dynamic item) => item, ), ), - trading: json['trading'] == null - ? null - : AuthorizeTrading.fromJson(json['trading']), upgradeableLandingCompanies: json['upgradeable_landing_companies'] == null ? null @@ -274,9 +277,6 @@ class Authorize extends AuthorizeModel { ), ), userId: json['user_id'], - wallet: json['wallet'] == null - ? null - : AuthorizeWallet.fromJson(json['wallet']), ); /// Converts an instance to JSON. @@ -298,6 +298,13 @@ class Authorize extends AuthorizeModel { resultMap['is_virtual'] = isVirtual; resultMap['landing_company_fullname'] = landingCompanyFullname; resultMap['landing_company_name'] = landingCompanyName; + if (linkedTo != null) { + resultMap['linked_to'] = linkedTo! + .map( + (AuthorizeLinkedToItem item) => item.toJson(), + ) + .toList(); + } resultMap['local_currencies'] = localCurrencies; resultMap['loginid'] = loginid; resultMap['preferred_language'] = preferredLanguage; @@ -308,9 +315,6 @@ class Authorize extends AuthorizeModel { ) .toList(); } - if (trading != null) { - resultMap['trading'] = trading!.toJson(); - } if (upgradeableLandingCompanies != null) { resultMap['upgradeable_landing_companies'] = upgradeableLandingCompanies! .map( @@ -319,9 +323,6 @@ class Authorize extends AuthorizeModel { .toList(); } resultMap['user_id'] = userId; - if (wallet != null) { - resultMap['wallet'] = wallet!.toJson(); - } return resultMap; } @@ -337,14 +338,13 @@ class Authorize extends AuthorizeModel { bool? isVirtual, String? landingCompanyFullname, String? landingCompanyName, + List? linkedTo, Map? localCurrencies, String? loginid, String? preferredLanguage, List? scopes, - AuthorizeTrading? trading, List? upgradeableLandingCompanies, int? userId, - AuthorizeWallet? wallet, }) => Authorize( accountList: accountList ?? this.accountList, @@ -357,21 +357,21 @@ class Authorize extends AuthorizeModel { landingCompanyFullname: landingCompanyFullname ?? this.landingCompanyFullname, landingCompanyName: landingCompanyName ?? this.landingCompanyName, + linkedTo: linkedTo ?? this.linkedTo, localCurrencies: localCurrencies ?? this.localCurrencies, loginid: loginid ?? this.loginid, preferredLanguage: preferredLanguage ?? this.preferredLanguage, scopes: scopes ?? this.scopes, - trading: trading ?? this.trading, upgradeableLandingCompanies: upgradeableLandingCompanies ?? this.upgradeableLandingCompanies, userId: userId ?? this.userId, - wallet: wallet ?? this.wallet, ); } /// Account list item model class. abstract class AccountListItemModel { /// Initializes Account list item model class . const AccountListItemModel({ + this.accountCategory, this.accountType, this.createdAt, this.currency, @@ -379,11 +379,13 @@ abstract class AccountListItemModel { this.isDisabled, this.isVirtual, this.landingCompanyName, + this.linkedTo, this.loginid, - this.trading, - this.wallet, }); + /// Account category. + final AccountCategoryEnum? accountCategory; + /// Account type. final String? accountType; @@ -405,46 +407,35 @@ abstract class AccountListItemModel { /// Landing company shortcode the account belongs to. final String? landingCompanyName; + /// Details of the list of Trading accounts linked to the Wallet account. + final List? linkedTo; + /// The account ID of specified account. final String? loginid; - - /// Details of the Trading account. - final Trading? trading; - - /// Details of the Wallet account. - final Wallet? wallet; } /// Account list item class. class AccountListItem extends AccountListItemModel { /// Initializes Account list item class. const AccountListItem({ - String? accountType, - DateTime? createdAt, - String? currency, - DateTime? excludedUntil, - bool? isDisabled, - bool? isVirtual, - String? landingCompanyName, - String? loginid, - Trading? trading, - Wallet? wallet, - }) : super( - accountType: accountType, - createdAt: createdAt, - currency: currency, - excludedUntil: excludedUntil, - isDisabled: isDisabled, - isVirtual: isVirtual, - landingCompanyName: landingCompanyName, - loginid: loginid, - trading: trading, - wallet: wallet, - ); + super.accountCategory, + super.accountType, + super.createdAt, + super.currency, + super.excludedUntil, + super.isDisabled, + super.isVirtual, + super.landingCompanyName, + super.linkedTo, + super.loginid, + }); /// Creates an instance from JSON. factory AccountListItem.fromJson(Map json) => AccountListItem( + accountCategory: json['account_category'] == null + ? null + : accountCategoryEnumMapper[json['account_category']], accountType: json['account_type'], createdAt: getDateTime(json['created_at']), currency: json['currency'], @@ -452,16 +443,24 @@ class AccountListItem extends AccountListItemModel { isDisabled: getBool(json['is_disabled']), isVirtual: getBool(json['is_virtual']), landingCompanyName: json['landing_company_name'], + linkedTo: json['linked_to'] == null + ? null + : List.from( + json['linked_to']?.map( + (dynamic item) => LinkedToItem.fromJson(item), + ), + ), loginid: json['loginid'], - trading: - json['trading'] == null ? null : Trading.fromJson(json['trading']), - wallet: json['wallet'] == null ? null : Wallet.fromJson(json['wallet']), ); /// Converts an instance to JSON. Map toJson() { final Map resultMap = {}; + resultMap['account_category'] = accountCategoryEnumMapper.entries + .firstWhere((MapEntry entry) => + entry.value == accountCategory) + .key; resultMap['account_type'] = accountType; resultMap['created_at'] = getSecondsSinceEpochDateTime(createdAt); resultMap['currency'] = currency; @@ -469,19 +468,21 @@ class AccountListItem extends AccountListItemModel { resultMap['is_disabled'] = isDisabled; resultMap['is_virtual'] = isVirtual; resultMap['landing_company_name'] = landingCompanyName; - resultMap['loginid'] = loginid; - if (trading != null) { - resultMap['trading'] = trading!.toJson(); - } - if (wallet != null) { - resultMap['wallet'] = wallet!.toJson(); + if (linkedTo != null) { + resultMap['linked_to'] = linkedTo! + .map( + (LinkedToItem item) => item.toJson(), + ) + .toList(); } + resultMap['loginid'] = loginid; return resultMap; } /// Creates a copy of instance with given parameters. AccountListItem copyWith({ + AccountCategoryEnum? accountCategory, String? accountType, DateTime? createdAt, String? currency, @@ -489,11 +490,11 @@ class AccountListItem extends AccountListItemModel { bool? isDisabled, bool? isVirtual, String? landingCompanyName, + List? linkedTo, String? loginid, - Trading? trading, - Wallet? wallet, }) => AccountListItem( + accountCategory: accountCategory ?? this.accountCategory, accountType: accountType ?? this.accountType, createdAt: createdAt ?? this.createdAt, currency: currency ?? this.currency, @@ -501,275 +502,91 @@ class AccountListItem extends AccountListItemModel { isDisabled: isDisabled ?? this.isDisabled, isVirtual: isVirtual ?? this.isVirtual, landingCompanyName: landingCompanyName ?? this.landingCompanyName, - loginid: loginid ?? this.loginid, - trading: trading ?? this.trading, - wallet: wallet ?? this.wallet, - ); -} -/// Trading model class. -abstract class TradingModel { - /// Initializes Trading model class . - const TradingModel({ - this.linkedTo, - }); - - /// Details of the Wallet account linked to the Trading account. - final List? linkedTo; -} - -/// Trading class. -class Trading extends TradingModel { - /// Initializes Trading class. - const Trading({ - List? linkedTo, - }) : super( - linkedTo: linkedTo, - ); - - /// Creates an instance from JSON. - factory Trading.fromJson(Map json) => Trading( - linkedTo: json['linked_to'] == null - ? null - : List.from( - json['linked_to']?.map( - (dynamic item) => LinkedToItem.fromJson(item), - ), - ), - ); - - /// Converts an instance to JSON. - Map toJson() { - final Map resultMap = {}; - - if (linkedTo != null) { - resultMap['linked_to'] = linkedTo! - .map( - (LinkedToItem item) => item.toJson(), - ) - .toList(); - } - - return resultMap; - } - - /// Creates a copy of instance with given parameters. - Trading copyWith({ - List? linkedTo, - }) => - Trading( linkedTo: linkedTo ?? this.linkedTo, + loginid: loginid ?? this.loginid, ); } /// Linked to item model class. abstract class LinkedToItemModel { /// Initializes Linked to item model class . const LinkedToItemModel({ - this.accountId, - this.balance, - this.currency, - this.paymentMethod, + this.loginid, + this.platform, }); - /// Wallet account ID. - final String? accountId; - - /// Wallet account balance. - final String? balance; - - /// Wallet account currency. - final String? currency; + /// Account ID. + final String? loginid; - /// Wallet account payment method. - final String? paymentMethod; + /// Account platform name. + final PlatformEnum? platform; } /// Linked to item class. class LinkedToItem extends LinkedToItemModel { /// Initializes Linked to item class. const LinkedToItem({ - String? accountId, - String? balance, - String? currency, - String? paymentMethod, - }) : super( - accountId: accountId, - balance: balance, - currency: currency, - paymentMethod: paymentMethod, - ); + super.loginid, + super.platform, + }); /// Creates an instance from JSON. factory LinkedToItem.fromJson(Map json) => LinkedToItem( - accountId: json['account_id'], - balance: json['balance'], - currency: json['currency'], - paymentMethod: json['payment_method'], + loginid: json['loginid'], + platform: json['platform'] == null + ? null + : platformEnumMapper[json['platform']], ); /// Converts an instance to JSON. Map toJson() { final Map resultMap = {}; - resultMap['account_id'] = accountId; - resultMap['balance'] = balance; - resultMap['currency'] = currency; - resultMap['payment_method'] = paymentMethod; + resultMap['loginid'] = loginid; + resultMap['platform'] = platformEnumMapper.entries + .firstWhere( + (MapEntry entry) => entry.value == platform) + .key; return resultMap; } /// Creates a copy of instance with given parameters. LinkedToItem copyWith({ - String? accountId, - String? balance, - String? currency, - String? paymentMethod, + String? loginid, + PlatformEnum? platform, }) => LinkedToItem( - accountId: accountId ?? this.accountId, - balance: balance ?? this.balance, - currency: currency ?? this.currency, - paymentMethod: paymentMethod ?? this.paymentMethod, - ); -} -/// Wallet model class. -abstract class WalletModel { - /// Initializes Wallet model class . - const WalletModel({ - this.accountId, - this.balance, - this.currency, - this.linkedTo, - this.paymentMethod, - }); - - /// Wallet account ID. - final String? accountId; - - /// Wallet account balance. - final double? balance; - - /// Wallet account currency. - final String? currency; - - /// Details of the list of Trading accounts linked to the Wallet account. - final List? linkedTo; - - /// Wallet account payment method. - final String? paymentMethod; -} - -/// Wallet class. -class Wallet extends WalletModel { - /// Initializes Wallet class. - const Wallet({ - String? accountId, - double? balance, - String? currency, - List? linkedTo, - String? paymentMethod, - }) : super( - accountId: accountId, - balance: balance, - currency: currency, - linkedTo: linkedTo, - paymentMethod: paymentMethod, - ); - - /// Creates an instance from JSON. - factory Wallet.fromJson(Map json) => Wallet( - accountId: json['account_id'], - balance: getDouble(json['balance']), - currency: json['currency'], - linkedTo: json['linked_to'] == null - ? null - : List.from( - json['linked_to']?.map( - (dynamic item) => WalletLinkedToItem.fromJson(item), - ), - ), - paymentMethod: json['payment_method'], - ); - - /// Converts an instance to JSON. - Map toJson() { - final Map resultMap = {}; - - resultMap['account_id'] = accountId; - resultMap['balance'] = balance; - resultMap['currency'] = currency; - if (linkedTo != null) { - resultMap['linked_to'] = linkedTo! - .map( - (WalletLinkedToItem item) => item.toJson(), - ) - .toList(); - } - resultMap['payment_method'] = paymentMethod; - - return resultMap; - } - - /// Creates a copy of instance with given parameters. - Wallet copyWith({ - String? accountId, - double? balance, - String? currency, - List? linkedTo, - String? paymentMethod, - }) => - Wallet( - accountId: accountId ?? this.accountId, - balance: balance ?? this.balance, - currency: currency ?? this.currency, - linkedTo: linkedTo ?? this.linkedTo, - paymentMethod: paymentMethod ?? this.paymentMethod, + loginid: loginid ?? this.loginid, + platform: platform ?? this.platform, ); } -/// Wallet linked to item model class. -abstract class WalletLinkedToItemModel { - /// Initializes Wallet linked to item model class . - const WalletLinkedToItemModel({ - this.accountId, - this.balance, - this.currency, +/// Authorize linked to item model class. +abstract class AuthorizeLinkedToItemModel { + /// Initializes Authorize linked to item model class . + const AuthorizeLinkedToItemModel({ + this.loginid, this.platform, }); - /// Trading account ID. - final String? accountId; - - /// Trading account balance. - final String? balance; - - /// Trading account currency. - final String? currency; + /// Account ID. + final String? loginid; - /// Trading account platform name. + /// Account platform name. final PlatformEnum? platform; } -/// Wallet linked to item class. -class WalletLinkedToItem extends WalletLinkedToItemModel { - /// Initializes Wallet linked to item class. - const WalletLinkedToItem({ - String? accountId, - String? balance, - String? currency, - PlatformEnum? platform, - }) : super( - accountId: accountId, - balance: balance, - currency: currency, - platform: platform, - ); +/// Authorize linked to item class. +class AuthorizeLinkedToItem extends AuthorizeLinkedToItemModel { + /// Initializes Authorize linked to item class. + const AuthorizeLinkedToItem({ + super.loginid, + super.platform, + }); /// Creates an instance from JSON. - factory WalletLinkedToItem.fromJson(Map json) => - WalletLinkedToItem( - accountId: json['account_id'], - balance: json['balance'], - currency: json['currency'], + factory AuthorizeLinkedToItem.fromJson(Map json) => + AuthorizeLinkedToItem( + loginid: json['loginid'], platform: json['platform'] == null ? null : platformEnumMapper[json['platform']], @@ -779,9 +596,7 @@ class WalletLinkedToItem extends WalletLinkedToItemModel { Map toJson() { final Map resultMap = {}; - resultMap['account_id'] = accountId; - resultMap['balance'] = balance; - resultMap['currency'] = currency; + resultMap['loginid'] = loginid; resultMap['platform'] = platformEnumMapper.entries .firstWhere( (MapEntry entry) => entry.value == platform) @@ -791,16 +606,12 @@ class WalletLinkedToItem extends WalletLinkedToItemModel { } /// Creates a copy of instance with given parameters. - WalletLinkedToItem copyWith({ - String? accountId, - String? balance, - String? currency, + AuthorizeLinkedToItem copyWith({ + String? loginid, PlatformEnum? platform, }) => - WalletLinkedToItem( - accountId: accountId ?? this.accountId, - balance: balance ?? this.balance, - currency: currency ?? this.currency, + AuthorizeLinkedToItem( + loginid: loginid ?? this.loginid, platform: platform ?? this.platform, ); } @@ -819,10 +630,8 @@ abstract class LocalCurrenciesPropertyModel { class LocalCurrenciesProperty extends LocalCurrenciesPropertyModel { /// Initializes Local currencies property class. const LocalCurrenciesProperty({ - required int fractionalDigits, - }) : super( - fractionalDigits: fractionalDigits, - ); + required super.fractionalDigits, + }); /// Creates an instance from JSON. factory LocalCurrenciesProperty.fromJson(Map json) => @@ -847,304 +656,3 @@ class LocalCurrenciesProperty extends LocalCurrenciesPropertyModel { fractionalDigits: fractionalDigits ?? this.fractionalDigits, ); } -/// Authorize trading model class. -abstract class AuthorizeTradingModel { - /// Initializes Authorize trading model class . - const AuthorizeTradingModel({ - this.linkedTo, - }); - - /// Details of the Wallet account linked to the Trading account. - final List? linkedTo; -} - -/// Authorize trading class. -class AuthorizeTrading extends AuthorizeTradingModel { - /// Initializes Authorize trading class. - const AuthorizeTrading({ - List? linkedTo, - }) : super( - linkedTo: linkedTo, - ); - - /// Creates an instance from JSON. - factory AuthorizeTrading.fromJson(Map json) => - AuthorizeTrading( - linkedTo: json['linked_to'] == null - ? null - : List.from( - json['linked_to']?.map( - (dynamic item) => TradingLinkedToItem.fromJson(item), - ), - ), - ); - - /// Converts an instance to JSON. - Map toJson() { - final Map resultMap = {}; - - if (linkedTo != null) { - resultMap['linked_to'] = linkedTo! - .map( - (TradingLinkedToItem item) => item.toJson(), - ) - .toList(); - } - - return resultMap; - } - - /// Creates a copy of instance with given parameters. - AuthorizeTrading copyWith({ - List? linkedTo, - }) => - AuthorizeTrading( - linkedTo: linkedTo ?? this.linkedTo, - ); -} -/// Trading linked to item model class. -abstract class TradingLinkedToItemModel { - /// Initializes Trading linked to item model class . - const TradingLinkedToItemModel({ - this.accountId, - this.balance, - this.currency, - this.paymentMethod, - }); - - /// Wallet account ID. - final String? accountId; - - /// Wallet account balance. - final String? balance; - - /// Wallet account currency. - final String? currency; - - /// Wallet account payment method. - final String? paymentMethod; -} - -/// Trading linked to item class. -class TradingLinkedToItem extends TradingLinkedToItemModel { - /// Initializes Trading linked to item class. - const TradingLinkedToItem({ - String? accountId, - String? balance, - String? currency, - String? paymentMethod, - }) : super( - accountId: accountId, - balance: balance, - currency: currency, - paymentMethod: paymentMethod, - ); - - /// Creates an instance from JSON. - factory TradingLinkedToItem.fromJson(Map json) => - TradingLinkedToItem( - accountId: json['account_id'], - balance: json['balance'], - currency: json['currency'], - paymentMethod: json['payment_method'], - ); - - /// Converts an instance to JSON. - Map toJson() { - final Map resultMap = {}; - - resultMap['account_id'] = accountId; - resultMap['balance'] = balance; - resultMap['currency'] = currency; - resultMap['payment_method'] = paymentMethod; - - return resultMap; - } - - /// Creates a copy of instance with given parameters. - TradingLinkedToItem copyWith({ - String? accountId, - String? balance, - String? currency, - String? paymentMethod, - }) => - TradingLinkedToItem( - accountId: accountId ?? this.accountId, - balance: balance ?? this.balance, - currency: currency ?? this.currency, - paymentMethod: paymentMethod ?? this.paymentMethod, - ); -} -/// Authorize wallet model class. -abstract class AuthorizeWalletModel { - /// Initializes Authorize wallet model class . - const AuthorizeWalletModel({ - this.accountId, - this.balance, - this.currency, - this.linkedTo, - this.paymentMethod, - }); - - /// Wallet account ID. - final String? accountId; - - /// Wallet account balance. - final double? balance; - - /// Wallet account currency. - final String? currency; - - /// Details of the list of Trading accounts linked to the Wallet account. - final List? linkedTo; - - /// Wallet account payment method. - final String? paymentMethod; -} - -/// Authorize wallet class. -class AuthorizeWallet extends AuthorizeWalletModel { - /// Initializes Authorize wallet class. - const AuthorizeWallet({ - String? accountId, - double? balance, - String? currency, - List? linkedTo, - String? paymentMethod, - }) : super( - accountId: accountId, - balance: balance, - currency: currency, - linkedTo: linkedTo, - paymentMethod: paymentMethod, - ); - - /// Creates an instance from JSON. - factory AuthorizeWallet.fromJson(Map json) => - AuthorizeWallet( - accountId: json['account_id'], - balance: getDouble(json['balance']), - currency: json['currency'], - linkedTo: json['linked_to'] == null - ? null - : List.from( - json['linked_to']?.map( - (dynamic item) => WalletLinkedToItem8.fromJson(item), - ), - ), - paymentMethod: json['payment_method'], - ); - - /// Converts an instance to JSON. - Map toJson() { - final Map resultMap = {}; - - resultMap['account_id'] = accountId; - resultMap['balance'] = balance; - resultMap['currency'] = currency; - if (linkedTo != null) { - resultMap['linked_to'] = linkedTo! - .map( - (WalletLinkedToItem8 item) => item.toJson(), - ) - .toList(); - } - resultMap['payment_method'] = paymentMethod; - - return resultMap; - } - - /// Creates a copy of instance with given parameters. - AuthorizeWallet copyWith({ - String? accountId, - double? balance, - String? currency, - List? linkedTo, - String? paymentMethod, - }) => - AuthorizeWallet( - accountId: accountId ?? this.accountId, - balance: balance ?? this.balance, - currency: currency ?? this.currency, - linkedTo: linkedTo ?? this.linkedTo, - paymentMethod: paymentMethod ?? this.paymentMethod, - ); -} -/// Wallet linked to item8 model class. -abstract class WalletLinkedToItem8Model { - /// Initializes Wallet linked to item8 model class . - const WalletLinkedToItem8Model({ - this.accountId, - this.balance, - this.currency, - this.platform, - }); - - /// Trading account ID. - final String? accountId; - - /// Trading account balance. - final String? balance; - - /// Trading account currency. - final String? currency; - - /// Trading account platform name. - final PlatformEnum? platform; -} - -/// Wallet linked to item8 class. -class WalletLinkedToItem8 extends WalletLinkedToItem8Model { - /// Initializes Wallet linked to item8 class. - const WalletLinkedToItem8({ - String? accountId, - String? balance, - String? currency, - PlatformEnum? platform, - }) : super( - accountId: accountId, - balance: balance, - currency: currency, - platform: platform, - ); - - /// Creates an instance from JSON. - factory WalletLinkedToItem8.fromJson(Map json) => - WalletLinkedToItem8( - accountId: json['account_id'], - balance: json['balance'], - currency: json['currency'], - platform: json['platform'] == null - ? null - : platformEnumMapper[json['platform']], - ); - - /// Converts an instance to JSON. - Map toJson() { - final Map resultMap = {}; - - resultMap['account_id'] = accountId; - resultMap['balance'] = balance; - resultMap['currency'] = currency; - resultMap['platform'] = platformEnumMapper.entries - .firstWhere( - (MapEntry entry) => entry.value == platform) - .key; - - return resultMap; - } - - /// Creates a copy of instance with given parameters. - WalletLinkedToItem8 copyWith({ - String? accountId, - String? balance, - String? currency, - PlatformEnum? platform, - }) => - WalletLinkedToItem8( - accountId: accountId ?? this.accountId, - balance: balance ?? this.balance, - currency: currency ?? this.currency, - platform: platform ?? this.platform, - ); -} diff --git a/lib/api/response/available_accounts_response_extended.dart b/lib/api/response/available_accounts_response_extended.dart new file mode 100644 index 0000000000..c7faf3c3e8 --- /dev/null +++ b/lib/api/response/available_accounts_response_extended.dart @@ -0,0 +1,28 @@ +import 'package:deriv_dependency_injector/dependency_injector.dart'; +import 'package:flutter_deriv_api/api/exceptions/exceptions.dart'; +import 'package:flutter_deriv_api/api/response/available_accounts_response_result.dart'; +import 'package:flutter_deriv_api/basic_api/generated/available_accounts_receive.dart'; +import 'package:flutter_deriv_api/basic_api/generated/available_accounts_send.dart'; +import 'package:flutter_deriv_api/helpers/helpers.dart'; +import 'package:flutter_deriv_api/services/connection/api_manager/base_api.dart'; + +/// The extended version of the [AvailableAccountsResponse] class to implement +/// the API call methods. +class AvailableAccountsResponseExtended extends AvailableAccountsResponse { + static final BaseAPI _api = Injector()(); + + /// Fetches the available wallets that can be created + static Future fetchAvailableWalletsToCreate({ + required AvailableAccountsRequest request, + }) async { + final AvailableAccountsReceive response = await _api.call(request: request); + + checkException( + response: response, + exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => + BaseAPIException(baseExceptionModel: baseExceptionModel), + ); + + return AvailableAccountsResponse.fromJson(response.availableAccounts); + } +} diff --git a/lib/api/response/available_accounts_response_result.dart b/lib/api/response/available_accounts_response_result.dart new file mode 100644 index 0000000000..b02d7c3c86 --- /dev/null +++ b/lib/api/response/available_accounts_response_result.dart @@ -0,0 +1,191 @@ +// ignore_for_file: prefer_single_quotes, unnecessary_import, unused_import + +import 'package:equatable/equatable.dart'; + +import 'package:flutter_deriv_api/helpers/helpers.dart'; + +/// Available accounts response model class. +abstract class AvailableAccountsResponseModel { + /// Initializes Available accounts response model class . + const AvailableAccountsResponseModel({ + this.availableAccounts, + }); + + /// Returns list of accounts that are available to be created - limited to wallets and can be extended + final AvailableAccounts? availableAccounts; +} + +/// Available accounts response class. +class AvailableAccountsResponse extends AvailableAccountsResponseModel { + /// Initializes Available accounts response class. + const AvailableAccountsResponse({ + super.availableAccounts, + }); + + /// Creates an instance from JSON. + factory AvailableAccountsResponse.fromJson( + dynamic availableAccountsJson, + ) => + AvailableAccountsResponse( + availableAccounts: availableAccountsJson == null + ? null + : AvailableAccounts.fromJson(availableAccountsJson), + ); + + /// Converts an instance to JSON. + Map toJson() { + final Map resultMap = {}; + + if (availableAccounts != null) { + resultMap['available_accounts'] = availableAccounts!.toJson(); + } + + return resultMap; + } + + /// Creates a copy of instance with given parameters. + AvailableAccountsResponse copyWith({ + AvailableAccounts? availableAccounts, + }) => + AvailableAccountsResponse( + availableAccounts: availableAccounts ?? this.availableAccounts, + ); +} + +/// AccountTypeEnum mapper. +final Map accountTypeEnumMapper = + { + "doughflow": AccountTypeEnum.doughflow, + "crypto": AccountTypeEnum.crypto, + "paymentagent": AccountTypeEnum.paymentagent, + "paymentagent_client": AccountTypeEnum.paymentagentClient, + "p2p": AccountTypeEnum.p2p, +}; + +/// AccountType Enum. +enum AccountTypeEnum { + /// doughflow. + doughflow, + + /// crypto. + crypto, + + /// paymentagent. + paymentagent, + + /// paymentagent_client. + paymentagentClient, + + /// p2p. + p2p, +} +/// Available accounts model class. +abstract class AvailableAccountsModel { + /// Initializes Available accounts model class . + const AvailableAccountsModel({ + required this.wallets, + }); + + /// Wallet account types that are available to be created + final List wallets; +} + +/// Available accounts class. +class AvailableAccounts extends AvailableAccountsModel { + /// Initializes Available accounts class. + const AvailableAccounts({ + required super.wallets, + }); + + /// Creates an instance from JSON. + factory AvailableAccounts.fromJson(Map json) => + AvailableAccounts( + wallets: List.from( + json['wallets'].map( + (dynamic item) => WalletsItem.fromJson(item), + ), + ), + ); + + /// Converts an instance to JSON. + Map toJson() { + final Map resultMap = {}; + + resultMap['wallets'] = wallets + .map( + (WalletsItem item) => item.toJson(), + ) + .toList(); + + return resultMap; + } + + /// Creates a copy of instance with given parameters. + AvailableAccounts copyWith({ + List? wallets, + }) => + AvailableAccounts( + wallets: wallets ?? this.wallets, + ); +} +/// Wallets item model class. +abstract class WalletsItemModel { + /// Initializes Wallets item model class . + const WalletsItemModel({ + required this.landingCompany, + required this.currency, + required this.accountType, + }); + + /// Landing Company of wallet. + final String landingCompany; + + /// Currency of wallet + final String currency; + + /// Account type of wallet + final AccountTypeEnum accountType; +} + +/// Wallets item class. +class WalletsItem extends WalletsItemModel { + /// Initializes Wallets item class. + const WalletsItem({ + required super.accountType, + required super.currency, + required super.landingCompany, + }); + + /// Creates an instance from JSON. + factory WalletsItem.fromJson(Map json) => WalletsItem( + accountType: accountTypeEnumMapper[json['account_type']]!, + currency: json['currency'], + landingCompany: json['landing_company'], + ); + + /// Converts an instance to JSON. + Map toJson() { + final Map resultMap = {}; + + resultMap['account_type'] = accountTypeEnumMapper.entries + .firstWhere((MapEntry entry) => + entry.value == accountType) + .key; + resultMap['currency'] = currency; + resultMap['landing_company'] = landingCompany; + + return resultMap; + } + + /// Creates a copy of instance with given parameters. + WalletsItem copyWith({ + AccountTypeEnum? accountType, + String? currency, + String? landingCompany, + }) => + WalletsItem( + accountType: accountType ?? this.accountType, + currency: currency ?? this.currency, + landingCompany: landingCompany ?? this.landingCompany, + ); +} diff --git a/lib/api/response/balance_response_result.dart b/lib/api/response/balance_response_result.dart index 383ea43793..1ad7a4bf56 100644 --- a/lib/api/response/balance_response_result.dart +++ b/lib/api/response/balance_response_result.dart @@ -74,14 +74,14 @@ class BalanceResponse extends BalanceResponseModel { /// Gets the balance of account /// /// For parameters info refer to [BalanceRequest] - /// Throws a [BalanceException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future fetchBalance(BalanceRequest request) async { final BalanceReceive response = await _api.call(request: request); checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - BalanceException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return BalanceResponse.fromJson(response.balance, response.subscription); @@ -89,7 +89,7 @@ class BalanceResponse extends BalanceResponseModel { /// Instead of one call [Balance.fetchBalance] gets stream of [Balance] /// - /// Throws a [BalanceException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Stream subscribeBalance( BalanceRequest request, { RequestCompareFunction? comparePredicate, @@ -100,7 +100,7 @@ class BalanceResponse extends BalanceResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - BalanceException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return response is BalanceReceive @@ -113,7 +113,7 @@ class BalanceResponse extends BalanceResponseModel { /// Unsubscribes from balance subscription. /// - /// Throws a [BalanceException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error Future unsubscribeBalance() async { if (subscription == null) { return null; @@ -125,7 +125,7 @@ class BalanceResponse extends BalanceResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - BalanceException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return ForgetResponse.fromJson(response.forget); @@ -133,7 +133,7 @@ class BalanceResponse extends BalanceResponseModel { /// Unsubscribes all balance subscriptions. /// - /// Throws a [BalanceException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future unsubscribeAllBalance() async { final ForgetAllReceive response = await _api.unsubscribeAll(method: ForgetStreamType.balance); @@ -141,7 +141,7 @@ class BalanceResponse extends BalanceResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - BalanceException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return ForgetAllResponse.fromJson(response.forgetAll); diff --git a/lib/api/response/buy_response_result.dart b/lib/api/response/buy_response_result.dart index 6045a80247..77d11d7a7e 100644 --- a/lib/api/response/buy_response_result.dart +++ b/lib/api/response/buy_response_result.dart @@ -73,7 +73,7 @@ class BuyResponse extends BuyResponseModel { /// Buys a contract with parameters specified in given [BuyRequest] /// - /// Throws a [ContractOperationException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future buyMethod(BuyRequest request) async { final BuyReceive response = await _api.call( request: request, @@ -82,7 +82,7 @@ class BuyResponse extends BuyResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - ContractOperationException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return BuyResponse.fromJson(response.buy, response.subscription); @@ -90,7 +90,7 @@ class BuyResponse extends BuyResponseModel { /// Buys contract with parameters specified in request and subscribes to it. /// - /// Throws a [ContractOperationException] is API response contains an error + /// Throws a [BaseAPIException] is API response contains an error static Stream buyAndSubscribe( BuyRequest request, { RequestCompareFunction? comparePredicate, @@ -102,8 +102,7 @@ class BuyResponse extends BuyResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - ContractOperationException( - baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return response is ProposalOpenContractReceive ? ProposalOpenContractResponse.fromJson( @@ -116,7 +115,7 @@ class BuyResponse extends BuyResponseModel { /// Gets the current spot of the this bought contract as [Contract]. /// - /// Throws a [ContractOperationException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error Future fetchState() => ProposalOpenContractResponse.fetchContractState( ProposalOpenContractRequest( @@ -126,7 +125,7 @@ class BuyResponse extends BuyResponseModel { /// Subscribes to this bought contract spot and returns its spot update as [ContractBaseModel]. /// - /// Throws a [ContractOperationException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error Stream subscribeState({ RequestCompareFunction? comparePredicate, }) => @@ -139,7 +138,7 @@ class BuyResponse extends BuyResponseModel { /// /// New [stopLoss] value for a contract. To cancel, pass null. /// New [takeProfit] value for a contract. To cancel, pass null. - /// Throws a [ContractOperationException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error Future update({ double? stopLoss, double? takeProfit, diff --git a/lib/api/response/cancel_response_result.dart b/lib/api/response/cancel_response_result.dart index dadf3f58b4..5ebcdc8da8 100644 --- a/lib/api/response/cancel_response_result.dart +++ b/lib/api/response/cancel_response_result.dart @@ -53,14 +53,14 @@ class CancelResponse extends CancelResponseModel { /// Cancels a contract with parameters specified in [CancelRequest]. /// - /// Throws a [ContractOperationException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future cancelContract(CancelRequest request) async { final CancelReceive response = await _api.call(request: request); checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - ContractOperationException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return CancelResponse.fromJson(response.cancel); diff --git a/lib/api/response/cashier_payments_response_extended.dart b/lib/api/response/cashier_payments_response_extended.dart new file mode 100644 index 0000000000..335f3cd5fc --- /dev/null +++ b/lib/api/response/cashier_payments_response_extended.dart @@ -0,0 +1,99 @@ +import 'package:deriv_dependency_injector/dependency_injector.dart'; +import 'package:flutter_deriv_api/api/exceptions/exceptions.dart'; +import 'package:flutter_deriv_api/api/models/enums.dart'; +import 'package:flutter_deriv_api/basic_api/generated/api.dart'; +import 'package:flutter_deriv_api/basic_api/response.dart'; +import 'package:flutter_deriv_api/helpers/helpers.dart'; +import 'package:flutter_deriv_api/services/connection/api_manager/base_api.dart'; +import 'package:flutter_deriv_api/services/connection/call_manager/base_call_manager.dart'; + +import 'cashier_payments_response_result.dart'; +import 'forget_all_response_result.dart'; +import 'forget_response_result.dart'; + +/// The extended version of the [CashierPaymentsResponse] class to implement +/// the API call methods. +class CashierPaymentsResponseExtended extends CashierPaymentsResponse { + static final BaseAPI _api = Injector()(); + + /// Fetches the cashier payments. + static Future fetchCashierPayments({ + required CashierPaymentsRequest request, + }) async { + final CashierPaymentsReceive response = await _api.call(request: request); + + checkException( + response: response, + exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => + BaseAPIException(baseExceptionModel: baseExceptionModel), + ); + + return CashierPaymentsResponse.fromJson( + response.cashierPayments, + response.subscription, + ); + } + + /// Subscribes to the bought contract state specified in [ProposalOpenContractRequest] + /// + /// Throws a [BaseAPIException] if API response contains an error + static Stream subscribeCashierPayment( + CashierPaymentsRequest request, { + RequestCompareFunction? comparePredicate, + }) => + _api + .subscribe(request: request, comparePredicate: comparePredicate)! + .map( + (Response response) { + checkException( + response: response, + exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => + BaseAPIException(baseExceptionModel: baseExceptionModel), + ); + + return response is CashierPaymentsReceive + ? CashierPaymentsResponse.fromJson( + response.cashierPayments, + response.subscription, + ) + : null; + }, + ); + + /// Unsubscribes from cashier payments subscription. + /// + /// Throws a [BaseAPIException] if API response contains an error + Future unsubscribeCashierPayments() async { + if (subscription == null) { + return null; + } + + final ForgetReceive response = + await _api.unsubscribe(subscriptionId: subscription!.id); + + checkException( + response: response, + exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => + BaseAPIException(baseExceptionModel: baseExceptionModel), + ); + + return ForgetResponse.fromJson(response.forget); + } + + /// Unsubscribes all open contract subscriptions. + /// + /// Throws a [BaseAPIException] if API response contains an error + static Future unsubscribeAllCashierPayments() async { + final ForgetAllReceive response = await _api.unsubscribeAll( + method: ForgetStreamType.cashierPayments, + ); + + checkException( + response: response, + exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => + BaseAPIException(baseExceptionModel: baseExceptionModel), + ); + + return ForgetAllResponse.fromJson(response.forgetAll); + } +} diff --git a/lib/api/response/cashier_payments_response_result.dart b/lib/api/response/cashier_payments_response_result.dart index 944787f374..5a7266a601 100644 --- a/lib/api/response/cashier_payments_response_result.dart +++ b/lib/api/response/cashier_payments_response_result.dart @@ -23,12 +23,9 @@ abstract class CashierPaymentsResponseModel { class CashierPaymentsResponse extends CashierPaymentsResponseModel { /// Initializes Cashier payments response class. const CashierPaymentsResponse({ - CashierPayments? cashierPayments, - Subscription? subscription, - }) : super( - cashierPayments: cashierPayments, - subscription: subscription, - ); + super.cashierPayments, + super.subscription, + }); /// Creates an instance from JSON. factory CashierPaymentsResponse.fromJson( @@ -80,6 +77,8 @@ final Map statusCodeEnumMapper = "PERFORMING_BLOCKCHAIN_TXN": StatusCodeEnum.performingBlockchainTxn, "PROCESSING": StatusCodeEnum.processing, "REJECTED": StatusCodeEnum.rejected, + "REVERTED": StatusCodeEnum.reverted, + "REVERTING": StatusCodeEnum.reverting, "SENT": StatusCodeEnum.sent, "VERIFIED": StatusCodeEnum.verified, }; @@ -110,6 +109,12 @@ enum StatusCodeEnum { /// REJECTED. rejected, + /// REVERTED. + reverted, + + /// REVERTING. + reverting, + /// SENT. sent, @@ -147,10 +152,8 @@ abstract class CashierPaymentsModel { class CashierPayments extends CashierPaymentsModel { /// Initializes Cashier payments class. const CashierPayments({ - List? crypto, - }) : super( - crypto: crypto, - ); + super.crypto, + }); /// Creates an instance from JSON. factory CashierPayments.fromJson(Map json) => @@ -198,6 +201,7 @@ abstract class CryptoItemModel { required this.addressUrl, required this.addressHash, this.amount, + this.confirmations, this.isValidToCancel, this.submitDate, this.transactionHash, @@ -210,7 +214,7 @@ abstract class CryptoItemModel { /// The status message of the transaction. final String statusMessage; - /// The status code of the transaction. Possible values for **deposit:** `PENDING|CONFIRMED|ERROR`, possible values for **withdrawal:** `LOCKED|VERIFIED|REJECTED|PERFORMING_BLOCKCHAIN_TXN|PROCESSING|SENT|ERROR|CANCELLED`. + /// The status code of the transaction. Possible values for **deposit:** `PENDING|CONFIRMED|ERROR`, possible values for **withdrawal:** `LOCKED|VERIFIED|REJECTED|PERFORMING_BLOCKCHAIN_TXN|PROCESSING|SENT|ERROR|CANCELLED|REVERTING|REVERTED`. final StatusCodeEnum statusCode; /// The unique identifier for the transaction. @@ -225,6 +229,9 @@ abstract class CryptoItemModel { /// [Optional] The transaction amount. Not present when deposit transaction still unconfirmed. final double? amount; + /// [Optional] The number of confirmations for pending deposits or withdrawals + final int? confirmations; + /// [Optional] Boolean value: `true` or `false`, indicating whether the transaction can be cancelled. Only applicable for `withdrawal` transactions. final bool? isValidToCancel; @@ -242,30 +249,19 @@ abstract class CryptoItemModel { class CryptoItem extends CryptoItemModel { /// Initializes Crypto item class. const CryptoItem({ - required String addressHash, - required String addressUrl, - required String id, - required StatusCodeEnum statusCode, - required String statusMessage, - required TransactionTypeEnum transactionType, - double? amount, - bool? isValidToCancel, - DateTime? submitDate, - String? transactionHash, - String? transactionUrl, - }) : super( - addressHash: addressHash, - addressUrl: addressUrl, - id: id, - statusCode: statusCode, - statusMessage: statusMessage, - transactionType: transactionType, - amount: amount, - isValidToCancel: isValidToCancel, - submitDate: submitDate, - transactionHash: transactionHash, - transactionUrl: transactionUrl, - ); + required super.addressHash, + required super.addressUrl, + required super.id, + required super.statusCode, + required super.statusMessage, + required super.transactionType, + super.amount, + super.confirmations, + super.isValidToCancel, + super.submitDate, + super.transactionHash, + super.transactionUrl, + }); /// Creates an instance from JSON. factory CryptoItem.fromJson(Map json) => CryptoItem( @@ -276,6 +272,7 @@ class CryptoItem extends CryptoItemModel { statusMessage: json['status_message'], transactionType: transactionTypeEnumMapper[json['transaction_type']]!, amount: getDouble(json['amount']), + confirmations: json['confirmations'], isValidToCancel: getBool(json['is_valid_to_cancel']), submitDate: getDateTime(json['submit_date']), transactionHash: json['transaction_hash'], @@ -299,6 +296,7 @@ class CryptoItem extends CryptoItemModel { entry.value == transactionType) .key; resultMap['amount'] = amount; + resultMap['confirmations'] = confirmations; resultMap['is_valid_to_cancel'] = isValidToCancel; resultMap['submit_date'] = getSecondsSinceEpochDateTime(submitDate); resultMap['transaction_hash'] = transactionHash; @@ -316,6 +314,7 @@ class CryptoItem extends CryptoItemModel { String? statusMessage, TransactionTypeEnum? transactionType, double? amount, + int? confirmations, bool? isValidToCancel, DateTime? submitDate, String? transactionHash, @@ -329,6 +328,7 @@ class CryptoItem extends CryptoItemModel { statusMessage: statusMessage ?? this.statusMessage, transactionType: transactionType ?? this.transactionType, amount: amount ?? this.amount, + confirmations: confirmations ?? this.confirmations, isValidToCancel: isValidToCancel ?? this.isValidToCancel, submitDate: submitDate ?? this.submitDate, transactionHash: transactionHash ?? this.transactionHash, @@ -350,10 +350,8 @@ abstract class SubscriptionModel { class Subscription extends SubscriptionModel { /// Initializes Subscription class. const Subscription({ - required String id, - }) : super( - id: id, - ); + required super.id, + }); /// Creates an instance from JSON. factory Subscription.fromJson(Map json) => Subscription( diff --git a/lib/api/response/cashier_response_result.dart b/lib/api/response/cashier_response_result.dart index 373335c940..a15605f57b 100644 --- a/lib/api/response/cashier_response_result.dart +++ b/lib/api/response/cashier_response_result.dart @@ -73,7 +73,7 @@ class CashierResponse extends CashierResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - CashierException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return CashierResponse.fromJson(response.cashier, response.cashier); diff --git a/lib/api/response/contract_update_history_response_result.dart b/lib/api/response/contract_update_history_response_result.dart index c1d9538bed..45bcc33ae2 100644 --- a/lib/api/response/contract_update_history_response_result.dart +++ b/lib/api/response/contract_update_history_response_result.dart @@ -63,7 +63,7 @@ class ContractUpdateHistoryResponse extends ContractUpdateHistoryResponseModel { /// Gets update history for contract as List of [HistorySpotPriceModel] /// - /// Throws a [ContractOperationException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future fetchContractUpdateHistory( ContractUpdateHistoryRequest request, ) async { @@ -73,7 +73,7 @@ class ContractUpdateHistoryResponse extends ContractUpdateHistoryResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - ContractOperationException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return ContractUpdateHistoryResponse.fromJson( diff --git a/lib/api/response/contract_update_response_result.dart b/lib/api/response/contract_update_response_result.dart index ea7be773a1..4eb247d49f 100644 --- a/lib/api/response/contract_update_response_result.dart +++ b/lib/api/response/contract_update_response_result.dart @@ -55,7 +55,7 @@ class ContractUpdateResponse extends ContractUpdateResponseModel { /// updates a contract with parameters specified in [ContractUpdateRequest]. /// - /// Throws a [ContractOperationException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future updateContract( ContractUpdateRequest request, ) async { @@ -64,7 +64,7 @@ class ContractUpdateResponse extends ContractUpdateResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - ContractOperationException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return ContractUpdateResponse.fromJson(response.contractUpdate); diff --git a/lib/api/response/contracts_for_response_result.dart b/lib/api/response/contracts_for_response_result.dart index 5bafb5871d..c8f9b535de 100644 --- a/lib/api/response/contracts_for_response_result.dart +++ b/lib/api/response/contracts_for_response_result.dart @@ -55,7 +55,7 @@ class ContractsForResponse extends ContractsForResponseModel { /// Gets available contracts for given symbol in [ContractsForRequest] /// - /// Throws a [ContractsForSymbolException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future fetchContractsForSymbol( ContractsForRequest request, ) async { @@ -66,7 +66,7 @@ class ContractsForResponse extends ContractsForResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - ContractsForSymbolException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return ContractsForResponse.fromJson(response.contractsFor); diff --git a/lib/api/response/copy_start_response_result.dart b/lib/api/response/copy_start_response_result.dart index 827c5cff2e..9fceb8a8f7 100644 --- a/lib/api/response/copy_start_response_result.dart +++ b/lib/api/response/copy_start_response_result.dart @@ -52,14 +52,14 @@ class CopyStartResponse extends CopyStartResponseModel { /// Starts copy trader bets. /// /// For parameters information refer to [CopyStartRequest]. - /// Throws a [CopyTradingException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future start(CopyStartRequest request) async { final CopyStartReceive response = await _api.call(request: request); checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - CopyTradingException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return CopyStartResponse.fromJson(response.copyStart); diff --git a/lib/api/response/copy_stop_response_result.dart b/lib/api/response/copy_stop_response_result.dart index 6e523659ab..d53a3fa34b 100644 --- a/lib/api/response/copy_stop_response_result.dart +++ b/lib/api/response/copy_stop_response_result.dart @@ -52,14 +52,14 @@ class CopyStopResponse extends CopyStopResponseModel { /// Stops copy trader bets. /// /// For parameters information refer to [CopyStopRequest]. - /// Throws a [CopyTradingException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future stop(CopyStopRequest request) async { final CopyStopReceive response = await _api.call(request: request); checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - CopyTradingException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return CopyStopResponse.fromJson(response.copyStop); diff --git a/lib/api/response/copytrading_list_response_result.dart b/lib/api/response/copytrading_list_response_result.dart index 9be55a7766..158d91def9 100644 --- a/lib/api/response/copytrading_list_response_result.dart +++ b/lib/api/response/copytrading_list_response_result.dart @@ -55,7 +55,7 @@ class CopytradingListResponse extends CopytradingListResponseModel { /// Gets the list of active copiers and/or traders for Copy Trading /// - /// Throws a [CopyTradingException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future fetchList([ CopytradingListRequest? request, ]) async { @@ -66,7 +66,7 @@ class CopytradingListResponse extends CopytradingListResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - CopyTradingException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return CopytradingListResponse.fromJson(response.copytradingList); diff --git a/lib/api/response/copytrading_statistics_response_result.dart b/lib/api/response/copytrading_statistics_response_result.dart index 16451446f9..55c3cb30ec 100644 --- a/lib/api/response/copytrading_statistics_response_result.dart +++ b/lib/api/response/copytrading_statistics_response_result.dart @@ -55,7 +55,7 @@ class CopytradingStatisticsResponse extends CopytradingStatisticsResponseModel { /// Gets the copy trading statistics for given `traderId` in [request] /// - /// Throws a [CopyTradingException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future fetchStatistics( CopytradingStatisticsRequest request, ) async { @@ -66,7 +66,7 @@ class CopytradingStatisticsResponse extends CopytradingStatisticsResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - CopyTradingException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return CopytradingStatisticsResponse.fromJson( diff --git a/lib/api/response/exchange_rates_response_result.dart b/lib/api/response/exchange_rates_response_result.dart index a62f0171c9..62c1a9194b 100644 --- a/lib/api/response/exchange_rates_response_result.dart +++ b/lib/api/response/exchange_rates_response_result.dart @@ -69,7 +69,7 @@ class ExchangeRatesResponse extends ExchangeRatesResponseModel { /// Retrieves the exchange rates from a base currency to all currencies supported by the system. /// /// For parameters information refer to [ExchangeRatesRequest]. - /// Throws an [ExchangeException] if API response contains an error. + /// Throws an [BaseAPIException] if API response contains an error. static Future fetchExchangeRatesRaw( ExchangeRatesRequest request, ) async { @@ -78,7 +78,7 @@ class ExchangeRatesResponse extends ExchangeRatesResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - ExchangeException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return response; @@ -87,7 +87,7 @@ class ExchangeRatesResponse extends ExchangeRatesResponseModel { /// Retrieves the exchange rates from a base currency to all currencies supported by the system. /// /// For parameters information refer to [ExchangeRatesRequest]. - /// Throws an [ExchangeException] if API response contains an error. + /// Throws an [BaseAPIException] if API response contains an error. static Future fetchExchangeRates( ExchangeRatesRequest request, ) async { diff --git a/lib/api/response/forget_all_response_result.dart b/lib/api/response/forget_all_response_result.dart index 3a6fd8e4d6..849c6ac321 100644 --- a/lib/api/response/forget_all_response_result.dart +++ b/lib/api/response/forget_all_response_result.dart @@ -64,7 +64,7 @@ class ForgetAllResponse extends ForgetAllResponseModel { /// Immediately cancels the real-time streams of messages of given type. /// /// For parameters information refer to [ForgetAllRequest]. - /// Throws a [ForgetException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future forgetAllMethod( ForgetAllRequest request, ) async { @@ -73,7 +73,7 @@ class ForgetAllResponse extends ForgetAllResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - ForgetException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return ForgetAllResponse.fromJson(response.forgetAll); diff --git a/lib/api/response/forget_response_result.dart b/lib/api/response/forget_response_result.dart index 95312f3ff7..96087b4812 100644 --- a/lib/api/response/forget_response_result.dart +++ b/lib/api/response/forget_response_result.dart @@ -52,7 +52,7 @@ class ForgetResponse extends ForgetResponseModel { /// Immediately cancels the real-time stream of messages with a specific id. /// /// For parameters information refer to [ForgetRequest]. - /// Throws a [ForgetException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future forgetMethod( ForgetRequest request, ) async { @@ -61,7 +61,7 @@ class ForgetResponse extends ForgetResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - ForgetException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return ForgetResponse.fromJson(response.forget); diff --git a/lib/api/response/get_account_status_response_result.dart b/lib/api/response/get_account_status_response_result.dart index 37887a3c83..8b1e4185fd 100644 --- a/lib/api/response/get_account_status_response_result.dart +++ b/lib/api/response/get_account_status_response_result.dart @@ -56,7 +56,7 @@ class GetAccountStatusResponse extends GetAccountStatusResponseModel { /// Gets the account's status. /// /// For parameters information refer to [GetAccountStatusRequest]. - /// Throws an [AccountStatusException] if API response contains an error. + /// Throws an [BaseAPIException] if API response contains an error. static Future fetchAccountStatusRaw() async { final GetAccountStatusReceive response = await _api.call( request: const GetAccountStatusRequest(), @@ -65,7 +65,7 @@ class GetAccountStatusResponse extends GetAccountStatusResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - AccountStatusException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return response; @@ -74,7 +74,7 @@ class GetAccountStatusResponse extends GetAccountStatusResponseModel { /// Gets the account's status. /// /// For parameters information refer to [GetAccountStatusRequest]. - /// Throws an [AccountStatusException] if API response contains an error. + /// Throws an [BaseAPIException] if API response contains an error. static Future fetchAccountStatus() async { final GetAccountStatusReceive response = await fetchAccountStatusRaw(); diff --git a/lib/api/response/get_account_types_response_extended.dart b/lib/api/response/get_account_types_response_extended.dart new file mode 100644 index 0000000000..6d18f1ead6 --- /dev/null +++ b/lib/api/response/get_account_types_response_extended.dart @@ -0,0 +1,28 @@ +import 'package:deriv_dependency_injector/dependency_injector.dart'; +import 'package:flutter_deriv_api/api/exceptions/exceptions.dart'; +import 'package:flutter_deriv_api/api/response/get_account_status_response_result.dart'; +import 'package:flutter_deriv_api/api/response/get_account_types_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'; + +/// The extended version of the [GetAccountStatusResponse] class to implement +/// the API call methods. +class GetAccountTypesResponseExtended extends GetAccountStatusResponse { + static final BaseAPI _api = Injector()(); + + /// Gets the account types user can register for. + static Future fetchAccountTypes({ + required GetAccountTypesRequest request, + }) async { + final GetAccountTypesReceive response = await _api.call(request: request); + + checkException( + response: response, + exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => + BaseAPIException(baseExceptionModel: baseExceptionModel), + ); + + return GetAccountTypesResponse.fromJson(response.getAccountTypes); + } +} diff --git a/lib/api/response/get_account_types_response_result.dart b/lib/api/response/get_account_types_response_result.dart index 96f3811415..e582c3a1a7 100644 --- a/lib/api/response/get_account_types_response_result.dart +++ b/lib/api/response/get_account_types_response_result.dart @@ -19,10 +19,8 @@ abstract class GetAccountTypesResponseModel { class GetAccountTypesResponse extends GetAccountTypesResponseModel { /// Initializes Get account types response class. const GetAccountTypesResponse({ - GetAccountTypes? getAccountTypes, - }) : super( - getAccountTypes: getAccountTypes, - ); + super.getAccountTypes, + }); /// Creates an instance from JSON. factory GetAccountTypesResponse.fromJson( @@ -59,408 +57,184 @@ abstract class GetAccountTypesModel { const GetAccountTypesModel({ required this.wallet, required this.trading, - this.binary, - this.derivx, - this.mt5, }); - /// Details of the wallet accounts. - final Wallet wallet; - - /// Trading accounts can trade in the Deriv website and apps - final Trading trading; - - /// Traditional accounts of binary.com - final Binary? binary; - - /// The accuonts created for the DerivX platform - final Derivx? derivx; + /// Wallet accounts types that are available to create or link to + final Map wallet; - /// Accounts created for the MT5 platfrom - final Mt5? mt5; + /// Trading account types that are available to create or link to + final Map trading; } /// Get account types class. class GetAccountTypes extends GetAccountTypesModel { /// Initializes Get account types class. const GetAccountTypes({ - required Trading trading, - required Wallet wallet, - Binary? binary, - Derivx? derivx, - Mt5? mt5, - }) : super( - trading: trading, - wallet: wallet, - binary: binary, - derivx: derivx, - mt5: mt5, - ); + required super.trading, + required super.wallet, + }); /// Creates an instance from JSON. factory GetAccountTypes.fromJson(Map json) => GetAccountTypes( - trading: Trading.fromJson(json['trading']), - wallet: Wallet.fromJson(json['wallet']), - binary: json['binary'] == null ? null : Binary.fromJson(json['binary']), - derivx: json['derivx'] == null ? null : Derivx.fromJson(json['derivx']), - mt5: json['mt5'] == null ? null : Mt5.fromJson(json['mt5']), + trading: Map.fromEntries(json['trading'] + .entries + .map>( + (MapEntry entry) => + MapEntry( + entry.key, TradingProperty.fromJson(entry.value)))), + wallet: Map.fromEntries(json['wallet'] + .entries + .map>( + (MapEntry entry) => + MapEntry( + entry.key, WalletProperty.fromJson(entry.value)))), ); /// Converts an instance to JSON. Map toJson() { final Map resultMap = {}; - resultMap['trading'] = trading.toJson(); - - resultMap['wallet'] = wallet.toJson(); - - if (binary != null) { - resultMap['binary'] = binary!.toJson(); - } - if (derivx != null) { - resultMap['derivx'] = derivx!.toJson(); - } - if (mt5 != null) { - resultMap['mt5'] = mt5!.toJson(); - } + resultMap['trading'] = trading; + resultMap['wallet'] = wallet; return resultMap; } /// Creates a copy of instance with given parameters. GetAccountTypes copyWith({ - Trading? trading, - Wallet? wallet, - Binary? binary, - Derivx? derivx, - Mt5? mt5, + Map? trading, + Map? wallet, }) => GetAccountTypes( trading: trading ?? this.trading, wallet: wallet ?? this.wallet, - binary: binary ?? this.binary, - derivx: derivx ?? this.derivx, - mt5: mt5 ?? this.mt5, - ); -} -/// Trading model class. -abstract class TradingModel { - /// Initializes Trading model class . - const TradingModel({ - required this.real, - required this.demo, - }); - - /// Real trading acocounts - final Map real; - - /// Demo trading account - final Map demo; -} - -/// Trading class. -class Trading extends TradingModel { - /// Initializes Trading class. - const Trading({ - required Map demo, - required Map real, - }) : super( - demo: demo, - real: real, - ); - - /// Creates an instance from JSON. - factory Trading.fromJson(Map json) => Trading( - demo: json['demo'], - real: json['real'], - ); - - /// Converts an instance to JSON. - Map toJson() { - final Map resultMap = {}; - - resultMap['demo'] = demo; - resultMap['real'] = real; - - return resultMap; - } - - /// Creates a copy of instance with given parameters. - Trading copyWith({ - Map? demo, - Map? real, - }) => - Trading( - demo: demo ?? this.demo, - real: real ?? this.real, ); } -/// Wallet model class. -abstract class WalletModel { - /// Initializes Wallet model class . - const WalletModel({ - required this.paymentagentClient, - required this.paymentagent, - required this.p2p, - required this.fiat, - required this.demo, - required this.crypto, - required this.affiliate, +/// Trading property model class. +abstract class TradingPropertyModel { + /// Initializes Trading property model class . + const TradingPropertyModel({ + required this.linkableWalletTypes, + required this.linkableToDifferentCurrency, + required this.allowedWalletCurrencies, }); - /// Can receive funds from a payment agent - final Map paymentagentClient; - - /// Can act as a payment agent to other clients - final Map paymentagent; - - /// Can buy/sell using P2P exchanges - final Map p2p; - - /// Can deposit and withdraw through the primary cashier - final Map fiat; + /// Wallet types that this trading account can be linked to. + final List linkableWalletTypes; - /// Demo wallets, linkable to demo accounts only - final Map demo; + /// Can this trading account linked to another currency after opening + final bool linkableToDifferentCurrency; - /// Can deposit and withdraw through the crypto-cashier - final Map crypto; - - /// Can receive affiliate commissions - final Map affiliate; + /// Wallet currencies allowed for this trading account + final List allowedWalletCurrencies; } -/// Wallet class. -class Wallet extends WalletModel { - /// Initializes Wallet class. - const Wallet({ - required Map affiliate, - required Map crypto, - required Map demo, - required Map fiat, - required Map p2p, - required Map paymentagent, - required Map paymentagentClient, - }) : super( - affiliate: affiliate, - crypto: crypto, - demo: demo, - fiat: fiat, - p2p: p2p, - paymentagent: paymentagent, - paymentagentClient: paymentagentClient, - ); - - /// Creates an instance from JSON. - factory Wallet.fromJson(Map json) => Wallet( - affiliate: json['affiliate'], - crypto: json['crypto'], - demo: json['demo'], - fiat: json['fiat'], - p2p: json['p2p'], - paymentagent: json['paymentagent'], - paymentagentClient: json['paymentagent_client'], - ); - - /// Converts an instance to JSON. - Map toJson() { - final Map resultMap = {}; - - resultMap['affiliate'] = affiliate; - resultMap['crypto'] = crypto; - resultMap['demo'] = demo; - resultMap['fiat'] = fiat; - resultMap['p2p'] = p2p; - resultMap['paymentagent'] = paymentagent; - resultMap['paymentagent_client'] = paymentagentClient; - - return resultMap; - } - - /// Creates a copy of instance with given parameters. - Wallet copyWith({ - Map? affiliate, - Map? crypto, - Map? demo, - Map? fiat, - Map? p2p, - Map? paymentagent, - Map? paymentagentClient, - }) => - Wallet( - affiliate: affiliate ?? this.affiliate, - crypto: crypto ?? this.crypto, - demo: demo ?? this.demo, - fiat: fiat ?? this.fiat, - p2p: p2p ?? this.p2p, - paymentagent: paymentagent ?? this.paymentagent, - paymentagentClient: paymentagentClient ?? this.paymentagentClient, - ); -} -/// Binary model class. -abstract class BinaryModel { - /// Initializes Binary model class . - const BinaryModel({ - required this.real, - required this.demo, +/// Trading property class. +class TradingProperty extends TradingPropertyModel { + /// Initializes Trading property class. + const TradingProperty({ + required super.allowedWalletCurrencies, + required super.linkableToDifferentCurrency, + required super.linkableWalletTypes, }); - /// Real acocount - final Map real; - - /// Demo account - final Map demo; -} - -/// Binary class. -class Binary extends BinaryModel { - /// Initializes Binary class. - const Binary({ - required Map demo, - required Map real, - }) : super( - demo: demo, - real: real, - ); - /// Creates an instance from JSON. - factory Binary.fromJson(Map json) => Binary( - demo: json['demo'], - real: json['real'], + factory TradingProperty.fromJson(Map json) => + TradingProperty( + allowedWalletCurrencies: List.from( + json['allowed_wallet_currencies'].map( + (dynamic item) => item, + ), + ), + linkableToDifferentCurrency: + getBool(json['linkable_to_different_currency'])!, + linkableWalletTypes: List.from( + json['linkable_wallet_types'].map( + (dynamic item) => item, + ), + ), ); /// Converts an instance to JSON. Map toJson() { final Map resultMap = {}; - resultMap['demo'] = demo; - resultMap['real'] = real; + resultMap['allowed_wallet_currencies'] = allowedWalletCurrencies + .map( + (String item) => item, + ) + .toList(); - return resultMap; - } - - /// Creates a copy of instance with given parameters. - Binary copyWith({ - Map? demo, - Map? real, - }) => - Binary( - demo: demo ?? this.demo, - real: real ?? this.real, - ); -} -/// Derivx model class. -abstract class DerivxModel { - /// Initializes Derivx model class . - const DerivxModel({ - required this.real, - required this.demo, - }); - - /// Real acocount - final Map real; - - /// Demo account - final Map demo; -} - -/// Derivx class. -class Derivx extends DerivxModel { - /// Initializes Derivx class. - const Derivx({ - required Map demo, - required Map real, - }) : super( - demo: demo, - real: real, - ); - - /// Creates an instance from JSON. - factory Derivx.fromJson(Map json) => Derivx( - demo: json['demo'], - real: json['real'], - ); - - /// Converts an instance to JSON. - Map toJson() { - final Map resultMap = {}; - - resultMap['demo'] = demo; - resultMap['real'] = real; + resultMap['linkable_to_different_currency'] = linkableToDifferentCurrency; + resultMap['linkable_wallet_types'] = linkableWalletTypes + .map( + (String item) => item, + ) + .toList(); return resultMap; } /// Creates a copy of instance with given parameters. - Derivx copyWith({ - Map? demo, - Map? real, + TradingProperty copyWith({ + List? allowedWalletCurrencies, + bool? linkableToDifferentCurrency, + List? linkableWalletTypes, }) => - Derivx( - demo: demo ?? this.demo, - real: real ?? this.real, + TradingProperty( + allowedWalletCurrencies: + allowedWalletCurrencies ?? this.allowedWalletCurrencies, + linkableToDifferentCurrency: + linkableToDifferentCurrency ?? this.linkableToDifferentCurrency, + linkableWalletTypes: linkableWalletTypes ?? this.linkableWalletTypes, ); } -/// Mt5 model class. -abstract class Mt5Model { - /// Initializes Mt5 model class . - const Mt5Model({ - required this.gaming, - required this.financial, - required this.demo, +/// Wallet property model class. +abstract class WalletPropertyModel { + /// Initializes Wallet property model class . + const WalletPropertyModel({ + required this.currencies, }); - /// MT5 trading with synthetic indices - final Map gaming; - - /// MT5 trading with finacial indices - final Map financial; - - /// Demo account - final Map demo; + /// Allowed currencies for creating accounts of this type; used or disallowed currencies are not listed. + final List currencies; } -/// Mt5 class. -class Mt5 extends Mt5Model { - /// Initializes Mt5 class. - const Mt5({ - required Map demo, - required Map financial, - required Map gaming, - }) : super( - demo: demo, - financial: financial, - gaming: gaming, - ); +/// Wallet property class. +class WalletProperty extends WalletPropertyModel { + /// Initializes Wallet property class. + const WalletProperty({ + required super.currencies, + }); /// Creates an instance from JSON. - factory Mt5.fromJson(Map json) => Mt5( - demo: json['demo'], - financial: json['financial'], - gaming: json['gaming'], + factory WalletProperty.fromJson(Map json) => WalletProperty( + currencies: List.from( + json['currencies'].map( + (dynamic item) => item, + ), + ), ); /// Converts an instance to JSON. Map toJson() { final Map resultMap = {}; - resultMap['demo'] = demo; - resultMap['financial'] = financial; - resultMap['gaming'] = gaming; + resultMap['currencies'] = currencies + .map( + (String item) => item, + ) + .toList(); return resultMap; } /// Creates a copy of instance with given parameters. - Mt5 copyWith({ - Map? demo, - Map? financial, - Map? gaming, + WalletProperty copyWith({ + List? currencies, }) => - Mt5( - demo: demo ?? this.demo, - financial: financial ?? this.financial, - gaming: gaming ?? this.gaming, + WalletProperty( + currencies: currencies ?? this.currencies, ); } diff --git a/lib/api/response/get_financial_assessment_response_result.dart b/lib/api/response/get_financial_assessment_response_result.dart index 7d45ce830b..0829e6d906 100644 --- a/lib/api/response/get_financial_assessment_response_result.dart +++ b/lib/api/response/get_financial_assessment_response_result.dart @@ -26,10 +26,8 @@ class GetFinancialAssessmentResponse extends GetFinancialAssessmentResponseModel { /// Initializes Get financial assessment response class. const GetFinancialAssessmentResponse({ - GetFinancialAssessment? getFinancialAssessment, - }) : super( - getFinancialAssessment: getFinancialAssessment, - ); + super.getFinancialAssessment, + }); /// Creates an instance from JSON. factory GetFinancialAssessmentResponse.fromJson( @@ -58,7 +56,7 @@ class GetFinancialAssessmentResponse /// /// The 'financial assessment' is a questionnaire that clients of certain Landing Companies need to complete, /// due to regulatory and KYC (know your client) requirements. - /// Throws a [FinancialAssessmentException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future fetchAssessment( GetFinancialAssessmentRequest request, ) async { @@ -68,7 +66,7 @@ class GetFinancialAssessmentResponse checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - FinancialAssessmentException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return GetFinancialAssessmentResponse.fromJson( @@ -84,7 +82,6 @@ class GetFinancialAssessmentResponse getFinancialAssessment ?? this.getFinancialAssessment, ); } - /// Get financial assessment model class. abstract class GetFinancialAssessmentModel { /// Initializes Get financial assessment model class . @@ -92,7 +89,10 @@ abstract class GetFinancialAssessmentModel { this.accountTurnover, this.binaryOptionsTradingExperience, this.binaryOptionsTradingFrequency, + this.cfdExperience, + this.cfdFrequency, this.cfdScore, + this.cfdTradingDefinition, this.cfdTradingExperience, this.cfdTradingFrequency, this.commoditiesTradingExperience, @@ -107,16 +107,23 @@ abstract class GetFinancialAssessmentModel { this.incomeSource, this.indicesTradingExperience, this.indicesTradingFrequency, + this.leverageImpactTrading, + this.leverageTradingHighRiskStopLoss, this.netIncome, this.occupation, this.otherDerivativesTradingExperience, this.otherDerivativesTradingFrequency, this.otherInstrumentsTradingExperience, this.otherInstrumentsTradingFrequency, + this.requiredInitialMargin, + this.riskTolerance, + this.sourceOfExperience, this.sourceOfWealth, this.stocksTradingExperience, this.stocksTradingFrequency, this.totalScore, + this.tradingExperienceFinancialInstruments, + this.tradingFrequencyFinancialInstruments, this.tradingScore, }); @@ -129,9 +136,18 @@ abstract class GetFinancialAssessmentModel { /// Binary options trading frequency final String? binaryOptionsTradingFrequency; + /// How much experience do you have in CFD trading? + final String? cfdExperience; + + /// How many CFD trades have you placed in the past 12 months? + final String? cfdFrequency; + /// CFD Score final int? cfdScore; + /// In your understanding, CFD trading allows you to: + final String? cfdTradingDefinition; + /// CFDs trading experience final String? cfdTradingExperience; @@ -174,6 +190,12 @@ abstract class GetFinancialAssessmentModel { /// Indices trading frequency final String? indicesTradingFrequency; + /// How does leverage affect CFD trading? + final String? leverageImpactTrading; + + /// Leverage trading is high-risk, so it's a good idea to use risk management features such as stop loss. Stop loss allows you to + final String? leverageTradingHighRiskStopLoss; + /// Net Annual Income final String? netIncome; @@ -192,6 +214,15 @@ abstract class GetFinancialAssessmentModel { /// Trading frequency in other financial instruments final String? otherInstrumentsTradingFrequency; + /// When would you be required to pay an initial margin? + final String? requiredInitialMargin; + + /// Do you understand that you could potentially lose 100% of the money you use to trade? + final String? riskTolerance; + + /// How much knowledge and experience do you have in relation to online trading? + final String? sourceOfExperience; + /// Source of wealth final String? sourceOfWealth; @@ -204,6 +235,12 @@ abstract class GetFinancialAssessmentModel { /// Total Score final int? totalScore; + /// How much experience do you have with other financial instruments? + final String? tradingExperienceFinancialInstruments; + + /// How many trades have you placed with other financial instruments in the past 12 months? + final String? tradingFrequencyFinancialInstruments; + /// Trading Experience Score final int? tradingScore; } @@ -212,66 +249,46 @@ abstract class GetFinancialAssessmentModel { class GetFinancialAssessment extends GetFinancialAssessmentModel { /// Initializes Get financial assessment class. const GetFinancialAssessment({ - String? accountTurnover, - String? binaryOptionsTradingExperience, - String? binaryOptionsTradingFrequency, - int? cfdScore, - String? cfdTradingExperience, - String? cfdTradingFrequency, - String? commoditiesTradingExperience, - String? commoditiesTradingFrequency, - String? educationLevel, - String? employmentIndustry, - String? employmentStatus, - String? estimatedWorth, - int? financialInformationScore, - String? forexTradingExperience, - String? forexTradingFrequency, - String? incomeSource, - String? indicesTradingExperience, - String? indicesTradingFrequency, - String? netIncome, - String? occupation, - String? otherDerivativesTradingExperience, - String? otherDerivativesTradingFrequency, - String? otherInstrumentsTradingExperience, - String? otherInstrumentsTradingFrequency, - String? sourceOfWealth, - String? stocksTradingExperience, - String? stocksTradingFrequency, - int? totalScore, - int? tradingScore, - }) : super( - accountTurnover: accountTurnover, - binaryOptionsTradingExperience: binaryOptionsTradingExperience, - binaryOptionsTradingFrequency: binaryOptionsTradingFrequency, - cfdScore: cfdScore, - cfdTradingExperience: cfdTradingExperience, - cfdTradingFrequency: cfdTradingFrequency, - commoditiesTradingExperience: commoditiesTradingExperience, - commoditiesTradingFrequency: commoditiesTradingFrequency, - educationLevel: educationLevel, - employmentIndustry: employmentIndustry, - employmentStatus: employmentStatus, - estimatedWorth: estimatedWorth, - financialInformationScore: financialInformationScore, - forexTradingExperience: forexTradingExperience, - forexTradingFrequency: forexTradingFrequency, - incomeSource: incomeSource, - indicesTradingExperience: indicesTradingExperience, - indicesTradingFrequency: indicesTradingFrequency, - netIncome: netIncome, - occupation: occupation, - otherDerivativesTradingExperience: otherDerivativesTradingExperience, - otherDerivativesTradingFrequency: otherDerivativesTradingFrequency, - otherInstrumentsTradingExperience: otherInstrumentsTradingExperience, - otherInstrumentsTradingFrequency: otherInstrumentsTradingFrequency, - sourceOfWealth: sourceOfWealth, - stocksTradingExperience: stocksTradingExperience, - stocksTradingFrequency: stocksTradingFrequency, - totalScore: totalScore, - tradingScore: tradingScore, - ); + super.accountTurnover, + super.binaryOptionsTradingExperience, + super.binaryOptionsTradingFrequency, + super.cfdExperience, + super.cfdFrequency, + super.cfdScore, + super.cfdTradingDefinition, + super.cfdTradingExperience, + super.cfdTradingFrequency, + super.commoditiesTradingExperience, + super.commoditiesTradingFrequency, + super.educationLevel, + super.employmentIndustry, + super.employmentStatus, + super.estimatedWorth, + super.financialInformationScore, + super.forexTradingExperience, + super.forexTradingFrequency, + super.incomeSource, + super.indicesTradingExperience, + super.indicesTradingFrequency, + super.leverageImpactTrading, + super.leverageTradingHighRiskStopLoss, + super.netIncome, + super.occupation, + super.otherDerivativesTradingExperience, + super.otherDerivativesTradingFrequency, + super.otherInstrumentsTradingExperience, + super.otherInstrumentsTradingFrequency, + super.requiredInitialMargin, + super.riskTolerance, + super.sourceOfExperience, + super.sourceOfWealth, + super.stocksTradingExperience, + super.stocksTradingFrequency, + super.totalScore, + super.tradingExperienceFinancialInstruments, + super.tradingFrequencyFinancialInstruments, + super.tradingScore, + }); /// Creates an instance from JSON. factory GetFinancialAssessment.fromJson(Map json) => @@ -280,7 +297,10 @@ class GetFinancialAssessment extends GetFinancialAssessmentModel { binaryOptionsTradingExperience: json['binary_options_trading_experience'], binaryOptionsTradingFrequency: json['binary_options_trading_frequency'], + cfdExperience: json['cfd_experience'], + cfdFrequency: json['cfd_frequency'], cfdScore: json['cfd_score'], + cfdTradingDefinition: json['cfd_trading_definition'], cfdTradingExperience: json['cfd_trading_experience'], cfdTradingFrequency: json['cfd_trading_frequency'], commoditiesTradingExperience: json['commodities_trading_experience'], @@ -295,6 +315,9 @@ class GetFinancialAssessment extends GetFinancialAssessmentModel { incomeSource: json['income_source'], indicesTradingExperience: json['indices_trading_experience'], indicesTradingFrequency: json['indices_trading_frequency'], + leverageImpactTrading: json['leverage_impact_trading'], + leverageTradingHighRiskStopLoss: + json['leverage_trading_high_risk_stop_loss'], netIncome: json['net_income'], occupation: json['occupation'], otherDerivativesTradingExperience: @@ -305,10 +328,17 @@ class GetFinancialAssessment extends GetFinancialAssessmentModel { json['other_instruments_trading_experience'], otherInstrumentsTradingFrequency: json['other_instruments_trading_frequency'], + requiredInitialMargin: json['required_initial_margin'], + riskTolerance: json['risk_tolerance'], + sourceOfExperience: json['source_of_experience'], sourceOfWealth: json['source_of_wealth'], stocksTradingExperience: json['stocks_trading_experience'], stocksTradingFrequency: json['stocks_trading_frequency'], totalScore: json['total_score'], + tradingExperienceFinancialInstruments: + json['trading_experience_financial_instruments'], + tradingFrequencyFinancialInstruments: + json['trading_frequency_financial_instruments'], tradingScore: json['trading_score'], ); @@ -321,7 +351,10 @@ class GetFinancialAssessment extends GetFinancialAssessmentModel { binaryOptionsTradingExperience; resultMap['binary_options_trading_frequency'] = binaryOptionsTradingFrequency; + resultMap['cfd_experience'] = cfdExperience; + resultMap['cfd_frequency'] = cfdFrequency; resultMap['cfd_score'] = cfdScore; + resultMap['cfd_trading_definition'] = cfdTradingDefinition; resultMap['cfd_trading_experience'] = cfdTradingExperience; resultMap['cfd_trading_frequency'] = cfdTradingFrequency; resultMap['commodities_trading_experience'] = commoditiesTradingExperience; @@ -336,6 +369,9 @@ class GetFinancialAssessment extends GetFinancialAssessmentModel { resultMap['income_source'] = incomeSource; resultMap['indices_trading_experience'] = indicesTradingExperience; resultMap['indices_trading_frequency'] = indicesTradingFrequency; + resultMap['leverage_impact_trading'] = leverageImpactTrading; + resultMap['leverage_trading_high_risk_stop_loss'] = + leverageTradingHighRiskStopLoss; resultMap['net_income'] = netIncome; resultMap['occupation'] = occupation; resultMap['other_derivatives_trading_experience'] = @@ -346,10 +382,17 @@ class GetFinancialAssessment extends GetFinancialAssessmentModel { otherInstrumentsTradingExperience; resultMap['other_instruments_trading_frequency'] = otherInstrumentsTradingFrequency; + resultMap['required_initial_margin'] = requiredInitialMargin; + resultMap['risk_tolerance'] = riskTolerance; + resultMap['source_of_experience'] = sourceOfExperience; resultMap['source_of_wealth'] = sourceOfWealth; resultMap['stocks_trading_experience'] = stocksTradingExperience; resultMap['stocks_trading_frequency'] = stocksTradingFrequency; resultMap['total_score'] = totalScore; + resultMap['trading_experience_financial_instruments'] = + tradingExperienceFinancialInstruments; + resultMap['trading_frequency_financial_instruments'] = + tradingFrequencyFinancialInstruments; resultMap['trading_score'] = tradingScore; return resultMap; @@ -360,7 +403,10 @@ class GetFinancialAssessment extends GetFinancialAssessmentModel { String? accountTurnover, String? binaryOptionsTradingExperience, String? binaryOptionsTradingFrequency, + String? cfdExperience, + String? cfdFrequency, int? cfdScore, + String? cfdTradingDefinition, String? cfdTradingExperience, String? cfdTradingFrequency, String? commoditiesTradingExperience, @@ -375,16 +421,23 @@ class GetFinancialAssessment extends GetFinancialAssessmentModel { String? incomeSource, String? indicesTradingExperience, String? indicesTradingFrequency, + String? leverageImpactTrading, + String? leverageTradingHighRiskStopLoss, String? netIncome, String? occupation, String? otherDerivativesTradingExperience, String? otherDerivativesTradingFrequency, String? otherInstrumentsTradingExperience, String? otherInstrumentsTradingFrequency, + String? requiredInitialMargin, + String? riskTolerance, + String? sourceOfExperience, String? sourceOfWealth, String? stocksTradingExperience, String? stocksTradingFrequency, int? totalScore, + String? tradingExperienceFinancialInstruments, + String? tradingFrequencyFinancialInstruments, int? tradingScore, }) => GetFinancialAssessment( @@ -393,7 +446,10 @@ class GetFinancialAssessment extends GetFinancialAssessmentModel { this.binaryOptionsTradingExperience, binaryOptionsTradingFrequency: binaryOptionsTradingFrequency ?? this.binaryOptionsTradingFrequency, + cfdExperience: cfdExperience ?? this.cfdExperience, + cfdFrequency: cfdFrequency ?? this.cfdFrequency, cfdScore: cfdScore ?? this.cfdScore, + cfdTradingDefinition: cfdTradingDefinition ?? this.cfdTradingDefinition, cfdTradingExperience: cfdTradingExperience ?? this.cfdTradingExperience, cfdTradingFrequency: cfdTradingFrequency ?? this.cfdTradingFrequency, commoditiesTradingExperience: @@ -415,6 +471,10 @@ class GetFinancialAssessment extends GetFinancialAssessmentModel { indicesTradingExperience ?? this.indicesTradingExperience, indicesTradingFrequency: indicesTradingFrequency ?? this.indicesTradingFrequency, + leverageImpactTrading: + leverageImpactTrading ?? this.leverageImpactTrading, + leverageTradingHighRiskStopLoss: leverageTradingHighRiskStopLoss ?? + this.leverageTradingHighRiskStopLoss, netIncome: netIncome ?? this.netIncome, occupation: occupation ?? this.occupation, otherDerivativesTradingExperience: otherDerivativesTradingExperience ?? @@ -425,12 +485,22 @@ class GetFinancialAssessment extends GetFinancialAssessmentModel { this.otherInstrumentsTradingExperience, otherInstrumentsTradingFrequency: otherInstrumentsTradingFrequency ?? this.otherInstrumentsTradingFrequency, + requiredInitialMargin: + requiredInitialMargin ?? this.requiredInitialMargin, + riskTolerance: riskTolerance ?? this.riskTolerance, + sourceOfExperience: sourceOfExperience ?? this.sourceOfExperience, sourceOfWealth: sourceOfWealth ?? this.sourceOfWealth, stocksTradingExperience: stocksTradingExperience ?? this.stocksTradingExperience, stocksTradingFrequency: stocksTradingFrequency ?? this.stocksTradingFrequency, totalScore: totalScore ?? this.totalScore, + tradingExperienceFinancialInstruments: + tradingExperienceFinancialInstruments ?? + this.tradingExperienceFinancialInstruments, + tradingFrequencyFinancialInstruments: + tradingFrequencyFinancialInstruments ?? + this.tradingFrequencyFinancialInstruments, tradingScore: tradingScore ?? this.tradingScore, ); } diff --git a/lib/api/response/get_limits_response_result.dart b/lib/api/response/get_limits_response_result.dart index 830e26f867..98c0e57a60 100644 --- a/lib/api/response/get_limits_response_result.dart +++ b/lib/api/response/get_limits_response_result.dart @@ -25,10 +25,8 @@ abstract class GetLimitsResponseModel { class GetLimitsResponse extends GetLimitsResponseModel { /// Initializes Get limits response class. const GetLimitsResponse({ - GetLimits? getLimits, - }) : super( - getLimits: getLimits, - ); + super.getLimits, + }); /// Creates an instance from JSON. factory GetLimitsResponse.fromJson( @@ -54,7 +52,7 @@ class GetLimitsResponse extends GetLimitsResponseModel { /// Gets the trading and withdrawal limits for logged in account /// - /// Throws an [AccountLimitsException] if API response contains an error + /// Throws an [BaseAPIException] if API response contains an error static Future fetchAccountLimits([ GetLimitsRequest? request, ]) async { @@ -65,7 +63,7 @@ class GetLimitsResponse extends GetLimitsResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - AccountLimitsException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return GetLimitsResponse.fromJson(response.getLimits); @@ -79,12 +77,12 @@ class GetLimitsResponse extends GetLimitsResponseModel { getLimits: getLimits ?? this.getLimits, ); } - /// Get limits model class. abstract class GetLimitsModel { /// Initializes Get limits model class . const GetLimitsModel({ this.accountBalance, + this.dailyCumulativeAmountTransfers, this.dailyTransfers, this.dailyTurnover, this.lifetimeLimit, @@ -103,6 +101,9 @@ abstract class GetLimitsModel { /// Maximum account cash balance final double? accountBalance; + /// Cumulative daily transfer limits + final Map? dailyCumulativeAmountTransfers; + /// Daily transfers final Map? dailyTransfers; @@ -147,40 +148,28 @@ abstract class GetLimitsModel { class GetLimits extends GetLimitsModel { /// Initializes Get limits class. const GetLimits({ - double? accountBalance, - Map? dailyTransfers, - double? dailyTurnover, - double? lifetimeLimit, - Map>? marketSpecific, - int? numOfDays, - double? numOfDaysLimit, - int? openPositions, - double? payout, - PayoutPerSymbol? payoutPerSymbol, - double? payoutPerSymbolAndContractType, - double? remainder, - double? withdrawalForXDaysMonetary, - double? withdrawalSinceInceptionMonetary, - }) : super( - accountBalance: accountBalance, - dailyTransfers: dailyTransfers, - dailyTurnover: dailyTurnover, - lifetimeLimit: lifetimeLimit, - marketSpecific: marketSpecific, - numOfDays: numOfDays, - numOfDaysLimit: numOfDaysLimit, - openPositions: openPositions, - payout: payout, - payoutPerSymbol: payoutPerSymbol, - payoutPerSymbolAndContractType: payoutPerSymbolAndContractType, - remainder: remainder, - withdrawalForXDaysMonetary: withdrawalForXDaysMonetary, - withdrawalSinceInceptionMonetary: withdrawalSinceInceptionMonetary, - ); + super.accountBalance, + super.dailyCumulativeAmountTransfers, + super.dailyTransfers, + super.dailyTurnover, + super.lifetimeLimit, + super.marketSpecific, + super.numOfDays, + super.numOfDaysLimit, + super.openPositions, + super.payout, + super.payoutPerSymbol, + super.payoutPerSymbolAndContractType, + super.remainder, + super.withdrawalForXDaysMonetary, + super.withdrawalSinceInceptionMonetary, + }); /// Creates an instance from JSON. factory GetLimits.fromJson(Map json) => GetLimits( accountBalance: getDouble(json['account_balance']), + dailyCumulativeAmountTransfers: + json['daily_cumulative_amount_transfers'], dailyTransfers: json['daily_transfers'], dailyTurnover: getDouble(json['daily_turnover']), lifetimeLimit: getDouble(json['lifetime_limit']), @@ -220,6 +209,8 @@ class GetLimits extends GetLimitsModel { final Map resultMap = {}; resultMap['account_balance'] = accountBalance; + resultMap['daily_cumulative_amount_transfers'] = + dailyCumulativeAmountTransfers; resultMap['daily_transfers'] = dailyTransfers; resultMap['daily_turnover'] = dailyTurnover; resultMap['lifetime_limit'] = lifetimeLimit; @@ -244,6 +235,7 @@ class GetLimits extends GetLimitsModel { /// Creates a copy of instance with given parameters. GetLimits copyWith({ double? accountBalance, + Map? dailyCumulativeAmountTransfers, Map? dailyTransfers, double? dailyTurnover, double? lifetimeLimit, @@ -260,6 +252,8 @@ class GetLimits extends GetLimitsModel { }) => GetLimits( accountBalance: accountBalance ?? this.accountBalance, + dailyCumulativeAmountTransfers: dailyCumulativeAmountTransfers ?? + this.dailyCumulativeAmountTransfers, dailyTransfers: dailyTransfers ?? this.dailyTransfers, dailyTurnover: dailyTurnover ?? this.dailyTurnover, lifetimeLimit: lifetimeLimit ?? this.lifetimeLimit, @@ -278,7 +272,6 @@ class GetLimits extends GetLimitsModel { this.withdrawalSinceInceptionMonetary, ); } - /// Market specific property item model class. abstract class MarketSpecificPropertyItemModel { /// Initializes Market specific property item model class . @@ -310,18 +303,12 @@ abstract class MarketSpecificPropertyItemModel { class MarketSpecificPropertyItem extends MarketSpecificPropertyItemModel { /// Initializes Market specific property item class. const MarketSpecificPropertyItem({ - String? level, - String? name, - double? payoutLimit, - String? profileName, - double? turnoverLimit, - }) : super( - level: level, - name: name, - payoutLimit: payoutLimit, - profileName: profileName, - turnoverLimit: turnoverLimit, - ); + super.level, + super.name, + super.payoutLimit, + super.profileName, + super.turnoverLimit, + }); /// Creates an instance from JSON. factory MarketSpecificPropertyItem.fromJson(Map json) => @@ -362,7 +349,6 @@ class MarketSpecificPropertyItem extends MarketSpecificPropertyItemModel { turnoverLimit: turnoverLimit ?? this.turnoverLimit, ); } - /// Payout per symbol model class. abstract class PayoutPerSymbolModel { /// Initializes Payout per symbol model class . @@ -382,12 +368,9 @@ abstract class PayoutPerSymbolModel { class PayoutPerSymbol extends PayoutPerSymbolModel { /// Initializes Payout per symbol class. const PayoutPerSymbol({ - double? atm, - NonAtm? nonAtm, - }) : super( - atm: atm, - nonAtm: nonAtm, - ); + super.atm, + super.nonAtm, + }); /// Creates an instance from JSON. factory PayoutPerSymbol.fromJson(Map json) => @@ -419,7 +402,6 @@ class PayoutPerSymbol extends PayoutPerSymbolModel { nonAtm: nonAtm ?? this.nonAtm, ); } - /// Non atm model class. abstract class NonAtmModel { /// Initializes Non atm model class . @@ -439,12 +421,9 @@ abstract class NonAtmModel { class NonAtm extends NonAtmModel { /// Initializes Non atm class. const NonAtm({ - double? lessThanSevenDays, - double? moreThanSevenDays, - }) : super( - lessThanSevenDays: lessThanSevenDays, - moreThanSevenDays: moreThanSevenDays, - ); + super.lessThanSevenDays, + super.moreThanSevenDays, + }); /// Creates an instance from JSON. factory NonAtm.fromJson(Map json) => NonAtm( diff --git a/lib/api/response/get_self_exclusion_response_result.dart b/lib/api/response/get_self_exclusion_response_result.dart index a1efd5829c..6a963c40dc 100644 --- a/lib/api/response/get_self_exclusion_response_result.dart +++ b/lib/api/response/get_self_exclusion_response_result.dart @@ -60,7 +60,7 @@ class GetSelfExclusionResponse extends GetSelfExclusionResponseModel { /// /// This facility is a regulatory requirement for certain Landing Companies. /// For parameters information refer to [GetSelfExclusionRequest]. - /// Throws a [SelfExclusionException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future fetchSelfExclusion([ GetSelfExclusionRequest? request, ]) async { @@ -71,7 +71,7 @@ class GetSelfExclusionResponse extends GetSelfExclusionResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - SelfExclusionException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return GetSelfExclusionResponse.fromJson(response.getSelfExclusion); @@ -80,14 +80,14 @@ class GetSelfExclusionResponse extends GetSelfExclusionResponseModel { /// Sets Self-Exclusion (this call should be used in conjunction with [fetchSelfExclusion]) /// /// For parameters information refer to [SetSelfExclusionRequest]. - /// Throws a [SelfExclusionException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future setSelfExclusion(SetSelfExclusionRequest request) async { final SetSelfExclusionReceive response = await _api.call(request: request); checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - SelfExclusionException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return getBool(response.setSelfExclusion); @@ -96,7 +96,7 @@ class GetSelfExclusionResponse extends GetSelfExclusionResponseModel { /// Excludes user from the website based this parameters /// /// (this call should be used in conjunction with [fetchSelfExclusion]) - /// Throws a [SelfExclusionException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error Future exclude() async { final SetSelfExclusionReceive response = await _api.call( request: SetSelfExclusionRequest( @@ -121,7 +121,7 @@ class GetSelfExclusionResponse extends GetSelfExclusionResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - SelfExclusionException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return getBool(response.setSelfExclusion); diff --git a/lib/api/response/get_settings_response_result.dart b/lib/api/response/get_settings_response_result.dart index 349c1b1203..1489031c2d 100644 --- a/lib/api/response/get_settings_response_result.dart +++ b/lib/api/response/get_settings_response_result.dart @@ -28,10 +28,8 @@ abstract class GetSettingsResponseModel { class GetSettingsResponse extends GetSettingsResponseModel { /// Initializes Get settings response class. const GetSettingsResponse({ - GetSettings? getSettings, - }) : super( - getSettings: getSettings, - ); + super.getSettings, + }); /// Creates an instance from JSON. factory GetSettingsResponse.fromJson( @@ -59,7 +57,7 @@ class GetSettingsResponse extends GetSettingsResponseModel { /// Gets user's settings (email, date of birth, address etc). /// /// For parameters information refer to [GetSettingsRequest]. - /// Throws an [AccountSettingsException] if API response contains an error. + /// Throws an [BaseAPIException] if API response contains an error. static Future fetchAccountSettingRaw([ GetSettingsRequest? request, ]) async { @@ -70,7 +68,7 @@ class GetSettingsResponse extends GetSettingsResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - AccountSettingsException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return response; @@ -79,7 +77,7 @@ class GetSettingsResponse extends GetSettingsResponseModel { /// Gets user's settings (email, date of birth, address etc). /// /// For parameters information refer to [GetSettingsRequest]. - /// Throws an [AccountSettingsException] if API response contains an error. + /// Throws an [BaseAPIException] if API response contains an error. static Future changeAccountSettingRaw( SetSettingsRequest request, ) async { @@ -88,7 +86,7 @@ class GetSettingsResponse extends GetSettingsResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - AccountSettingsException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return response; @@ -96,7 +94,7 @@ class GetSettingsResponse extends GetSettingsResponseModel { /// Gets user's settings (email, date of birth, address etc). /// - /// Throws an [AccountSettingsException] if API response contains an error. + /// Throws an [BaseAPIException] if API response contains an error. static Future fetchAccountSetting([ GetSettingsRequest? request, ]) async { @@ -107,7 +105,7 @@ class GetSettingsResponse extends GetSettingsResponseModel { /// Changes the user's settings with parameters specified as [SetSettingsRequest]. /// - /// Throws an [AccountSettingsException] if API response contains an error. + /// Throws an [BaseAPIException] if API response contains an error. static Future changeAccountSetting( SetSettingsRequest request, ) async { @@ -132,6 +130,7 @@ class GetSettingsResponse extends GetSettingsResponseModel { allowCopiers: getSettings?.allowCopiers, citizen: getSettings?.citizen, dateOfBirth: getStringFromDateTime(getSettings?.dateOfBirth), + dxtradeUserException: getSettings?.dxtradeUserException, emailConsent: getSettings?.emailConsent, firstName: getSettings?.firstName, lastName: getSettings?.lastName, @@ -157,6 +156,34 @@ class GetSettingsResponse extends GetSettingsResponseModel { ); } +/// EmploymentStatusEnum mapper. +final Map employmentStatusEnumMapper = + { + "Employed": EmploymentStatusEnum.employed, + "Pensioner": EmploymentStatusEnum.pensioner, + "Self-Employed": EmploymentStatusEnum.selfEmployed, + "Student": EmploymentStatusEnum.student, + "Unemployed": EmploymentStatusEnum.unemployed, +}; + +/// EmploymentStatus Enum. +enum EmploymentStatusEnum { + /// Employed. + employed, + + /// Pensioner. + pensioner, + + /// Self-Employed. + selfEmployed, + + /// Student. + student, + + /// Unemployed. + unemployed, +} + /// Get settings model class. abstract class GetSettingsModel { /// Initializes Get settings model class . @@ -170,11 +197,14 @@ abstract class GetSettingsModel { this.allowCopiers, this.citizen, this.clientTncStatus, + this.coolingOffExpirationDate, this.country, this.countryCode, this.dateOfBirth, + this.dxtradeUserException, this.email, this.emailConsent, + this.employmentStatus, this.featureFlag, this.firstName, this.hasSecretAnswer, @@ -221,6 +251,9 @@ abstract class GetSettingsModel { /// Latest terms and conditions version accepted by client final String? clientTncStatus; + /// Cooldown expiration epoch date when a client fails appropriateness tests + final DateTime? coolingOffExpirationDate; + /// User Country (same as residence field) - deprecated final String? country; @@ -230,12 +263,18 @@ abstract class GetSettingsModel { /// Epoch of user's birthday (note: Only available for users who have at least one real account) final DateTime? dateOfBirth; + /// Boolean value `true` or `false`, indicating if user email belong to dxtrade exception list. + final bool? dxtradeUserException; + /// User Email final String? email; /// Boolean value `true` or `false`, indicating permission to use email address for any contact which may include marketing final bool? emailConsent; + /// Employment Status. + final EmploymentStatusEnum? employmentStatus; + /// Contains features that are enabled or disabled for this user final FeatureFlag? featureFlag; @@ -292,70 +331,41 @@ abstract class GetSettingsModel { class GetSettings extends GetSettingsModel { /// Initializes Get settings class. const GetSettings({ - String? accountOpeningReason, - String? addressCity, - String? addressLine1, - String? addressLine2, - String? addressPostcode, - String? addressState, - bool? allowCopiers, - String? citizen, - String? clientTncStatus, - String? country, - String? countryCode, - DateTime? dateOfBirth, - String? email, - bool? emailConsent, - FeatureFlag? featureFlag, - String? firstName, - bool? hasSecretAnswer, - List? immutableFields, - bool? isAuthenticatedPaymentAgent, - String? lastName, - bool? nonPepDeclaration, - String? phone, - String? placeOfBirth, - String? preferredLanguage, - bool? requestProfessionalStatus, - String? residence, - String? salutation, - String? taxIdentificationNumber, - String? taxResidence, - int? tradingHub, - String? userHash, - }) : super( - accountOpeningReason: accountOpeningReason, - addressCity: addressCity, - addressLine1: addressLine1, - addressLine2: addressLine2, - addressPostcode: addressPostcode, - addressState: addressState, - allowCopiers: allowCopiers, - citizen: citizen, - clientTncStatus: clientTncStatus, - country: country, - countryCode: countryCode, - dateOfBirth: dateOfBirth, - email: email, - emailConsent: emailConsent, - featureFlag: featureFlag, - firstName: firstName, - hasSecretAnswer: hasSecretAnswer, - immutableFields: immutableFields, - isAuthenticatedPaymentAgent: isAuthenticatedPaymentAgent, - lastName: lastName, - nonPepDeclaration: nonPepDeclaration, - phone: phone, - placeOfBirth: placeOfBirth, - preferredLanguage: preferredLanguage, - requestProfessionalStatus: requestProfessionalStatus, - residence: residence, - salutation: salutation, - taxIdentificationNumber: taxIdentificationNumber, - taxResidence: taxResidence, - tradingHub: tradingHub, - userHash: userHash, - ); + super.accountOpeningReason, + super.addressCity, + super.addressLine1, + super.addressLine2, + super.addressPostcode, + super.addressState, + super.allowCopiers, + super.citizen, + super.clientTncStatus, + super.coolingOffExpirationDate, + super.country, + super.countryCode, + super.dateOfBirth, + super.dxtradeUserException, + super.email, + super.emailConsent, + super.employmentStatus, + super.featureFlag, + super.firstName, + super.hasSecretAnswer, + super.immutableFields, + super.isAuthenticatedPaymentAgent, + super.lastName, + super.nonPepDeclaration, + super.phone, + super.placeOfBirth, + super.preferredLanguage, + super.requestProfessionalStatus, + super.residence, + super.salutation, + super.taxIdentificationNumber, + super.taxResidence, + super.tradingHub, + super.userHash, + }); /// Creates an instance from JSON. factory GetSettings.fromJson(Map json) => GetSettings( @@ -368,11 +378,17 @@ class GetSettings extends GetSettingsModel { allowCopiers: getBool(json['allow_copiers']), citizen: json['citizen'], clientTncStatus: json['client_tnc_status'], + coolingOffExpirationDate: + getDateTime(json['cooling_off_expiration_date']), country: json['country'], countryCode: json['country_code'], dateOfBirth: getDateTime(json['date_of_birth']), + dxtradeUserException: getBool(json['dxtrade_user_exception']), email: json['email'], emailConsent: getBool(json['email_consent']), + employmentStatus: json['employment_status'] == null + ? null + : employmentStatusEnumMapper[json['employment_status']], featureFlag: json['feature_flag'] == null ? null : FeatureFlag.fromJson(json['feature_flag']), @@ -414,11 +430,18 @@ class GetSettings extends GetSettingsModel { resultMap['allow_copiers'] = allowCopiers; resultMap['citizen'] = citizen; resultMap['client_tnc_status'] = clientTncStatus; + resultMap['cooling_off_expiration_date'] = + getSecondsSinceEpochDateTime(coolingOffExpirationDate); resultMap['country'] = country; resultMap['country_code'] = countryCode; resultMap['date_of_birth'] = getSecondsSinceEpochDateTime(dateOfBirth); + resultMap['dxtrade_user_exception'] = dxtradeUserException; resultMap['email'] = email; resultMap['email_consent'] = emailConsent; + resultMap['employment_status'] = employmentStatusEnumMapper.entries + .firstWhere((MapEntry entry) => + entry.value == employmentStatus) + .key; if (featureFlag != null) { resultMap['feature_flag'] = featureFlag!.toJson(); } @@ -459,11 +482,14 @@ class GetSettings extends GetSettingsModel { bool? allowCopiers, String? citizen, String? clientTncStatus, + DateTime? coolingOffExpirationDate, String? country, String? countryCode, DateTime? dateOfBirth, + bool? dxtradeUserException, String? email, bool? emailConsent, + EmploymentStatusEnum? employmentStatus, FeatureFlag? featureFlag, String? firstName, bool? hasSecretAnswer, @@ -492,11 +518,15 @@ class GetSettings extends GetSettingsModel { allowCopiers: allowCopiers ?? this.allowCopiers, citizen: citizen ?? this.citizen, clientTncStatus: clientTncStatus ?? this.clientTncStatus, + coolingOffExpirationDate: + coolingOffExpirationDate ?? this.coolingOffExpirationDate, country: country ?? this.country, countryCode: countryCode ?? this.countryCode, dateOfBirth: dateOfBirth ?? this.dateOfBirth, + dxtradeUserException: dxtradeUserException ?? this.dxtradeUserException, email: email ?? this.email, emailConsent: emailConsent ?? this.emailConsent, + employmentStatus: employmentStatus ?? this.employmentStatus, featureFlag: featureFlag ?? this.featureFlag, firstName: firstName ?? this.firstName, hasSecretAnswer: hasSecretAnswer ?? this.hasSecretAnswer, @@ -535,10 +565,8 @@ abstract class FeatureFlagModel { class FeatureFlag extends FeatureFlagModel { /// Initializes Feature flag class. const FeatureFlag({ - bool? wallet, - }) : super( - wallet: wallet, - ); + super.wallet, + }); /// Creates an instance from JSON. factory FeatureFlag.fromJson(Map json) => FeatureFlag( diff --git a/lib/api/response/landing_company_details_response_result.dart b/lib/api/response/landing_company_details_response_result.dart index 78eed6e04b..aa9c3ccce2 100644 --- a/lib/api/response/landing_company_details_response_result.dart +++ b/lib/api/response/landing_company_details_response_result.dart @@ -18,10 +18,8 @@ abstract class LandingCompanyDetailsResponseModel { class LandingCompanyDetailsResponse extends LandingCompanyDetailsResponseModel { /// Initializes Landing company details response class. const LandingCompanyDetailsResponse({ - LandingCompanyDetails? landingCompanyDetails, - }) : super( - landingCompanyDetails: landingCompanyDetails, - ); + super.landingCompanyDetails, + }); /// Creates an instance from JSON. factory LandingCompanyDetailsResponse.fromJson( @@ -70,6 +68,7 @@ abstract class LandingCompanyDetailsModel { this.requirements, this.shortcode, this.supportProfessionalClient, + this.tinNotMandatory, }); /// Landing Company address. @@ -110,40 +109,30 @@ abstract class LandingCompanyDetailsModel { /// Flag that indicates whether the landing company supports professional accounts or not final bool? supportProfessionalClient; + + /// Flag that indicates whether tax identifier number is not mandatory for the current country and landing company. + final bool? tinNotMandatory; } /// Landing company details class. class LandingCompanyDetails extends LandingCompanyDetailsModel { /// Initializes Landing company details class. const LandingCompanyDetails({ - List? address, - Map? changeableFields, - String? country, - CurrencyConfig? currencyConfig, - bool? hasRealityCheck, - List? legalAllowedContractCategories, - List? legalAllowedCurrencies, - List? legalAllowedMarkets, - String? legalDefaultCurrency, - String? name, - Requirements? requirements, - String? shortcode, - bool? supportProfessionalClient, - }) : super( - address: address, - changeableFields: changeableFields, - country: country, - currencyConfig: currencyConfig, - hasRealityCheck: hasRealityCheck, - legalAllowedContractCategories: legalAllowedContractCategories, - legalAllowedCurrencies: legalAllowedCurrencies, - legalAllowedMarkets: legalAllowedMarkets, - legalDefaultCurrency: legalDefaultCurrency, - name: name, - requirements: requirements, - shortcode: shortcode, - supportProfessionalClient: supportProfessionalClient, - ); + super.address, + super.changeableFields, + super.country, + super.currencyConfig, + super.hasRealityCheck, + super.legalAllowedContractCategories, + super.legalAllowedCurrencies, + super.legalAllowedMarkets, + super.legalDefaultCurrency, + super.name, + super.requirements, + super.shortcode, + super.supportProfessionalClient, + super.tinNotMandatory, + }); /// Creates an instance from JSON. factory LandingCompanyDetails.fromJson(Map json) => @@ -190,6 +179,7 @@ class LandingCompanyDetails extends LandingCompanyDetailsModel { : Requirements.fromJson(json['requirements']), shortcode: json['shortcode'], supportProfessionalClient: getBool(json['support_professional_client']), + tinNotMandatory: getBool(json['tin_not_mandatory']), ); /// Converts an instance to JSON. @@ -238,6 +228,7 @@ class LandingCompanyDetails extends LandingCompanyDetailsModel { } resultMap['shortcode'] = shortcode; resultMap['support_professional_client'] = supportProfessionalClient; + resultMap['tin_not_mandatory'] = tinNotMandatory; return resultMap; } @@ -257,6 +248,7 @@ class LandingCompanyDetails extends LandingCompanyDetailsModel { Requirements? requirements, String? shortcode, bool? supportProfessionalClient, + bool? tinNotMandatory, }) => LandingCompanyDetails( address: address ?? this.address, @@ -275,6 +267,7 @@ class LandingCompanyDetails extends LandingCompanyDetailsModel { shortcode: shortcode ?? this.shortcode, supportProfessionalClient: supportProfessionalClient ?? this.supportProfessionalClient, + tinNotMandatory: tinNotMandatory ?? this.tinNotMandatory, ); } /// Currency config model class. @@ -312,20 +305,13 @@ abstract class CurrencyConfigModel { class CurrencyConfig extends CurrencyConfigModel { /// Initializes Currency config class. const CurrencyConfig({ - Map? commodities, - Map? cryptocurrency, - Map? forex, - Map? indices, - Market? market, - Map? syntheticIndex, - }) : super( - commodities: commodities, - cryptocurrency: cryptocurrency, - forex: forex, - indices: indices, - market: market, - syntheticIndex: syntheticIndex, - ); + super.commodities, + super.cryptocurrency, + super.forex, + super.indices, + super.market, + super.syntheticIndex, + }); /// Creates an instance from JSON. factory CurrencyConfig.fromJson(Map json) => CurrencyConfig( @@ -386,10 +372,8 @@ abstract class MarketModel { class Market extends MarketModel { /// Initializes Market class. const Market({ - Currency? currency, - }) : super( - currency: currency, - ); + super.currency, + }); /// Creates an instance from JSON. factory Market.fromJson(Map json) => Market( @@ -436,12 +420,9 @@ abstract class CurrencyModel { class Currency extends CurrencyModel { /// Initializes Currency class. const Currency({ - int? maxPayout, - int? minStake, - }) : super( - maxPayout: maxPayout, - minStake: minStake, - ); + super.maxPayout, + super.minStake, + }); /// Creates an instance from JSON. factory Currency.fromJson(Map json) => Currency( @@ -496,16 +477,11 @@ abstract class RequirementsModel { class Requirements extends RequirementsModel { /// Initializes Requirements class. const Requirements({ - AfterFirstDeposit? afterFirstDeposit, - Compliance? compliance, - List? signup, - List? withdrawal, - }) : super( - afterFirstDeposit: afterFirstDeposit, - compliance: compliance, - signup: signup, - withdrawal: withdrawal, - ); + super.afterFirstDeposit, + super.compliance, + super.signup, + super.withdrawal, + }); /// Creates an instance from JSON. factory Requirements.fromJson(Map json) => Requirements( @@ -588,10 +564,8 @@ abstract class AfterFirstDepositModel { class AfterFirstDeposit extends AfterFirstDepositModel { /// Initializes After first deposit class. const AfterFirstDeposit({ - List? financialAssessment, - }) : super( - financialAssessment: financialAssessment, - ); + super.financialAssessment, + }); /// Creates an instance from JSON. factory AfterFirstDeposit.fromJson(Map json) => @@ -647,12 +621,9 @@ abstract class ComplianceModel { class Compliance extends ComplianceModel { /// Initializes Compliance class. const Compliance({ - List? mt5, - List? taxInformation, - }) : super( - mt5: mt5, - taxInformation: taxInformation, - ); + super.mt5, + super.taxInformation, + }); /// Creates an instance from JSON. factory Compliance.fromJson(Map json) => Compliance( diff --git a/lib/api/response/landing_company_response_result.dart b/lib/api/response/landing_company_response_result.dart index 65f777c437..009547c9ae 100644 --- a/lib/api/response/landing_company_response_result.dart +++ b/lib/api/response/landing_company_response_result.dart @@ -28,10 +28,8 @@ abstract class LandingCompanyResponseModel { class LandingCompanyResponse extends LandingCompanyResponseModel { /// Initializes Landing company response class. const LandingCompanyResponse({ - LandingCompany? landingCompany, - }) : super( - landingCompany: landingCompany, - ); + super.landingCompany, + }); /// Creates an instance from JSON. factory LandingCompanyResponse.fromJson( @@ -58,7 +56,7 @@ class LandingCompanyResponse extends LandingCompanyResponseModel { /// Gets landing companies for given [LandingCompanyRequest] /// - /// Throws a [LandingCompanyException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future fetchLandingCompanies( LandingCompanyRequest request, ) async { @@ -67,7 +65,7 @@ class LandingCompanyResponse extends LandingCompanyResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - LandingCompanyException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return LandingCompanyResponse.fromJson(response.landingCompany); @@ -75,7 +73,7 @@ class LandingCompanyResponse extends LandingCompanyResponseModel { /// Gets details of a landing company specified in [LandingCompanyDetailsRequest] /// - /// Throws a [LandingCompanyException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future fetchLandingCompanyDetails( LandingCompanyDetailsRequest request, ) async { @@ -86,7 +84,7 @@ class LandingCompanyResponse extends LandingCompanyResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - LandingCompanyException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return LandingCompanyDetailsResponse.fromJson( @@ -132,7 +130,6 @@ enum StandardEnum { /// none. none, } - /// Landing company model class. abstract class LandingCompanyModel { /// Initializes Landing company model class . @@ -140,6 +137,7 @@ abstract class LandingCompanyModel { this.addressParseable, this.allCompany, this.config, + this.ctrader, this.derivez, this.dxtradeAllCompany, this.dxtradeFinancialCompany, @@ -147,12 +145,12 @@ abstract class LandingCompanyModel { this.financialCompany, this.forbiddenPostcodePattern, this.gamingCompany, - this.gamstopCompany, this.id, this.isIdvSupported, this.lcToOpenMfAccount, this.minimumAge, this.mt5AgeVerification, + this.mtAllCompany, this.mtFinancialCompany, this.mtGamingCompany, this.name, @@ -176,6 +174,9 @@ abstract class LandingCompanyModel { /// Config structure with document types ,taxRequired ,tin format details. final Map? config; + /// Available CTrader accounts. + final Ctrader? ctrader; + /// Available DerivEZ accounts. final Derivez? derivez; @@ -197,9 +198,6 @@ abstract class LandingCompanyModel { /// Landing Company for gaming contracts (Synthetic Indices) final GamingCompany? gamingCompany; - /// Gamestop company details. - final List? gamstopCompany; - /// Country code final String? id; @@ -215,6 +213,9 @@ abstract class LandingCompanyModel { /// Flag to indicate if mt5 age verification detail. final bool? mt5AgeVerification; + /// Landing Company for MT5 standard combined all Synthetic and financial, currently has Financial as subtype. + final MtAllCompany? mtAllCompany; + /// Landing Company for MT5 financial contracts (all except Synthetic Indices), currently divided into Financial STP, Financial (standard) as subtypes. final MtFinancialCompany? mtFinancialCompany; @@ -256,65 +257,36 @@ abstract class LandingCompanyModel { class LandingCompany extends LandingCompanyModel { /// Initializes Landing company class. const LandingCompany({ - bool? addressParseable, - AllCompanyEnum? allCompany, - Map? config, - Derivez? derivez, - DxtradeAllCompany? dxtradeAllCompany, - DxtradeFinancialCompany? dxtradeFinancialCompany, - DxtradeGamingCompany? dxtradeGamingCompany, - FinancialCompany? financialCompany, - String? forbiddenPostcodePattern, - GamingCompany? gamingCompany, - List? gamstopCompany, - String? id, - bool? isIdvSupported, - String? lcToOpenMfAccount, - int? minimumAge, - bool? mt5AgeVerification, - MtFinancialCompany? mtFinancialCompany, - MtGamingCompany? mtGamingCompany, - String? name, - bool? needSetMaxTurnoverLimit, - bool? noProvince, - bool? requireAddressPostcode, - bool? requireAgeVerifiedForSynthetic, - bool? requirePoi, - bool? requireVerificationWhenNotAgeVerified, - bool? skipDepositVerification, - bool? ukgcFundsProtection, - String? virtualCompany, - }) : super( - addressParseable: addressParseable, - allCompany: allCompany, - config: config, - derivez: derivez, - dxtradeAllCompany: dxtradeAllCompany, - dxtradeFinancialCompany: dxtradeFinancialCompany, - dxtradeGamingCompany: dxtradeGamingCompany, - financialCompany: financialCompany, - forbiddenPostcodePattern: forbiddenPostcodePattern, - gamingCompany: gamingCompany, - gamstopCompany: gamstopCompany, - id: id, - isIdvSupported: isIdvSupported, - lcToOpenMfAccount: lcToOpenMfAccount, - minimumAge: minimumAge, - mt5AgeVerification: mt5AgeVerification, - mtFinancialCompany: mtFinancialCompany, - mtGamingCompany: mtGamingCompany, - name: name, - needSetMaxTurnoverLimit: needSetMaxTurnoverLimit, - noProvince: noProvince, - requireAddressPostcode: requireAddressPostcode, - requireAgeVerifiedForSynthetic: requireAgeVerifiedForSynthetic, - requirePoi: requirePoi, - requireVerificationWhenNotAgeVerified: - requireVerificationWhenNotAgeVerified, - skipDepositVerification: skipDepositVerification, - ukgcFundsProtection: ukgcFundsProtection, - virtualCompany: virtualCompany, - ); + super.addressParseable, + super.allCompany, + super.config, + super.ctrader, + super.derivez, + super.dxtradeAllCompany, + super.dxtradeFinancialCompany, + super.dxtradeGamingCompany, + super.financialCompany, + super.forbiddenPostcodePattern, + super.gamingCompany, + super.id, + super.isIdvSupported, + super.lcToOpenMfAccount, + super.minimumAge, + super.mt5AgeVerification, + super.mtAllCompany, + super.mtFinancialCompany, + super.mtGamingCompany, + super.name, + super.needSetMaxTurnoverLimit, + super.noProvince, + super.requireAddressPostcode, + super.requireAgeVerifiedForSynthetic, + super.requirePoi, + super.requireVerificationWhenNotAgeVerified, + super.skipDepositVerification, + super.ukgcFundsProtection, + super.virtualCompany, + }); /// Creates an instance from JSON. factory LandingCompany.fromJson(Map json) => LandingCompany( @@ -323,6 +295,8 @@ class LandingCompany extends LandingCompanyModel { ? null : allCompanyEnumMapper[json['all_company']], config: json['config'], + ctrader: + json['ctrader'] == null ? null : Ctrader.fromJson(json['ctrader']), derivez: json['derivez'] == null ? null : Derivez.fromJson(json['derivez']), dxtradeAllCompany: json['dxtrade_all_company'] == null @@ -342,18 +316,14 @@ class LandingCompany extends LandingCompanyModel { gamingCompany: json['gaming_company'] == null ? null : GamingCompany.fromJson(json['gaming_company']), - gamstopCompany: json['gamstop_company'] == null - ? null - : List.from( - json['gamstop_company']?.map( - (dynamic item) => item, - ), - ), id: json['id'], isIdvSupported: getBool(json['is_idv_supported']), lcToOpenMfAccount: json['lc_to_open_mf_account'], minimumAge: json['minimum_age'], mt5AgeVerification: getBool(json['mt5_age_verification']), + mtAllCompany: json['mt_all_company'] == null + ? null + : MtAllCompany.fromJson(json['mt_all_company']), mtFinancialCompany: json['mt_financial_company'] == null ? null : MtFinancialCompany.fromJson(json['mt_financial_company']), @@ -384,6 +354,9 @@ class LandingCompany extends LandingCompanyModel { entry.value == allCompany) .key; resultMap['config'] = config; + if (ctrader != null) { + resultMap['ctrader'] = ctrader!.toJson(); + } if (derivez != null) { resultMap['derivez'] = derivez!.toJson(); } @@ -404,18 +377,14 @@ class LandingCompany extends LandingCompanyModel { if (gamingCompany != null) { resultMap['gaming_company'] = gamingCompany!.toJson(); } - if (gamstopCompany != null) { - resultMap['gamstop_company'] = gamstopCompany! - .map( - (String item) => item, - ) - .toList(); - } resultMap['id'] = id; resultMap['is_idv_supported'] = isIdvSupported; resultMap['lc_to_open_mf_account'] = lcToOpenMfAccount; resultMap['minimum_age'] = minimumAge; resultMap['mt5_age_verification'] = mt5AgeVerification; + if (mtAllCompany != null) { + resultMap['mt_all_company'] = mtAllCompany!.toJson(); + } if (mtFinancialCompany != null) { resultMap['mt_financial_company'] = mtFinancialCompany!.toJson(); } @@ -443,6 +412,7 @@ class LandingCompany extends LandingCompanyModel { bool? addressParseable, AllCompanyEnum? allCompany, Map? config, + Ctrader? ctrader, Derivez? derivez, DxtradeAllCompany? dxtradeAllCompany, DxtradeFinancialCompany? dxtradeFinancialCompany, @@ -450,12 +420,12 @@ class LandingCompany extends LandingCompanyModel { FinancialCompany? financialCompany, String? forbiddenPostcodePattern, GamingCompany? gamingCompany, - List? gamstopCompany, String? id, bool? isIdvSupported, String? lcToOpenMfAccount, int? minimumAge, bool? mt5AgeVerification, + MtAllCompany? mtAllCompany, MtFinancialCompany? mtFinancialCompany, MtGamingCompany? mtGamingCompany, String? name, @@ -473,6 +443,7 @@ class LandingCompany extends LandingCompanyModel { addressParseable: addressParseable ?? this.addressParseable, allCompany: allCompany ?? this.allCompany, config: config ?? this.config, + ctrader: ctrader ?? this.ctrader, derivez: derivez ?? this.derivez, dxtradeAllCompany: dxtradeAllCompany ?? this.dxtradeAllCompany, dxtradeFinancialCompany: @@ -482,12 +453,12 @@ class LandingCompany extends LandingCompanyModel { forbiddenPostcodePattern: forbiddenPostcodePattern ?? this.forbiddenPostcodePattern, gamingCompany: gamingCompany ?? this.gamingCompany, - gamstopCompany: gamstopCompany ?? this.gamstopCompany, id: id ?? this.id, isIdvSupported: isIdvSupported ?? this.isIdvSupported, lcToOpenMfAccount: lcToOpenMfAccount ?? this.lcToOpenMfAccount, minimumAge: minimumAge ?? this.minimumAge, mt5AgeVerification: mt5AgeVerification ?? this.mt5AgeVerification, + mtAllCompany: mtAllCompany ?? this.mtAllCompany, mtFinancialCompany: mtFinancialCompany ?? this.mtFinancialCompany, mtGamingCompany: mtGamingCompany ?? this.mtGamingCompany, name: name ?? this.name, @@ -508,29 +479,26 @@ class LandingCompany extends LandingCompanyModel { virtualCompany: virtualCompany ?? this.virtualCompany, ); } - -/// Derivez model class. -abstract class DerivezModel { - /// Initializes Derivez model class . - const DerivezModel({ +/// Ctrader model class. +abstract class CtraderModel { + /// Initializes Ctrader model class . + const CtraderModel({ this.all, }); - /// DerivEZ all account types (Synthetic Indices and Financials). + /// CTrader all account types (Synthetic Indices and Financials). final All? all; } -/// Derivez class. -class Derivez extends DerivezModel { - /// Initializes Derivez class. - const Derivez({ - All? all, - }) : super( - all: all, - ); +/// Ctrader class. +class Ctrader extends CtraderModel { + /// Initializes Ctrader class. + const Ctrader({ + super.all, + }); /// Creates an instance from JSON. - factory Derivez.fromJson(Map json) => Derivez( + factory Ctrader.fromJson(Map json) => Ctrader( all: json['all'] == null ? null : All.fromJson(json['all']), ); @@ -546,14 +514,13 @@ class Derivez extends DerivezModel { } /// Creates a copy of instance with given parameters. - Derivez copyWith({ + Ctrader copyWith({ All? all, }) => - Derivez( + Ctrader( all: all ?? this.all, ); } - /// All model class. abstract class AllModel { /// Initializes All model class . @@ -569,10 +536,8 @@ abstract class AllModel { class All extends AllModel { /// Initializes All class. const All({ - StandardEnum? standard, - }) : super( - standard: standard, - ); + super.standard, + }); /// Creates an instance from JSON. factory All.fromJson(Map json) => All( @@ -601,7 +566,93 @@ class All extends AllModel { standard: standard ?? this.standard, ); } +/// Derivez model class. +abstract class DerivezModel { + /// Initializes Derivez model class . + const DerivezModel({ + this.all, + }); + + /// DerivEZ all account types (Synthetic Indices and Financials). + final DerivezAll? all; +} + +/// Derivez class. +class Derivez extends DerivezModel { + /// Initializes Derivez class. + const Derivez({ + super.all, + }); + + /// Creates an instance from JSON. + factory Derivez.fromJson(Map json) => Derivez( + all: json['all'] == null ? null : DerivezAll.fromJson(json['all']), + ); + + /// Converts an instance to JSON. + Map toJson() { + final Map resultMap = {}; + + if (all != null) { + resultMap['all'] = all!.toJson(); + } + + return resultMap; + } + + /// Creates a copy of instance with given parameters. + Derivez copyWith({ + DerivezAll? all, + }) => + Derivez( + all: all ?? this.all, + ); +} +/// Derivez all model class. +abstract class DerivezAllModel { + /// Initializes Derivez all model class . + const DerivezAllModel({ + this.standard, + }); + + /// For standard client + final StandardEnum? standard; +} + +/// Derivez all class. +class DerivezAll extends DerivezAllModel { + /// Initializes Derivez all class. + const DerivezAll({ + super.standard, + }); + + /// Creates an instance from JSON. + factory DerivezAll.fromJson(Map json) => DerivezAll( + standard: json['standard'] == null + ? null + : standardEnumMapper[json['standard']], + ); + + /// Converts an instance to JSON. + Map toJson() { + final Map resultMap = {}; + + resultMap['standard'] = standardEnumMapper.entries + .firstWhere( + (MapEntry entry) => entry.value == standard) + .key; + + return resultMap; + } + /// Creates a copy of instance with given parameters. + DerivezAll copyWith({ + StandardEnum? standard, + }) => + DerivezAll( + standard: standard ?? this.standard, + ); +} /// Dxtrade all company model class. abstract class DxtradeAllCompanyModel { /// Initializes Dxtrade all company model class . @@ -617,10 +668,8 @@ abstract class DxtradeAllCompanyModel { class DxtradeAllCompany extends DxtradeAllCompanyModel { /// Initializes Dxtrade all company class. const DxtradeAllCompany({ - Standard? standard, - }) : super( - standard: standard, - ); + super.standard, + }); /// Creates an instance from JSON. factory DxtradeAllCompany.fromJson(Map json) => @@ -649,7 +698,6 @@ class DxtradeAllCompany extends DxtradeAllCompanyModel { standard: standard ?? this.standard, ); } - /// Standard model class. abstract class StandardModel { /// Initializes Standard model class . @@ -667,6 +715,7 @@ abstract class StandardModel { this.requirements, this.shortcode, this.supportProfessionalClient, + this.tinNotMandatory, }); /// Landing Company address @@ -707,40 +756,30 @@ abstract class StandardModel { /// Flag that indicates whether the landing company supports professional accounts or not final bool? supportProfessionalClient; + + /// Flag that indicates whether tax identifier number is not mandatory for the current country and landing company. + final bool? tinNotMandatory; } /// Standard class. class Standard extends StandardModel { /// Initializes Standard class. const Standard({ - List? address, - Map? changeableFields, - String? country, - Map? currencyConfig, - bool? hasRealityCheck, - List? legalAllowedContractCategories, - List? legalAllowedCurrencies, - List? legalAllowedMarkets, - String? legalDefaultCurrency, - String? name, - Requirements? requirements, - String? shortcode, - bool? supportProfessionalClient, - }) : super( - address: address, - changeableFields: changeableFields, - country: country, - currencyConfig: currencyConfig, - hasRealityCheck: hasRealityCheck, - legalAllowedContractCategories: legalAllowedContractCategories, - legalAllowedCurrencies: legalAllowedCurrencies, - legalAllowedMarkets: legalAllowedMarkets, - legalDefaultCurrency: legalDefaultCurrency, - name: name, - requirements: requirements, - shortcode: shortcode, - supportProfessionalClient: supportProfessionalClient, - ); + super.address, + super.changeableFields, + super.country, + super.currencyConfig, + super.hasRealityCheck, + super.legalAllowedContractCategories, + super.legalAllowedCurrencies, + super.legalAllowedMarkets, + super.legalDefaultCurrency, + super.name, + super.requirements, + super.shortcode, + super.supportProfessionalClient, + super.tinNotMandatory, + }); /// Creates an instance from JSON. factory Standard.fromJson(Map json) => Standard( @@ -784,6 +823,7 @@ class Standard extends StandardModel { : Requirements.fromJson(json['requirements']), shortcode: json['shortcode'], supportProfessionalClient: getBool(json['support_professional_client']), + tinNotMandatory: getBool(json['tin_not_mandatory']), ); /// Converts an instance to JSON. @@ -830,6 +870,7 @@ class Standard extends StandardModel { } resultMap['shortcode'] = shortcode; resultMap['support_professional_client'] = supportProfessionalClient; + resultMap['tin_not_mandatory'] = tinNotMandatory; return resultMap; } @@ -849,6 +890,7 @@ class Standard extends StandardModel { Requirements? requirements, String? shortcode, bool? supportProfessionalClient, + bool? tinNotMandatory, }) => Standard( address: address ?? this.address, @@ -867,9 +909,9 @@ class Standard extends StandardModel { shortcode: shortcode ?? this.shortcode, supportProfessionalClient: supportProfessionalClient ?? this.supportProfessionalClient, + tinNotMandatory: tinNotMandatory ?? this.tinNotMandatory, ); } - /// Requirements model class. abstract class RequirementsModel { /// Initializes Requirements model class . @@ -897,16 +939,11 @@ abstract class RequirementsModel { class Requirements extends RequirementsModel { /// Initializes Requirements class. const Requirements({ - AfterFirstDeposit? afterFirstDeposit, - Compliance? compliance, - List? signup, - List? withdrawal, - }) : super( - afterFirstDeposit: afterFirstDeposit, - compliance: compliance, - signup: signup, - withdrawal: withdrawal, - ); + super.afterFirstDeposit, + super.compliance, + super.signup, + super.withdrawal, + }); /// Creates an instance from JSON. factory Requirements.fromJson(Map json) => Requirements( @@ -974,7 +1011,6 @@ class Requirements extends RequirementsModel { withdrawal: withdrawal ?? this.withdrawal, ); } - /// After first deposit model class. abstract class AfterFirstDepositModel { /// Initializes After first deposit model class . @@ -990,10 +1026,8 @@ abstract class AfterFirstDepositModel { class AfterFirstDeposit extends AfterFirstDepositModel { /// Initializes After first deposit class. const AfterFirstDeposit({ - List? financialAssessment, - }) : super( - financialAssessment: financialAssessment, - ); + super.financialAssessment, + }); /// Creates an instance from JSON. factory AfterFirstDeposit.fromJson(Map json) => @@ -1030,7 +1064,6 @@ class AfterFirstDeposit extends AfterFirstDepositModel { financialAssessment: financialAssessment ?? this.financialAssessment, ); } - /// Compliance model class. abstract class ComplianceModel { /// Initializes Compliance model class . @@ -1050,12 +1083,9 @@ abstract class ComplianceModel { class Compliance extends ComplianceModel { /// Initializes Compliance class. const Compliance({ - List? mt5, - List? taxInformation, - }) : super( - mt5: mt5, - taxInformation: taxInformation, - ); + super.mt5, + super.taxInformation, + }); /// Creates an instance from JSON. factory Compliance.fromJson(Map json) => Compliance( @@ -1107,7 +1137,6 @@ class Compliance extends ComplianceModel { taxInformation: taxInformation ?? this.taxInformation, ); } - /// Dxtrade financial company model class. abstract class DxtradeFinancialCompanyModel { /// Initializes Dxtrade financial company model class . @@ -1123,10 +1152,8 @@ abstract class DxtradeFinancialCompanyModel { class DxtradeFinancialCompany extends DxtradeFinancialCompanyModel { /// Initializes Dxtrade financial company class. const DxtradeFinancialCompany({ - DxtradeFinancialCompanyStandard? standard, - }) : super( - standard: standard, - ); + super.standard, + }); /// Creates an instance from JSON. factory DxtradeFinancialCompany.fromJson(Map json) => @@ -1155,7 +1182,6 @@ class DxtradeFinancialCompany extends DxtradeFinancialCompanyModel { standard: standard ?? this.standard, ); } - /// Dxtrade financial company standard model class. abstract class DxtradeFinancialCompanyStandardModel { /// Initializes Dxtrade financial company standard model class . @@ -1173,6 +1199,7 @@ abstract class DxtradeFinancialCompanyStandardModel { this.requirements, this.shortcode, this.supportProfessionalClient, + this.tinNotMandatory, }); /// Landing Company address @@ -1213,6 +1240,9 @@ abstract class DxtradeFinancialCompanyStandardModel { /// Flag that indicates whether the landing company supports professional accounts or not final bool? supportProfessionalClient; + + /// Flag that indicates whether tax identifier number is not mandatory for the current country and landing company. + final bool? tinNotMandatory; } /// Dxtrade financial company standard class. @@ -1220,34 +1250,21 @@ class DxtradeFinancialCompanyStandard extends DxtradeFinancialCompanyStandardModel { /// Initializes Dxtrade financial company standard class. const DxtradeFinancialCompanyStandard({ - List? address, - Map? changeableFields, - String? country, - Map? currencyConfig, - bool? hasRealityCheck, - List? legalAllowedContractCategories, - List? legalAllowedCurrencies, - List? legalAllowedMarkets, - String? legalDefaultCurrency, - String? name, - StandardRequirements? requirements, - String? shortcode, - bool? supportProfessionalClient, - }) : super( - address: address, - changeableFields: changeableFields, - country: country, - currencyConfig: currencyConfig, - hasRealityCheck: hasRealityCheck, - legalAllowedContractCategories: legalAllowedContractCategories, - legalAllowedCurrencies: legalAllowedCurrencies, - legalAllowedMarkets: legalAllowedMarkets, - legalDefaultCurrency: legalDefaultCurrency, - name: name, - requirements: requirements, - shortcode: shortcode, - supportProfessionalClient: supportProfessionalClient, - ); + super.address, + super.changeableFields, + super.country, + super.currencyConfig, + super.hasRealityCheck, + super.legalAllowedContractCategories, + super.legalAllowedCurrencies, + super.legalAllowedMarkets, + super.legalDefaultCurrency, + super.name, + super.requirements, + super.shortcode, + super.supportProfessionalClient, + super.tinNotMandatory, + }); /// Creates an instance from JSON. factory DxtradeFinancialCompanyStandard.fromJson(Map json) => @@ -1292,6 +1309,7 @@ class DxtradeFinancialCompanyStandard : StandardRequirements.fromJson(json['requirements']), shortcode: json['shortcode'], supportProfessionalClient: getBool(json['support_professional_client']), + tinNotMandatory: getBool(json['tin_not_mandatory']), ); /// Converts an instance to JSON. @@ -1338,6 +1356,7 @@ class DxtradeFinancialCompanyStandard } resultMap['shortcode'] = shortcode; resultMap['support_professional_client'] = supportProfessionalClient; + resultMap['tin_not_mandatory'] = tinNotMandatory; return resultMap; } @@ -1357,6 +1376,7 @@ class DxtradeFinancialCompanyStandard StandardRequirements? requirements, String? shortcode, bool? supportProfessionalClient, + bool? tinNotMandatory, }) => DxtradeFinancialCompanyStandard( address: address ?? this.address, @@ -1375,9 +1395,9 @@ class DxtradeFinancialCompanyStandard shortcode: shortcode ?? this.shortcode, supportProfessionalClient: supportProfessionalClient ?? this.supportProfessionalClient, + tinNotMandatory: tinNotMandatory ?? this.tinNotMandatory, ); } - /// Standard requirements model class. abstract class StandardRequirementsModel { /// Initializes Standard requirements model class . @@ -1405,16 +1425,11 @@ abstract class StandardRequirementsModel { class StandardRequirements extends StandardRequirementsModel { /// Initializes Standard requirements class. const StandardRequirements({ - RequirementsAfterFirstDeposit? afterFirstDeposit, - RequirementsCompliance? compliance, - List? signup, - List? withdrawal, - }) : super( - afterFirstDeposit: afterFirstDeposit, - compliance: compliance, - signup: signup, - withdrawal: withdrawal, - ); + super.afterFirstDeposit, + super.compliance, + super.signup, + super.withdrawal, + }); /// Creates an instance from JSON. factory StandardRequirements.fromJson(Map json) => @@ -1484,7 +1499,6 @@ class StandardRequirements extends StandardRequirementsModel { withdrawal: withdrawal ?? this.withdrawal, ); } - /// Requirements after first deposit model class. abstract class RequirementsAfterFirstDepositModel { /// Initializes Requirements after first deposit model class . @@ -1500,10 +1514,8 @@ abstract class RequirementsAfterFirstDepositModel { class RequirementsAfterFirstDeposit extends RequirementsAfterFirstDepositModel { /// Initializes Requirements after first deposit class. const RequirementsAfterFirstDeposit({ - List? financialAssessment, - }) : super( - financialAssessment: financialAssessment, - ); + super.financialAssessment, + }); /// Creates an instance from JSON. factory RequirementsAfterFirstDeposit.fromJson(Map json) => @@ -1540,7 +1552,6 @@ class RequirementsAfterFirstDeposit extends RequirementsAfterFirstDepositModel { financialAssessment: financialAssessment ?? this.financialAssessment, ); } - /// Requirements compliance model class. abstract class RequirementsComplianceModel { /// Initializes Requirements compliance model class . @@ -1560,12 +1571,9 @@ abstract class RequirementsComplianceModel { class RequirementsCompliance extends RequirementsComplianceModel { /// Initializes Requirements compliance class. const RequirementsCompliance({ - List? mt5, - List? taxInformation, - }) : super( - mt5: mt5, - taxInformation: taxInformation, - ); + super.mt5, + super.taxInformation, + }); /// Creates an instance from JSON. factory RequirementsCompliance.fromJson(Map json) => @@ -1618,7 +1626,6 @@ class RequirementsCompliance extends RequirementsComplianceModel { taxInformation: taxInformation ?? this.taxInformation, ); } - /// Dxtrade gaming company model class. abstract class DxtradeGamingCompanyModel { /// Initializes Dxtrade gaming company model class . @@ -1634,10 +1641,8 @@ abstract class DxtradeGamingCompanyModel { class DxtradeGamingCompany extends DxtradeGamingCompanyModel { /// Initializes Dxtrade gaming company class. const DxtradeGamingCompany({ - DxtradeGamingCompanyStandard? standard, - }) : super( - standard: standard, - ); + super.standard, + }); /// Creates an instance from JSON. factory DxtradeGamingCompany.fromJson(Map json) => @@ -1666,7 +1671,6 @@ class DxtradeGamingCompany extends DxtradeGamingCompanyModel { standard: standard ?? this.standard, ); } - /// Dxtrade gaming company standard model class. abstract class DxtradeGamingCompanyStandardModel { /// Initializes Dxtrade gaming company standard model class . @@ -1684,6 +1688,7 @@ abstract class DxtradeGamingCompanyStandardModel { this.requirements, this.shortcode, this.supportProfessionalClient, + this.tinNotMandatory, }); /// Landing Company address @@ -1717,47 +1722,37 @@ abstract class DxtradeGamingCompanyStandardModel { final String? name; /// Legal requirements for the Landing Company - final StandardRequirements2? requirements; + final StandardRequirements16? requirements; /// Landing Company short code final String? shortcode; /// Flag that indicates whether the landing company supports professional accounts or not final bool? supportProfessionalClient; + + /// Flag that indicates whether tax identifier number is not mandatory for the current country and landing company. + final bool? tinNotMandatory; } /// Dxtrade gaming company standard class. class DxtradeGamingCompanyStandard extends DxtradeGamingCompanyStandardModel { /// Initializes Dxtrade gaming company standard class. const DxtradeGamingCompanyStandard({ - List? address, - Map? changeableFields, - String? country, - Map? currencyConfig, - bool? hasRealityCheck, - List? legalAllowedContractCategories, - List? legalAllowedCurrencies, - List? legalAllowedMarkets, - String? legalDefaultCurrency, - String? name, - StandardRequirements2? requirements, - String? shortcode, - bool? supportProfessionalClient, - }) : super( - address: address, - changeableFields: changeableFields, - country: country, - currencyConfig: currencyConfig, - hasRealityCheck: hasRealityCheck, - legalAllowedContractCategories: legalAllowedContractCategories, - legalAllowedCurrencies: legalAllowedCurrencies, - legalAllowedMarkets: legalAllowedMarkets, - legalDefaultCurrency: legalDefaultCurrency, - name: name, - requirements: requirements, - shortcode: shortcode, - supportProfessionalClient: supportProfessionalClient, - ); + super.address, + super.changeableFields, + super.country, + super.currencyConfig, + super.hasRealityCheck, + super.legalAllowedContractCategories, + super.legalAllowedCurrencies, + super.legalAllowedMarkets, + super.legalDefaultCurrency, + super.name, + super.requirements, + super.shortcode, + super.supportProfessionalClient, + super.tinNotMandatory, + }); /// Creates an instance from JSON. factory DxtradeGamingCompanyStandard.fromJson(Map json) => @@ -1799,9 +1794,10 @@ class DxtradeGamingCompanyStandard extends DxtradeGamingCompanyStandardModel { name: json['name'], requirements: json['requirements'] == null ? null - : StandardRequirements2.fromJson(json['requirements']), + : StandardRequirements16.fromJson(json['requirements']), shortcode: json['shortcode'], supportProfessionalClient: getBool(json['support_professional_client']), + tinNotMandatory: getBool(json['tin_not_mandatory']), ); /// Converts an instance to JSON. @@ -1848,6 +1844,7 @@ class DxtradeGamingCompanyStandard extends DxtradeGamingCompanyStandardModel { } resultMap['shortcode'] = shortcode; resultMap['support_professional_client'] = supportProfessionalClient; + resultMap['tin_not_mandatory'] = tinNotMandatory; return resultMap; } @@ -1864,9 +1861,10 @@ class DxtradeGamingCompanyStandard extends DxtradeGamingCompanyStandardModel { List? legalAllowedMarkets, String? legalDefaultCurrency, String? name, - StandardRequirements2? requirements, + StandardRequirements16? requirements, String? shortcode, bool? supportProfessionalClient, + bool? tinNotMandatory, }) => DxtradeGamingCompanyStandard( address: address ?? this.address, @@ -1885,13 +1883,13 @@ class DxtradeGamingCompanyStandard extends DxtradeGamingCompanyStandardModel { shortcode: shortcode ?? this.shortcode, supportProfessionalClient: supportProfessionalClient ?? this.supportProfessionalClient, + tinNotMandatory: tinNotMandatory ?? this.tinNotMandatory, ); } - -/// Standard requirements2 model class. -abstract class StandardRequirements2Model { - /// Initializes Standard requirements2 model class . - const StandardRequirements2Model({ +/// Standard requirements16 model class. +abstract class StandardRequirements16Model { + /// Initializes Standard requirements16 model class . + const StandardRequirements16Model({ this.afterFirstDeposit, this.compliance, this.signup, @@ -1899,10 +1897,10 @@ abstract class StandardRequirements2Model { }); /// After first deposit requirements - final RequirementsAfterFirstDeposit2? afterFirstDeposit; + final RequirementsAfterFirstDeposit14? afterFirstDeposit; /// Compliance requirements - final RequirementsCompliance2? compliance; + final RequirementsCompliance15? compliance; /// Sign up requirements final List? signup; @@ -1911,31 +1909,26 @@ abstract class StandardRequirements2Model { final List? withdrawal; } -/// Standard requirements2 class. -class StandardRequirements2 extends StandardRequirements2Model { - /// Initializes Standard requirements2 class. - const StandardRequirements2({ - RequirementsAfterFirstDeposit2? afterFirstDeposit, - RequirementsCompliance2? compliance, - List? signup, - List? withdrawal, - }) : super( - afterFirstDeposit: afterFirstDeposit, - compliance: compliance, - signup: signup, - withdrawal: withdrawal, - ); +/// Standard requirements16 class. +class StandardRequirements16 extends StandardRequirements16Model { + /// Initializes Standard requirements16 class. + const StandardRequirements16({ + super.afterFirstDeposit, + super.compliance, + super.signup, + super.withdrawal, + }); /// Creates an instance from JSON. - factory StandardRequirements2.fromJson(Map json) => - StandardRequirements2( + factory StandardRequirements16.fromJson(Map json) => + StandardRequirements16( afterFirstDeposit: json['after_first_deposit'] == null ? null - : RequirementsAfterFirstDeposit2.fromJson( + : RequirementsAfterFirstDeposit14.fromJson( json['after_first_deposit']), compliance: json['compliance'] == null ? null - : RequirementsCompliance2.fromJson(json['compliance']), + : RequirementsCompliance15.fromJson(json['compliance']), signup: json['signup'] == null ? null : List.from( @@ -1981,24 +1974,23 @@ class StandardRequirements2 extends StandardRequirements2Model { } /// Creates a copy of instance with given parameters. - StandardRequirements2 copyWith({ - RequirementsAfterFirstDeposit2? afterFirstDeposit, - RequirementsCompliance2? compliance, + StandardRequirements16 copyWith({ + RequirementsAfterFirstDeposit14? afterFirstDeposit, + RequirementsCompliance15? compliance, List? signup, List? withdrawal, }) => - StandardRequirements2( + StandardRequirements16( afterFirstDeposit: afterFirstDeposit ?? this.afterFirstDeposit, compliance: compliance ?? this.compliance, signup: signup ?? this.signup, withdrawal: withdrawal ?? this.withdrawal, ); } - -/// Requirements after first deposit2 model class. -abstract class RequirementsAfterFirstDeposit2Model { - /// Initializes Requirements after first deposit2 model class . - const RequirementsAfterFirstDeposit2Model({ +/// Requirements after first deposit14 model class. +abstract class RequirementsAfterFirstDeposit14Model { + /// Initializes Requirements after first deposit14 model class . + const RequirementsAfterFirstDeposit14Model({ this.financialAssessment, }); @@ -2006,19 +1998,17 @@ abstract class RequirementsAfterFirstDeposit2Model { final List? financialAssessment; } -/// Requirements after first deposit2 class. -class RequirementsAfterFirstDeposit2 - extends RequirementsAfterFirstDeposit2Model { - /// Initializes Requirements after first deposit2 class. - const RequirementsAfterFirstDeposit2({ - List? financialAssessment, - }) : super( - financialAssessment: financialAssessment, - ); +/// Requirements after first deposit14 class. +class RequirementsAfterFirstDeposit14 + extends RequirementsAfterFirstDeposit14Model { + /// Initializes Requirements after first deposit14 class. + const RequirementsAfterFirstDeposit14({ + super.financialAssessment, + }); /// Creates an instance from JSON. - factory RequirementsAfterFirstDeposit2.fromJson(Map json) => - RequirementsAfterFirstDeposit2( + factory RequirementsAfterFirstDeposit14.fromJson(Map json) => + RequirementsAfterFirstDeposit14( financialAssessment: json['financial_assessment'] == null ? null : List.from( @@ -2044,18 +2034,17 @@ class RequirementsAfterFirstDeposit2 } /// Creates a copy of instance with given parameters. - RequirementsAfterFirstDeposit2 copyWith({ + RequirementsAfterFirstDeposit14 copyWith({ List? financialAssessment, }) => - RequirementsAfterFirstDeposit2( + RequirementsAfterFirstDeposit14( financialAssessment: financialAssessment ?? this.financialAssessment, ); } - -/// Requirements compliance2 model class. -abstract class RequirementsCompliance2Model { - /// Initializes Requirements compliance2 model class . - const RequirementsCompliance2Model({ +/// Requirements compliance15 model class. +abstract class RequirementsCompliance15Model { + /// Initializes Requirements compliance15 model class . + const RequirementsCompliance15Model({ this.mt5, this.taxInformation, }); @@ -2067,20 +2056,17 @@ abstract class RequirementsCompliance2Model { final List? taxInformation; } -/// Requirements compliance2 class. -class RequirementsCompliance2 extends RequirementsCompliance2Model { - /// Initializes Requirements compliance2 class. - const RequirementsCompliance2({ - List? mt5, - List? taxInformation, - }) : super( - mt5: mt5, - taxInformation: taxInformation, - ); +/// Requirements compliance15 class. +class RequirementsCompliance15 extends RequirementsCompliance15Model { + /// Initializes Requirements compliance15 class. + const RequirementsCompliance15({ + super.mt5, + super.taxInformation, + }); /// Creates an instance from JSON. - factory RequirementsCompliance2.fromJson(Map json) => - RequirementsCompliance2( + factory RequirementsCompliance15.fromJson(Map json) => + RequirementsCompliance15( mt5: json['mt5'] == null ? null : List.from( @@ -2120,16 +2106,15 @@ class RequirementsCompliance2 extends RequirementsCompliance2Model { } /// Creates a copy of instance with given parameters. - RequirementsCompliance2 copyWith({ + RequirementsCompliance15 copyWith({ List? mt5, List? taxInformation, }) => - RequirementsCompliance2( + RequirementsCompliance15( mt5: mt5 ?? this.mt5, taxInformation: taxInformation ?? this.taxInformation, ); } - /// Financial company model class. abstract class FinancialCompanyModel { /// Initializes Financial company model class . @@ -2147,6 +2132,7 @@ abstract class FinancialCompanyModel { this.requirements, this.shortcode, this.supportProfessionalClient, + this.tinNotMandatory, }); /// Landing Company address @@ -2187,40 +2173,30 @@ abstract class FinancialCompanyModel { /// Flag that indicates whether the landing company supports professional accounts or not final bool? supportProfessionalClient; + + /// Flag that indicates whether tax identifier number is not mandatory for the current country and landing company. + final bool? tinNotMandatory; } /// Financial company class. class FinancialCompany extends FinancialCompanyModel { /// Initializes Financial company class. const FinancialCompany({ - List? address, - Map? changeableFields, - String? country, - Map? currencyConfig, - bool? hasRealityCheck, - List? legalAllowedContractCategories, - List? legalAllowedCurrencies, - List? legalAllowedMarkets, - String? legalDefaultCurrency, - String? name, - FinancialCompanyRequirements? requirements, - String? shortcode, - bool? supportProfessionalClient, - }) : super( - address: address, - changeableFields: changeableFields, - country: country, - currencyConfig: currencyConfig, - hasRealityCheck: hasRealityCheck, - legalAllowedContractCategories: legalAllowedContractCategories, - legalAllowedCurrencies: legalAllowedCurrencies, - legalAllowedMarkets: legalAllowedMarkets, - legalDefaultCurrency: legalDefaultCurrency, - name: name, - requirements: requirements, - shortcode: shortcode, - supportProfessionalClient: supportProfessionalClient, - ); + super.address, + super.changeableFields, + super.country, + super.currencyConfig, + super.hasRealityCheck, + super.legalAllowedContractCategories, + super.legalAllowedCurrencies, + super.legalAllowedMarkets, + super.legalDefaultCurrency, + super.name, + super.requirements, + super.shortcode, + super.supportProfessionalClient, + super.tinNotMandatory, + }); /// Creates an instance from JSON. factory FinancialCompany.fromJson(Map json) => @@ -2265,6 +2241,7 @@ class FinancialCompany extends FinancialCompanyModel { : FinancialCompanyRequirements.fromJson(json['requirements']), shortcode: json['shortcode'], supportProfessionalClient: getBool(json['support_professional_client']), + tinNotMandatory: getBool(json['tin_not_mandatory']), ); /// Converts an instance to JSON. @@ -2311,6 +2288,7 @@ class FinancialCompany extends FinancialCompanyModel { } resultMap['shortcode'] = shortcode; resultMap['support_professional_client'] = supportProfessionalClient; + resultMap['tin_not_mandatory'] = tinNotMandatory; return resultMap; } @@ -2330,6 +2308,7 @@ class FinancialCompany extends FinancialCompanyModel { FinancialCompanyRequirements? requirements, String? shortcode, bool? supportProfessionalClient, + bool? tinNotMandatory, }) => FinancialCompany( address: address ?? this.address, @@ -2348,9 +2327,9 @@ class FinancialCompany extends FinancialCompanyModel { shortcode: shortcode ?? this.shortcode, supportProfessionalClient: supportProfessionalClient ?? this.supportProfessionalClient, + tinNotMandatory: tinNotMandatory ?? this.tinNotMandatory, ); } - /// Financial company requirements model class. abstract class FinancialCompanyRequirementsModel { /// Initializes Financial company requirements model class . @@ -2362,10 +2341,10 @@ abstract class FinancialCompanyRequirementsModel { }); /// After first deposit requirements - final RequirementsAfterFirstDeposit2? afterFirstDeposit; + final RequirementsAfterFirstDeposit19? afterFirstDeposit; /// Compliance requirements - final RequirementsCompliance2? compliance; + final RequirementsCompliance20? compliance; /// Sign up requirements final List? signup; @@ -2378,27 +2357,22 @@ abstract class FinancialCompanyRequirementsModel { class FinancialCompanyRequirements extends FinancialCompanyRequirementsModel { /// Initializes Financial company requirements class. const FinancialCompanyRequirements({ - RequirementsAfterFirstDeposit2? afterFirstDeposit, - RequirementsCompliance2? compliance, - List? signup, - List? withdrawal, - }) : super( - afterFirstDeposit: afterFirstDeposit, - compliance: compliance, - signup: signup, - withdrawal: withdrawal, - ); + super.afterFirstDeposit, + super.compliance, + super.signup, + super.withdrawal, + }); /// Creates an instance from JSON. factory FinancialCompanyRequirements.fromJson(Map json) => FinancialCompanyRequirements( afterFirstDeposit: json['after_first_deposit'] == null ? null - : RequirementsAfterFirstDeposit2.fromJson( + : RequirementsAfterFirstDeposit19.fromJson( json['after_first_deposit']), compliance: json['compliance'] == null ? null - : RequirementsCompliance2.fromJson(json['compliance']), + : RequirementsCompliance20.fromJson(json['compliance']), signup: json['signup'] == null ? null : List.from( @@ -2445,8 +2419,8 @@ class FinancialCompanyRequirements extends FinancialCompanyRequirementsModel { /// Creates a copy of instance with given parameters. FinancialCompanyRequirements copyWith({ - RequirementsAfterFirstDeposit2? afterFirstDeposit, - RequirementsCompliance2? compliance, + RequirementsAfterFirstDeposit19? afterFirstDeposit, + RequirementsCompliance20? compliance, List? signup, List? withdrawal, }) => @@ -2457,14 +2431,141 @@ class FinancialCompanyRequirements extends FinancialCompanyRequirementsModel { withdrawal: withdrawal ?? this.withdrawal, ); } +/// Requirements after first deposit19 model class. +abstract class RequirementsAfterFirstDeposit19Model { + /// Initializes Requirements after first deposit19 model class . + const RequirementsAfterFirstDeposit19Model({ + this.financialAssessment, + }); -/// Gaming company model class. -abstract class GamingCompanyModel { - /// Initializes Gaming company model class . - const GamingCompanyModel({ - this.address, - this.changeableFields, - this.country, + /// Financial assessment requirements + final List? financialAssessment; +} + +/// Requirements after first deposit19 class. +class RequirementsAfterFirstDeposit19 + extends RequirementsAfterFirstDeposit19Model { + /// Initializes Requirements after first deposit19 class. + const RequirementsAfterFirstDeposit19({ + super.financialAssessment, + }); + + /// Creates an instance from JSON. + factory RequirementsAfterFirstDeposit19.fromJson(Map json) => + RequirementsAfterFirstDeposit19( + financialAssessment: json['financial_assessment'] == null + ? null + : List.from( + json['financial_assessment']?.map( + (dynamic item) => item, + ), + ), + ); + + /// Converts an instance to JSON. + Map toJson() { + final Map resultMap = {}; + + if (financialAssessment != null) { + resultMap['financial_assessment'] = financialAssessment! + .map( + (String item) => item, + ) + .toList(); + } + + return resultMap; + } + + /// Creates a copy of instance with given parameters. + RequirementsAfterFirstDeposit19 copyWith({ + List? financialAssessment, + }) => + RequirementsAfterFirstDeposit19( + financialAssessment: financialAssessment ?? this.financialAssessment, + ); +} +/// Requirements compliance20 model class. +abstract class RequirementsCompliance20Model { + /// Initializes Requirements compliance20 model class . + const RequirementsCompliance20Model({ + this.mt5, + this.taxInformation, + }); + + /// Compliance MT5 requirements + final List? mt5; + + /// Compliance tax information requirements + final List? taxInformation; +} + +/// Requirements compliance20 class. +class RequirementsCompliance20 extends RequirementsCompliance20Model { + /// Initializes Requirements compliance20 class. + const RequirementsCompliance20({ + super.mt5, + super.taxInformation, + }); + + /// Creates an instance from JSON. + factory RequirementsCompliance20.fromJson(Map json) => + RequirementsCompliance20( + mt5: json['mt5'] == null + ? null + : List.from( + json['mt5']?.map( + (dynamic item) => item, + ), + ), + taxInformation: json['tax_information'] == null + ? null + : List.from( + json['tax_information']?.map( + (dynamic item) => item, + ), + ), + ); + + /// Converts an instance to JSON. + Map toJson() { + final Map resultMap = {}; + + if (mt5 != null) { + resultMap['mt5'] = mt5! + .map( + (String item) => item, + ) + .toList(); + } + if (taxInformation != null) { + resultMap['tax_information'] = taxInformation! + .map( + (String item) => item, + ) + .toList(); + } + + return resultMap; + } + + /// Creates a copy of instance with given parameters. + RequirementsCompliance20 copyWith({ + List? mt5, + List? taxInformation, + }) => + RequirementsCompliance20( + mt5: mt5 ?? this.mt5, + taxInformation: taxInformation ?? this.taxInformation, + ); +} +/// Gaming company model class. +abstract class GamingCompanyModel { + /// Initializes Gaming company model class . + const GamingCompanyModel({ + this.address, + this.changeableFields, + this.country, this.currencyConfig, this.hasRealityCheck, this.legalAllowedContractCategories, @@ -2475,6 +2576,7 @@ abstract class GamingCompanyModel { this.requirements, this.shortcode, this.supportProfessionalClient, + this.tinNotMandatory, }); /// Landing Company address @@ -2515,12 +2617,127 @@ abstract class GamingCompanyModel { /// Flag that indicates whether the landing company supports professional accounts or not final bool? supportProfessionalClient; + + /// Flag that indicates whether tax identifier number is not mandatory for the current country and landing company. + final bool? tinNotMandatory; } /// Gaming company class. class GamingCompany extends GamingCompanyModel { /// Initializes Gaming company class. const GamingCompany({ + super.address, + super.changeableFields, + super.country, + super.currencyConfig, + super.hasRealityCheck, + super.legalAllowedContractCategories, + super.legalAllowedCurrencies, + super.legalAllowedMarkets, + super.legalDefaultCurrency, + super.name, + super.requirements, + super.shortcode, + super.supportProfessionalClient, + super.tinNotMandatory, + }); + + /// Creates an instance from JSON. + factory GamingCompany.fromJson(Map json) => GamingCompany( + address: json['address'] == null + ? null + : List.from( + json['address']?.map( + (dynamic item) => item, + ), + ), + changeableFields: json['changeable_fields'], + country: json['country'], + currencyConfig: json['currency_config'], + hasRealityCheck: getBool(json['has_reality_check']), + legalAllowedContractCategories: + json['legal_allowed_contract_categories'] == null + ? null + : List.from( + json['legal_allowed_contract_categories']?.map( + (dynamic item) => item, + ), + ), + legalAllowedCurrencies: json['legal_allowed_currencies'] == null + ? null + : List.from( + json['legal_allowed_currencies']?.map( + (dynamic item) => item, + ), + ), + legalAllowedMarkets: json['legal_allowed_markets'] == null + ? null + : List.from( + json['legal_allowed_markets']?.map( + (dynamic item) => item, + ), + ), + legalDefaultCurrency: json['legal_default_currency'], + name: json['name'], + requirements: json['requirements'] == null + ? null + : GamingCompanyRequirements.fromJson(json['requirements']), + shortcode: json['shortcode'], + supportProfessionalClient: getBool(json['support_professional_client']), + tinNotMandatory: getBool(json['tin_not_mandatory']), + ); + + /// Converts an instance to JSON. + Map toJson() { + final Map resultMap = {}; + + if (address != null) { + resultMap['address'] = address! + .map( + (String item) => item, + ) + .toList(); + } + resultMap['changeable_fields'] = changeableFields; + resultMap['country'] = country; + resultMap['currency_config'] = currencyConfig; + resultMap['has_reality_check'] = hasRealityCheck; + if (legalAllowedContractCategories != null) { + resultMap['legal_allowed_contract_categories'] = + legalAllowedContractCategories! + .map( + (String item) => item, + ) + .toList(); + } + if (legalAllowedCurrencies != null) { + resultMap['legal_allowed_currencies'] = legalAllowedCurrencies! + .map( + (String item) => item, + ) + .toList(); + } + if (legalAllowedMarkets != null) { + resultMap['legal_allowed_markets'] = legalAllowedMarkets! + .map( + (String item) => item, + ) + .toList(); + } + resultMap['legal_default_currency'] = legalDefaultCurrency; + resultMap['name'] = name; + if (requirements != null) { + resultMap['requirements'] = requirements!.toJson(); + } + resultMap['shortcode'] = shortcode; + resultMap['support_professional_client'] = supportProfessionalClient; + resultMap['tin_not_mandatory'] = tinNotMandatory; + + return resultMap; + } + + /// Creates a copy of instance with given parameters. + GamingCompany copyWith({ List? address, Map? changeableFields, String? country, @@ -2534,24 +2751,386 @@ class GamingCompany extends GamingCompanyModel { GamingCompanyRequirements? requirements, String? shortcode, bool? supportProfessionalClient, - }) : super( - address: address, - changeableFields: changeableFields, - country: country, - currencyConfig: currencyConfig, - hasRealityCheck: hasRealityCheck, - legalAllowedContractCategories: legalAllowedContractCategories, - legalAllowedCurrencies: legalAllowedCurrencies, - legalAllowedMarkets: legalAllowedMarkets, - legalDefaultCurrency: legalDefaultCurrency, - name: name, - requirements: requirements, - shortcode: shortcode, - supportProfessionalClient: supportProfessionalClient, - ); + bool? tinNotMandatory, + }) => + GamingCompany( + address: address ?? this.address, + changeableFields: changeableFields ?? this.changeableFields, + country: country ?? this.country, + currencyConfig: currencyConfig ?? this.currencyConfig, + hasRealityCheck: hasRealityCheck ?? this.hasRealityCheck, + legalAllowedContractCategories: legalAllowedContractCategories ?? + this.legalAllowedContractCategories, + legalAllowedCurrencies: + legalAllowedCurrencies ?? this.legalAllowedCurrencies, + legalAllowedMarkets: legalAllowedMarkets ?? this.legalAllowedMarkets, + legalDefaultCurrency: legalDefaultCurrency ?? this.legalDefaultCurrency, + name: name ?? this.name, + requirements: requirements ?? this.requirements, + shortcode: shortcode ?? this.shortcode, + supportProfessionalClient: + supportProfessionalClient ?? this.supportProfessionalClient, + tinNotMandatory: tinNotMandatory ?? this.tinNotMandatory, + ); +} +/// Gaming company requirements model class. +abstract class GamingCompanyRequirementsModel { + /// Initializes Gaming company requirements model class . + const GamingCompanyRequirementsModel({ + this.afterFirstDeposit, + this.compliance, + this.signup, + this.withdrawal, + }); + + /// After first deposit requirements + final RequirementsAfterFirstDeposit23? afterFirstDeposit; + + /// Compliance requirements + final RequirementsCompliance24? compliance; + + /// Sign up requirements + final List? signup; + + /// Withdrawal requirements + final List? withdrawal; +} + +/// Gaming company requirements class. +class GamingCompanyRequirements extends GamingCompanyRequirementsModel { + /// Initializes Gaming company requirements class. + const GamingCompanyRequirements({ + super.afterFirstDeposit, + super.compliance, + super.signup, + super.withdrawal, + }); + + /// Creates an instance from JSON. + factory GamingCompanyRequirements.fromJson(Map json) => + GamingCompanyRequirements( + afterFirstDeposit: json['after_first_deposit'] == null + ? null + : RequirementsAfterFirstDeposit23.fromJson( + json['after_first_deposit']), + compliance: json['compliance'] == null + ? null + : RequirementsCompliance24.fromJson(json['compliance']), + signup: json['signup'] == null + ? null + : List.from( + json['signup']?.map( + (dynamic item) => item, + ), + ), + withdrawal: json['withdrawal'] == null + ? null + : List.from( + json['withdrawal']?.map( + (dynamic item) => item, + ), + ), + ); + + /// Converts an instance to JSON. + Map toJson() { + final Map resultMap = {}; + + if (afterFirstDeposit != null) { + resultMap['after_first_deposit'] = afterFirstDeposit!.toJson(); + } + if (compliance != null) { + resultMap['compliance'] = compliance!.toJson(); + } + if (signup != null) { + resultMap['signup'] = signup! + .map( + (String item) => item, + ) + .toList(); + } + if (withdrawal != null) { + resultMap['withdrawal'] = withdrawal! + .map( + (String item) => item, + ) + .toList(); + } + + return resultMap; + } + + /// Creates a copy of instance with given parameters. + GamingCompanyRequirements copyWith({ + RequirementsAfterFirstDeposit23? afterFirstDeposit, + RequirementsCompliance24? compliance, + List? signup, + List? withdrawal, + }) => + GamingCompanyRequirements( + afterFirstDeposit: afterFirstDeposit ?? this.afterFirstDeposit, + compliance: compliance ?? this.compliance, + signup: signup ?? this.signup, + withdrawal: withdrawal ?? this.withdrawal, + ); +} +/// Requirements after first deposit23 model class. +abstract class RequirementsAfterFirstDeposit23Model { + /// Initializes Requirements after first deposit23 model class . + const RequirementsAfterFirstDeposit23Model({ + this.financialAssessment, + }); + + /// Financial assessment requirements + final List? financialAssessment; +} + +/// Requirements after first deposit23 class. +class RequirementsAfterFirstDeposit23 + extends RequirementsAfterFirstDeposit23Model { + /// Initializes Requirements after first deposit23 class. + const RequirementsAfterFirstDeposit23({ + super.financialAssessment, + }); + + /// Creates an instance from JSON. + factory RequirementsAfterFirstDeposit23.fromJson(Map json) => + RequirementsAfterFirstDeposit23( + financialAssessment: json['financial_assessment'] == null + ? null + : List.from( + json['financial_assessment']?.map( + (dynamic item) => item, + ), + ), + ); + + /// Converts an instance to JSON. + Map toJson() { + final Map resultMap = {}; + + if (financialAssessment != null) { + resultMap['financial_assessment'] = financialAssessment! + .map( + (String item) => item, + ) + .toList(); + } + + return resultMap; + } + + /// Creates a copy of instance with given parameters. + RequirementsAfterFirstDeposit23 copyWith({ + List? financialAssessment, + }) => + RequirementsAfterFirstDeposit23( + financialAssessment: financialAssessment ?? this.financialAssessment, + ); +} +/// Requirements compliance24 model class. +abstract class RequirementsCompliance24Model { + /// Initializes Requirements compliance24 model class . + const RequirementsCompliance24Model({ + this.mt5, + this.taxInformation, + }); + + /// Compliance MT5 requirements + final List? mt5; + + /// Compliance tax information requirements + final List? taxInformation; +} + +/// Requirements compliance24 class. +class RequirementsCompliance24 extends RequirementsCompliance24Model { + /// Initializes Requirements compliance24 class. + const RequirementsCompliance24({ + super.mt5, + super.taxInformation, + }); + + /// Creates an instance from JSON. + factory RequirementsCompliance24.fromJson(Map json) => + RequirementsCompliance24( + mt5: json['mt5'] == null + ? null + : List.from( + json['mt5']?.map( + (dynamic item) => item, + ), + ), + taxInformation: json['tax_information'] == null + ? null + : List.from( + json['tax_information']?.map( + (dynamic item) => item, + ), + ), + ); + + /// Converts an instance to JSON. + Map toJson() { + final Map resultMap = {}; + + if (mt5 != null) { + resultMap['mt5'] = mt5! + .map( + (String item) => item, + ) + .toList(); + } + if (taxInformation != null) { + resultMap['tax_information'] = taxInformation! + .map( + (String item) => item, + ) + .toList(); + } + + return resultMap; + } + + /// Creates a copy of instance with given parameters. + RequirementsCompliance24 copyWith({ + List? mt5, + List? taxInformation, + }) => + RequirementsCompliance24( + mt5: mt5 ?? this.mt5, + taxInformation: taxInformation ?? this.taxInformation, + ); +} +/// Mt all company model class. +abstract class MtAllCompanyModel { + /// Initializes Mt all company model class . + const MtAllCompanyModel({ + this.swapFree, + }); + + /// Landing Company for MT5 combined all Synthetic and financial + final SwapFree? swapFree; +} + +/// Mt all company class. +class MtAllCompany extends MtAllCompanyModel { + /// Initializes Mt all company class. + const MtAllCompany({ + super.swapFree, + }); + + /// Creates an instance from JSON. + factory MtAllCompany.fromJson(Map json) => MtAllCompany( + swapFree: json['swap_free'] == null + ? null + : SwapFree.fromJson(json['swap_free']), + ); + + /// Converts an instance to JSON. + Map toJson() { + final Map resultMap = {}; + + if (swapFree != null) { + resultMap['swap_free'] = swapFree!.toJson(); + } + + return resultMap; + } + + /// Creates a copy of instance with given parameters. + MtAllCompany copyWith({ + SwapFree? swapFree, + }) => + MtAllCompany( + swapFree: swapFree ?? this.swapFree, + ); +} +/// Swap free model class. +abstract class SwapFreeModel { + /// Initializes Swap free model class . + const SwapFreeModel({ + this.address, + this.changeableFields, + this.country, + this.currencyConfig, + this.hasRealityCheck, + this.legalAllowedContractCategories, + this.legalAllowedCurrencies, + this.legalAllowedMarkets, + this.legalDefaultCurrency, + this.name, + this.requirements, + this.shortcode, + this.supportProfessionalClient, + this.tinNotMandatory, + }); + + /// Landing Company address + final List? address; + + /// Special conditions for changing sensitive fields + final Map? changeableFields; + + /// Landing Company country of incorporation + final String? country; + + /// The configuration of each currency. + final Map? currencyConfig; + + /// Flag to indicate whether reality check is applicable for this Landing Company. `true`: applicable, `false`: not applicable. The Reality Check is a feature that gives a summary of the client's trades and account balances on a regular basis throughout his session, and is a regulatory requirement for certain Landing Companies. + final bool? hasRealityCheck; + + /// Allowed contract types + final List? legalAllowedContractCategories; + + /// Allowable currencies + final List? legalAllowedCurrencies; + + /// Allowable markets + final List? legalAllowedMarkets; + + /// Default account currency + final String? legalDefaultCurrency; + + /// Landing Company legal name + final String? name; + + /// Legal requirements for the Landing Company + final SwapFreeRequirements? requirements; + + /// Landing Company short code + final String? shortcode; + + /// Flag that indicates whether the landing company supports professional accounts or not + final bool? supportProfessionalClient; + + /// Flag that indicates whether tax identifier number is not mandatory for the current country and landing company. + final bool? tinNotMandatory; +} + +/// Swap free class. +class SwapFree extends SwapFreeModel { + /// Initializes Swap free class. + const SwapFree({ + super.address, + super.changeableFields, + super.country, + super.currencyConfig, + super.hasRealityCheck, + super.legalAllowedContractCategories, + super.legalAllowedCurrencies, + super.legalAllowedMarkets, + super.legalDefaultCurrency, + super.name, + super.requirements, + super.shortcode, + super.supportProfessionalClient, + super.tinNotMandatory, + }); /// Creates an instance from JSON. - factory GamingCompany.fromJson(Map json) => GamingCompany( + factory SwapFree.fromJson(Map json) => SwapFree( address: json['address'] == null ? null : List.from( @@ -2589,9 +3168,10 @@ class GamingCompany extends GamingCompanyModel { name: json['name'], requirements: json['requirements'] == null ? null - : GamingCompanyRequirements.fromJson(json['requirements']), + : SwapFreeRequirements.fromJson(json['requirements']), shortcode: json['shortcode'], supportProfessionalClient: getBool(json['support_professional_client']), + tinNotMandatory: getBool(json['tin_not_mandatory']), ); /// Converts an instance to JSON. @@ -2638,12 +3218,13 @@ class GamingCompany extends GamingCompanyModel { } resultMap['shortcode'] = shortcode; resultMap['support_professional_client'] = supportProfessionalClient; + resultMap['tin_not_mandatory'] = tinNotMandatory; return resultMap; } /// Creates a copy of instance with given parameters. - GamingCompany copyWith({ + SwapFree copyWith({ List? address, Map? changeableFields, String? country, @@ -2654,11 +3235,12 @@ class GamingCompany extends GamingCompanyModel { List? legalAllowedMarkets, String? legalDefaultCurrency, String? name, - GamingCompanyRequirements? requirements, + SwapFreeRequirements? requirements, String? shortcode, bool? supportProfessionalClient, + bool? tinNotMandatory, }) => - GamingCompany( + SwapFree( address: address ?? this.address, changeableFields: changeableFields ?? this.changeableFields, country: country ?? this.country, @@ -2675,13 +3257,13 @@ class GamingCompany extends GamingCompanyModel { shortcode: shortcode ?? this.shortcode, supportProfessionalClient: supportProfessionalClient ?? this.supportProfessionalClient, + tinNotMandatory: tinNotMandatory ?? this.tinNotMandatory, ); } - -/// Gaming company requirements model class. -abstract class GamingCompanyRequirementsModel { - /// Initializes Gaming company requirements model class . - const GamingCompanyRequirementsModel({ +/// Swap free requirements model class. +abstract class SwapFreeRequirementsModel { + /// Initializes Swap free requirements model class . + const SwapFreeRequirementsModel({ this.afterFirstDeposit, this.compliance, this.signup, @@ -2689,10 +3271,10 @@ abstract class GamingCompanyRequirementsModel { }); /// After first deposit requirements - final RequirementsAfterFirstDeposit2? afterFirstDeposit; + final RequirementsAfterFirstDeposit27? afterFirstDeposit; /// Compliance requirements - final RequirementsCompliance2? compliance; + final RequirementsCompliance28? compliance; /// Sign up requirements final List? signup; @@ -2701,31 +3283,26 @@ abstract class GamingCompanyRequirementsModel { final List? withdrawal; } -/// Gaming company requirements class. -class GamingCompanyRequirements extends GamingCompanyRequirementsModel { - /// Initializes Gaming company requirements class. - const GamingCompanyRequirements({ - RequirementsAfterFirstDeposit2? afterFirstDeposit, - RequirementsCompliance2? compliance, - List? signup, - List? withdrawal, - }) : super( - afterFirstDeposit: afterFirstDeposit, - compliance: compliance, - signup: signup, - withdrawal: withdrawal, - ); +/// Swap free requirements class. +class SwapFreeRequirements extends SwapFreeRequirementsModel { + /// Initializes Swap free requirements class. + const SwapFreeRequirements({ + super.afterFirstDeposit, + super.compliance, + super.signup, + super.withdrawal, + }); /// Creates an instance from JSON. - factory GamingCompanyRequirements.fromJson(Map json) => - GamingCompanyRequirements( + factory SwapFreeRequirements.fromJson(Map json) => + SwapFreeRequirements( afterFirstDeposit: json['after_first_deposit'] == null ? null - : RequirementsAfterFirstDeposit2.fromJson( + : RequirementsAfterFirstDeposit27.fromJson( json['after_first_deposit']), compliance: json['compliance'] == null ? null - : RequirementsCompliance2.fromJson(json['compliance']), + : RequirementsCompliance28.fromJson(json['compliance']), signup: json['signup'] == null ? null : List.from( @@ -2771,20 +3348,147 @@ class GamingCompanyRequirements extends GamingCompanyRequirementsModel { } /// Creates a copy of instance with given parameters. - GamingCompanyRequirements copyWith({ - RequirementsAfterFirstDeposit2? afterFirstDeposit, - RequirementsCompliance2? compliance, + SwapFreeRequirements copyWith({ + RequirementsAfterFirstDeposit27? afterFirstDeposit, + RequirementsCompliance28? compliance, List? signup, List? withdrawal, }) => - GamingCompanyRequirements( + SwapFreeRequirements( afterFirstDeposit: afterFirstDeposit ?? this.afterFirstDeposit, compliance: compliance ?? this.compliance, signup: signup ?? this.signup, withdrawal: withdrawal ?? this.withdrawal, ); } +/// Requirements after first deposit27 model class. +abstract class RequirementsAfterFirstDeposit27Model { + /// Initializes Requirements after first deposit27 model class . + const RequirementsAfterFirstDeposit27Model({ + this.financialAssessment, + }); + + /// Financial assessment requirements + final List? financialAssessment; +} + +/// Requirements after first deposit27 class. +class RequirementsAfterFirstDeposit27 + extends RequirementsAfterFirstDeposit27Model { + /// Initializes Requirements after first deposit27 class. + const RequirementsAfterFirstDeposit27({ + super.financialAssessment, + }); + + /// Creates an instance from JSON. + factory RequirementsAfterFirstDeposit27.fromJson(Map json) => + RequirementsAfterFirstDeposit27( + financialAssessment: json['financial_assessment'] == null + ? null + : List.from( + json['financial_assessment']?.map( + (dynamic item) => item, + ), + ), + ); + + /// Converts an instance to JSON. + Map toJson() { + final Map resultMap = {}; + + if (financialAssessment != null) { + resultMap['financial_assessment'] = financialAssessment! + .map( + (String item) => item, + ) + .toList(); + } + + return resultMap; + } + + /// Creates a copy of instance with given parameters. + RequirementsAfterFirstDeposit27 copyWith({ + List? financialAssessment, + }) => + RequirementsAfterFirstDeposit27( + financialAssessment: financialAssessment ?? this.financialAssessment, + ); +} +/// Requirements compliance28 model class. +abstract class RequirementsCompliance28Model { + /// Initializes Requirements compliance28 model class . + const RequirementsCompliance28Model({ + this.mt5, + this.taxInformation, + }); + + /// Compliance MT5 requirements + final List? mt5; + + /// Compliance tax information requirements + final List? taxInformation; +} + +/// Requirements compliance28 class. +class RequirementsCompliance28 extends RequirementsCompliance28Model { + /// Initializes Requirements compliance28 class. + const RequirementsCompliance28({ + super.mt5, + super.taxInformation, + }); + + /// Creates an instance from JSON. + factory RequirementsCompliance28.fromJson(Map json) => + RequirementsCompliance28( + mt5: json['mt5'] == null + ? null + : List.from( + json['mt5']?.map( + (dynamic item) => item, + ), + ), + taxInformation: json['tax_information'] == null + ? null + : List.from( + json['tax_information']?.map( + (dynamic item) => item, + ), + ), + ); + + /// Converts an instance to JSON. + Map toJson() { + final Map resultMap = {}; + + if (mt5 != null) { + resultMap['mt5'] = mt5! + .map( + (String item) => item, + ) + .toList(); + } + if (taxInformation != null) { + resultMap['tax_information'] = taxInformation! + .map( + (String item) => item, + ) + .toList(); + } + + return resultMap; + } + /// Creates a copy of instance with given parameters. + RequirementsCompliance28 copyWith({ + List? mt5, + List? taxInformation, + }) => + RequirementsCompliance28( + mt5: mt5 ?? this.mt5, + taxInformation: taxInformation ?? this.taxInformation, + ); +} /// Mt financial company model class. abstract class MtFinancialCompanyModel { /// Initializes Mt financial company model class . @@ -2804,12 +3508,9 @@ abstract class MtFinancialCompanyModel { class MtFinancialCompany extends MtFinancialCompanyModel { /// Initializes Mt financial company class. const MtFinancialCompany({ - Financial? financial, - FinancialStp? financialStp, - }) : super( - financial: financial, - financialStp: financialStp, - ); + super.financial, + super.financialStp, + }); /// Creates an instance from JSON. factory MtFinancialCompany.fromJson(Map json) => @@ -2846,7 +3547,6 @@ class MtFinancialCompany extends MtFinancialCompanyModel { financialStp: financialStp ?? this.financialStp, ); } - /// Financial model class. abstract class FinancialModel { /// Initializes Financial model class . @@ -2864,6 +3564,7 @@ abstract class FinancialModel { this.requirements, this.shortcode, this.supportProfessionalClient, + this.tinNotMandatory, }); /// Landing Company address @@ -2904,40 +3605,30 @@ abstract class FinancialModel { /// Flag that indicates whether the landing company supports professional accounts or not final bool? supportProfessionalClient; + + /// Flag that indicates whether tax identifier number is not mandatory for the current country and landing company. + final bool? tinNotMandatory; } /// Financial class. class Financial extends FinancialModel { /// Initializes Financial class. const Financial({ - List? address, - Map? changeableFields, - String? country, - Map? currencyConfig, - bool? hasRealityCheck, - List? legalAllowedContractCategories, - List? legalAllowedCurrencies, - List? legalAllowedMarkets, - String? legalDefaultCurrency, - String? name, - FinancialRequirements? requirements, - String? shortcode, - bool? supportProfessionalClient, - }) : super( - address: address, - changeableFields: changeableFields, - country: country, - currencyConfig: currencyConfig, - hasRealityCheck: hasRealityCheck, - legalAllowedContractCategories: legalAllowedContractCategories, - legalAllowedCurrencies: legalAllowedCurrencies, - legalAllowedMarkets: legalAllowedMarkets, - legalDefaultCurrency: legalDefaultCurrency, - name: name, - requirements: requirements, - shortcode: shortcode, - supportProfessionalClient: supportProfessionalClient, - ); + super.address, + super.changeableFields, + super.country, + super.currencyConfig, + super.hasRealityCheck, + super.legalAllowedContractCategories, + super.legalAllowedCurrencies, + super.legalAllowedMarkets, + super.legalDefaultCurrency, + super.name, + super.requirements, + super.shortcode, + super.supportProfessionalClient, + super.tinNotMandatory, + }); /// Creates an instance from JSON. factory Financial.fromJson(Map json) => Financial( @@ -2981,6 +3672,7 @@ class Financial extends FinancialModel { : FinancialRequirements.fromJson(json['requirements']), shortcode: json['shortcode'], supportProfessionalClient: getBool(json['support_professional_client']), + tinNotMandatory: getBool(json['tin_not_mandatory']), ); /// Converts an instance to JSON. @@ -3027,6 +3719,7 @@ class Financial extends FinancialModel { } resultMap['shortcode'] = shortcode; resultMap['support_professional_client'] = supportProfessionalClient; + resultMap['tin_not_mandatory'] = tinNotMandatory; return resultMap; } @@ -3046,6 +3739,7 @@ class Financial extends FinancialModel { FinancialRequirements? requirements, String? shortcode, bool? supportProfessionalClient, + bool? tinNotMandatory, }) => Financial( address: address ?? this.address, @@ -3064,9 +3758,9 @@ class Financial extends FinancialModel { shortcode: shortcode ?? this.shortcode, supportProfessionalClient: supportProfessionalClient ?? this.supportProfessionalClient, + tinNotMandatory: tinNotMandatory ?? this.tinNotMandatory, ); } - /// Financial requirements model class. abstract class FinancialRequirementsModel { /// Initializes Financial requirements model class . @@ -3078,10 +3772,10 @@ abstract class FinancialRequirementsModel { }); /// After first deposit requirements - final RequirementsAfterFirstDeposit2? afterFirstDeposit; + final RequirementsAfterFirstDeposit32? afterFirstDeposit; /// Compliance requirements - final RequirementsCompliance2? compliance; + final RequirementsCompliance33? compliance; /// Sign up requirements final List? signup; @@ -3094,27 +3788,22 @@ abstract class FinancialRequirementsModel { class FinancialRequirements extends FinancialRequirementsModel { /// Initializes Financial requirements class. const FinancialRequirements({ - RequirementsAfterFirstDeposit2? afterFirstDeposit, - RequirementsCompliance2? compliance, - List? signup, - List? withdrawal, - }) : super( - afterFirstDeposit: afterFirstDeposit, - compliance: compliance, - signup: signup, - withdrawal: withdrawal, - ); + super.afterFirstDeposit, + super.compliance, + super.signup, + super.withdrawal, + }); /// Creates an instance from JSON. factory FinancialRequirements.fromJson(Map json) => FinancialRequirements( afterFirstDeposit: json['after_first_deposit'] == null ? null - : RequirementsAfterFirstDeposit2.fromJson( + : RequirementsAfterFirstDeposit32.fromJson( json['after_first_deposit']), compliance: json['compliance'] == null ? null - : RequirementsCompliance2.fromJson(json['compliance']), + : RequirementsCompliance33.fromJson(json['compliance']), signup: json['signup'] == null ? null : List.from( @@ -3148,8 +3837,140 @@ class FinancialRequirements extends FinancialRequirementsModel { ) .toList(); } - if (withdrawal != null) { - resultMap['withdrawal'] = withdrawal! + if (withdrawal != null) { + resultMap['withdrawal'] = withdrawal! + .map( + (String item) => item, + ) + .toList(); + } + + return resultMap; + } + + /// Creates a copy of instance with given parameters. + FinancialRequirements copyWith({ + RequirementsAfterFirstDeposit32? afterFirstDeposit, + RequirementsCompliance33? compliance, + List? signup, + List? withdrawal, + }) => + FinancialRequirements( + afterFirstDeposit: afterFirstDeposit ?? this.afterFirstDeposit, + compliance: compliance ?? this.compliance, + signup: signup ?? this.signup, + withdrawal: withdrawal ?? this.withdrawal, + ); +} +/// Requirements after first deposit32 model class. +abstract class RequirementsAfterFirstDeposit32Model { + /// Initializes Requirements after first deposit32 model class . + const RequirementsAfterFirstDeposit32Model({ + this.financialAssessment, + }); + + /// Financial assessment requirements + final List? financialAssessment; +} + +/// Requirements after first deposit32 class. +class RequirementsAfterFirstDeposit32 + extends RequirementsAfterFirstDeposit32Model { + /// Initializes Requirements after first deposit32 class. + const RequirementsAfterFirstDeposit32({ + super.financialAssessment, + }); + + /// Creates an instance from JSON. + factory RequirementsAfterFirstDeposit32.fromJson(Map json) => + RequirementsAfterFirstDeposit32( + financialAssessment: json['financial_assessment'] == null + ? null + : List.from( + json['financial_assessment']?.map( + (dynamic item) => item, + ), + ), + ); + + /// Converts an instance to JSON. + Map toJson() { + final Map resultMap = {}; + + if (financialAssessment != null) { + resultMap['financial_assessment'] = financialAssessment! + .map( + (String item) => item, + ) + .toList(); + } + + return resultMap; + } + + /// Creates a copy of instance with given parameters. + RequirementsAfterFirstDeposit32 copyWith({ + List? financialAssessment, + }) => + RequirementsAfterFirstDeposit32( + financialAssessment: financialAssessment ?? this.financialAssessment, + ); +} +/// Requirements compliance33 model class. +abstract class RequirementsCompliance33Model { + /// Initializes Requirements compliance33 model class . + const RequirementsCompliance33Model({ + this.mt5, + this.taxInformation, + }); + + /// Compliance MT5 requirements + final List? mt5; + + /// Compliance tax information requirements + final List? taxInformation; +} + +/// Requirements compliance33 class. +class RequirementsCompliance33 extends RequirementsCompliance33Model { + /// Initializes Requirements compliance33 class. + const RequirementsCompliance33({ + super.mt5, + super.taxInformation, + }); + + /// Creates an instance from JSON. + factory RequirementsCompliance33.fromJson(Map json) => + RequirementsCompliance33( + mt5: json['mt5'] == null + ? null + : List.from( + json['mt5']?.map( + (dynamic item) => item, + ), + ), + taxInformation: json['tax_information'] == null + ? null + : List.from( + json['tax_information']?.map( + (dynamic item) => item, + ), + ), + ); + + /// Converts an instance to JSON. + Map toJson() { + final Map resultMap = {}; + + if (mt5 != null) { + resultMap['mt5'] = mt5! + .map( + (String item) => item, + ) + .toList(); + } + if (taxInformation != null) { + resultMap['tax_information'] = taxInformation! .map( (String item) => item, ) @@ -3160,20 +3981,15 @@ class FinancialRequirements extends FinancialRequirementsModel { } /// Creates a copy of instance with given parameters. - FinancialRequirements copyWith({ - RequirementsAfterFirstDeposit2? afterFirstDeposit, - RequirementsCompliance2? compliance, - List? signup, - List? withdrawal, + RequirementsCompliance33 copyWith({ + List? mt5, + List? taxInformation, }) => - FinancialRequirements( - afterFirstDeposit: afterFirstDeposit ?? this.afterFirstDeposit, - compliance: compliance ?? this.compliance, - signup: signup ?? this.signup, - withdrawal: withdrawal ?? this.withdrawal, + RequirementsCompliance33( + mt5: mt5 ?? this.mt5, + taxInformation: taxInformation ?? this.taxInformation, ); } - /// Financial stp model class. abstract class FinancialStpModel { /// Initializes Financial stp model class . @@ -3191,6 +4007,7 @@ abstract class FinancialStpModel { this.requirements, this.shortcode, this.supportProfessionalClient, + this.tinNotMandatory, }); /// Landing Company address @@ -3231,40 +4048,30 @@ abstract class FinancialStpModel { /// Flag that indicates whether the landing company supports professional accounts or not final bool? supportProfessionalClient; + + /// Flag that indicates whether tax identifier number is not mandatory for the current country and landing company. + final bool? tinNotMandatory; } /// Financial stp class. class FinancialStp extends FinancialStpModel { /// Initializes Financial stp class. const FinancialStp({ - List? address, - Map? changeableFields, - String? country, - Map? currencyConfig, - bool? hasRealityCheck, - List? legalAllowedContractCategories, - List? legalAllowedCurrencies, - List? legalAllowedMarkets, - String? legalDefaultCurrency, - String? name, - FinancialStpRequirements? requirements, - String? shortcode, - bool? supportProfessionalClient, - }) : super( - address: address, - changeableFields: changeableFields, - country: country, - currencyConfig: currencyConfig, - hasRealityCheck: hasRealityCheck, - legalAllowedContractCategories: legalAllowedContractCategories, - legalAllowedCurrencies: legalAllowedCurrencies, - legalAllowedMarkets: legalAllowedMarkets, - legalDefaultCurrency: legalDefaultCurrency, - name: name, - requirements: requirements, - shortcode: shortcode, - supportProfessionalClient: supportProfessionalClient, - ); + super.address, + super.changeableFields, + super.country, + super.currencyConfig, + super.hasRealityCheck, + super.legalAllowedContractCategories, + super.legalAllowedCurrencies, + super.legalAllowedMarkets, + super.legalDefaultCurrency, + super.name, + super.requirements, + super.shortcode, + super.supportProfessionalClient, + super.tinNotMandatory, + }); /// Creates an instance from JSON. factory FinancialStp.fromJson(Map json) => FinancialStp( @@ -3308,6 +4115,7 @@ class FinancialStp extends FinancialStpModel { : FinancialStpRequirements.fromJson(json['requirements']), shortcode: json['shortcode'], supportProfessionalClient: getBool(json['support_professional_client']), + tinNotMandatory: getBool(json['tin_not_mandatory']), ); /// Converts an instance to JSON. @@ -3354,6 +4162,7 @@ class FinancialStp extends FinancialStpModel { } resultMap['shortcode'] = shortcode; resultMap['support_professional_client'] = supportProfessionalClient; + resultMap['tin_not_mandatory'] = tinNotMandatory; return resultMap; } @@ -3373,6 +4182,7 @@ class FinancialStp extends FinancialStpModel { FinancialStpRequirements? requirements, String? shortcode, bool? supportProfessionalClient, + bool? tinNotMandatory, }) => FinancialStp( address: address ?? this.address, @@ -3391,9 +4201,9 @@ class FinancialStp extends FinancialStpModel { shortcode: shortcode ?? this.shortcode, supportProfessionalClient: supportProfessionalClient ?? this.supportProfessionalClient, + tinNotMandatory: tinNotMandatory ?? this.tinNotMandatory, ); } - /// Financial stp requirements model class. abstract class FinancialStpRequirementsModel { /// Initializes Financial stp requirements model class . @@ -3405,10 +4215,10 @@ abstract class FinancialStpRequirementsModel { }); /// After first deposit requirements - final RequirementsAfterFirstDeposit2? afterFirstDeposit; + final RequirementsAfterFirstDeposit36? afterFirstDeposit; /// Compliance requirements - final RequirementsCompliance2? compliance; + final RequirementsCompliance37? compliance; /// Sign up requirements final List? signup; @@ -3421,27 +4231,22 @@ abstract class FinancialStpRequirementsModel { class FinancialStpRequirements extends FinancialStpRequirementsModel { /// Initializes Financial stp requirements class. const FinancialStpRequirements({ - RequirementsAfterFirstDeposit2? afterFirstDeposit, - RequirementsCompliance2? compliance, - List? signup, - List? withdrawal, - }) : super( - afterFirstDeposit: afterFirstDeposit, - compliance: compliance, - signup: signup, - withdrawal: withdrawal, - ); + super.afterFirstDeposit, + super.compliance, + super.signup, + super.withdrawal, + }); /// Creates an instance from JSON. factory FinancialStpRequirements.fromJson(Map json) => FinancialStpRequirements( afterFirstDeposit: json['after_first_deposit'] == null ? null - : RequirementsAfterFirstDeposit2.fromJson( + : RequirementsAfterFirstDeposit36.fromJson( json['after_first_deposit']), compliance: json['compliance'] == null ? null - : RequirementsCompliance2.fromJson(json['compliance']), + : RequirementsCompliance37.fromJson(json['compliance']), signup: json['signup'] == null ? null : List.from( @@ -3488,8 +4293,8 @@ class FinancialStpRequirements extends FinancialStpRequirementsModel { /// Creates a copy of instance with given parameters. FinancialStpRequirements copyWith({ - RequirementsAfterFirstDeposit2? afterFirstDeposit, - RequirementsCompliance2? compliance, + RequirementsAfterFirstDeposit36? afterFirstDeposit, + RequirementsCompliance37? compliance, List? signup, List? withdrawal, }) => @@ -3500,7 +4305,134 @@ class FinancialStpRequirements extends FinancialStpRequirementsModel { withdrawal: withdrawal ?? this.withdrawal, ); } +/// Requirements after first deposit36 model class. +abstract class RequirementsAfterFirstDeposit36Model { + /// Initializes Requirements after first deposit36 model class . + const RequirementsAfterFirstDeposit36Model({ + this.financialAssessment, + }); + + /// Financial assessment requirements + final List? financialAssessment; +} + +/// Requirements after first deposit36 class. +class RequirementsAfterFirstDeposit36 + extends RequirementsAfterFirstDeposit36Model { + /// Initializes Requirements after first deposit36 class. + const RequirementsAfterFirstDeposit36({ + super.financialAssessment, + }); + + /// Creates an instance from JSON. + factory RequirementsAfterFirstDeposit36.fromJson(Map json) => + RequirementsAfterFirstDeposit36( + financialAssessment: json['financial_assessment'] == null + ? null + : List.from( + json['financial_assessment']?.map( + (dynamic item) => item, + ), + ), + ); + + /// Converts an instance to JSON. + Map toJson() { + final Map resultMap = {}; + + if (financialAssessment != null) { + resultMap['financial_assessment'] = financialAssessment! + .map( + (String item) => item, + ) + .toList(); + } + + return resultMap; + } + + /// Creates a copy of instance with given parameters. + RequirementsAfterFirstDeposit36 copyWith({ + List? financialAssessment, + }) => + RequirementsAfterFirstDeposit36( + financialAssessment: financialAssessment ?? this.financialAssessment, + ); +} +/// Requirements compliance37 model class. +abstract class RequirementsCompliance37Model { + /// Initializes Requirements compliance37 model class . + const RequirementsCompliance37Model({ + this.mt5, + this.taxInformation, + }); + + /// Compliance MT5 requirements + final List? mt5; + + /// Compliance tax information requirements + final List? taxInformation; +} + +/// Requirements compliance37 class. +class RequirementsCompliance37 extends RequirementsCompliance37Model { + /// Initializes Requirements compliance37 class. + const RequirementsCompliance37({ + super.mt5, + super.taxInformation, + }); + + /// Creates an instance from JSON. + factory RequirementsCompliance37.fromJson(Map json) => + RequirementsCompliance37( + mt5: json['mt5'] == null + ? null + : List.from( + json['mt5']?.map( + (dynamic item) => item, + ), + ), + taxInformation: json['tax_information'] == null + ? null + : List.from( + json['tax_information']?.map( + (dynamic item) => item, + ), + ), + ); + + /// Converts an instance to JSON. + Map toJson() { + final Map resultMap = {}; + + if (mt5 != null) { + resultMap['mt5'] = mt5! + .map( + (String item) => item, + ) + .toList(); + } + if (taxInformation != null) { + resultMap['tax_information'] = taxInformation! + .map( + (String item) => item, + ) + .toList(); + } + return resultMap; + } + + /// Creates a copy of instance with given parameters. + RequirementsCompliance37 copyWith({ + List? mt5, + List? taxInformation, + }) => + RequirementsCompliance37( + mt5: mt5 ?? this.mt5, + taxInformation: taxInformation ?? this.taxInformation, + ); +} /// Mt gaming company model class. abstract class MtGamingCompanyModel { /// Initializes Mt gaming company model class . @@ -3516,10 +4448,8 @@ abstract class MtGamingCompanyModel { class MtGamingCompany extends MtGamingCompanyModel { /// Initializes Mt gaming company class. const MtGamingCompany({ - MtGamingCompanyFinancial? financial, - }) : super( - financial: financial, - ); + super.financial, + }); /// Creates an instance from JSON. factory MtGamingCompany.fromJson(Map json) => @@ -3548,7 +4478,6 @@ class MtGamingCompany extends MtGamingCompanyModel { financial: financial ?? this.financial, ); } - /// Mt gaming company financial model class. abstract class MtGamingCompanyFinancialModel { /// Initializes Mt gaming company financial model class . @@ -3566,6 +4495,7 @@ abstract class MtGamingCompanyFinancialModel { this.requirements, this.shortcode, this.supportProfessionalClient, + this.tinNotMandatory, }); /// Landing Company address @@ -3599,47 +4529,37 @@ abstract class MtGamingCompanyFinancialModel { final String? name; /// Legal requirements for the Landing Company - final FinancialRequirements2? requirements; + final FinancialRequirements43? requirements; /// Landing Company short code final String? shortcode; /// Flag that indicates whether the landing company supports professional accounts or not final bool? supportProfessionalClient; + + /// Flag that indicates whether tax identifier number is not mandatory for the current country and landing company. + final bool? tinNotMandatory; } /// Mt gaming company financial class. class MtGamingCompanyFinancial extends MtGamingCompanyFinancialModel { /// Initializes Mt gaming company financial class. const MtGamingCompanyFinancial({ - List? address, - Map? changeableFields, - String? country, - Map? currencyConfig, - bool? hasRealityCheck, - List? legalAllowedContractCategories, - List? legalAllowedCurrencies, - List? legalAllowedMarkets, - String? legalDefaultCurrency, - String? name, - FinancialRequirements2? requirements, - String? shortcode, - bool? supportProfessionalClient, - }) : super( - address: address, - changeableFields: changeableFields, - country: country, - currencyConfig: currencyConfig, - hasRealityCheck: hasRealityCheck, - legalAllowedContractCategories: legalAllowedContractCategories, - legalAllowedCurrencies: legalAllowedCurrencies, - legalAllowedMarkets: legalAllowedMarkets, - legalDefaultCurrency: legalDefaultCurrency, - name: name, - requirements: requirements, - shortcode: shortcode, - supportProfessionalClient: supportProfessionalClient, - ); + super.address, + super.changeableFields, + super.country, + super.currencyConfig, + super.hasRealityCheck, + super.legalAllowedContractCategories, + super.legalAllowedCurrencies, + super.legalAllowedMarkets, + super.legalDefaultCurrency, + super.name, + super.requirements, + super.shortcode, + super.supportProfessionalClient, + super.tinNotMandatory, + }); /// Creates an instance from JSON. factory MtGamingCompanyFinancial.fromJson(Map json) => @@ -3681,9 +4601,10 @@ class MtGamingCompanyFinancial extends MtGamingCompanyFinancialModel { name: json['name'], requirements: json['requirements'] == null ? null - : FinancialRequirements2.fromJson(json['requirements']), + : FinancialRequirements43.fromJson(json['requirements']), shortcode: json['shortcode'], supportProfessionalClient: getBool(json['support_professional_client']), + tinNotMandatory: getBool(json['tin_not_mandatory']), ); /// Converts an instance to JSON. @@ -3730,6 +4651,7 @@ class MtGamingCompanyFinancial extends MtGamingCompanyFinancialModel { } resultMap['shortcode'] = shortcode; resultMap['support_professional_client'] = supportProfessionalClient; + resultMap['tin_not_mandatory'] = tinNotMandatory; return resultMap; } @@ -3746,9 +4668,10 @@ class MtGamingCompanyFinancial extends MtGamingCompanyFinancialModel { List? legalAllowedMarkets, String? legalDefaultCurrency, String? name, - FinancialRequirements2? requirements, + FinancialRequirements43? requirements, String? shortcode, bool? supportProfessionalClient, + bool? tinNotMandatory, }) => MtGamingCompanyFinancial( address: address ?? this.address, @@ -3767,13 +4690,13 @@ class MtGamingCompanyFinancial extends MtGamingCompanyFinancialModel { shortcode: shortcode ?? this.shortcode, supportProfessionalClient: supportProfessionalClient ?? this.supportProfessionalClient, + tinNotMandatory: tinNotMandatory ?? this.tinNotMandatory, ); } - -/// Financial requirements2 model class. -abstract class FinancialRequirements2Model { - /// Initializes Financial requirements2 model class . - const FinancialRequirements2Model({ +/// Financial requirements43 model class. +abstract class FinancialRequirements43Model { + /// Initializes Financial requirements43 model class . + const FinancialRequirements43Model({ this.afterFirstDeposit, this.compliance, this.signup, @@ -3781,10 +4704,10 @@ abstract class FinancialRequirements2Model { }); /// After first deposit requirements - final RequirementsAfterFirstDeposit2? afterFirstDeposit; + final RequirementsAfterFirstDeposit41? afterFirstDeposit; /// Compliance requirements - final RequirementsCompliance2? compliance; + final RequirementsCompliance42? compliance; /// Sign up requirements final List? signup; @@ -3793,31 +4716,26 @@ abstract class FinancialRequirements2Model { final List? withdrawal; } -/// Financial requirements2 class. -class FinancialRequirements2 extends FinancialRequirements2Model { - /// Initializes Financial requirements2 class. - const FinancialRequirements2({ - RequirementsAfterFirstDeposit2? afterFirstDeposit, - RequirementsCompliance2? compliance, - List? signup, - List? withdrawal, - }) : super( - afterFirstDeposit: afterFirstDeposit, - compliance: compliance, - signup: signup, - withdrawal: withdrawal, - ); +/// Financial requirements43 class. +class FinancialRequirements43 extends FinancialRequirements43Model { + /// Initializes Financial requirements43 class. + const FinancialRequirements43({ + super.afterFirstDeposit, + super.compliance, + super.signup, + super.withdrawal, + }); /// Creates an instance from JSON. - factory FinancialRequirements2.fromJson(Map json) => - FinancialRequirements2( + factory FinancialRequirements43.fromJson(Map json) => + FinancialRequirements43( afterFirstDeposit: json['after_first_deposit'] == null ? null - : RequirementsAfterFirstDeposit2.fromJson( + : RequirementsAfterFirstDeposit41.fromJson( json['after_first_deposit']), compliance: json['compliance'] == null ? null - : RequirementsCompliance2.fromJson(json['compliance']), + : RequirementsCompliance42.fromJson(json['compliance']), signup: json['signup'] == null ? null : List.from( @@ -3863,16 +4781,144 @@ class FinancialRequirements2 extends FinancialRequirements2Model { } /// Creates a copy of instance with given parameters. - FinancialRequirements2 copyWith({ - RequirementsAfterFirstDeposit2? afterFirstDeposit, - RequirementsCompliance2? compliance, + FinancialRequirements43 copyWith({ + RequirementsAfterFirstDeposit41? afterFirstDeposit, + RequirementsCompliance42? compliance, List? signup, List? withdrawal, }) => - FinancialRequirements2( + FinancialRequirements43( afterFirstDeposit: afterFirstDeposit ?? this.afterFirstDeposit, compliance: compliance ?? this.compliance, signup: signup ?? this.signup, withdrawal: withdrawal ?? this.withdrawal, ); } +/// Requirements after first deposit41 model class. +abstract class RequirementsAfterFirstDeposit41Model { + /// Initializes Requirements after first deposit41 model class . + const RequirementsAfterFirstDeposit41Model({ + this.financialAssessment, + }); + + /// Financial assessment requirements + final List? financialAssessment; +} + +/// Requirements after first deposit41 class. +class RequirementsAfterFirstDeposit41 + extends RequirementsAfterFirstDeposit41Model { + /// Initializes Requirements after first deposit41 class. + const RequirementsAfterFirstDeposit41({ + super.financialAssessment, + }); + + /// Creates an instance from JSON. + factory RequirementsAfterFirstDeposit41.fromJson(Map json) => + RequirementsAfterFirstDeposit41( + financialAssessment: json['financial_assessment'] == null + ? null + : List.from( + json['financial_assessment']?.map( + (dynamic item) => item, + ), + ), + ); + + /// Converts an instance to JSON. + Map toJson() { + final Map resultMap = {}; + + if (financialAssessment != null) { + resultMap['financial_assessment'] = financialAssessment! + .map( + (String item) => item, + ) + .toList(); + } + + return resultMap; + } + + /// Creates a copy of instance with given parameters. + RequirementsAfterFirstDeposit41 copyWith({ + List? financialAssessment, + }) => + RequirementsAfterFirstDeposit41( + financialAssessment: financialAssessment ?? this.financialAssessment, + ); +} +/// Requirements compliance42 model class. +abstract class RequirementsCompliance42Model { + /// Initializes Requirements compliance42 model class . + const RequirementsCompliance42Model({ + this.mt5, + this.taxInformation, + }); + + /// Compliance MT5 requirements + final List? mt5; + + /// Compliance tax information requirements + final List? taxInformation; +} + +/// Requirements compliance42 class. +class RequirementsCompliance42 extends RequirementsCompliance42Model { + /// Initializes Requirements compliance42 class. + const RequirementsCompliance42({ + super.mt5, + super.taxInformation, + }); + + /// Creates an instance from JSON. + factory RequirementsCompliance42.fromJson(Map json) => + RequirementsCompliance42( + mt5: json['mt5'] == null + ? null + : List.from( + json['mt5']?.map( + (dynamic item) => item, + ), + ), + taxInformation: json['tax_information'] == null + ? null + : List.from( + json['tax_information']?.map( + (dynamic item) => item, + ), + ), + ); + + /// Converts an instance to JSON. + Map toJson() { + final Map resultMap = {}; + + if (mt5 != null) { + resultMap['mt5'] = mt5! + .map( + (String item) => item, + ) + .toList(); + } + if (taxInformation != null) { + resultMap['tax_information'] = taxInformation! + .map( + (String item) => item, + ) + .toList(); + } + + return resultMap; + } + + /// Creates a copy of instance with given parameters. + RequirementsCompliance42 copyWith({ + List? mt5, + List? taxInformation, + }) => + RequirementsCompliance42( + mt5: mt5 ?? this.mt5, + taxInformation: taxInformation ?? this.taxInformation, + ); +} diff --git a/lib/api/response/link_wallet_response_result.dart b/lib/api/response/link_wallet_response_result.dart index 319d0737c3..2517470ee3 100644 --- a/lib/api/response/link_wallet_response_result.dart +++ b/lib/api/response/link_wallet_response_result.dart @@ -19,10 +19,8 @@ abstract class LinkWalletResponseModel { class LinkWalletResponse extends LinkWalletResponseModel { /// Initializes Link wallet response class. const LinkWalletResponse({ - int? linkWallet, - }) : super( - linkWallet: linkWallet, - ); + super.linkWallet, + }); /// Creates an instance from JSON. factory LinkWalletResponse.fromJson( diff --git a/lib/api/response/login_history_response_result.dart b/lib/api/response/login_history_response_result.dart index 0e65ea6168..90f67743d8 100644 --- a/lib/api/response/login_history_response_result.dart +++ b/lib/api/response/login_history_response_result.dart @@ -64,7 +64,7 @@ class LoginHistoryResponse extends LoginHistoryResponseModel { /// Retrieves a summary of login history for user. /// /// For parameters information refer to [LoginHistory]. - /// Throws an [AuthorizeException] if API response contains an error + /// Throws an [BaseAPIException] if API response contains an error static Future fetchHistory([ LoginHistoryRequest? request, ]) async { @@ -75,7 +75,7 @@ class LoginHistoryResponse extends LoginHistoryResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - AuthorizeException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return LoginHistoryResponse.fromJson(response.loginHistory); diff --git a/lib/api/response/logout_response_result.dart b/lib/api/response/logout_response_result.dart index 48a9e15500..c72f0a1235 100644 --- a/lib/api/response/logout_response_result.dart +++ b/lib/api/response/logout_response_result.dart @@ -52,7 +52,7 @@ class LogoutResponse extends LogoutResponseModel { /// Logs out from the web-socket's session. /// /// For parameters information refer to [LogoutRequest]. - /// Throws an [AuthorizeException] if API response contains an error. + /// Throws an [BaseAPIException] if API response contains an error. static Future logoutMethodRaw([LogoutRequest? request]) async { final LogoutReceive response = await _api.call(request: request ?? const LogoutRequest()); @@ -60,7 +60,7 @@ class LogoutResponse extends LogoutResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - AuthorizeException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return response; @@ -69,7 +69,7 @@ class LogoutResponse extends LogoutResponseModel { /// Logs out from the web-socket's session. /// /// For parameters information refer to [LogoutRequest]. - /// Throws an [AuthorizeException] if API response contains an error. + /// Throws an [BaseAPIException] if API response contains an error. static Future logoutMethod([LogoutRequest? request]) async { final LogoutReceive response = await logoutMethodRaw(request); diff --git a/lib/api/response/mt5_deposit_response_result.dart b/lib/api/response/mt5_deposit_response_result.dart index 3944d1b990..594ba1936d 100644 --- a/lib/api/response/mt5_deposit_response_result.dart +++ b/lib/api/response/mt5_deposit_response_result.dart @@ -61,14 +61,14 @@ class Mt5DepositResponse extends Mt5DepositResponseModel { /// Allows deposit into MT5 account from binary account. /// /// For parameters information refer to [Mt5DepositRequest]. - /// Throws a [MT5Exception] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future deposit(Mt5DepositRequest request) async { final Mt5DepositReceive response = await _api.call(request: request); checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - MT5Exception(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return Mt5DepositResponse.fromJson( diff --git a/lib/api/response/mt5_get_settings_response_result.dart b/lib/api/response/mt5_get_settings_response_result.dart index 8430eaa0e0..5a2dc3d5ef 100644 --- a/lib/api/response/mt5_get_settings_response_result.dart +++ b/lib/api/response/mt5_get_settings_response_result.dart @@ -25,10 +25,8 @@ abstract class Mt5GetSettingsResponseModel { class Mt5GetSettingsResponse extends Mt5GetSettingsResponseModel { /// Initializes Mt5 get settings response class. const Mt5GetSettingsResponse({ - Mt5GetSettings? mt5GetSettings, - }) : super( - mt5GetSettings: mt5GetSettings, - ); + super.mt5GetSettings, + }); /// Creates an instance from JSON. factory Mt5GetSettingsResponse.fromJson( @@ -56,7 +54,7 @@ class Mt5GetSettingsResponse extends Mt5GetSettingsResponseModel { /// Gets MT5 user account settings. /// /// For parameters information refer to [Mt5GetSettingsRequest]. - /// Throws a [MT5Exception] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future fetchSettings( Mt5GetSettingsRequest request, ) async { @@ -65,7 +63,7 @@ class Mt5GetSettingsResponse extends Mt5GetSettingsResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - MT5Exception(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return Mt5GetSettingsResponse.fromJson(response.mt5GetSettings); @@ -103,6 +101,7 @@ final Map landingCompanyShortEnumMapper = "labuan": LandingCompanyShortEnum.labuan, "malta": LandingCompanyShortEnum.malta, "maltainvest": LandingCompanyShortEnum.maltainvest, + "seychelles": LandingCompanyShortEnum.seychelles, "svg": LandingCompanyShortEnum.svg, "vanuatu": LandingCompanyShortEnum.vanuatu, }; @@ -121,6 +120,9 @@ enum LandingCompanyShortEnum { /// maltainvest. maltainvest, + /// seychelles. + seychelles, + /// svg. svg, @@ -131,12 +133,16 @@ enum LandingCompanyShortEnum { /// MarketTypeEnum mapper. final Map marketTypeEnumMapper = { + "all": MarketTypeEnum.all, "financial": MarketTypeEnum.financial, "synthetic": MarketTypeEnum.synthetic, }; /// MarketType Enum. enum MarketTypeEnum { + /// all. + all, + /// financial. financial, @@ -144,22 +150,81 @@ enum MarketTypeEnum { synthetic, } +/// EnvironmentEnum mapper. +final Map environmentEnumMapper = + { + "Deriv-Demo": EnvironmentEnum.derivDemo, + "Deriv-Server": EnvironmentEnum.derivServer, + "Deriv-Server-02": EnvironmentEnum.derivServer02, +}; + +/// Environment Enum. +enum EnvironmentEnum { + /// Deriv-Demo. + derivDemo, + + /// Deriv-Server. + derivServer, + + /// Deriv-Server-02. + derivServer02, +} + +/// SubAccountCategoryEnum mapper. +final Map subAccountCategoryEnumMapper = + { + "none": SubAccountCategoryEnum.none, + "ibt": SubAccountCategoryEnum.ibt, + "lim": SubAccountCategoryEnum.lim, + "stp": SubAccountCategoryEnum.stp, + "swap_free": SubAccountCategoryEnum.swapFree, + "swap_free_high_risk": SubAccountCategoryEnum.swapFreeHighRisk, +}; + +/// SubAccountCategory Enum. +enum SubAccountCategoryEnum { + /// none. + none, + + /// ibt. + ibt, + + /// lim. + lim, + + /// stp. + stp, + + /// swap_free. + swapFree, + + /// swap_free_high_risk. + swapFreeHighRisk, +} + /// SubAccountTypeEnum mapper. final Map subAccountTypeEnumMapper = { + "derivez": SubAccountTypeEnum.derivez, "financial": SubAccountTypeEnum.financial, "financial_stp": SubAccountTypeEnum.financialStp, + "standard": SubAccountTypeEnum.standard, }; /// SubAccountType Enum. enum SubAccountTypeEnum { + /// derivez. + derivez, + /// financial. financial, /// financial_stp. financialStp, -} + /// standard. + standard, +} /// Mt5 get settings model class. abstract class Mt5GetSettingsModel { /// Initializes Mt5 get settings model class . @@ -171,6 +236,7 @@ abstract class Mt5GetSettingsModel { this.company, this.country, this.currency, + this.displayBalance, this.email, this.group, this.landingCompanyShort, @@ -180,7 +246,10 @@ abstract class Mt5GetSettingsModel { this.name, this.phone, this.phonePassword, + this.server, + this.serverInfo, this.state, + this.subAccountCategory, this.subAccountType, this.zipCode, }); @@ -191,8 +260,8 @@ abstract class Mt5GetSettingsModel { /// The address of the user. The maximum length of the address is 128 characters. final String? address; - /// Account balance. - final String? balance; + /// Balance of the Trading account. + final double? balance; /// User's city of residence. final String? city; @@ -206,6 +275,9 @@ abstract class Mt5GetSettingsModel { /// MT5 account currency (`USD` or `EUR`) that depends on the MT5 company (`vanuatu`, `svg`, `malta`). final String? currency; + /// Account balance, formatted to appropriate decimal places. + final String? displayBalance; + /// Email address. final String? email; @@ -233,9 +305,18 @@ abstract class Mt5GetSettingsModel { /// The user's phone password. final String? phonePassword; + /// Trade server name of the MT5 account. + final String? server; + + /// Trade server information. + final ServerInfo? serverInfo; + /// User's state (region) of residence. final String? state; + /// Sub account category. + final SubAccountCategoryEnum? subAccountCategory; + /// Sub account type final SubAccountTypeEnum? subAccountType; @@ -247,46 +328,30 @@ abstract class Mt5GetSettingsModel { class Mt5GetSettings extends Mt5GetSettingsModel { /// Initializes Mt5 get settings class. const Mt5GetSettings({ - AccountTypeEnum? accountType, - String? address, - String? balance, - String? city, - String? company, - String? country, - String? currency, - String? email, - String? group, - LandingCompanyShortEnum? landingCompanyShort, - double? leverage, - String? login, - MarketTypeEnum? marketType, - String? name, - String? phone, - String? phonePassword, - String? state, - SubAccountTypeEnum? subAccountType, - String? zipCode, - }) : super( - accountType: accountType, - address: address, - balance: balance, - city: city, - company: company, - country: country, - currency: currency, - email: email, - group: group, - landingCompanyShort: landingCompanyShort, - leverage: leverage, - login: login, - marketType: marketType, - name: name, - phone: phone, - phonePassword: phonePassword, - state: state, - subAccountType: subAccountType, - zipCode: zipCode, - ); + super.accountType, + super.address, + super.balance, + super.city, + super.company, + super.country, + super.currency, + super.displayBalance, + super.email, + super.group, + super.landingCompanyShort, + super.leverage, + super.login, + super.marketType, + super.name, + super.phone, + super.phonePassword, + super.server, + super.serverInfo, + super.state, + super.subAccountCategory, + super.subAccountType, + super.zipCode, + }); /// Creates an instance from JSON. factory Mt5GetSettings.fromJson(Map json) => Mt5GetSettings( @@ -294,11 +359,12 @@ class Mt5GetSettings extends Mt5GetSettingsModel { ? null : accountTypeEnumMapper[json['account_type']], address: json['address'], - balance: json['balance'], + balance: getDouble(json['balance']), city: json['city'], company: json['company'], country: json['country'], currency: json['currency'], + displayBalance: json['display_balance'], email: json['email'], group: json['group'], landingCompanyShort: json['landing_company_short'] == null @@ -312,7 +378,14 @@ class Mt5GetSettings extends Mt5GetSettingsModel { name: json['name'], phone: json['phone'], phonePassword: json['phonePassword'], + server: json['server'], + serverInfo: json['server_info'] == null + ? null + : ServerInfo.fromJson(json['server_info']), state: json['state'], + subAccountCategory: json['sub_account_category'] == null + ? null + : subAccountCategoryEnumMapper[json['sub_account_category']], subAccountType: json['sub_account_type'] == null ? null : subAccountTypeEnumMapper[json['sub_account_type']], @@ -333,6 +406,7 @@ class Mt5GetSettings extends Mt5GetSettingsModel { resultMap['company'] = company; resultMap['country'] = country; resultMap['currency'] = currency; + resultMap['display_balance'] = displayBalance; resultMap['email'] = email; resultMap['group'] = group; resultMap['landing_company_short'] = landingCompanyShortEnumMapper.entries @@ -348,7 +422,15 @@ class Mt5GetSettings extends Mt5GetSettingsModel { resultMap['name'] = name; resultMap['phone'] = phone; resultMap['phonePassword'] = phonePassword; + resultMap['server'] = server; + if (serverInfo != null) { + resultMap['server_info'] = serverInfo!.toJson(); + } resultMap['state'] = state; + resultMap['sub_account_category'] = subAccountCategoryEnumMapper.entries + .firstWhere((MapEntry entry) => + entry.value == subAccountCategory) + .key; resultMap['sub_account_type'] = subAccountTypeEnumMapper.entries .firstWhere((MapEntry entry) => entry.value == subAccountType) @@ -362,11 +444,12 @@ class Mt5GetSettings extends Mt5GetSettingsModel { Mt5GetSettings copyWith({ AccountTypeEnum? accountType, String? address, - String? balance, + double? balance, String? city, String? company, String? country, String? currency, + String? displayBalance, String? email, String? group, LandingCompanyShortEnum? landingCompanyShort, @@ -376,7 +459,10 @@ class Mt5GetSettings extends Mt5GetSettingsModel { String? name, String? phone, String? phonePassword, + String? server, + ServerInfo? serverInfo, String? state, + SubAccountCategoryEnum? subAccountCategory, SubAccountTypeEnum? subAccountType, String? zipCode, }) => @@ -388,6 +474,7 @@ class Mt5GetSettings extends Mt5GetSettingsModel { company: company ?? this.company, country: country ?? this.country, currency: currency ?? this.currency, + displayBalance: displayBalance ?? this.displayBalance, email: email ?? this.email, group: group ?? this.group, landingCompanyShort: landingCompanyShort ?? this.landingCompanyShort, @@ -397,8 +484,145 @@ class Mt5GetSettings extends Mt5GetSettingsModel { name: name ?? this.name, phone: phone ?? this.phone, phonePassword: phonePassword ?? this.phonePassword, + server: server ?? this.server, + serverInfo: serverInfo ?? this.serverInfo, state: state ?? this.state, + subAccountCategory: subAccountCategory ?? this.subAccountCategory, subAccountType: subAccountType ?? this.subAccountType, zipCode: zipCode ?? this.zipCode, ); } +/// Server info model class. +abstract class ServerInfoModel { + /// Initializes Server info model class . + const ServerInfoModel({ + this.environment, + this.geolocation, + this.id, + }); + + /// The environment. E.g. Deriv-Server. + final EnvironmentEnum? environment; + + /// Geographical location of the server. + final Geolocation? geolocation; + + /// Server id. + final String? id; +} + +/// Server info class. +class ServerInfo extends ServerInfoModel { + /// Initializes Server info class. + const ServerInfo({ + super.environment, + super.geolocation, + super.id, + }); + + /// Creates an instance from JSON. + factory ServerInfo.fromJson(Map json) => ServerInfo( + environment: json['environment'] == null + ? null + : environmentEnumMapper[json['environment']], + geolocation: json['geolocation'] == null + ? null + : Geolocation.fromJson(json['geolocation']), + id: json['id'], + ); + + /// Converts an instance to JSON. + Map toJson() { + final Map resultMap = {}; + + resultMap['environment'] = environmentEnumMapper.entries + .firstWhere((MapEntry entry) => + entry.value == environment) + .key; + if (geolocation != null) { + resultMap['geolocation'] = geolocation!.toJson(); + } + resultMap['id'] = id; + + return resultMap; + } + + /// Creates a copy of instance with given parameters. + ServerInfo copyWith({ + EnvironmentEnum? environment, + Geolocation? geolocation, + String? id, + }) => + ServerInfo( + environment: environment ?? this.environment, + geolocation: geolocation ?? this.geolocation, + id: id ?? this.id, + ); +} +/// Geolocation model class. +abstract class GeolocationModel { + /// Initializes Geolocation model class . + const GeolocationModel({ + this.group, + this.location, + this.region, + this.sequence, + }); + + /// Internal server grouping. + final String? group; + + /// Server location. + final String? location; + + /// Server region. + final String? region; + + /// Server sequence. + final int? sequence; +} + +/// Geolocation class. +class Geolocation extends GeolocationModel { + /// Initializes Geolocation class. + const Geolocation({ + super.group, + super.location, + super.region, + super.sequence, + }); + + /// Creates an instance from JSON. + factory Geolocation.fromJson(Map json) => Geolocation( + group: json['group'], + location: json['location'], + region: json['region'], + sequence: json['sequence'], + ); + + /// Converts an instance to JSON. + Map toJson() { + final Map resultMap = {}; + + resultMap['group'] = group; + resultMap['location'] = location; + resultMap['region'] = region; + resultMap['sequence'] = sequence; + + return resultMap; + } + + /// Creates a copy of instance with given parameters. + Geolocation copyWith({ + String? group, + String? location, + String? region, + int? sequence, + }) => + Geolocation( + group: group ?? this.group, + location: location ?? this.location, + region: region ?? this.region, + sequence: sequence ?? this.sequence, + ); +} diff --git a/lib/api/response/mt5_login_list_response_result.dart b/lib/api/response/mt5_login_list_response_result.dart index 40dbd21955..2591f6af1b 100644 --- a/lib/api/response/mt5_login_list_response_result.dart +++ b/lib/api/response/mt5_login_list_response_result.dart @@ -64,7 +64,7 @@ class Mt5LoginListResponse extends Mt5LoginListResponseModel { /// Gets the list of MT5 accounts for client. /// /// For parameters information refer to [Mt5LoginListRequest]. - /// Throws a [MT5Exception] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future fetchLoginList( Mt5LoginListRequest request, ) async { @@ -73,7 +73,7 @@ class Mt5LoginListResponse extends Mt5LoginListResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - MT5Exception(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return Mt5LoginListResponse.fromJson(response.mt5LoginList); diff --git a/lib/api/response/mt5_new_account_response_result.dart b/lib/api/response/mt5_new_account_response_result.dart index bf6126eff7..3e3d158412 100644 --- a/lib/api/response/mt5_new_account_response_result.dart +++ b/lib/api/response/mt5_new_account_response_result.dart @@ -69,7 +69,7 @@ class Mt5NewAccountResponse extends Mt5NewAccountResponseModel { /// Creates new MT5 user, either demo or real money user. /// /// For parameters information refer to [Mt5NewAccountRequest]. - /// Throws a [MT5Exception] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future createNewAccount( Mt5NewAccountRequest request, ) async { @@ -78,7 +78,7 @@ class Mt5NewAccountResponse extends Mt5NewAccountResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - MT5Exception(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return Mt5NewAccountResponse.fromJson(response.mt5NewAccount); @@ -86,7 +86,7 @@ class Mt5NewAccountResponse extends Mt5NewAccountResponseModel { /// Allows deposit into MT5 account from binary account. /// - /// Throws a [MT5Exception] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error Future deposit({ required double amount, required String fromBinary, @@ -101,7 +101,7 @@ class Mt5NewAccountResponse extends Mt5NewAccountResponseModel { /// Changes password of the MT5 account. /// - /// Throws a [MT5Exception] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error Future changePassword({ required String newPassword, required String oldPassword, @@ -118,7 +118,7 @@ class Mt5NewAccountResponse extends Mt5NewAccountResponseModel { /// Validates the main password for the MT5 user. /// - /// Throws a [MT5Exception] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error Future checkPassword({ required String password, required PasswordType passwordType, @@ -133,7 +133,7 @@ class Mt5NewAccountResponse extends Mt5NewAccountResponseModel { /// Resets the password of MT5 account. /// - /// Throws a [MT5Exception] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error Future resetPassword({ required String newPassword, required PasswordType passwordType, @@ -150,14 +150,14 @@ class Mt5NewAccountResponse extends Mt5NewAccountResponseModel { /// Gets the MT5 user account settings. /// - /// Throws a [MT5Exception] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error Future fetchSettings() => Mt5GetSettingsResponse.fetchSettings( Mt5GetSettingsRequest(login: mt5NewAccount?.login)); /// Allows withdrawal from MT5 account to Binary account. /// - /// Throws a [MT5Exception] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error Future withdraw({ required double amount, required String toBinary, diff --git a/lib/api/response/mt5_password_change_response_result.dart b/lib/api/response/mt5_password_change_response_result.dart index 8f496ea504..a6ac7e462e 100644 --- a/lib/api/response/mt5_password_change_response_result.dart +++ b/lib/api/response/mt5_password_change_response_result.dart @@ -52,7 +52,7 @@ class Mt5PasswordChangeResponse extends Mt5PasswordChangeResponseModel { /// Changes the password of the MT5 account. /// /// For parameters information refer to [Mt5PasswordChangeRequest]. - /// Throws a [MT5Exception] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future changePassword( Mt5PasswordChangeRequest request, ) async { @@ -61,7 +61,7 @@ class Mt5PasswordChangeResponse extends Mt5PasswordChangeResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - MT5Exception(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return Mt5PasswordChangeResponse.fromJson(response.mt5PasswordChange); diff --git a/lib/api/response/mt5_password_check_response_result.dart b/lib/api/response/mt5_password_check_response_result.dart index 80884b7269..b534d8f80a 100644 --- a/lib/api/response/mt5_password_check_response_result.dart +++ b/lib/api/response/mt5_password_check_response_result.dart @@ -52,7 +52,7 @@ class Mt5PasswordCheckResponse extends Mt5PasswordCheckResponseModel { /// Validates the main password for the MT5 user. /// /// For parameters information refer to [Mt5PasswordCheckRequest]. - /// Throws a [MT5Exception] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future checkPassword( Mt5PasswordCheckRequest request) async { final Mt5PasswordCheckReceive response = await _api.call(request: request); @@ -60,7 +60,7 @@ class Mt5PasswordCheckResponse extends Mt5PasswordCheckResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - MT5Exception(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return Mt5PasswordCheckResponse.fromJson(response.mt5PasswordCheck); diff --git a/lib/api/response/mt5_password_reset_response_result.dart b/lib/api/response/mt5_password_reset_response_result.dart index b1c832805d..f83a757c16 100644 --- a/lib/api/response/mt5_password_reset_response_result.dart +++ b/lib/api/response/mt5_password_reset_response_result.dart @@ -52,7 +52,7 @@ class Mt5PasswordResetResponse extends Mt5PasswordResetResponseModel { /// Resets the password of MT5 account. /// /// For parameters information refer to [Mt5PasswordResetRequest]. - /// Throws a [MT5Exception] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future resetPassword( Mt5PasswordResetRequest request, ) async { @@ -61,7 +61,7 @@ class Mt5PasswordResetResponse extends Mt5PasswordResetResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - MT5Exception(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return Mt5PasswordResetResponse.fromJson(response.mt5PasswordReset); diff --git a/lib/api/response/mt5_withdrawal_response_result.dart b/lib/api/response/mt5_withdrawal_response_result.dart index e8c046f4bc..c123ca54b2 100644 --- a/lib/api/response/mt5_withdrawal_response_result.dart +++ b/lib/api/response/mt5_withdrawal_response_result.dart @@ -61,7 +61,7 @@ class Mt5WithdrawalResponse extends Mt5WithdrawalResponseModel { /// Allows withdrawal from MT5 account to Binary account. /// /// For parameters information refer to [Mt5WithdrawalRequest]. - /// Throws a [MT5Exception] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future withdraw( Mt5WithdrawalRequest request, ) async { @@ -70,7 +70,7 @@ class Mt5WithdrawalResponse extends Mt5WithdrawalResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - MT5Exception(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return Mt5WithdrawalResponse.fromJson( diff --git a/lib/api/response/new_account_real_response_result.dart b/lib/api/response/new_account_real_response_result.dart index a303547210..aa47f00328 100644 --- a/lib/api/response/new_account_real_response_result.dart +++ b/lib/api/response/new_account_real_response_result.dart @@ -56,7 +56,7 @@ class NewAccountRealResponse extends NewAccountRealResponseModel { /// Opens a new real account. /// /// For parameters information refer to [NewAccountRealRequest]. - /// Throws a [NewAccountException] ifAP + /// Throws a [BaseAPIException] ifAP static Future openNewRealAccount( NewAccountRealRequest request, ) async { @@ -65,7 +65,7 @@ class NewAccountRealResponse extends NewAccountRealResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - NewAccountException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return NewAccountRealResponse.fromJson(response.newAccountReal); diff --git a/lib/api/response/new_account_virtual_response_result.dart b/lib/api/response/new_account_virtual_response_result.dart index c4f22f7792..2b87d4a37b 100644 --- a/lib/api/response/new_account_virtual_response_result.dart +++ b/lib/api/response/new_account_virtual_response_result.dart @@ -56,7 +56,7 @@ class NewAccountVirtualResponse extends NewAccountVirtualResponseModel { /// Opens a new virtual account. /// /// For parameters information refer to [NewAccountVirtualRequest]. - /// Throws a [NewAccountException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future openNewVirtualAccount( NewAccountVirtualRequest request, ) async { @@ -65,7 +65,7 @@ class NewAccountVirtualResponse extends NewAccountVirtualResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - NewAccountException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return NewAccountVirtualResponse.fromJson(response.newAccountVirtual); diff --git a/lib/api/response/new_account_wallet_response_extended.dart b/lib/api/response/new_account_wallet_response_extended.dart new file mode 100644 index 0000000000..0a4d1fb073 --- /dev/null +++ b/lib/api/response/new_account_wallet_response_extended.dart @@ -0,0 +1,28 @@ +import 'package:deriv_dependency_injector/dependency_injector.dart'; +import 'package:flutter_deriv_api/api/exceptions/exceptions.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'; + +import 'new_account_wallet_response_result.dart'; + +/// The extended version of the [NewAccountWalletResponse] class to implement +/// the API call methods. +class NewAccountWalletResponseExtended extends NewAccountWalletResponse { + static final BaseAPI _api = Injector()(); + + /// Creates a new wallet account. + static Future createNewWalletAccount({ + required NewAccountWalletRequest request, + }) async { + final NewAccountWalletReceive response = await _api.call(request: request); + + checkException( + response: response, + exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => + BaseAPIException(baseExceptionModel: baseExceptionModel), + ); + + return NewAccountWalletResponse.fromJson(response.newAccountWallet); + } +} diff --git a/lib/api/response/new_account_wallet_response_result.dart b/lib/api/response/new_account_wallet_response_result.dart index cffea611f3..bab5e442bb 100644 --- a/lib/api/response/new_account_wallet_response_result.dart +++ b/lib/api/response/new_account_wallet_response_result.dart @@ -19,10 +19,8 @@ abstract class NewAccountWalletResponseModel { class NewAccountWalletResponse extends NewAccountWalletResponseModel { /// Initializes New account wallet response class. const NewAccountWalletResponse({ - NewAccountWallet? newAccountWallet, - }) : super( - newAccountWallet: newAccountWallet, - ); + super.newAccountWallet, + }); /// Creates an instance from JSON. factory NewAccountWalletResponse.fromJson( @@ -88,20 +86,13 @@ abstract class NewAccountWalletModel { class NewAccountWallet extends NewAccountWalletModel { /// Initializes New account wallet class. const NewAccountWallet({ - required String clientId, - required String landingCompany, - required String oauthToken, - String? currency, - String? landingCompanyShort, - String? landingCompanyShortcode, - }) : super( - clientId: clientId, - landingCompany: landingCompany, - oauthToken: oauthToken, - currency: currency, - landingCompanyShort: landingCompanyShort, - landingCompanyShortcode: landingCompanyShortcode, - ); + required super.clientId, + required super.landingCompany, + required super.oauthToken, + super.currency, + super.landingCompanyShort, + super.landingCompanyShortcode, + }); /// Creates an instance from JSON. factory NewAccountWallet.fromJson(Map json) => diff --git a/lib/api/response/oauth_apps_response_result.dart b/lib/api/response/oauth_apps_response_result.dart index 2d0f2aafcc..3da3325f49 100644 --- a/lib/api/response/oauth_apps_response_result.dart +++ b/lib/api/response/oauth_apps_response_result.dart @@ -63,7 +63,7 @@ class OauthAppsResponse extends OauthAppsResponseModel { /// Gets oauth application that used for the authorized account. /// - /// Throws an [AppException] if API response contains an error + /// Throws an [BaseAPIException] if API response contains an error static Future fetchOauthApps([ OauthAppsRequest? request, ]) async { @@ -74,7 +74,7 @@ class OauthAppsResponse extends OauthAppsResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - AppException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return OauthAppsResponse.fromJson(response.oauthApps); diff --git a/lib/api/response/p2p_advert_create_response_result.dart b/lib/api/response/p2p_advert_create_response_result.dart index 9a99fecef5..6cdd91498f 100644 --- a/lib/api/response/p2p_advert_create_response_result.dart +++ b/lib/api/response/p2p_advert_create_response_result.dart @@ -2,7 +2,7 @@ import 'package:equatable/equatable.dart'; -import 'package:flutter_deriv_api/api/exceptions/p2p_advert_exception.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/basic_api/generated/p2p_advert_create_receive.dart'; import 'package:flutter_deriv_api/basic_api/generated/p2p_advert_create_send.dart'; @@ -25,10 +25,8 @@ abstract class P2pAdvertCreateResponseModel { class P2pAdvertCreateResponse extends P2pAdvertCreateResponseModel { /// Initializes P2p advert create response class. const P2pAdvertCreateResponse({ - P2pAdvertCreate? p2pAdvertCreate, - }) : super( - p2pAdvertCreate: p2pAdvertCreate, - ); + super.p2pAdvertCreate, + }); /// Creates an instance from JSON. factory P2pAdvertCreateResponse.fromJson( @@ -56,7 +54,7 @@ class P2pAdvertCreateResponse extends P2pAdvertCreateResponseModel { /// Creates a P2P (peer to peer) advert. Can only be used by an approved P2P advertiser. /// /// For parameters information refer to [P2pAdvertCreateRequest]. - /// Throws a [P2PAdvertException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future createAdvert( P2pAdvertCreateRequest request, ) async { @@ -68,7 +66,7 @@ class P2pAdvertCreateResponse extends P2pAdvertCreateResponseModel { /// Creates a P2P (peer to peer) advert. Can only be used by an approved P2P advertiser. /// /// For parameters information refer to [P2pAdvertCreateRequest]. - /// Throws a [P2PAdvertException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future createAdvertRaw( P2pAdvertCreateRequest request, ) async { @@ -77,7 +75,7 @@ class P2pAdvertCreateResponse extends P2pAdvertCreateResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - P2PAdvertException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return response; @@ -185,6 +183,8 @@ final Map visibilityStatusItemEnumMapper = "advertiser_ads_paused": VisibilityStatusItemEnum.advertiserAdsPaused, "advertiser_approval": VisibilityStatusItemEnum.advertiserApproval, "advertiser_balance": VisibilityStatusItemEnum.advertiserBalance, + "advertiser_block_trade_ineligible": + VisibilityStatusItemEnum.advertiserBlockTradeIneligible, "advertiser_daily_limit": VisibilityStatusItemEnum.advertiserDailyLimit, "advertiser_temp_ban": VisibilityStatusItemEnum.advertiserTempBan, }; @@ -212,6 +212,9 @@ enum VisibilityStatusItemEnum { /// advertiser_balance. advertiserBalance, + /// advertiser_block_trade_ineligible. + advertiserBlockTradeIneligible, + /// advertiser_daily_limit. advertiserDailyLimit, @@ -229,6 +232,7 @@ abstract class P2pAdvertCreateModel { required this.rateType, required this.rateDisplay, required this.rate, + required this.orderExpiryPeriod, required this.minOrderAmountLimitDisplay, required this.minOrderAmountLimit, required this.minOrderAmountDisplay, @@ -245,6 +249,7 @@ abstract class P2pAdvertCreateModel { required this.createdTime, required this.country, required this.counterpartyType, + required this.blockTrade, required this.amountDisplay, required this.amount, required this.advertiserDetails, @@ -280,6 +285,9 @@ abstract class P2pAdvertCreateModel { /// Conversion rate from advertiser's account currency to `local_currency`. An absolute rate value (fixed), or percentage offset from current market rate (floating). final double rate; + /// Expiry period (seconds) for order created against this ad. + final int orderExpiryPeriod; + /// Minimum order amount at this time, in `account_currency`, formatted to appropriate decimal places. final String minOrderAmountLimitDisplay; @@ -328,6 +336,9 @@ abstract class P2pAdvertCreateModel { /// Type of transaction from the opposite party's perspective. final CounterpartyTypeEnum counterpartyType; + /// Indicates if this is block trade advert or not. + final bool blockTrade; + /// The total amount specified in advert, in `account_currency`, formatted to appropriate decimal places. final String amountDisplay; @@ -378,6 +389,7 @@ abstract class P2pAdvertCreateModel { /// - `advertiser_ads_paused`: the advertiser has paused all adverts. /// - `advertiser_approval`: the advertiser's proof of identity is not verified. /// - `advertiser_balance`: the advertiser's P2P balance is less than the minimum order. + /// - `advertiser_block_trade_ineligible`: the advertiser is not currently eligible for block trading. /// - `advertiser_daily_limit`: the advertiser's remaining daily limit is less than the minimum order. /// - `advertiser_temp_ban`: the advertiser is temporarily banned from P2P. final List? visibilityStatus; @@ -387,82 +399,46 @@ abstract class P2pAdvertCreateModel { class P2pAdvertCreate extends P2pAdvertCreateModel { /// Initializes P2p advert create class. const P2pAdvertCreate({ - required String accountCurrency, - required int activeOrders, - required AdvertiserDetails advertiserDetails, - required double amount, - required String amountDisplay, - required CounterpartyTypeEnum counterpartyType, - required String country, - required DateTime createdTime, - required String description, - required String id, - required bool isActive, - required bool isVisible, - required String localCurrency, - required double maxOrderAmount, - required String maxOrderAmountDisplay, - required double maxOrderAmountLimit, - required String maxOrderAmountLimitDisplay, - required double minOrderAmount, - required String minOrderAmountDisplay, - required double minOrderAmountLimit, - required String minOrderAmountLimitDisplay, - required double rate, - required String rateDisplay, - required RateTypeEnum rateType, - required double remainingAmount, - required String remainingAmountDisplay, - required P2pAdvertCreateTypeEnum type, - String? contactInfo, - double? effectiveRate, - String? effectiveRateDisplay, - String? paymentInfo, - String? paymentMethod, - Map? paymentMethodDetails, - List? paymentMethodNames, - double? price, - String? priceDisplay, - List? visibilityStatus, - }) : super( - accountCurrency: accountCurrency, - activeOrders: activeOrders, - advertiserDetails: advertiserDetails, - amount: amount, - amountDisplay: amountDisplay, - counterpartyType: counterpartyType, - country: country, - createdTime: createdTime, - description: description, - id: id, - isActive: isActive, - isVisible: isVisible, - localCurrency: localCurrency, - maxOrderAmount: maxOrderAmount, - maxOrderAmountDisplay: maxOrderAmountDisplay, - maxOrderAmountLimit: maxOrderAmountLimit, - maxOrderAmountLimitDisplay: maxOrderAmountLimitDisplay, - minOrderAmount: minOrderAmount, - minOrderAmountDisplay: minOrderAmountDisplay, - minOrderAmountLimit: minOrderAmountLimit, - minOrderAmountLimitDisplay: minOrderAmountLimitDisplay, - rate: rate, - rateDisplay: rateDisplay, - rateType: rateType, - remainingAmount: remainingAmount, - remainingAmountDisplay: remainingAmountDisplay, - type: type, - contactInfo: contactInfo, - effectiveRate: effectiveRate, - effectiveRateDisplay: effectiveRateDisplay, - paymentInfo: paymentInfo, - paymentMethod: paymentMethod, - paymentMethodDetails: paymentMethodDetails, - paymentMethodNames: paymentMethodNames, - price: price, - priceDisplay: priceDisplay, - visibilityStatus: visibilityStatus, - ); + required super.accountCurrency, + required super.activeOrders, + required super.advertiserDetails, + required super.amount, + required super.amountDisplay, + required super.blockTrade, + required super.counterpartyType, + required super.country, + required super.createdTime, + required super.description, + required super.id, + required super.isActive, + required super.isVisible, + required super.localCurrency, + required super.maxOrderAmount, + required super.maxOrderAmountDisplay, + required super.maxOrderAmountLimit, + required super.maxOrderAmountLimitDisplay, + required super.minOrderAmount, + required super.minOrderAmountDisplay, + required super.minOrderAmountLimit, + required super.minOrderAmountLimitDisplay, + required super.orderExpiryPeriod, + required super.rate, + required super.rateDisplay, + required super.rateType, + required super.remainingAmount, + required super.remainingAmountDisplay, + required super.type, + super.contactInfo, + super.effectiveRate, + super.effectiveRateDisplay, + super.paymentInfo, + super.paymentMethod, + super.paymentMethodDetails, + super.paymentMethodNames, + super.price, + super.priceDisplay, + super.visibilityStatus, + }); /// Creates an instance from JSON. factory P2pAdvertCreate.fromJson(Map json) => @@ -473,6 +449,7 @@ class P2pAdvertCreate extends P2pAdvertCreateModel { AdvertiserDetails.fromJson(json['advertiser_details']), amount: getDouble(json['amount'])!, amountDisplay: json['amount_display'], + blockTrade: getBool(json['block_trade'])!, counterpartyType: counterpartyTypeEnumMapper[json['counterparty_type']]!, country: json['country'], @@ -490,6 +467,7 @@ class P2pAdvertCreate extends P2pAdvertCreateModel { minOrderAmountDisplay: json['min_order_amount_display'], minOrderAmountLimit: getDouble(json['min_order_amount_limit'])!, minOrderAmountLimitDisplay: json['min_order_amount_limit_display'], + orderExpiryPeriod: json['order_expiry_period'], rate: getDouble(json['rate'])!, rateDisplay: json['rate_display'], rateType: rateTypeEnumMapper[json['rate_type']]!, @@ -542,6 +520,7 @@ class P2pAdvertCreate extends P2pAdvertCreateModel { resultMap['amount'] = amount; resultMap['amount_display'] = amountDisplay; + resultMap['block_trade'] = blockTrade; resultMap['counterparty_type'] = counterpartyTypeEnumMapper.entries .firstWhere((MapEntry entry) => entry.value == counterpartyType) @@ -561,6 +540,7 @@ class P2pAdvertCreate extends P2pAdvertCreateModel { resultMap['min_order_amount_display'] = minOrderAmountDisplay; resultMap['min_order_amount_limit'] = minOrderAmountLimit; resultMap['min_order_amount_limit_display'] = minOrderAmountLimitDisplay; + resultMap['order_expiry_period'] = orderExpiryPeriod; resultMap['rate'] = rate; resultMap['rate_display'] = rateDisplay; resultMap['rate_type'] = rateTypeEnumMapper.entries @@ -611,6 +591,7 @@ class P2pAdvertCreate extends P2pAdvertCreateModel { AdvertiserDetails? advertiserDetails, double? amount, String? amountDisplay, + bool? blockTrade, CounterpartyTypeEnum? counterpartyType, String? country, DateTime? createdTime, @@ -627,6 +608,7 @@ class P2pAdvertCreate extends P2pAdvertCreateModel { String? minOrderAmountDisplay, double? minOrderAmountLimit, String? minOrderAmountLimitDisplay, + int? orderExpiryPeriod, double? rate, String? rateDisplay, RateTypeEnum? rateType, @@ -650,6 +632,7 @@ class P2pAdvertCreate extends P2pAdvertCreateModel { advertiserDetails: advertiserDetails ?? this.advertiserDetails, amount: amount ?? this.amount, amountDisplay: amountDisplay ?? this.amountDisplay, + blockTrade: blockTrade ?? this.blockTrade, counterpartyType: counterpartyType ?? this.counterpartyType, country: country ?? this.country, createdTime: createdTime ?? this.createdTime, @@ -670,6 +653,7 @@ class P2pAdvertCreate extends P2pAdvertCreateModel { minOrderAmountLimit: minOrderAmountLimit ?? this.minOrderAmountLimit, minOrderAmountLimitDisplay: minOrderAmountLimitDisplay ?? this.minOrderAmountLimitDisplay, + orderExpiryPeriod: orderExpiryPeriod ?? this.orderExpiryPeriod, rate: rate ?? this.rate, rateDisplay: rateDisplay ?? this.rateDisplay, rateType: rateType ?? this.rateType, @@ -749,32 +733,19 @@ abstract class AdvertiserDetailsModel { class AdvertiserDetails extends AdvertiserDetailsModel { /// Initializes Advertiser details class. const AdvertiserDetails({ - required int completedOrdersCount, - required String id, - required bool isOnline, - required String name, - required int ratingCount, - String? firstName, - String? lastName, - DateTime? lastOnlineTime, - double? ratingAverage, - double? recommendedAverage, - int? recommendedCount, - double? totalCompletionRate, - }) : super( - completedOrdersCount: completedOrdersCount, - id: id, - isOnline: isOnline, - name: name, - ratingCount: ratingCount, - firstName: firstName, - lastName: lastName, - lastOnlineTime: lastOnlineTime, - ratingAverage: ratingAverage, - recommendedAverage: recommendedAverage, - recommendedCount: recommendedCount, - totalCompletionRate: totalCompletionRate, - ); + required super.completedOrdersCount, + required super.id, + required super.isOnline, + required super.name, + required super.ratingCount, + super.firstName, + super.lastName, + super.lastOnlineTime, + super.ratingAverage, + super.recommendedAverage, + super.recommendedCount, + super.totalCompletionRate, + }); /// Creates an instance from JSON. factory AdvertiserDetails.fromJson(Map json) => @@ -884,22 +855,14 @@ abstract class PaymentMethodDetailsPropertyModel { class PaymentMethodDetailsProperty extends PaymentMethodDetailsPropertyModel { /// Initializes Payment method details property class. const PaymentMethodDetailsProperty({ - required Map fields, - required bool isEnabled, - required String method, - required PaymentMethodDetailsPropertyTypeEnum type, - String? displayName, - List? usedByAdverts, - List? usedByOrders, - }) : super( - fields: fields, - isEnabled: isEnabled, - method: method, - type: type, - displayName: displayName, - usedByAdverts: usedByAdverts, - usedByOrders: usedByOrders, - ); + required super.fields, + required super.isEnabled, + required super.method, + required super.type, + super.displayName, + super.usedByAdverts, + super.usedByOrders, + }); /// Creates an instance from JSON. factory PaymentMethodDetailsProperty.fromJson(Map json) => @@ -1009,16 +972,11 @@ abstract class FieldsPropertyModel { class FieldsProperty extends FieldsPropertyModel { /// Initializes Fields property class. const FieldsProperty({ - required String displayName, - required int required, - required TypeEnum type, - required String value, - }) : super( - displayName: displayName, - required: required, - type: type, - value: value, - ); + required super.displayName, + required super.required, + required super.type, + required super.value, + }); /// Creates an instance from JSON. factory FieldsProperty.fromJson(Map json) => FieldsProperty( diff --git a/lib/api/response/p2p_advert_info_response_result.dart b/lib/api/response/p2p_advert_info_response_result.dart index f2186228d3..eac7137470 100644 --- a/lib/api/response/p2p_advert_info_response_result.dart +++ b/lib/api/response/p2p_advert_info_response_result.dart @@ -17,7 +17,6 @@ import 'package:flutter_deriv_api/basic_api/generated/p2p_advert_update_receive. import 'package:flutter_deriv_api/basic_api/generated/p2p_advert_update_send.dart'; import 'package:flutter_deriv_api/basic_api/generated/p2p_order_create_receive.dart'; import 'package:flutter_deriv_api/basic_api/generated/p2p_order_create_send.dart'; - /// P2p advert info response model class. abstract class P2pAdvertInfoResponseModel { /// Initializes P2p advert info response model class . @@ -37,12 +36,9 @@ abstract class P2pAdvertInfoResponseModel { class P2pAdvertInfoResponse extends P2pAdvertInfoResponseModel { /// Initializes P2p advert info response class. const P2pAdvertInfoResponse({ - P2pAdvertInfo? p2pAdvertInfo, - Subscription? subscription, - }) : super( - p2pAdvertInfo: p2pAdvertInfo, - subscription: subscription, - ); + super.p2pAdvertInfo, + super.subscription, + }); /// Creates an instance from JSON. factory P2pAdvertInfoResponse.fromJson( @@ -77,7 +73,7 @@ class P2pAdvertInfoResponse extends P2pAdvertInfoResponseModel { /// Retrieves information about a P2P (peer to peer) advert. /// /// For parameters information refer to [P2pAdvertInfoRequest]. - /// Throws a [P2PAdvertException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future fetchAdvert( P2pAdvertInfoRequest request, ) async { @@ -90,7 +86,7 @@ class P2pAdvertInfoResponse extends P2pAdvertInfoResponseModel { /// Retrieves information about a P2P (peer to peer) advert. /// /// For parameters information refer to [P2pAdvertInfoRequest]. - /// Throws a [P2PAdvertException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future fetchAdvertRaw( P2pAdvertInfoRequest request, ) async { @@ -99,7 +95,7 @@ class P2pAdvertInfoResponse extends P2pAdvertInfoResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - P2PAdvertException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return response; @@ -109,7 +105,7 @@ class P2pAdvertInfoResponse extends P2pAdvertInfoResponseModel { /// /// [delete] to permanently delete the advert /// [isActive] to activate or deactivate the advert - /// Throws a [P2PAdvertException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error Future update({ bool? delete, bool? isActive, @@ -126,7 +122,7 @@ class P2pAdvertInfoResponse extends P2pAdvertInfoResponseModel { /// /// [delete] to permanently delete the advert /// [isActive] to activate or deactivate the advert - /// Throws a [P2PAdvertException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error Future updateRaw({ bool? delete, bool? isActive, @@ -141,33 +137,33 @@ class P2pAdvertInfoResponse extends P2pAdvertInfoResponseModel { /// Deletes permanently a P2P (peer to peer) advert. Can only be used by the advertiser. /// - /// Throws a [P2PAdvertException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error Future delete() => update(delete: true); /// Deletes permanently a P2P (peer to peer) advert. Can only be used by the advertiser. /// - /// Throws a [P2PAdvertException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error Future deleteRaw() => updateRaw(delete: true); /// Activates a P2P (peer to peer) advert. Can only be used by the advertiser. /// - /// Throws a [P2PAdvertException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error Future activate() async => update(isActive: true); /// Activates a P2P (peer to peer) advert. Can only be used by the advertiser. /// - /// Throws a [P2PAdvertException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error Future activateRaw() async => updateRaw(isActive: true); /// Deactivates a P2P (peer to peer) advert. Can only be used by the advertiser. /// - /// Throws a [P2PAdvertException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error Future deactivate() async => update(isActive: false); /// Deactivates a P2P (peer to peer) advert. Can only be used by the advertiser. /// - /// Throws a [P2PAdvertException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error Future deactivateRaw() async => updateRaw(isActive: false); @@ -176,7 +172,7 @@ class P2pAdvertInfoResponse extends P2pAdvertInfoResponseModel { /// [amount] is the amount of currency to be bought or sold. /// [contactInfo] is seller contact information. Only applicable for [OrderType.sell]. /// [paymentInfo] is payment instructions. Only applicable for [OrderType.sell]. - /// Throws [P2POrderException] if API response contains an error. + /// Throws [BaseAPIException] if API response contains an error. Future createOrder({ required double amount, String? contactInfo, @@ -197,7 +193,7 @@ class P2pAdvertInfoResponse extends P2pAdvertInfoResponseModel { /// [amount] is the amount of currency to be bought or sold. /// [contactInfo] is seller contact information. Only applicable for [OrderType.sell]. /// [paymentInfo] is payment instructions. Only applicable for [OrderType.sell]. - /// Throws [P2POrderException] if API response contains an error. + /// Throws [BaseAPIException] if API response contains an error. Future createOrderRaw({ required double amount, String? contactInfo, @@ -317,6 +313,8 @@ final Map visibilityStatusItemEnumMapper = "advertiser_ads_paused": VisibilityStatusItemEnum.advertiserAdsPaused, "advertiser_approval": VisibilityStatusItemEnum.advertiserApproval, "advertiser_balance": VisibilityStatusItemEnum.advertiserBalance, + "advertiser_block_trade_ineligible": + VisibilityStatusItemEnum.advertiserBlockTradeIneligible, "advertiser_daily_limit": VisibilityStatusItemEnum.advertiserDailyLimit, "advertiser_temp_ban": VisibilityStatusItemEnum.advertiserTempBan, }; @@ -344,13 +342,15 @@ enum VisibilityStatusItemEnum { /// advertiser_balance. advertiserBalance, + /// advertiser_block_trade_ineligible. + advertiserBlockTradeIneligible, + /// advertiser_daily_limit. advertiserDailyLimit, /// advertiser_temp_ban. advertiserTempBan, } - /// P2p advert info model class. abstract class P2pAdvertInfoModel { /// Initializes P2p advert info model class . @@ -360,6 +360,7 @@ abstract class P2pAdvertInfoModel { this.advertiserDetails, this.amount, this.amountDisplay, + this.blockTrade, this.contactInfo, this.counterpartyType, this.country, @@ -381,6 +382,7 @@ abstract class P2pAdvertInfoModel { this.minOrderAmountDisplay, this.minOrderAmountLimit, this.minOrderAmountLimitDisplay, + this.orderExpiryPeriod, this.paymentInfo, this.paymentMethod, this.paymentMethodDetails, @@ -411,6 +413,9 @@ abstract class P2pAdvertInfoModel { /// The total amount specified in advert, in `account_currency`, formatted to appropriate decimal places. It is only visible to the advert owner. final String? amountDisplay; + /// Indicates if this is block trade advert or not. + final bool? blockTrade; + /// Advertiser contact information. Only applicable for 'sell adverts'. final String? contactInfo; @@ -474,6 +479,9 @@ abstract class P2pAdvertInfoModel { /// Minimum order amount at this time, in `account_currency`, formatted to appropriate decimal places. final String? minOrderAmountLimitDisplay; + /// Expiry period (seconds) for order created against this ad. + final int? orderExpiryPeriod; + /// Payment instructions. Only applicable for 'sell adverts'. final String? paymentInfo; @@ -518,6 +526,7 @@ abstract class P2pAdvertInfoModel { /// - `advertiser_ads_paused`: the advertiser has paused all adverts. /// - `advertiser_approval`: the advertiser's proof of identity is not verified. /// - `advertiser_balance`: the advertiser's P2P balance is less than the minimum order. + /// - `advertiser_block_trade_ineligible`: the advertiser is not currently eligible for block trading. /// - `advertiser_daily_limit`: the advertiser's remaining daily limit is less than the minimum order. /// - `advertiser_temp_ban`: the advertiser is temporarily banned from P2P. final List? visibilityStatus; @@ -527,86 +536,48 @@ abstract class P2pAdvertInfoModel { class P2pAdvertInfo extends P2pAdvertInfoModel { /// Initializes P2p advert info class. const P2pAdvertInfo({ - String? accountCurrency, - int? activeOrders, - AdvertiserDetails? advertiserDetails, - double? amount, - String? amountDisplay, - String? contactInfo, - CounterpartyTypeEnum? counterpartyType, - String? country, - DateTime? createdTime, - int? daysUntilArchive, - int? deleted, - String? description, - double? effectiveRate, - String? effectiveRateDisplay, - String? id, - bool? isActive, - bool? isVisible, - String? localCurrency, - double? maxOrderAmount, - String? maxOrderAmountDisplay, - double? maxOrderAmountLimit, - String? maxOrderAmountLimitDisplay, - double? minOrderAmount, - String? minOrderAmountDisplay, - double? minOrderAmountLimit, - String? minOrderAmountLimitDisplay, - String? paymentInfo, - String? paymentMethod, - Map? paymentMethodDetails, - List? paymentMethodNames, - double? price, - String? priceDisplay, - double? rate, - String? rateDisplay, - RateTypeEnum? rateType, - double? remainingAmount, - String? remainingAmountDisplay, - P2pAdvertInfoTypeEnum? type, - List? visibilityStatus, - }) : super( - accountCurrency: accountCurrency, - activeOrders: activeOrders, - advertiserDetails: advertiserDetails, - amount: amount, - amountDisplay: amountDisplay, - contactInfo: contactInfo, - counterpartyType: counterpartyType, - country: country, - createdTime: createdTime, - daysUntilArchive: daysUntilArchive, - deleted: deleted, - description: description, - effectiveRate: effectiveRate, - effectiveRateDisplay: effectiveRateDisplay, - id: id, - isActive: isActive, - isVisible: isVisible, - localCurrency: localCurrency, - maxOrderAmount: maxOrderAmount, - maxOrderAmountDisplay: maxOrderAmountDisplay, - maxOrderAmountLimit: maxOrderAmountLimit, - maxOrderAmountLimitDisplay: maxOrderAmountLimitDisplay, - minOrderAmount: minOrderAmount, - minOrderAmountDisplay: minOrderAmountDisplay, - minOrderAmountLimit: minOrderAmountLimit, - minOrderAmountLimitDisplay: minOrderAmountLimitDisplay, - paymentInfo: paymentInfo, - paymentMethod: paymentMethod, - paymentMethodDetails: paymentMethodDetails, - paymentMethodNames: paymentMethodNames, - price: price, - priceDisplay: priceDisplay, - rate: rate, - rateDisplay: rateDisplay, - rateType: rateType, - remainingAmount: remainingAmount, - remainingAmountDisplay: remainingAmountDisplay, - type: type, - visibilityStatus: visibilityStatus, - ); + super.accountCurrency, + super.activeOrders, + super.advertiserDetails, + super.amount, + super.amountDisplay, + super.blockTrade, + super.contactInfo, + super.counterpartyType, + super.country, + super.createdTime, + super.daysUntilArchive, + super.deleted, + super.description, + super.effectiveRate, + super.effectiveRateDisplay, + super.id, + super.isActive, + super.isVisible, + super.localCurrency, + super.maxOrderAmount, + super.maxOrderAmountDisplay, + super.maxOrderAmountLimit, + super.maxOrderAmountLimitDisplay, + super.minOrderAmount, + super.minOrderAmountDisplay, + super.minOrderAmountLimit, + super.minOrderAmountLimitDisplay, + super.orderExpiryPeriod, + super.paymentInfo, + super.paymentMethod, + super.paymentMethodDetails, + super.paymentMethodNames, + super.price, + super.priceDisplay, + super.rate, + super.rateDisplay, + super.rateType, + super.remainingAmount, + super.remainingAmountDisplay, + super.type, + super.visibilityStatus, + }); /// Creates an instance from JSON. factory P2pAdvertInfo.fromJson(Map json) => P2pAdvertInfo( @@ -617,6 +588,7 @@ class P2pAdvertInfo extends P2pAdvertInfoModel { : AdvertiserDetails.fromJson(json['advertiser_details']), amount: getDouble(json['amount']), amountDisplay: json['amount_display'], + blockTrade: getBool(json['block_trade']), contactInfo: json['contact_info'], counterpartyType: json['counterparty_type'] == null ? null @@ -640,6 +612,7 @@ class P2pAdvertInfo extends P2pAdvertInfoModel { minOrderAmountDisplay: json['min_order_amount_display'], minOrderAmountLimit: getDouble(json['min_order_amount_limit']), minOrderAmountLimitDisplay: json['min_order_amount_limit_display'], + orderExpiryPeriod: json['order_expiry_period'], paymentInfo: json['payment_info'], paymentMethod: json['payment_method'], paymentMethodDetails: json['payment_method_details'] == null @@ -694,6 +667,7 @@ class P2pAdvertInfo extends P2pAdvertInfoModel { } resultMap['amount'] = amount; resultMap['amount_display'] = amountDisplay; + resultMap['block_trade'] = blockTrade; resultMap['contact_info'] = contactInfo; resultMap['counterparty_type'] = counterpartyTypeEnumMapper.entries .firstWhere((MapEntry entry) => @@ -718,6 +692,7 @@ class P2pAdvertInfo extends P2pAdvertInfoModel { resultMap['min_order_amount_display'] = minOrderAmountDisplay; resultMap['min_order_amount_limit'] = minOrderAmountLimit; resultMap['min_order_amount_limit_display'] = minOrderAmountLimitDisplay; + resultMap['order_expiry_period'] = orderExpiryPeriod; resultMap['payment_info'] = paymentInfo; resultMap['payment_method'] = paymentMethod; resultMap['payment_method_details'] = paymentMethodDetails; @@ -765,6 +740,7 @@ class P2pAdvertInfo extends P2pAdvertInfoModel { AdvertiserDetails? advertiserDetails, double? amount, String? amountDisplay, + bool? blockTrade, String? contactInfo, CounterpartyTypeEnum? counterpartyType, String? country, @@ -786,6 +762,7 @@ class P2pAdvertInfo extends P2pAdvertInfoModel { String? minOrderAmountDisplay, double? minOrderAmountLimit, String? minOrderAmountLimitDisplay, + int? orderExpiryPeriod, String? paymentInfo, String? paymentMethod, Map? paymentMethodDetails, @@ -806,6 +783,7 @@ class P2pAdvertInfo extends P2pAdvertInfoModel { advertiserDetails: advertiserDetails ?? this.advertiserDetails, amount: amount ?? this.amount, amountDisplay: amountDisplay ?? this.amountDisplay, + blockTrade: blockTrade ?? this.blockTrade, contactInfo: contactInfo ?? this.contactInfo, counterpartyType: counterpartyType ?? this.counterpartyType, country: country ?? this.country, @@ -831,6 +809,7 @@ class P2pAdvertInfo extends P2pAdvertInfoModel { minOrderAmountLimit: minOrderAmountLimit ?? this.minOrderAmountLimit, minOrderAmountLimitDisplay: minOrderAmountLimitDisplay ?? this.minOrderAmountLimitDisplay, + orderExpiryPeriod: orderExpiryPeriod ?? this.orderExpiryPeriod, paymentInfo: paymentInfo ?? this.paymentInfo, paymentMethod: paymentMethod ?? this.paymentMethod, paymentMethodDetails: paymentMethodDetails ?? this.paymentMethodDetails, @@ -847,7 +826,6 @@ class P2pAdvertInfo extends P2pAdvertInfoModel { visibilityStatus: visibilityStatus ?? this.visibilityStatus, ); } - /// Advertiser details model class. abstract class AdvertiserDetailsModel { /// Initializes Advertiser details model class . @@ -919,38 +897,22 @@ abstract class AdvertiserDetailsModel { class AdvertiserDetails extends AdvertiserDetailsModel { /// Initializes Advertiser details class. const AdvertiserDetails({ - required int completedOrdersCount, - required String id, - required bool isOnline, - required String name, - required int ratingCount, - String? firstName, - bool? isBlocked, - bool? isFavourite, - int? isRecommended, - String? lastName, - DateTime? lastOnlineTime, - double? ratingAverage, - double? recommendedAverage, - int? recommendedCount, - double? totalCompletionRate, - }) : super( - completedOrdersCount: completedOrdersCount, - id: id, - isOnline: isOnline, - name: name, - ratingCount: ratingCount, - firstName: firstName, - isBlocked: isBlocked, - isFavourite: isFavourite, - isRecommended: isRecommended, - lastName: lastName, - lastOnlineTime: lastOnlineTime, - ratingAverage: ratingAverage, - recommendedAverage: recommendedAverage, - recommendedCount: recommendedCount, - totalCompletionRate: totalCompletionRate, - ); + required super.completedOrdersCount, + required super.id, + required super.isOnline, + required super.name, + required super.ratingCount, + super.firstName, + super.isBlocked, + super.isFavourite, + super.isRecommended, + super.lastName, + super.lastOnlineTime, + super.ratingAverage, + super.recommendedAverage, + super.recommendedCount, + super.totalCompletionRate, + }); /// Creates an instance from JSON. factory AdvertiserDetails.fromJson(Map json) => @@ -1032,7 +994,6 @@ class AdvertiserDetails extends AdvertiserDetailsModel { totalCompletionRate: totalCompletionRate ?? this.totalCompletionRate, ); } - /// Payment method details property model class. abstract class PaymentMethodDetailsPropertyModel { /// Initializes Payment method details property model class . @@ -1072,22 +1033,14 @@ abstract class PaymentMethodDetailsPropertyModel { class PaymentMethodDetailsProperty extends PaymentMethodDetailsPropertyModel { /// Initializes Payment method details property class. const PaymentMethodDetailsProperty({ - required Map fields, - required bool isEnabled, - required String method, - required PaymentMethodDetailsPropertyTypeEnum type, - String? displayName, - List? usedByAdverts, - List? usedByOrders, - }) : super( - fields: fields, - isEnabled: isEnabled, - method: method, - type: type, - displayName: displayName, - usedByAdverts: usedByAdverts, - usedByOrders: usedByOrders, - ); + required super.fields, + required super.isEnabled, + required super.method, + required super.type, + super.displayName, + super.usedByAdverts, + super.usedByOrders, + }); /// Creates an instance from JSON. factory PaymentMethodDetailsProperty.fromJson(Map json) => @@ -1169,7 +1122,6 @@ class PaymentMethodDetailsProperty extends PaymentMethodDetailsPropertyModel { usedByOrders: usedByOrders ?? this.usedByOrders, ); } - /// Fields property model class. abstract class FieldsPropertyModel { /// Initializes Fields property model class . @@ -1197,16 +1149,11 @@ abstract class FieldsPropertyModel { class FieldsProperty extends FieldsPropertyModel { /// Initializes Fields property class. const FieldsProperty({ - required String displayName, - required int required, - required TypeEnum type, - required String value, - }) : super( - displayName: displayName, - required: required, - type: type, - value: value, - ); + required super.displayName, + required super.required, + required super.type, + required super.value, + }); /// Creates an instance from JSON. factory FieldsProperty.fromJson(Map json) => FieldsProperty( @@ -1244,7 +1191,6 @@ class FieldsProperty extends FieldsPropertyModel { value: value ?? this.value, ); } - /// Subscription model class. abstract class SubscriptionModel { /// Initializes Subscription model class . @@ -1260,10 +1206,8 @@ abstract class SubscriptionModel { class Subscription extends SubscriptionModel { /// Initializes Subscription class. const Subscription({ - required String id, - }) : super( - id: id, - ); + required super.id, + }); /// Creates an instance from JSON. factory Subscription.fromJson(Map json) => Subscription( diff --git a/lib/api/response/p2p_advert_list_response_result.dart b/lib/api/response/p2p_advert_list_response_result.dart index 0b6f31c80a..2f4d2bf0a2 100644 --- a/lib/api/response/p2p_advert_list_response_result.dart +++ b/lib/api/response/p2p_advert_list_response_result.dart @@ -2,7 +2,7 @@ import 'package:equatable/equatable.dart'; -import 'package:flutter_deriv_api/api/exceptions/p2p_advert_exception.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/basic_api/generated/p2p_advert_list_receive.dart'; import 'package:flutter_deriv_api/basic_api/generated/p2p_advert_list_send.dart'; @@ -25,10 +25,8 @@ abstract class P2pAdvertListResponseModel { class P2pAdvertListResponse extends P2pAdvertListResponseModel { /// Initializes P2p advert list response class. const P2pAdvertListResponse({ - P2pAdvertList? p2pAdvertList, - }) : super( - p2pAdvertList: p2pAdvertList, - ); + super.p2pAdvertList, + }); /// Creates an instance from JSON. factory P2pAdvertListResponse.fromJson( @@ -56,7 +54,7 @@ class P2pAdvertListResponse extends P2pAdvertListResponseModel { /// Returns available adverts. /// /// For parameters information refer to [P2pAdvertListRequest]. - /// Throws a [P2PAdvertException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future fetchAdvertList( P2pAdvertListRequest request, ) async { @@ -68,7 +66,7 @@ class P2pAdvertListResponse extends P2pAdvertListResponseModel { /// Returns available adverts. /// /// For parameters information refer to [P2pAdvertListRequest]. - /// Throws a [P2PAdvertException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future fetchAdvertListRaw( P2pAdvertListRequest request, ) async { @@ -77,7 +75,7 @@ class P2pAdvertListResponse extends P2pAdvertListResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - P2PAdvertException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return response; @@ -148,6 +146,8 @@ final Map visibilityStatusItemEnumMapper = "advertiser_ads_paused": VisibilityStatusItemEnum.advertiserAdsPaused, "advertiser_approval": VisibilityStatusItemEnum.advertiserApproval, "advertiser_balance": VisibilityStatusItemEnum.advertiserBalance, + "advertiser_block_trade_ineligible": + VisibilityStatusItemEnum.advertiserBlockTradeIneligible, "advertiser_daily_limit": VisibilityStatusItemEnum.advertiserDailyLimit, "advertiser_temp_ban": VisibilityStatusItemEnum.advertiserTempBan, }; @@ -175,6 +175,9 @@ enum VisibilityStatusItemEnum { /// advertiser_balance. advertiserBalance, + /// advertiser_block_trade_ineligible. + advertiserBlockTradeIneligible, + /// advertiser_daily_limit. advertiserDailyLimit, @@ -197,10 +200,8 @@ abstract class P2pAdvertListModel { class P2pAdvertList extends P2pAdvertListModel { /// Initializes P2p advert list class. const P2pAdvertList({ - required List list, - }) : super( - list: list, - ); + required super.list, + }); /// Creates an instance from JSON. factory P2pAdvertList.fromJson(Map json) => P2pAdvertList( @@ -241,6 +242,7 @@ abstract class ListItemModel { required this.rateType, required this.rateDisplay, required this.rate, + required this.orderExpiryPeriod, required this.minOrderAmountLimitDisplay, required this.minOrderAmountLimit, required this.maxOrderAmountLimitDisplay, @@ -253,6 +255,7 @@ abstract class ListItemModel { required this.createdTime, required this.country, required this.counterpartyType, + required this.blockTrade, required this.advertiserDetails, required this.accountCurrency, this.activeOrders, @@ -288,6 +291,9 @@ abstract class ListItemModel { /// Conversion rate from advertiser's account currency to `local_currency`. An absolute rate value (fixed), or percentage offset from current market rate (floating). final double rate; + /// Expiry period (seconds) for order created against this ad. + final int orderExpiryPeriod; + /// Minimum order amount at this time, in `account_currency`, formatted to appropriate decimal places. final String minOrderAmountLimitDisplay; @@ -324,6 +330,9 @@ abstract class ListItemModel { /// Type of transaction from the opposite party's perspective. final CounterpartyTypeEnum counterpartyType; + /// Indicates if this is block trade advert or not. + final bool blockTrade; + /// Details of the advertiser for this advert. final AdvertiserDetails advertiserDetails; @@ -392,6 +401,7 @@ abstract class ListItemModel { /// - `advertiser_ads_paused`: the advertiser has paused all adverts. /// - `advertiser_approval`: the advertiser's proof of identity is not verified. /// - `advertiser_balance`: the advertiser's P2P balance is less than the minimum order. + /// - `advertiser_block_trade_ineligible`: the advertiser is not currently eligible for block trading. /// - `advertiser_daily_limit`: the advertiser's remaining daily limit is less than the minimum order. /// - `advertiser_temp_ban`: the advertiser is temporarily banned from P2P. final List? visibilityStatus; @@ -401,88 +411,53 @@ abstract class ListItemModel { class ListItem extends ListItemModel { /// Initializes List item class. const ListItem({ - required String accountCurrency, - required AdvertiserDetails advertiserDetails, - required CounterpartyTypeEnum counterpartyType, - required String country, - required DateTime createdTime, - required String description, - required String id, - required bool isActive, - required bool isVisible, - required String localCurrency, - required double maxOrderAmountLimit, - required String maxOrderAmountLimitDisplay, - required double minOrderAmountLimit, - required String minOrderAmountLimitDisplay, - required double rate, - required String rateDisplay, - required RateTypeEnum rateType, - required TypeEnum type, - int? activeOrders, - double? amount, - String? amountDisplay, - String? contactInfo, - int? daysUntilArchive, - double? effectiveRate, - String? effectiveRateDisplay, - double? maxOrderAmount, - String? maxOrderAmountDisplay, - double? minOrderAmount, - String? minOrderAmountDisplay, - String? paymentInfo, - String? paymentMethod, - List? paymentMethodNames, - double? price, - String? priceDisplay, - double? remainingAmount, - String? remainingAmountDisplay, - List? visibilityStatus, - }) : super( - accountCurrency: accountCurrency, - advertiserDetails: advertiserDetails, - counterpartyType: counterpartyType, - country: country, - createdTime: createdTime, - description: description, - id: id, - isActive: isActive, - isVisible: isVisible, - localCurrency: localCurrency, - maxOrderAmountLimit: maxOrderAmountLimit, - maxOrderAmountLimitDisplay: maxOrderAmountLimitDisplay, - minOrderAmountLimit: minOrderAmountLimit, - minOrderAmountLimitDisplay: minOrderAmountLimitDisplay, - rate: rate, - rateDisplay: rateDisplay, - rateType: rateType, - type: type, - activeOrders: activeOrders, - amount: amount, - amountDisplay: amountDisplay, - contactInfo: contactInfo, - daysUntilArchive: daysUntilArchive, - effectiveRate: effectiveRate, - effectiveRateDisplay: effectiveRateDisplay, - maxOrderAmount: maxOrderAmount, - maxOrderAmountDisplay: maxOrderAmountDisplay, - minOrderAmount: minOrderAmount, - minOrderAmountDisplay: minOrderAmountDisplay, - paymentInfo: paymentInfo, - paymentMethod: paymentMethod, - paymentMethodNames: paymentMethodNames, - price: price, - priceDisplay: priceDisplay, - remainingAmount: remainingAmount, - remainingAmountDisplay: remainingAmountDisplay, - visibilityStatus: visibilityStatus, - ); + required super.accountCurrency, + required super.advertiserDetails, + required super.blockTrade, + required super.counterpartyType, + required super.country, + required super.createdTime, + required super.description, + required super.id, + required super.isActive, + required super.isVisible, + required super.localCurrency, + required super.maxOrderAmountLimit, + required super.maxOrderAmountLimitDisplay, + required super.minOrderAmountLimit, + required super.minOrderAmountLimitDisplay, + required super.orderExpiryPeriod, + required super.rate, + required super.rateDisplay, + required super.rateType, + required super.type, + super.activeOrders, + super.amount, + super.amountDisplay, + super.contactInfo, + super.daysUntilArchive, + super.effectiveRate, + super.effectiveRateDisplay, + super.maxOrderAmount, + super.maxOrderAmountDisplay, + super.minOrderAmount, + super.minOrderAmountDisplay, + super.paymentInfo, + super.paymentMethod, + super.paymentMethodNames, + super.price, + super.priceDisplay, + super.remainingAmount, + super.remainingAmountDisplay, + super.visibilityStatus, + }); /// Creates an instance from JSON. factory ListItem.fromJson(Map json) => ListItem( accountCurrency: json['account_currency'], advertiserDetails: AdvertiserDetails.fromJson(json['advertiser_details']), + blockTrade: getBool(json['block_trade'])!, counterpartyType: counterpartyTypeEnumMapper[json['counterparty_type']]!, country: json['country'], @@ -496,6 +471,7 @@ class ListItem extends ListItemModel { maxOrderAmountLimitDisplay: json['max_order_amount_limit_display'], minOrderAmountLimit: getDouble(json['min_order_amount_limit'])!, minOrderAmountLimitDisplay: json['min_order_amount_limit_display'], + orderExpiryPeriod: json['order_expiry_period'], rate: getDouble(json['rate'])!, rateDisplay: json['rate_display'], rateType: rateTypeEnumMapper[json['rate_type']]!, @@ -542,6 +518,7 @@ class ListItem extends ListItemModel { resultMap['account_currency'] = accountCurrency; resultMap['advertiser_details'] = advertiserDetails.toJson(); + resultMap['block_trade'] = blockTrade; resultMap['counterparty_type'] = counterpartyTypeEnumMapper.entries .firstWhere((MapEntry entry) => entry.value == counterpartyType) @@ -557,6 +534,7 @@ class ListItem extends ListItemModel { resultMap['max_order_amount_limit_display'] = maxOrderAmountLimitDisplay; resultMap['min_order_amount_limit'] = minOrderAmountLimit; resultMap['min_order_amount_limit_display'] = minOrderAmountLimitDisplay; + resultMap['order_expiry_period'] = orderExpiryPeriod; resultMap['rate'] = rate; resultMap['rate_display'] = rateDisplay; resultMap['rate_type'] = rateTypeEnumMapper.entries @@ -610,6 +588,7 @@ class ListItem extends ListItemModel { ListItem copyWith({ String? accountCurrency, AdvertiserDetails? advertiserDetails, + bool? blockTrade, CounterpartyTypeEnum? counterpartyType, String? country, DateTime? createdTime, @@ -622,6 +601,7 @@ class ListItem extends ListItemModel { String? maxOrderAmountLimitDisplay, double? minOrderAmountLimit, String? minOrderAmountLimitDisplay, + int? orderExpiryPeriod, double? rate, String? rateDisplay, RateTypeEnum? rateType, @@ -649,6 +629,7 @@ class ListItem extends ListItemModel { ListItem( accountCurrency: accountCurrency ?? this.accountCurrency, advertiserDetails: advertiserDetails ?? this.advertiserDetails, + blockTrade: blockTrade ?? this.blockTrade, counterpartyType: counterpartyType ?? this.counterpartyType, country: country ?? this.country, createdTime: createdTime ?? this.createdTime, @@ -663,6 +644,7 @@ class ListItem extends ListItemModel { minOrderAmountLimit: minOrderAmountLimit ?? this.minOrderAmountLimit, minOrderAmountLimitDisplay: minOrderAmountLimitDisplay ?? this.minOrderAmountLimitDisplay, + orderExpiryPeriod: orderExpiryPeriod ?? this.orderExpiryPeriod, rate: rate ?? this.rate, rateDisplay: rateDisplay ?? this.rateDisplay, rateType: rateType ?? this.rateType, @@ -763,38 +745,22 @@ abstract class AdvertiserDetailsModel { class AdvertiserDetails extends AdvertiserDetailsModel { /// Initializes Advertiser details class. const AdvertiserDetails({ - required int completedOrdersCount, - required String id, - required bool isOnline, - required String name, - required int ratingCount, - String? firstName, - int? isBlocked, - bool? isFavourite, - int? isRecommended, - String? lastName, - DateTime? lastOnlineTime, - double? ratingAverage, - double? recommendedAverage, - double? recommendedCount, - double? totalCompletionRate, - }) : super( - completedOrdersCount: completedOrdersCount, - id: id, - isOnline: isOnline, - name: name, - ratingCount: ratingCount, - firstName: firstName, - isBlocked: isBlocked, - isFavourite: isFavourite, - isRecommended: isRecommended, - lastName: lastName, - lastOnlineTime: lastOnlineTime, - ratingAverage: ratingAverage, - recommendedAverage: recommendedAverage, - recommendedCount: recommendedCount, - totalCompletionRate: totalCompletionRate, - ); + required super.completedOrdersCount, + required super.id, + required super.isOnline, + required super.name, + required super.ratingCount, + super.firstName, + super.isBlocked, + super.isFavourite, + super.isRecommended, + super.lastName, + super.lastOnlineTime, + super.ratingAverage, + super.recommendedAverage, + super.recommendedCount, + super.totalCompletionRate, + }); /// Creates an instance from JSON. factory AdvertiserDetails.fromJson(Map json) => diff --git a/lib/api/response/p2p_advert_update_response_result.dart b/lib/api/response/p2p_advert_update_response_result.dart index c4cf25b319..29dda903dd 100644 --- a/lib/api/response/p2p_advert_update_response_result.dart +++ b/lib/api/response/p2p_advert_update_response_result.dart @@ -25,10 +25,8 @@ abstract class P2pAdvertUpdateResponseModel { class P2pAdvertUpdateResponse extends P2pAdvertUpdateResponseModel { /// Initializes P2p advert update response class. const P2pAdvertUpdateResponse({ - P2pAdvertUpdate? p2pAdvertUpdate, - }) : super( - p2pAdvertUpdate: p2pAdvertUpdate, - ); + super.p2pAdvertUpdate, + }); /// Creates an instance from JSON. factory P2pAdvertUpdateResponse.fromJson( @@ -56,7 +54,7 @@ class P2pAdvertUpdateResponse extends P2pAdvertUpdateResponseModel { /// Updates a P2P (peer to peer) advert. Can only be used by the advertiser. /// /// For parameters information refer to [P2pAdvertUpdateRequest]. - /// Throws a [P2PAdvertException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future updateAdvert( P2pAdvertUpdateRequest request, ) async { @@ -68,7 +66,7 @@ class P2pAdvertUpdateResponse extends P2pAdvertUpdateResponseModel { /// Updates a P2P (peer to peer) advert. Can only be used by the advertiser. /// /// For parameters information refer to [P2pAdvertUpdateRequest]. - /// Throws a [P2PAdvertException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future updateAdvertRaw( P2pAdvertUpdateRequest request, ) async { @@ -77,7 +75,7 @@ class P2pAdvertUpdateResponse extends P2pAdvertUpdateResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - P2PAdvertException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return response; @@ -185,6 +183,8 @@ final Map visibilityStatusItemEnumMapper = "advertiser_ads_paused": VisibilityStatusItemEnum.advertiserAdsPaused, "advertiser_approval": VisibilityStatusItemEnum.advertiserApproval, "advertiser_balance": VisibilityStatusItemEnum.advertiserBalance, + "advertiser_block_trade_ineligible": + VisibilityStatusItemEnum.advertiserBlockTradeIneligible, "advertiser_daily_limit": VisibilityStatusItemEnum.advertiserDailyLimit, "advertiser_temp_ban": VisibilityStatusItemEnum.advertiserTempBan, }; @@ -212,13 +212,15 @@ enum VisibilityStatusItemEnum { /// advertiser_balance. advertiserBalance, + /// advertiser_block_trade_ineligible. + advertiserBlockTradeIneligible, + /// advertiser_daily_limit. advertiserDailyLimit, /// advertiser_temp_ban. advertiserTempBan, } - /// P2p advert update model class. abstract class P2pAdvertUpdateModel { /// Initializes P2p advert update model class . @@ -229,6 +231,7 @@ abstract class P2pAdvertUpdateModel { this.advertiserDetails, this.amount, this.amountDisplay, + this.blockTrade, this.contactInfo, this.counterpartyType, this.country, @@ -249,6 +252,7 @@ abstract class P2pAdvertUpdateModel { this.minOrderAmountDisplay, this.minOrderAmountLimit, this.minOrderAmountLimitDisplay, + this.orderExpiryPeriod, this.paymentInfo, this.paymentMethod, this.paymentMethodDetails, @@ -282,6 +286,9 @@ abstract class P2pAdvertUpdateModel { /// The total amount specified in advert, in `account_currency`, formatted to appropriate decimal places. final String? amountDisplay; + /// Indicates if this is block trade advert or not. + final bool? blockTrade; + /// Advertiser contact information. Only applicable for 'sell adverts'. final String? contactInfo; @@ -342,6 +349,9 @@ abstract class P2pAdvertUpdateModel { /// Minimum order amount at this time, in `account_currency`, formatted to appropriate decimal places. final String? minOrderAmountLimitDisplay; + /// Expiry period (seconds) for order created against this ad. + final int? orderExpiryPeriod; + /// Payment instructions. Only applicable for 'sell adverts'. final String? paymentInfo; @@ -386,6 +396,7 @@ abstract class P2pAdvertUpdateModel { /// - `advertiser_ads_paused`: the advertiser has paused all adverts. /// - `advertiser_approval`: the advertiser's proof of identity is not verified. /// - `advertiser_balance`: the advertiser's P2P balance is less than the minimum order. + /// - `advertiser_block_trade_ineligible`: the advertiser is not currently eligible for block trading. /// - `advertiser_daily_limit`: the advertiser's remaining daily limit is less than the minimum order. /// - `advertiser_temp_ban`: the advertiser is temporarily banned from P2P. final List? visibilityStatus; @@ -395,86 +406,48 @@ abstract class P2pAdvertUpdateModel { class P2pAdvertUpdate extends P2pAdvertUpdateModel { /// Initializes P2p advert update class. const P2pAdvertUpdate({ - required String id, - String? accountCurrency, - int? activeOrders, - AdvertiserDetails? advertiserDetails, - double? amount, - String? amountDisplay, - String? contactInfo, - CounterpartyTypeEnum? counterpartyType, - String? country, - DateTime? createdTime, - int? daysUntilArchive, - int? deleted, - String? description, - double? effectiveRate, - String? effectiveRateDisplay, - bool? isActive, - bool? isVisible, - String? localCurrency, - double? maxOrderAmount, - String? maxOrderAmountDisplay, - double? maxOrderAmountLimit, - String? maxOrderAmountLimitDisplay, - double? minOrderAmount, - String? minOrderAmountDisplay, - double? minOrderAmountLimit, - String? minOrderAmountLimitDisplay, - String? paymentInfo, - String? paymentMethod, - Map? paymentMethodDetails, - List? paymentMethodNames, - double? price, - String? priceDisplay, - double? rate, - String? rateDisplay, - RateTypeEnum? rateType, - double? remainingAmount, - String? remainingAmountDisplay, - P2pAdvertUpdateTypeEnum? type, - List? visibilityStatus, - }) : super( - id: id, - accountCurrency: accountCurrency, - activeOrders: activeOrders, - advertiserDetails: advertiserDetails, - amount: amount, - amountDisplay: amountDisplay, - contactInfo: contactInfo, - counterpartyType: counterpartyType, - country: country, - createdTime: createdTime, - daysUntilArchive: daysUntilArchive, - deleted: deleted, - description: description, - effectiveRate: effectiveRate, - effectiveRateDisplay: effectiveRateDisplay, - isActive: isActive, - isVisible: isVisible, - localCurrency: localCurrency, - maxOrderAmount: maxOrderAmount, - maxOrderAmountDisplay: maxOrderAmountDisplay, - maxOrderAmountLimit: maxOrderAmountLimit, - maxOrderAmountLimitDisplay: maxOrderAmountLimitDisplay, - minOrderAmount: minOrderAmount, - minOrderAmountDisplay: minOrderAmountDisplay, - minOrderAmountLimit: minOrderAmountLimit, - minOrderAmountLimitDisplay: minOrderAmountLimitDisplay, - paymentInfo: paymentInfo, - paymentMethod: paymentMethod, - paymentMethodDetails: paymentMethodDetails, - paymentMethodNames: paymentMethodNames, - price: price, - priceDisplay: priceDisplay, - rate: rate, - rateDisplay: rateDisplay, - rateType: rateType, - remainingAmount: remainingAmount, - remainingAmountDisplay: remainingAmountDisplay, - type: type, - visibilityStatus: visibilityStatus, - ); + required super.id, + super.accountCurrency, + super.activeOrders, + super.advertiserDetails, + super.amount, + super.amountDisplay, + super.blockTrade, + super.contactInfo, + super.counterpartyType, + super.country, + super.createdTime, + super.daysUntilArchive, + super.deleted, + super.description, + super.effectiveRate, + super.effectiveRateDisplay, + super.isActive, + super.isVisible, + super.localCurrency, + super.maxOrderAmount, + super.maxOrderAmountDisplay, + super.maxOrderAmountLimit, + super.maxOrderAmountLimitDisplay, + super.minOrderAmount, + super.minOrderAmountDisplay, + super.minOrderAmountLimit, + super.minOrderAmountLimitDisplay, + super.orderExpiryPeriod, + super.paymentInfo, + super.paymentMethod, + super.paymentMethodDetails, + super.paymentMethodNames, + super.price, + super.priceDisplay, + super.rate, + super.rateDisplay, + super.rateType, + super.remainingAmount, + super.remainingAmountDisplay, + super.type, + super.visibilityStatus, + }); /// Creates an instance from JSON. factory P2pAdvertUpdate.fromJson(Map json) => @@ -487,6 +460,7 @@ class P2pAdvertUpdate extends P2pAdvertUpdateModel { : AdvertiserDetails.fromJson(json['advertiser_details']), amount: getDouble(json['amount']), amountDisplay: json['amount_display'], + blockTrade: getBool(json['block_trade']), contactInfo: json['contact_info'], counterpartyType: json['counterparty_type'] == null ? null @@ -509,6 +483,7 @@ class P2pAdvertUpdate extends P2pAdvertUpdateModel { minOrderAmountDisplay: json['min_order_amount_display'], minOrderAmountLimit: getDouble(json['min_order_amount_limit']), minOrderAmountLimitDisplay: json['min_order_amount_limit_display'], + orderExpiryPeriod: json['order_expiry_period'], paymentInfo: json['payment_info'], paymentMethod: json['payment_method'], paymentMethodDetails: json['payment_method_details'] == null @@ -564,6 +539,7 @@ class P2pAdvertUpdate extends P2pAdvertUpdateModel { } resultMap['amount'] = amount; resultMap['amount_display'] = amountDisplay; + resultMap['block_trade'] = blockTrade; resultMap['contact_info'] = contactInfo; resultMap['counterparty_type'] = counterpartyTypeEnumMapper.entries .firstWhere((MapEntry entry) => @@ -587,6 +563,7 @@ class P2pAdvertUpdate extends P2pAdvertUpdateModel { resultMap['min_order_amount_display'] = minOrderAmountDisplay; resultMap['min_order_amount_limit'] = minOrderAmountLimit; resultMap['min_order_amount_limit_display'] = minOrderAmountLimitDisplay; + resultMap['order_expiry_period'] = orderExpiryPeriod; resultMap['payment_info'] = paymentInfo; resultMap['payment_method'] = paymentMethod; resultMap['payment_method_details'] = paymentMethodDetails; @@ -635,6 +612,7 @@ class P2pAdvertUpdate extends P2pAdvertUpdateModel { AdvertiserDetails? advertiserDetails, double? amount, String? amountDisplay, + bool? blockTrade, String? contactInfo, CounterpartyTypeEnum? counterpartyType, String? country, @@ -655,6 +633,7 @@ class P2pAdvertUpdate extends P2pAdvertUpdateModel { String? minOrderAmountDisplay, double? minOrderAmountLimit, String? minOrderAmountLimitDisplay, + int? orderExpiryPeriod, String? paymentInfo, String? paymentMethod, Map? paymentMethodDetails, @@ -676,6 +655,7 @@ class P2pAdvertUpdate extends P2pAdvertUpdateModel { advertiserDetails: advertiserDetails ?? this.advertiserDetails, amount: amount ?? this.amount, amountDisplay: amountDisplay ?? this.amountDisplay, + blockTrade: blockTrade ?? this.blockTrade, contactInfo: contactInfo ?? this.contactInfo, counterpartyType: counterpartyType ?? this.counterpartyType, country: country ?? this.country, @@ -700,6 +680,7 @@ class P2pAdvertUpdate extends P2pAdvertUpdateModel { minOrderAmountLimit: minOrderAmountLimit ?? this.minOrderAmountLimit, minOrderAmountLimitDisplay: minOrderAmountLimitDisplay ?? this.minOrderAmountLimitDisplay, + orderExpiryPeriod: orderExpiryPeriod ?? this.orderExpiryPeriod, paymentInfo: paymentInfo ?? this.paymentInfo, paymentMethod: paymentMethod ?? this.paymentMethod, paymentMethodDetails: paymentMethodDetails ?? this.paymentMethodDetails, @@ -716,7 +697,6 @@ class P2pAdvertUpdate extends P2pAdvertUpdateModel { visibilityStatus: visibilityStatus ?? this.visibilityStatus, ); } - /// Advertiser details model class. abstract class AdvertiserDetailsModel { /// Initializes Advertiser details model class . @@ -776,32 +756,19 @@ abstract class AdvertiserDetailsModel { class AdvertiserDetails extends AdvertiserDetailsModel { /// Initializes Advertiser details class. const AdvertiserDetails({ - required int completedOrdersCount, - required String id, - required bool isOnline, - required String name, - required int ratingCount, - String? firstName, - String? lastName, - DateTime? lastOnlineTime, - double? ratingAverage, - double? recommendedAverage, - int? recommendedCount, - double? totalCompletionRate, - }) : super( - completedOrdersCount: completedOrdersCount, - id: id, - isOnline: isOnline, - name: name, - ratingCount: ratingCount, - firstName: firstName, - lastName: lastName, - lastOnlineTime: lastOnlineTime, - ratingAverage: ratingAverage, - recommendedAverage: recommendedAverage, - recommendedCount: recommendedCount, - totalCompletionRate: totalCompletionRate, - ); + required super.completedOrdersCount, + required super.id, + required super.isOnline, + required super.name, + required super.ratingCount, + super.firstName, + super.lastName, + super.lastOnlineTime, + super.ratingAverage, + super.recommendedAverage, + super.recommendedCount, + super.totalCompletionRate, + }); /// Creates an instance from JSON. factory AdvertiserDetails.fromJson(Map json) => @@ -871,7 +838,6 @@ class AdvertiserDetails extends AdvertiserDetailsModel { totalCompletionRate: totalCompletionRate ?? this.totalCompletionRate, ); } - /// Payment method details property model class. abstract class PaymentMethodDetailsPropertyModel { /// Initializes Payment method details property model class . @@ -911,22 +877,14 @@ abstract class PaymentMethodDetailsPropertyModel { class PaymentMethodDetailsProperty extends PaymentMethodDetailsPropertyModel { /// Initializes Payment method details property class. const PaymentMethodDetailsProperty({ - required Map fields, - required bool isEnabled, - required String method, - required PaymentMethodDetailsPropertyTypeEnum type, - String? displayName, - List? usedByAdverts, - List? usedByOrders, - }) : super( - fields: fields, - isEnabled: isEnabled, - method: method, - type: type, - displayName: displayName, - usedByAdverts: usedByAdverts, - usedByOrders: usedByOrders, - ); + required super.fields, + required super.isEnabled, + required super.method, + required super.type, + super.displayName, + super.usedByAdverts, + super.usedByOrders, + }); /// Creates an instance from JSON. factory PaymentMethodDetailsProperty.fromJson(Map json) => @@ -1008,7 +966,6 @@ class PaymentMethodDetailsProperty extends PaymentMethodDetailsPropertyModel { usedByOrders: usedByOrders ?? this.usedByOrders, ); } - /// Fields property model class. abstract class FieldsPropertyModel { /// Initializes Fields property model class . @@ -1036,16 +993,11 @@ abstract class FieldsPropertyModel { class FieldsProperty extends FieldsPropertyModel { /// Initializes Fields property class. const FieldsProperty({ - required String displayName, - required int required, - required TypeEnum type, - required String value, - }) : super( - displayName: displayName, - required: required, - type: type, - value: value, - ); + required super.displayName, + required super.required, + required super.type, + required super.value, + }); /// Creates an instance from JSON. factory FieldsProperty.fromJson(Map json) => FieldsProperty( diff --git a/lib/api/response/p2p_advertiser_adverts_response_result.dart b/lib/api/response/p2p_advertiser_adverts_response_result.dart index 009499b828..89334957f2 100644 --- a/lib/api/response/p2p_advertiser_adverts_response_result.dart +++ b/lib/api/response/p2p_advertiser_adverts_response_result.dart @@ -25,10 +25,8 @@ abstract class P2pAdvertiserAdvertsResponseModel { class P2pAdvertiserAdvertsResponse extends P2pAdvertiserAdvertsResponseModel { /// Initializes P2p advertiser adverts response class. const P2pAdvertiserAdvertsResponse({ - P2pAdvertiserAdverts? p2pAdvertiserAdverts, - }) : super( - p2pAdvertiserAdverts: p2pAdvertiserAdverts, - ); + super.p2pAdvertiserAdverts, + }); /// Creates an instance from JSON. factory P2pAdvertiserAdvertsResponse.fromJson( @@ -77,7 +75,7 @@ class P2pAdvertiserAdvertsResponse extends P2pAdvertiserAdvertsResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - P2PAdvertiserException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return response; @@ -148,6 +146,8 @@ final Map visibilityStatusItemEnumMapper = "advertiser_ads_paused": VisibilityStatusItemEnum.advertiserAdsPaused, "advertiser_approval": VisibilityStatusItemEnum.advertiserApproval, "advertiser_balance": VisibilityStatusItemEnum.advertiserBalance, + "advertiser_block_trade_ineligible": + VisibilityStatusItemEnum.advertiserBlockTradeIneligible, "advertiser_daily_limit": VisibilityStatusItemEnum.advertiserDailyLimit, "advertiser_temp_ban": VisibilityStatusItemEnum.advertiserTempBan, }; @@ -175,13 +175,15 @@ enum VisibilityStatusItemEnum { /// advertiser_balance. advertiserBalance, + /// advertiser_block_trade_ineligible. + advertiserBlockTradeIneligible, + /// advertiser_daily_limit. advertiserDailyLimit, /// advertiser_temp_ban. advertiserTempBan, } - /// P2p advertiser adverts model class. abstract class P2pAdvertiserAdvertsModel { /// Initializes P2p advertiser adverts model class . @@ -197,10 +199,8 @@ abstract class P2pAdvertiserAdvertsModel { class P2pAdvertiserAdverts extends P2pAdvertiserAdvertsModel { /// Initializes P2p advertiser adverts class. const P2pAdvertiserAdverts({ - required List list, - }) : super( - list: list, - ); + required super.list, + }); /// Creates an instance from JSON. factory P2pAdvertiserAdverts.fromJson(Map json) => @@ -233,7 +233,6 @@ class P2pAdvertiserAdverts extends P2pAdvertiserAdvertsModel { list: list ?? this.list, ); } - /// List item model class. abstract class ListItemModel { /// Initializes List item model class . @@ -245,6 +244,7 @@ abstract class ListItemModel { required this.rateDisplay, required this.rate, required this.paymentInfo, + required this.orderExpiryPeriod, required this.minOrderAmountLimitDisplay, required this.minOrderAmountLimit, required this.minOrderAmountDisplay, @@ -262,6 +262,7 @@ abstract class ListItemModel { required this.country, required this.counterpartyType, required this.contactInfo, + required this.blockTrade, required this.amountDisplay, required this.amount, required this.advertiserDetails, @@ -298,6 +299,9 @@ abstract class ListItemModel { /// Payment instructions. Only applicable for 'sell adverts'. final String paymentInfo; + /// Expiry period (seconds) for order created against this ad. + final int orderExpiryPeriod; + /// Minimum order amount at this time, in `account_currency`, formatted to appropriate decimal places. final String minOrderAmountLimitDisplay; @@ -349,6 +353,9 @@ abstract class ListItemModel { /// Advertiser contact information. Only applicable for 'sell adverts'. final String contactInfo; + /// Indicates if this is block trade advert or not. + final bool blockTrade; + /// The total amount specified in advert, in `account_currency`, formatted to appropriate decimal places. final String amountDisplay; @@ -393,6 +400,7 @@ abstract class ListItemModel { /// - `advertiser_ads_paused`: the advertiser has paused all adverts. /// - `advertiser_approval`: the advertiser's proof of identity is not verified. /// - `advertiser_balance`: the advertiser's P2P balance is less than the minimum order. + /// - `advertiser_block_trade_ineligible`: the advertiser is not currently eligible for block trading. /// - `advertiser_daily_limit`: the advertiser's remaining daily limit is less than the minimum order. /// - `advertiser_temp_ban`: the advertiser is temporarily banned from P2P. final List? visibilityStatus; @@ -402,82 +410,46 @@ abstract class ListItemModel { class ListItem extends ListItemModel { /// Initializes List item class. const ListItem({ - required String accountCurrency, - required int activeOrders, - required AdvertiserDetails advertiserDetails, - required double amount, - required String amountDisplay, - required String contactInfo, - required CounterpartyTypeEnum counterpartyType, - required String country, - required DateTime createdTime, - required String description, - required String id, - required bool isActive, - required bool isVisible, - required String localCurrency, - required double maxOrderAmount, - required String maxOrderAmountDisplay, - required double maxOrderAmountLimit, - required String maxOrderAmountLimitDisplay, - required double minOrderAmount, - required String minOrderAmountDisplay, - required double minOrderAmountLimit, - required String minOrderAmountLimitDisplay, - required String paymentInfo, - required double rate, - required String rateDisplay, - required RateTypeEnum rateType, - required double remainingAmount, - required String remainingAmountDisplay, - required TypeEnum type, - int? daysUntilArchive, - double? effectiveRate, - String? effectiveRateDisplay, - String? paymentMethod, - List? paymentMethodNames, - double? price, - String? priceDisplay, - List? visibilityStatus, - }) : super( - accountCurrency: accountCurrency, - activeOrders: activeOrders, - advertiserDetails: advertiserDetails, - amount: amount, - amountDisplay: amountDisplay, - contactInfo: contactInfo, - counterpartyType: counterpartyType, - country: country, - createdTime: createdTime, - description: description, - id: id, - isActive: isActive, - isVisible: isVisible, - localCurrency: localCurrency, - maxOrderAmount: maxOrderAmount, - maxOrderAmountDisplay: maxOrderAmountDisplay, - maxOrderAmountLimit: maxOrderAmountLimit, - maxOrderAmountLimitDisplay: maxOrderAmountLimitDisplay, - minOrderAmount: minOrderAmount, - minOrderAmountDisplay: minOrderAmountDisplay, - minOrderAmountLimit: minOrderAmountLimit, - minOrderAmountLimitDisplay: minOrderAmountLimitDisplay, - paymentInfo: paymentInfo, - rate: rate, - rateDisplay: rateDisplay, - rateType: rateType, - remainingAmount: remainingAmount, - remainingAmountDisplay: remainingAmountDisplay, - type: type, - daysUntilArchive: daysUntilArchive, - effectiveRate: effectiveRate, - effectiveRateDisplay: effectiveRateDisplay, - paymentMethod: paymentMethod, - paymentMethodNames: paymentMethodNames, - price: price, - priceDisplay: priceDisplay, - visibilityStatus: visibilityStatus, - ); + required super.accountCurrency, + required super.activeOrders, + required super.advertiserDetails, + required super.amount, + required super.amountDisplay, + required super.blockTrade, + required super.contactInfo, + required super.counterpartyType, + required super.country, + required super.createdTime, + required super.description, + required super.id, + required super.isActive, + required super.isVisible, + required super.localCurrency, + required super.maxOrderAmount, + required super.maxOrderAmountDisplay, + required super.maxOrderAmountLimit, + required super.maxOrderAmountLimitDisplay, + required super.minOrderAmount, + required super.minOrderAmountDisplay, + required super.minOrderAmountLimit, + required super.minOrderAmountLimitDisplay, + required super.orderExpiryPeriod, + required super.paymentInfo, + required super.rate, + required super.rateDisplay, + required super.rateType, + required super.remainingAmount, + required super.remainingAmountDisplay, + required super.type, + super.daysUntilArchive, + super.effectiveRate, + super.effectiveRateDisplay, + super.paymentMethod, + super.paymentMethodNames, + super.price, + super.priceDisplay, + super.visibilityStatus, + }); /// Creates an instance from JSON. factory ListItem.fromJson(Map json) => ListItem( @@ -487,6 +459,7 @@ class ListItem extends ListItemModel { AdvertiserDetails.fromJson(json['advertiser_details']), amount: getDouble(json['amount'])!, amountDisplay: json['amount_display'], + blockTrade: getBool(json['block_trade'])!, contactInfo: json['contact_info'], counterpartyType: counterpartyTypeEnumMapper[json['counterparty_type']]!, @@ -505,6 +478,7 @@ class ListItem extends ListItemModel { minOrderAmountDisplay: json['min_order_amount_display'], minOrderAmountLimit: getDouble(json['min_order_amount_limit'])!, minOrderAmountLimitDisplay: json['min_order_amount_limit_display'], + orderExpiryPeriod: json['order_expiry_period'], paymentInfo: json['payment_info'], rate: getDouble(json['rate'])!, rateDisplay: json['rate_display'], @@ -546,6 +520,7 @@ class ListItem extends ListItemModel { resultMap['amount'] = amount; resultMap['amount_display'] = amountDisplay; + resultMap['block_trade'] = blockTrade; resultMap['contact_info'] = contactInfo; resultMap['counterparty_type'] = counterpartyTypeEnumMapper.entries .firstWhere((MapEntry entry) => @@ -566,6 +541,7 @@ class ListItem extends ListItemModel { resultMap['min_order_amount_display'] = minOrderAmountDisplay; resultMap['min_order_amount_limit'] = minOrderAmountLimit; resultMap['min_order_amount_limit_display'] = minOrderAmountLimitDisplay; + resultMap['order_expiry_period'] = orderExpiryPeriod; resultMap['payment_info'] = paymentInfo; resultMap['rate'] = rate; resultMap['rate_display'] = rateDisplay; @@ -614,6 +590,7 @@ class ListItem extends ListItemModel { AdvertiserDetails? advertiserDetails, double? amount, String? amountDisplay, + bool? blockTrade, String? contactInfo, CounterpartyTypeEnum? counterpartyType, String? country, @@ -631,6 +608,7 @@ class ListItem extends ListItemModel { String? minOrderAmountDisplay, double? minOrderAmountLimit, String? minOrderAmountLimitDisplay, + int? orderExpiryPeriod, String? paymentInfo, double? rate, String? rateDisplay, @@ -653,6 +631,7 @@ class ListItem extends ListItemModel { advertiserDetails: advertiserDetails ?? this.advertiserDetails, amount: amount ?? this.amount, amountDisplay: amountDisplay ?? this.amountDisplay, + blockTrade: blockTrade ?? this.blockTrade, contactInfo: contactInfo ?? this.contactInfo, counterpartyType: counterpartyType ?? this.counterpartyType, country: country ?? this.country, @@ -674,6 +653,7 @@ class ListItem extends ListItemModel { minOrderAmountLimit: minOrderAmountLimit ?? this.minOrderAmountLimit, minOrderAmountLimitDisplay: minOrderAmountLimitDisplay ?? this.minOrderAmountLimitDisplay, + orderExpiryPeriod: orderExpiryPeriod ?? this.orderExpiryPeriod, paymentInfo: paymentInfo ?? this.paymentInfo, rate: rate ?? this.rate, rateDisplay: rateDisplay ?? this.rateDisplay, @@ -692,7 +672,6 @@ class ListItem extends ListItemModel { visibilityStatus: visibilityStatus ?? this.visibilityStatus, ); } - /// Advertiser details model class. abstract class AdvertiserDetailsModel { /// Initializes Advertiser details model class . @@ -752,32 +731,19 @@ abstract class AdvertiserDetailsModel { class AdvertiserDetails extends AdvertiserDetailsModel { /// Initializes Advertiser details class. const AdvertiserDetails({ - required int completedOrdersCount, - required String id, - required bool isOnline, - required String name, - required int ratingCount, - String? firstName, - String? lastName, - DateTime? lastOnlineTime, - double? ratingAverage, - double? recommendedAverage, - int? recommendedCount, - double? totalCompletionRate, - }) : super( - completedOrdersCount: completedOrdersCount, - id: id, - isOnline: isOnline, - name: name, - ratingCount: ratingCount, - firstName: firstName, - lastName: lastName, - lastOnlineTime: lastOnlineTime, - ratingAverage: ratingAverage, - recommendedAverage: recommendedAverage, - recommendedCount: recommendedCount, - totalCompletionRate: totalCompletionRate, - ); + required super.completedOrdersCount, + required super.id, + required super.isOnline, + required super.name, + required super.ratingCount, + super.firstName, + super.lastName, + super.lastOnlineTime, + super.ratingAverage, + super.recommendedAverage, + super.recommendedCount, + super.totalCompletionRate, + }); /// Creates an instance from JSON. factory AdvertiserDetails.fromJson(Map json) => diff --git a/lib/api/response/p2p_advertiser_create_response_result.dart b/lib/api/response/p2p_advertiser_create_response_result.dart index 68bcc98fc5..abb9fc5f7f 100644 --- a/lib/api/response/p2p_advertiser_create_response_result.dart +++ b/lib/api/response/p2p_advertiser_create_response_result.dart @@ -92,7 +92,7 @@ class P2pAdvertiserCreateResponse extends P2pAdvertiserCreateResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - P2PAdvertiserException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return response; @@ -129,7 +129,7 @@ class P2pAdvertiserCreateResponse extends P2pAdvertiserCreateResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - P2PAdvertiserException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return response is P2pAdvertiserCreateReceive ? response : null; diff --git a/lib/api/response/p2p_advertiser_info_response_result.dart b/lib/api/response/p2p_advertiser_info_response_result.dart index 77bfc31f50..7d0da5dc1e 100644 --- a/lib/api/response/p2p_advertiser_info_response_result.dart +++ b/lib/api/response/p2p_advertiser_info_response_result.dart @@ -76,7 +76,7 @@ class P2pAdvertiserInfoResponse extends P2pAdvertiserInfoResponseModel { /// Retrieves information about a P2P (peer to peer) advertiser. /// /// For parameters information refer to [P2pAdvertiserInfoRequest]. - /// Throws a [P2PAdvertiserException] if API response contains an error. + /// Throws a [BaseAPIException] if API response contains an error. static Future fetchAdvertiserInformation( P2pAdvertiserInfoRequest request, ) async { @@ -90,7 +90,7 @@ class P2pAdvertiserInfoResponse extends P2pAdvertiserInfoResponseModel { /// Retrieves information about a P2P (peer to peer) advertiser. /// /// For parameters information refer to [P2pAdvertiserInfoRequest]. - /// Throws a [P2PAdvertiserException] if API response contains an error. + /// Throws a [BaseAPIException] if API response contains an error. static Future fetchAdvertiserInformationRaw( P2pAdvertiserInfoRequest request, ) async { @@ -132,7 +132,7 @@ class P2pAdvertiserInfoResponse extends P2pAdvertiserInfoResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - P2PAdvertiserException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return response is P2pAdvertiserInfoReceive ? response : null; @@ -141,7 +141,7 @@ class P2pAdvertiserInfoResponse extends P2pAdvertiserInfoResponseModel { /// Unsubscribes from P2P (peer to peer) advertiser information. /// - /// Throws a [P2PAdvertiserException] if API response contains an error. + /// Throws a [BaseAPIException] if API response contains an error. Future unsubscribeAdvertiser() async { if (subscription == null) { return null; @@ -153,7 +153,7 @@ class P2pAdvertiserInfoResponse extends P2pAdvertiserInfoResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - P2PAdvertiserException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return ForgetResponse.fromJson(response.forget); @@ -161,7 +161,7 @@ class P2pAdvertiserInfoResponse extends P2pAdvertiserInfoResponseModel { /// Unsubscribes all P2P (peer to peer) advertisers. /// - /// Throws a [P2PAdvertiserException] if API response contains an error. + /// Throws a [BaseAPIException] if API response contains an error. static Future unsubscribeAllAdvertiser() async { final ForgetAllReceive response = await _api.unsubscribeAll(method: ForgetStreamType.p2pAdvertiser); @@ -169,7 +169,7 @@ class P2pAdvertiserInfoResponse extends P2pAdvertiserInfoResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - P2PAdvertiserException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return ForgetAllResponse.fromJson(response.forgetAll); diff --git a/lib/api/response/p2p_advertiser_list_response_result.dart b/lib/api/response/p2p_advertiser_list_response_result.dart index c32c40ee20..3f08084852 100644 --- a/lib/api/response/p2p_advertiser_list_response_result.dart +++ b/lib/api/response/p2p_advertiser_list_response_result.dart @@ -62,7 +62,7 @@ class P2pAdvertiserListResponse extends P2pAdvertiserListResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - P2PAdvertiserException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return response; diff --git a/lib/api/response/p2p_advertiser_payment_methods_response_result.dart b/lib/api/response/p2p_advertiser_payment_methods_response_result.dart index 6207a8c885..5b86419857 100644 --- a/lib/api/response/p2p_advertiser_payment_methods_response_result.dart +++ b/lib/api/response/p2p_advertiser_payment_methods_response_result.dart @@ -64,7 +64,7 @@ class P2pAdvertiserPaymentMethodsResponse /// Manage or list P2P advertiser payment methods. /// /// For parameters information refer to [P2pAdvertiserPaymentMethodsRequest]. - /// Throws an [P2PAdvertiserException] if API response contains an error. + /// Throws an [BaseAPIException] if API response contains an error. static Future fetchMethodsRaw( P2pAdvertiserPaymentMethodsRequest request, ) async { @@ -74,7 +74,7 @@ class P2pAdvertiserPaymentMethodsResponse checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - P2PAdvertiserException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return response; @@ -83,7 +83,7 @@ class P2pAdvertiserPaymentMethodsResponse /// Manage or list P2P advertiser payment methods. /// /// For parameters information refer to [P2pAdvertiserPaymentMethodsRequest]. - /// Throws an [P2PAdvertiserException] if API response contains an error. + /// Throws an [BaseAPIException] if API response contains an error. static Future fetchMethods( P2pAdvertiserPaymentMethodsRequest request, ) async { diff --git a/lib/api/response/p2p_advertiser_relations_response_result.dart b/lib/api/response/p2p_advertiser_relations_response_result.dart index f60863450f..aebad9df82 100644 --- a/lib/api/response/p2p_advertiser_relations_response_result.dart +++ b/lib/api/response/p2p_advertiser_relations_response_result.dart @@ -57,7 +57,7 @@ class P2pAdvertiserRelationsResponse /// Updates and returns favourite and blocked advertisers of the current user. /// /// For parameters information refer to [P2pAdvertiserRelationsRequest]. - /// Throws an [P2PAdvertiserException] if API response contains an error. + /// Throws an [BaseAPIException] if API response contains an error. static Future fetchRaw( P2pAdvertiserRelationsRequest request, ) async { @@ -67,7 +67,7 @@ class P2pAdvertiserRelationsResponse checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - P2PAdvertiserException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return response; @@ -76,7 +76,7 @@ class P2pAdvertiserRelationsResponse /// Updates and returns favourite and blocked advertisers of the current user. /// /// For parameters information refer to [P2pAdvertiserRelationsRequest]. - /// Throws an [P2PAdvertiserException] if API response contains an error. + /// Throws an [BaseAPIException] if API response contains an error. static Future fetch( P2pAdvertiserRelationsRequest request, ) async { diff --git a/lib/api/response/p2p_advertiser_update_response_result.dart b/lib/api/response/p2p_advertiser_update_response_result.dart index 115139e539..c6c470e5f5 100644 --- a/lib/api/response/p2p_advertiser_update_response_result.dart +++ b/lib/api/response/p2p_advertiser_update_response_result.dart @@ -77,7 +77,7 @@ class P2pAdvertiserUpdateResponse extends P2pAdvertiserUpdateResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - P2PAdvertiserException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return response; diff --git a/lib/api/response/p2p_chat_create_response_result.dart b/lib/api/response/p2p_chat_create_response_result.dart index 32fb719aac..7a9764e85c 100644 --- a/lib/api/response/p2p_chat_create_response_result.dart +++ b/lib/api/response/p2p_chat_create_response_result.dart @@ -77,7 +77,7 @@ class P2pChatCreateResponse extends P2pChatCreateResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - P2PChatException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return response; diff --git a/lib/api/response/p2p_order_cancel_response_result.dart b/lib/api/response/p2p_order_cancel_response_result.dart index e7bc907df0..b38f92e2c4 100644 --- a/lib/api/response/p2p_order_cancel_response_result.dart +++ b/lib/api/response/p2p_order_cancel_response_result.dart @@ -55,7 +55,7 @@ class P2pOrderCancelResponse extends P2pOrderCancelResponseModel { /// Cancel a P2P order. /// /// For parameters information refer to [P2pOrderCancelRequest]. - /// Throws a [P2POrderException] if API response contains an error. + /// Throws a [BaseAPIException] if API response contains an error. static Future cancelOrderRaw( P2pOrderCancelRequest request, ) async { @@ -64,7 +64,7 @@ class P2pOrderCancelResponse extends P2pOrderCancelResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - P2POrderException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return response; @@ -73,7 +73,7 @@ class P2pOrderCancelResponse extends P2pOrderCancelResponseModel { /// Cancel a P2P order. /// /// For parameters information refer to [P2pOrderCancelRequest]. - /// Throws a [P2POrderException] if API response contains an error. + /// Throws a [BaseAPIException] if API response contains an error. static Future cancelOrder( P2pOrderCancelRequest request, ) async { diff --git a/lib/api/response/p2p_order_confirm_response_result.dart b/lib/api/response/p2p_order_confirm_response_result.dart index c1d6c9de3a..e0fc40b8b2 100644 --- a/lib/api/response/p2p_order_confirm_response_result.dart +++ b/lib/api/response/p2p_order_confirm_response_result.dart @@ -55,7 +55,7 @@ class P2pOrderConfirmResponse extends P2pOrderConfirmResponseModel { /// Cancel a P2P order confirm. /// /// For parameters information refer to [P2pOrderConfirmRequest]. - /// Throws an [P2POrderException] if API response contains an error. + /// Throws an [BaseAPIException] if API response contains an error. static Future confirmOrderRaw( P2pOrderConfirmRequest request, ) async { @@ -64,7 +64,7 @@ class P2pOrderConfirmResponse extends P2pOrderConfirmResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - P2POrderException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return response; @@ -73,7 +73,7 @@ class P2pOrderConfirmResponse extends P2pOrderConfirmResponseModel { /// Cancel a P2P order confirm. /// /// For parameters information refer to [P2pOrderConfirmRequest]. - /// Throws an [P2POrderException] if API response contains an error. + /// Throws an [BaseAPIException] if API response contains an error. static Future confirmOrder( P2pOrderConfirmRequest request, ) async { diff --git a/lib/api/response/p2p_order_create_response_result.dart b/lib/api/response/p2p_order_create_response_result.dart index 31f3270e02..0c0b04b3af 100644 --- a/lib/api/response/p2p_order_create_response_result.dart +++ b/lib/api/response/p2p_order_create_response_result.dart @@ -85,7 +85,7 @@ class P2pOrderCreateResponse extends P2pOrderCreateResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - P2POrderException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return response; @@ -93,7 +93,7 @@ class P2pOrderCreateResponse extends P2pOrderCreateResponseModel { /// Creates order and subscribes to the result with parameters specified in [P2pOrderCreateRequest] /// - /// Throws a [P2POrderException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Stream createAndSubscribe( P2pOrderCreateRequest request, { RequestCompareFunction? comparePredicate, @@ -112,7 +112,7 @@ class P2pOrderCreateResponse extends P2pOrderCreateResponseModel { /// Creates order and subscribes to the result with parameters specified in [P2pOrderCreateRequest] /// - /// Throws a [P2POrderException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Stream createAndSubscribeRaw( P2pOrderCreateRequest request, { RequestCompareFunction? comparePredicate, @@ -122,7 +122,7 @@ class P2pOrderCreateResponse extends P2pOrderCreateResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - P2POrderException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return response is P2pOrderCreateReceive ? response : null; diff --git a/lib/api/response/p2p_order_dispute_response_result.dart b/lib/api/response/p2p_order_dispute_response_result.dart index 8344e5511e..a2bdaae1be 100644 --- a/lib/api/response/p2p_order_dispute_response_result.dart +++ b/lib/api/response/p2p_order_dispute_response_result.dart @@ -56,7 +56,7 @@ class P2pOrderDisputeResponse extends P2pOrderDisputeResponseModel { /// Cancel a P2P order dispute. /// /// For parameters information refer to [P2pOrderDisputeRequest]. - /// Throws an [P2POrderException] if API response contains an error. + /// Throws an [BaseAPIException] if API response contains an error. static Future disputeOrderRaw( P2pOrderDisputeRequest request, ) async { @@ -65,7 +65,7 @@ class P2pOrderDisputeResponse extends P2pOrderDisputeResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - P2POrderException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return response; @@ -74,7 +74,7 @@ class P2pOrderDisputeResponse extends P2pOrderDisputeResponseModel { /// Cancel a P2P order dispute. /// /// For parameters information refer to [P2pOrderDisputeRequest]. - /// Throws an [P2POrderException] if API response contains an error. + /// Throws an [BaseAPIException] if API response contains an error. static Future disputeOrder( P2pOrderDisputeRequest request, ) async { diff --git a/lib/api/response/p2p_order_info_response_result.dart b/lib/api/response/p2p_order_info_response_result.dart index 972339e3ce..e3785742ed 100644 --- a/lib/api/response/p2p_order_info_response_result.dart +++ b/lib/api/response/p2p_order_info_response_result.dart @@ -81,7 +81,7 @@ class P2pOrderInfoResponse extends P2pOrderInfoResponseModel { /// Gets order with parameters specified in [P2pOrderInfoRequest] /// - /// Throws a [P2POrderException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future fetchOrder( P2pOrderInfoRequest request) async { final P2pOrderInfoReceive response = await fetchOrderRaw(request); @@ -92,7 +92,7 @@ class P2pOrderInfoResponse extends P2pOrderInfoResponseModel { /// Gets order with parameters specified in [P2pOrderInfoRequest] /// - /// Throws a [P2POrderException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future fetchOrderRaw( P2pOrderInfoRequest request) async { final P2pOrderInfoReceive response = await _api.call(request: request); @@ -100,7 +100,7 @@ class P2pOrderInfoResponse extends P2pOrderInfoResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - P2POrderException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return response; @@ -126,7 +126,7 @@ class P2pOrderInfoResponse extends P2pOrderInfoResponseModel { /// Subscribes to order with parameters specified in [P2pOrderInfoRequest] /// - /// Throws a [P2POrderException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Stream subscribeOrder( P2pOrderInfoRequest request, { RequestCompareFunction? comparePredicate, @@ -145,7 +145,7 @@ class P2pOrderInfoResponse extends P2pOrderInfoResponseModel { /// Subscribes to order with parameters specified in [P2pOrderInfoRequest] /// - /// Throws a [P2POrderException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Stream subscribeOrderRaw( P2pOrderInfoRequest request, { RequestCompareFunction? comparePredicate, @@ -157,7 +157,7 @@ class P2pOrderInfoResponse extends P2pOrderInfoResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - P2POrderException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return response is P2pOrderInfoReceive ? response : null; @@ -166,7 +166,7 @@ class P2pOrderInfoResponse extends P2pOrderInfoResponseModel { /// Unsubscribes from order subscription. /// - /// Throws a [P2POrderException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error Future unsubscribeOrder() async { if (subscription == null) { return null; @@ -178,7 +178,7 @@ class P2pOrderInfoResponse extends P2pOrderInfoResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - P2POrderException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return ForgetResponse.fromJson(response.forget); @@ -186,7 +186,7 @@ class P2pOrderInfoResponse extends P2pOrderInfoResponseModel { /// Unsubscribes all order subscriptions (Subscriptions to a single order or list). /// - /// Throws a [P2POrderException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future unsubscribeAllOrder() async { final ForgetAllReceive response = await _api.unsubscribeAll(method: ForgetStreamType.p2pOrder); @@ -194,7 +194,7 @@ class P2pOrderInfoResponse extends P2pOrderInfoResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - P2POrderException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return ForgetAllResponse.fromJson(response.forgetAll); @@ -203,7 +203,7 @@ class P2pOrderInfoResponse extends P2pOrderInfoResponseModel { /// Cancels this order /// /// Returns an order with updated status if successful. - /// Throws a [P2POrderException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error Future cancel() async { final P2pOrderCancelReceive response = await cancelRaw(); return P2pOrderCancelResponse.fromJson(response.p2pOrderCancel); @@ -212,7 +212,7 @@ class P2pOrderInfoResponse extends P2pOrderInfoResponseModel { /// Cancels this order /// /// Returns an order with updated status if successful. - /// Throws a [P2POrderException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error Future cancelRaw() async { final P2pOrderCancelReceive response = await _api.call(request: P2pOrderCancelRequest(id: p2pOrderInfo?.id)); @@ -220,7 +220,7 @@ class P2pOrderInfoResponse extends P2pOrderInfoResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - P2POrderException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return response; @@ -229,7 +229,7 @@ class P2pOrderInfoResponse extends P2pOrderInfoResponseModel { /// Confirms this order /// /// Returns an order with updated status if successful. - /// Throws a [P2POrderException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error Future confirm() async { final P2pOrderConfirmReceive response = await confirmRaw(); @@ -239,7 +239,7 @@ class P2pOrderInfoResponse extends P2pOrderInfoResponseModel { /// Confirms this order /// /// Returns an order with updated status if successful. - /// Throws a [P2POrderException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error Future confirmRaw() async { final P2pOrderConfirmReceive response = await _api.call(request: P2pOrderConfirmRequest(id: p2pOrderInfo?.id)); @@ -247,7 +247,7 @@ class P2pOrderInfoResponse extends P2pOrderInfoResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - P2POrderException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return response; diff --git a/lib/api/response/p2p_order_list_response_result.dart b/lib/api/response/p2p_order_list_response_result.dart index 2a0459a68f..d094361c9a 100644 --- a/lib/api/response/p2p_order_list_response_result.dart +++ b/lib/api/response/p2p_order_list_response_result.dart @@ -94,7 +94,7 @@ class P2pOrderListResponse extends P2pOrderListResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - P2POrderException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return response; @@ -132,7 +132,7 @@ class P2pOrderListResponse extends P2pOrderListResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - P2POrderException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return response is P2pOrderListReceive ? response : null; @@ -141,7 +141,7 @@ class P2pOrderListResponse extends P2pOrderListResponseModel { /// Unsubscribes from order list subscription. /// - /// Throws a [P2POrderException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error Future unsubscribeOrderList() async { if (subscription == null) { return null; @@ -153,7 +153,7 @@ class P2pOrderListResponse extends P2pOrderListResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - P2POrderException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return ForgetResponse.fromJson(response.forget); @@ -161,7 +161,7 @@ class P2pOrderListResponse extends P2pOrderListResponseModel { /// Unsubscribes from all order subscriptions (Subscriptions to a single order or list). /// - /// Throws a [P2POrderException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future unsubscribeAllOrder() => P2pOrderInfoResponse.unsubscribeAllOrder(); diff --git a/lib/api/response/p2p_order_review_response_result.dart b/lib/api/response/p2p_order_review_response_result.dart index e33f52528e..8e4e29fe9b 100644 --- a/lib/api/response/p2p_order_review_response_result.dart +++ b/lib/api/response/p2p_order_review_response_result.dart @@ -55,7 +55,7 @@ class P2pOrderReviewResponse extends P2pOrderReviewResponseModel { /// Cancel a P2P order review. /// /// For parameters information refer to [P2pOrderReviewReceive]. - /// Throws an [P2POrderException] if API response contains an error. + /// Throws an [BaseAPIException] if API response contains an error. static Future reviewOrderRaw( P2pOrderReviewRequest request, ) async { @@ -64,7 +64,7 @@ class P2pOrderReviewResponse extends P2pOrderReviewResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - P2POrderException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return response; @@ -73,7 +73,7 @@ class P2pOrderReviewResponse extends P2pOrderReviewResponseModel { /// Cancel a P2P order review. /// /// For parameters information refer to [P2pOrderReviewReceive]. - /// Throws an [P2POrderException] if API response contains an error. + /// Throws an [BaseAPIException] if API response contains an error. static Future reviewOrder( P2pOrderReviewRequest request, ) async { diff --git a/lib/api/response/p2p_payment_methods_response_result.dart b/lib/api/response/p2p_payment_methods_response_result.dart index a7d130588f..7a464168ae 100644 --- a/lib/api/response/p2p_payment_methods_response_result.dart +++ b/lib/api/response/p2p_payment_methods_response_result.dart @@ -73,7 +73,7 @@ class P2pPaymentMethodsResponse extends P2pPaymentMethodsResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - P2POrderException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return response; diff --git a/lib/api/response/p2p_ping_response_result.dart b/lib/api/response/p2p_ping_response_result.dart index 02d97a4ccb..a82581922a 100644 --- a/lib/api/response/p2p_ping_response_result.dart +++ b/lib/api/response/p2p_ping_response_result.dart @@ -67,7 +67,7 @@ class P2pPingResponse extends P2pPingResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - APIBaseException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return response; diff --git a/lib/api/response/payment_methods_response_result.dart b/lib/api/response/payment_methods_response_result.dart index 32b4aa502d..7847473d31 100644 --- a/lib/api/response/payment_methods_response_result.dart +++ b/lib/api/response/payment_methods_response_result.dart @@ -63,7 +63,7 @@ class PaymentMethodsResponse extends PaymentMethodsResponseModel { /// Get List of available payment methods for a given country. /// /// For parameters information refer to [PaymentMethodsRequest]. - /// Throws an [PaymentException] if API response contains an error + /// Throws an [BaseAPIException] if API response contains an error static Future updateApplication( PaymentMethodsRequest request) async { final PaymentMethodsReceive response = await _api.call(request: request); @@ -71,7 +71,7 @@ class PaymentMethodsResponse extends PaymentMethodsResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - PaymentException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return PaymentMethodsResponse.fromJson(response.paymentMethods); diff --git a/lib/api/response/paymentagent_list_response_result.dart b/lib/api/response/paymentagent_list_response_result.dart index 2656b74821..fd0c3f7d7b 100644 --- a/lib/api/response/paymentagent_list_response_result.dart +++ b/lib/api/response/paymentagent_list_response_result.dart @@ -56,7 +56,7 @@ class PaymentagentListResponse extends PaymentagentListResponseModel { /// Returns a list of Payment Agents for a given country for a given currency. /// /// For parameters information refer to [PaymentagentListRequest]. - /// Throws a [PaymentAgentException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future fetch( PaymentagentListRequest request, ) async { @@ -65,7 +65,7 @@ class PaymentagentListResponse extends PaymentagentListResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - PaymentAgentException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return PaymentagentListResponse.fromJson(response.paymentagentList); diff --git a/lib/api/response/paymentagent_transfer_response_result.dart b/lib/api/response/paymentagent_transfer_response_result.dart index c210072c7c..5367e3d2f9 100644 --- a/lib/api/response/paymentagent_transfer_response_result.dart +++ b/lib/api/response/paymentagent_transfer_response_result.dart @@ -80,7 +80,7 @@ class PaymentagentTransferResponse extends PaymentagentTransferResponseModel { /// /// This call is available only to accounts that are approved payment agents. /// For parameters information refer to [PaymentagentTransferRequest]. - /// Throws a [PaymentAgentException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future transfer( PaymentagentTransferRequest request, ) async { @@ -90,7 +90,7 @@ class PaymentagentTransferResponse extends PaymentagentTransferResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - PaymentAgentException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return PaymentagentTransferResponse.fromJson( diff --git a/lib/api/response/paymentagent_withdraw_response_result.dart b/lib/api/response/paymentagent_withdraw_response_result.dart index 4caa274b66..e416a89f67 100644 --- a/lib/api/response/paymentagent_withdraw_response_result.dart +++ b/lib/api/response/paymentagent_withdraw_response_result.dart @@ -70,7 +70,7 @@ class PaymentagentWithdrawResponse extends PaymentagentWithdrawResponseModel { /// Initiates a withdrawal to an approved payment agent. /// /// For parameters information refer to [PaymentagentWithdrawRequest]. - /// Throws a [PaymentAgentException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future withdraw( PaymentagentWithdrawRequest request, ) async { @@ -80,7 +80,7 @@ class PaymentagentWithdrawResponse extends PaymentagentWithdrawResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - PaymentAgentException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return PaymentagentWithdrawResponse.fromJson(response.paymentagentWithdraw, diff --git a/lib/api/response/payout_currencies_response_result.dart b/lib/api/response/payout_currencies_response_result.dart index 5b556e045f..3186bf5fa8 100644 --- a/lib/api/response/payout_currencies_response_result.dart +++ b/lib/api/response/payout_currencies_response_result.dart @@ -64,7 +64,7 @@ class PayoutCurrenciesResponse extends PayoutCurrenciesResponseModel { /// Retrieves a list of available option payout currencies. /// /// If a user is logged in, only the currencies available for the account will be returned. - /// Throws a [PayoutCurrencyException] if API response contains a error + /// Throws a [BaseAPIException] if API response contains a error static Future fetchPayoutCurrencies([ PayoutCurrenciesRequest? request, ]) async { @@ -75,7 +75,7 @@ class PayoutCurrenciesResponse extends PayoutCurrenciesResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - PayoutCurrencyException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return PayoutCurrenciesResponse.fromJson(response.payoutCurrencies); diff --git a/lib/api/response/ping_response_result.dart b/lib/api/response/ping_response_result.dart index beaebf0d02..d9cd881e22 100644 --- a/lib/api/response/ping_response_result.dart +++ b/lib/api/response/ping_response_result.dart @@ -54,7 +54,7 @@ class PingResponse extends PingResponseModel { /// Requests the ping request to the server. /// /// Mostly used to test the connection or to keep it alive. - /// Throws a [PingException] if API response contains an error. + /// Throws a [BaseAPIException] if API response contains an error. static Future pingMethodRaw([PingRequest? request]) async { final PingReceive response = await _api.call( request: request ?? const PingRequest(), @@ -63,7 +63,7 @@ class PingResponse extends PingResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - PingException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return response; @@ -72,7 +72,7 @@ class PingResponse extends PingResponseModel { /// Requests the ping request to the server. /// /// Mostly used to test the connection or to keep it alive. - /// Throws a [PingException] if API response contains an error. + /// Throws a [BaseAPIException] if API response contains an error. static Future pingMethod([PingRequest? request]) async { final PingReceive response = await pingMethodRaw(request); diff --git a/lib/api/response/portfolio_response_result.dart b/lib/api/response/portfolio_response_result.dart index caab859ee2..86e4e44e9c 100644 --- a/lib/api/response/portfolio_response_result.dart +++ b/lib/api/response/portfolio_response_result.dart @@ -54,7 +54,7 @@ class PortfolioResponse extends PortfolioResponseModel { /// Gets the portfolio fo logged-in account /// - /// Throws a [PortfolioException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future fetchPortfolio( PortfolioRequest request) async { final PortfolioReceive response = await _api.call(request: request); @@ -62,7 +62,7 @@ class PortfolioResponse extends PortfolioResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - PortfolioException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return PortfolioResponse.fromJson(response.portfolio); diff --git a/lib/api/response/profit_table_response_result.dart b/lib/api/response/profit_table_response_result.dart index 38a3e3739a..c4593de8aa 100644 --- a/lib/api/response/profit_table_response_result.dart +++ b/lib/api/response/profit_table_response_result.dart @@ -56,14 +56,14 @@ class ProfitTableResponse extends ProfitTableResponseModel { /// Retrieves a summary of account Profit Table, according to given search criteria. /// /// For parameters information refer to [ProfitTableRequest]. - /// Throws a [ProfitTableException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future fetch(ProfitTableRequest request) async { final ProfitTableReceive response = await _api.call(request: request); checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - ProfitTableException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return ProfitTableResponse.fromJson(response.profitTable); diff --git a/lib/api/response/proposal_open_contract_response_result.dart b/lib/api/response/proposal_open_contract_response_result.dart index 4ccf0bf686..35823a6354 100644 --- a/lib/api/response/proposal_open_contract_response_result.dart +++ b/lib/api/response/proposal_open_contract_response_result.dart @@ -20,7 +20,6 @@ import 'package:flutter_deriv_api/helpers/helpers.dart'; import 'package:flutter_deriv_api/services/connection/api_manager/base_api.dart'; import 'package:flutter_deriv_api/services/connection/call_manager/base_call_manager.dart'; import 'package:deriv_dependency_injector/dependency_injector.dart'; - /// Proposal open contract response model class. abstract class ProposalOpenContractResponseModel { /// Initializes Proposal open contract response model class . @@ -40,12 +39,9 @@ abstract class ProposalOpenContractResponseModel { class ProposalOpenContractResponse extends ProposalOpenContractResponseModel { /// Initializes Proposal open contract response class. const ProposalOpenContractResponse({ - ProposalOpenContract? proposalOpenContract, - Subscription? subscription, - }) : super( - proposalOpenContract: proposalOpenContract, - subscription: subscription, - ); + super.proposalOpenContract, + super.subscription, + }); /// Creates an instance from JSON. factory ProposalOpenContractResponse.fromJson( @@ -79,7 +75,7 @@ class ProposalOpenContractResponse extends ProposalOpenContractResponseModel { /// Gets the current spot of the the bought contract specified in [ProposalOpenContractRequest] /// - /// Throws a [ContractOperationException] if API response contains any error + /// Throws a [BaseAPIException] if API response contains any error static Future fetchContractState( ProposalOpenContractRequest request, ) async { @@ -90,7 +86,7 @@ class ProposalOpenContractResponse extends ProposalOpenContractResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - ContractOperationException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return ProposalOpenContractResponse.fromJson( @@ -99,7 +95,7 @@ class ProposalOpenContractResponse extends ProposalOpenContractResponseModel { /// Subscribes to the bought contract state specified in [ProposalOpenContractRequest] /// - /// Throws a [ContractOperationException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Stream subscribeContractState( ProposalOpenContractRequest request, { RequestCompareFunction? comparePredicate, @@ -111,8 +107,7 @@ class ProposalOpenContractResponse extends ProposalOpenContractResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - ContractOperationException( - baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return response is ProposalOpenContractReceive @@ -126,7 +121,7 @@ class ProposalOpenContractResponse extends ProposalOpenContractResponseModel { /// Unsubscribes from open contract subscription. /// - /// Throws a [ContractOperationException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error Future unsubscribeOpenContract() async { if (subscription == null) { return null; @@ -138,7 +133,7 @@ class ProposalOpenContractResponse extends ProposalOpenContractResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - ContractOperationException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return ForgetResponse.fromJson(response.forget); @@ -146,7 +141,7 @@ class ProposalOpenContractResponse extends ProposalOpenContractResponseModel { /// Unsubscribes all open contract subscriptions. /// - /// Throws a [ContractOperationException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future unsubscribeAllOpenContract() async { final ForgetAllReceive response = await _api.unsubscribeAll( method: ForgetStreamType.proposalOpenContract, @@ -155,7 +150,7 @@ class ProposalOpenContractResponse extends ProposalOpenContractResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - ContractOperationException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return ForgetAllResponse.fromJson(response.forgetAll); @@ -165,14 +160,14 @@ class ProposalOpenContractResponse extends ProposalOpenContractResponseModel { /// /// [price] is the Minimum price at which to sell the contract, /// Default be 0 for 'sell at market'. - /// Throws a [ContractOperationException] if API response contains an error + /// 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)); /// Cancels this contract /// - /// Throws a [ContractOperationException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future cancel(int contractId) => CancelResponse.cancelContract(CancelRequest(cancel: contractId)); @@ -217,7 +212,6 @@ enum StatusEnum { /// null. _null, } - /// Proposal open contract model class. abstract class ProposalOpenContractModel { /// Initializes Proposal open contract model class . @@ -226,6 +220,7 @@ abstract class ProposalOpenContractModel { this.auditDetails, this.barrier, this.barrierCount, + this.barrierSpotDistance, this.bidPrice, this.buyPrice, this.cancellation, @@ -236,11 +231,14 @@ abstract class ProposalOpenContractModel { this.currency, this.currentSpot, this.currentSpotDisplayValue, + this.currentSpotHighBarrier, + this.currentSpotLowBarrier, this.currentSpotTime, this.dateExpiry, this.dateSettlement, this.dateStart, this.displayName, + this.displayNumberOfContracts, this.displayValue, this.entrySpot, this.entrySpotDisplayValue, @@ -266,10 +264,12 @@ abstract class ProposalOpenContractModel { this.longcode, this.lowBarrier, this.multiplier, + this.numberOfContracts, this.payout, this.profit, this.profitPercentage, this.purchaseTime, + this.resetBarrier, this.resetTime, this.sellPrice, this.sellSpot, @@ -284,6 +284,7 @@ abstract class ProposalOpenContractModel { this.transactionIds, this.underlying, this.validationError, + this.validationErrorCode, }); /// Account Id @@ -298,6 +299,9 @@ abstract class ProposalOpenContractModel { /// The number of barriers a contract has. final double? barrierCount; + /// [Only for accumulator] Absolute difference between high/low barrier and spot + final String? barrierSpotDistance; + /// Price at which the contract could be sold back to the company. final double? bidPrice; @@ -328,6 +332,12 @@ abstract class ProposalOpenContractModel { /// Spot value with the correct precision if we have license to stream this symbol. final String? currentSpotDisplayValue; + /// [Applicable for accumulator] High barrier based on current spot. + final String? currentSpotHighBarrier; + + /// [Applicable for accumulator] Low barrier based on current spot. + final String? currentSpotLowBarrier; + /// The corresponding time of the current spot. final DateTime? currentSpotTime; @@ -343,6 +353,9 @@ abstract class ProposalOpenContractModel { /// Display name of underlying final String? displayName; + /// [Only for vanilla or turbos options] The implied number of contracts + final String? displayNumberOfContracts; + /// The `bid_price` with the correct precision final String? displayValue; @@ -418,6 +431,9 @@ abstract class ProposalOpenContractModel { /// [Only for lookback trades] Multiplier applies when calculating the final payoff for each type of lookback. e.g. (Exit spot - Lowest historical price) * multiplier = Payout final double? multiplier; + /// [Only for vanilla or turbos options] The implied number of contracts + final double? numberOfContracts; + /// Payout value of the contract. final double? payout; @@ -430,7 +446,10 @@ abstract class ProposalOpenContractModel { /// Epoch of purchase time, will be same as `date_start` for all contracts except forward starting contracts. final DateTime? purchaseTime; - /// [Only for reset trades] The epoch time of a barrier reset. + /// [Only for reset trades i.e. RESETCALL and RESETPUT] Reset barrier of the contract. + final String? resetBarrier; + + /// [Only for reset trades i.e. RESETCALL and RESETPUT] The epoch time of a barrier reset. final DateTime? resetTime; /// Price at which contract was sold, only available when contract has been sold. @@ -471,138 +490,85 @@ abstract class ProposalOpenContractModel { /// Error message if validation fails final String? validationError; + + /// Error code if validation fails + final String? validationErrorCode; } /// Proposal open contract class. class ProposalOpenContract extends ProposalOpenContractModel { /// Initializes Proposal open contract class. const ProposalOpenContract({ - double? accountId, - AuditDetails? auditDetails, - String? barrier, - double? barrierCount, - double? bidPrice, - double? buyPrice, - Cancellation? cancellation, - double? commision, - double? commission, - int? contractId, - String? contractType, - String? currency, - double? currentSpot, - String? currentSpotDisplayValue, - DateTime? currentSpotTime, - DateTime? dateExpiry, - DateTime? dateSettlement, - DateTime? dateStart, - String? displayName, - String? displayValue, - double? entrySpot, - String? entrySpotDisplayValue, - double? entryTick, - String? entryTickDisplayValue, - DateTime? entryTickTime, - double? exitTick, - String? exitTickDisplayValue, - DateTime? exitTickTime, - DateTime? expiryTime, - double? growthRate, - String? highBarrier, - String? id, - bool? isExpired, - bool? isForwardStarting, - bool? isIntraday, - bool? isPathDependent, - bool? isSettleable, - bool? isSold, - bool? isValidToCancel, - bool? isValidToSell, - LimitOrder? limitOrder, - String? longcode, - String? lowBarrier, - double? multiplier, - double? payout, - double? profit, - double? profitPercentage, - DateTime? purchaseTime, - DateTime? resetTime, - double? sellPrice, - double? sellSpot, - String? sellSpotDisplayValue, - DateTime? sellSpotTime, - DateTime? sellTime, - String? shortcode, - StatusEnum? status, - int? tickCount, - int? tickPassed, - List? tickStream, - TransactionIds? transactionIds, - String? underlying, - String? validationError, - }) : super( - accountId: accountId, - auditDetails: auditDetails, - barrier: barrier, - barrierCount: barrierCount, - bidPrice: bidPrice, - buyPrice: buyPrice, - cancellation: cancellation, - commision: commision, - commission: commission, - contractId: contractId, - contractType: contractType, - currency: currency, - currentSpot: currentSpot, - currentSpotDisplayValue: currentSpotDisplayValue, - currentSpotTime: currentSpotTime, - dateExpiry: dateExpiry, - dateSettlement: dateSettlement, - dateStart: dateStart, - displayName: displayName, - displayValue: displayValue, - entrySpot: entrySpot, - entrySpotDisplayValue: entrySpotDisplayValue, - entryTick: entryTick, - entryTickDisplayValue: entryTickDisplayValue, - entryTickTime: entryTickTime, - exitTick: exitTick, - exitTickDisplayValue: exitTickDisplayValue, - exitTickTime: exitTickTime, - expiryTime: expiryTime, - growthRate: growthRate, - highBarrier: highBarrier, - id: id, - isExpired: isExpired, - isForwardStarting: isForwardStarting, - isIntraday: isIntraday, - isPathDependent: isPathDependent, - isSettleable: isSettleable, - isSold: isSold, - isValidToCancel: isValidToCancel, - isValidToSell: isValidToSell, - limitOrder: limitOrder, - longcode: longcode, - lowBarrier: lowBarrier, - multiplier: multiplier, - payout: payout, - profit: profit, - profitPercentage: profitPercentage, - purchaseTime: purchaseTime, - resetTime: resetTime, - sellPrice: sellPrice, - sellSpot: sellSpot, - sellSpotDisplayValue: sellSpotDisplayValue, - sellSpotTime: sellSpotTime, - sellTime: sellTime, - shortcode: shortcode, - status: status, - tickCount: tickCount, - tickPassed: tickPassed, - tickStream: tickStream, - transactionIds: transactionIds, - underlying: underlying, - validationError: validationError, - ); + super.accountId, + super.auditDetails, + super.barrier, + super.barrierCount, + super.barrierSpotDistance, + super.bidPrice, + super.buyPrice, + super.cancellation, + super.commision, + super.commission, + super.contractId, + super.contractType, + super.currency, + super.currentSpot, + super.currentSpotDisplayValue, + super.currentSpotHighBarrier, + super.currentSpotLowBarrier, + super.currentSpotTime, + super.dateExpiry, + super.dateSettlement, + super.dateStart, + super.displayName, + super.displayNumberOfContracts, + super.displayValue, + super.entrySpot, + super.entrySpotDisplayValue, + super.entryTick, + super.entryTickDisplayValue, + super.entryTickTime, + super.exitTick, + super.exitTickDisplayValue, + super.exitTickTime, + super.expiryTime, + super.growthRate, + super.highBarrier, + super.id, + super.isExpired, + super.isForwardStarting, + super.isIntraday, + super.isPathDependent, + super.isSettleable, + super.isSold, + super.isValidToCancel, + super.isValidToSell, + super.limitOrder, + super.longcode, + super.lowBarrier, + super.multiplier, + super.numberOfContracts, + super.payout, + super.profit, + super.profitPercentage, + super.purchaseTime, + super.resetBarrier, + super.resetTime, + super.sellPrice, + super.sellSpot, + super.sellSpotDisplayValue, + super.sellSpotTime, + super.sellTime, + super.shortcode, + super.status, + super.tickCount, + super.tickPassed, + super.tickStream, + super.transactionIds, + super.underlying, + super.validationError, + super.validationErrorCode, + }); /// Creates an instance from JSON. factory ProposalOpenContract.fromJson(Map json) => @@ -613,6 +579,7 @@ class ProposalOpenContract extends ProposalOpenContractModel { : AuditDetails.fromJson(json['audit_details']), barrier: json['barrier'], barrierCount: getDouble(json['barrier_count']), + barrierSpotDistance: json['barrier_spot_distance'], bidPrice: getDouble(json['bid_price']), buyPrice: getDouble(json['buy_price']), cancellation: json['cancellation'] == null @@ -625,11 +592,14 @@ class ProposalOpenContract extends ProposalOpenContractModel { currency: json['currency'], currentSpot: getDouble(json['current_spot']), currentSpotDisplayValue: json['current_spot_display_value'], + currentSpotHighBarrier: json['current_spot_high_barrier'], + currentSpotLowBarrier: json['current_spot_low_barrier'], currentSpotTime: getDateTime(json['current_spot_time']), dateExpiry: getDateTime(json['date_expiry']), dateSettlement: getDateTime(json['date_settlement']), dateStart: getDateTime(json['date_start']), displayName: json['display_name'], + displayNumberOfContracts: json['display_number_of_contracts'], displayValue: json['display_value'], entrySpot: getDouble(json['entry_spot']), entrySpotDisplayValue: json['entry_spot_display_value'], @@ -657,10 +627,12 @@ class ProposalOpenContract extends ProposalOpenContractModel { longcode: json['longcode'], lowBarrier: json['low_barrier'], multiplier: getDouble(json['multiplier']), + numberOfContracts: getDouble(json['number_of_contracts']), payout: getDouble(json['payout']), profit: getDouble(json['profit']), profitPercentage: getDouble(json['profit_percentage']), purchaseTime: getDateTime(json['purchase_time']), + resetBarrier: json['reset_barrier'], resetTime: getDateTime(json['reset_time']), sellPrice: getDouble(json['sell_price']), sellSpot: getDouble(json['sell_spot']), @@ -684,6 +656,7 @@ class ProposalOpenContract extends ProposalOpenContractModel { : TransactionIds.fromJson(json['transaction_ids']), underlying: json['underlying'], validationError: json['validation_error'], + validationErrorCode: json['validation_error_code'], ); /// Converts an instance to JSON. @@ -696,6 +669,7 @@ class ProposalOpenContract extends ProposalOpenContractModel { } resultMap['barrier'] = barrier; resultMap['barrier_count'] = barrierCount; + resultMap['barrier_spot_distance'] = barrierSpotDistance; resultMap['bid_price'] = bidPrice; resultMap['buy_price'] = buyPrice; if (cancellation != null) { @@ -708,12 +682,15 @@ class ProposalOpenContract extends ProposalOpenContractModel { resultMap['currency'] = currency; resultMap['current_spot'] = currentSpot; resultMap['current_spot_display_value'] = currentSpotDisplayValue; + resultMap['current_spot_high_barrier'] = currentSpotHighBarrier; + resultMap['current_spot_low_barrier'] = currentSpotLowBarrier; resultMap['current_spot_time'] = getSecondsSinceEpochDateTime(currentSpotTime); resultMap['date_expiry'] = getSecondsSinceEpochDateTime(dateExpiry); resultMap['date_settlement'] = getSecondsSinceEpochDateTime(dateSettlement); resultMap['date_start'] = getSecondsSinceEpochDateTime(dateStart); resultMap['display_name'] = displayName; + resultMap['display_number_of_contracts'] = displayNumberOfContracts; resultMap['display_value'] = displayValue; resultMap['entry_spot'] = entrySpot; resultMap['entry_spot_display_value'] = entrySpotDisplayValue; @@ -741,10 +718,12 @@ class ProposalOpenContract extends ProposalOpenContractModel { resultMap['longcode'] = longcode; resultMap['low_barrier'] = lowBarrier; resultMap['multiplier'] = multiplier; + resultMap['number_of_contracts'] = numberOfContracts; resultMap['payout'] = payout; resultMap['profit'] = profit; resultMap['profit_percentage'] = profitPercentage; resultMap['purchase_time'] = getSecondsSinceEpochDateTime(purchaseTime); + resultMap['reset_barrier'] = resetBarrier; resultMap['reset_time'] = getSecondsSinceEpochDateTime(resetTime); resultMap['sell_price'] = sellPrice; resultMap['sell_spot'] = sellSpot; @@ -770,6 +749,7 @@ class ProposalOpenContract extends ProposalOpenContractModel { } resultMap['underlying'] = underlying; resultMap['validation_error'] = validationError; + resultMap['validation_error_code'] = validationErrorCode; return resultMap; } @@ -780,6 +760,7 @@ class ProposalOpenContract extends ProposalOpenContractModel { AuditDetails? auditDetails, String? barrier, double? barrierCount, + String? barrierSpotDistance, double? bidPrice, double? buyPrice, Cancellation? cancellation, @@ -790,11 +771,14 @@ class ProposalOpenContract extends ProposalOpenContractModel { String? currency, double? currentSpot, String? currentSpotDisplayValue, + String? currentSpotHighBarrier, + String? currentSpotLowBarrier, DateTime? currentSpotTime, DateTime? dateExpiry, DateTime? dateSettlement, DateTime? dateStart, String? displayName, + String? displayNumberOfContracts, String? displayValue, double? entrySpot, String? entrySpotDisplayValue, @@ -820,10 +804,12 @@ class ProposalOpenContract extends ProposalOpenContractModel { String? longcode, String? lowBarrier, double? multiplier, + double? numberOfContracts, double? payout, double? profit, double? profitPercentage, DateTime? purchaseTime, + String? resetBarrier, DateTime? resetTime, double? sellPrice, double? sellSpot, @@ -838,12 +824,14 @@ class ProposalOpenContract extends ProposalOpenContractModel { TransactionIds? transactionIds, String? underlying, String? validationError, + String? validationErrorCode, }) => ProposalOpenContract( accountId: accountId ?? this.accountId, auditDetails: auditDetails ?? this.auditDetails, barrier: barrier ?? this.barrier, barrierCount: barrierCount ?? this.barrierCount, + barrierSpotDistance: barrierSpotDistance ?? this.barrierSpotDistance, bidPrice: bidPrice ?? this.bidPrice, buyPrice: buyPrice ?? this.buyPrice, cancellation: cancellation ?? this.cancellation, @@ -855,11 +843,17 @@ class ProposalOpenContract extends ProposalOpenContractModel { currentSpot: currentSpot ?? this.currentSpot, currentSpotDisplayValue: currentSpotDisplayValue ?? this.currentSpotDisplayValue, + currentSpotHighBarrier: + currentSpotHighBarrier ?? this.currentSpotHighBarrier, + currentSpotLowBarrier: + currentSpotLowBarrier ?? this.currentSpotLowBarrier, currentSpotTime: currentSpotTime ?? this.currentSpotTime, dateExpiry: dateExpiry ?? this.dateExpiry, dateSettlement: dateSettlement ?? this.dateSettlement, dateStart: dateStart ?? this.dateStart, displayName: displayName ?? this.displayName, + displayNumberOfContracts: + displayNumberOfContracts ?? this.displayNumberOfContracts, displayValue: displayValue ?? this.displayValue, entrySpot: entrySpot ?? this.entrySpot, entrySpotDisplayValue: @@ -887,10 +881,12 @@ class ProposalOpenContract extends ProposalOpenContractModel { longcode: longcode ?? this.longcode, lowBarrier: lowBarrier ?? this.lowBarrier, multiplier: multiplier ?? this.multiplier, + numberOfContracts: numberOfContracts ?? this.numberOfContracts, payout: payout ?? this.payout, profit: profit ?? this.profit, profitPercentage: profitPercentage ?? this.profitPercentage, purchaseTime: purchaseTime ?? this.purchaseTime, + resetBarrier: resetBarrier ?? this.resetBarrier, resetTime: resetTime ?? this.resetTime, sellPrice: sellPrice ?? this.sellPrice, sellSpot: sellSpot ?? this.sellSpot, @@ -905,9 +901,9 @@ class ProposalOpenContract extends ProposalOpenContractModel { transactionIds: transactionIds ?? this.transactionIds, underlying: underlying ?? this.underlying, validationError: validationError ?? this.validationError, + validationErrorCode: validationErrorCode ?? this.validationErrorCode, ); } - /// Audit details model class. abstract class AuditDetailsModel { /// Initializes Audit details model class . @@ -931,14 +927,10 @@ abstract class AuditDetailsModel { class AuditDetails extends AuditDetailsModel { /// Initializes Audit details class. const AuditDetails({ - List? allTicks, - List? contractEnd, - List? contractStart, - }) : super( - allTicks: allTicks, - contractEnd: contractEnd, - contractStart: contractStart, - ); + super.allTicks, + super.contractEnd, + super.contractStart, + }); /// Creates an instance from JSON. factory AuditDetails.fromJson(Map json) => AuditDetails( @@ -1006,7 +998,6 @@ class AuditDetails extends AuditDetailsModel { contractStart: contractStart ?? this.contractStart, ); } - /// All ticks item model class. abstract class AllTicksItemModel { /// Initializes All ticks item model class . @@ -1038,18 +1029,12 @@ abstract class AllTicksItemModel { class AllTicksItem extends AllTicksItemModel { /// Initializes All ticks item class. const AllTicksItem({ - DateTime? epoch, - String? flag, - String? name, - double? tick, - String? tickDisplayValue, - }) : super( - epoch: epoch, - flag: flag, - name: name, - tick: tick, - tickDisplayValue: tickDisplayValue, - ); + super.epoch, + super.flag, + super.name, + super.tick, + super.tickDisplayValue, + }); /// Creates an instance from JSON. factory AllTicksItem.fromJson(Map json) => AllTicksItem( @@ -1089,7 +1074,6 @@ class AllTicksItem extends AllTicksItemModel { tickDisplayValue: tickDisplayValue ?? this.tickDisplayValue, ); } - /// Contract end item model class. abstract class ContractEndItemModel { /// Initializes Contract end item model class . @@ -1121,18 +1105,12 @@ abstract class ContractEndItemModel { class ContractEndItem extends ContractEndItemModel { /// Initializes Contract end item class. const ContractEndItem({ - DateTime? epoch, - String? flag, - String? name, - double? tick, - String? tickDisplayValue, - }) : super( - epoch: epoch, - flag: flag, - name: name, - tick: tick, - tickDisplayValue: tickDisplayValue, - ); + super.epoch, + super.flag, + super.name, + super.tick, + super.tickDisplayValue, + }); /// Creates an instance from JSON. factory ContractEndItem.fromJson(Map json) => @@ -1173,7 +1151,6 @@ class ContractEndItem extends ContractEndItemModel { tickDisplayValue: tickDisplayValue ?? this.tickDisplayValue, ); } - /// Contract start item model class. abstract class ContractStartItemModel { /// Initializes Contract start item model class . @@ -1205,18 +1182,12 @@ abstract class ContractStartItemModel { class ContractStartItem extends ContractStartItemModel { /// Initializes Contract start item class. const ContractStartItem({ - DateTime? epoch, - String? flag, - String? name, - double? tick, - String? tickDisplayValue, - }) : super( - epoch: epoch, - flag: flag, - name: name, - tick: tick, - tickDisplayValue: tickDisplayValue, - ); + super.epoch, + super.flag, + super.name, + super.tick, + super.tickDisplayValue, + }); /// Creates an instance from JSON. factory ContractStartItem.fromJson(Map json) => @@ -1257,7 +1228,6 @@ class ContractStartItem extends ContractStartItemModel { tickDisplayValue: tickDisplayValue ?? this.tickDisplayValue, ); } - /// Cancellation model class. abstract class CancellationModel extends Equatable { /// Initializes Cancellation model class . @@ -1277,12 +1247,9 @@ abstract class CancellationModel extends Equatable { class Cancellation extends CancellationModel { /// Initializes Cancellation class. const Cancellation({ - double? askPrice, - DateTime? dateExpiry, - }) : super( - askPrice: askPrice, - dateExpiry: dateExpiry, - ); + super.askPrice, + super.dateExpiry, + }); /// Creates an instance from JSON. factory Cancellation.fromJson(Map json) => Cancellation( @@ -1317,7 +1284,6 @@ class Cancellation extends CancellationModel { dateExpiry, ]; } - /// Limit order model class. abstract class LimitOrderModel extends Equatable { /// Initializes Limit order model class . @@ -1341,14 +1307,10 @@ abstract class LimitOrderModel extends Equatable { class LimitOrder extends LimitOrderModel { /// Initializes Limit order class. const LimitOrder({ - StopLoss? stopLoss, - StopOut? stopOut, - TakeProfit? takeProfit, - }) : super( - stopLoss: stopLoss, - stopOut: stopOut, - takeProfit: takeProfit, - ); + super.stopLoss, + super.stopOut, + super.takeProfit, + }); /// Creates an instance from JSON. factory LimitOrder.fromJson(Map json) => LimitOrder( @@ -1400,7 +1362,6 @@ class LimitOrder extends LimitOrderModel { takeProfit, ]; } - /// Stop loss model class. abstract class StopLossModel extends Equatable { /// Initializes Stop loss model class . @@ -1428,16 +1389,11 @@ abstract class StopLossModel extends Equatable { class StopLoss extends StopLossModel { /// Initializes Stop loss class. const StopLoss({ - String? displayName, - double? orderAmount, - DateTime? orderDate, - String? value, - }) : super( - displayName: displayName, - orderAmount: orderAmount, - orderDate: orderDate, - value: value, - ); + super.displayName, + super.orderAmount, + super.orderDate, + super.value, + }); /// Creates an instance from JSON. factory StopLoss.fromJson(Map json) => StopLoss( @@ -1480,7 +1436,6 @@ class StopLoss extends StopLossModel { orderAmount, ]; } - /// Stop out model class. abstract class StopOutModel extends Equatable { /// Initializes Stop out model class . @@ -1508,16 +1463,11 @@ abstract class StopOutModel extends Equatable { class StopOut extends StopOutModel { /// Initializes Stop out class. const StopOut({ - String? displayName, - double? orderAmount, - DateTime? orderDate, - String? value, - }) : super( - displayName: displayName, - orderAmount: orderAmount, - orderDate: orderDate, - value: value, - ); + super.displayName, + super.orderAmount, + super.orderDate, + super.value, + }); /// Creates an instance from JSON. factory StopOut.fromJson(Map json) => StopOut( @@ -1560,7 +1510,6 @@ class StopOut extends StopOutModel { orderAmount, ]; } - /// Take profit model class. abstract class TakeProfitModel extends Equatable { /// Initializes Take profit model class . @@ -1588,16 +1537,11 @@ abstract class TakeProfitModel extends Equatable { class TakeProfit extends TakeProfitModel { /// Initializes Take profit class. const TakeProfit({ - String? displayName, - double? orderAmount, - DateTime? orderDate, - String? value, - }) : super( - displayName: displayName, - orderAmount: orderAmount, - orderDate: orderDate, - value: value, - ); + super.displayName, + super.orderAmount, + super.orderDate, + super.value, + }); /// Creates an instance from JSON. factory TakeProfit.fromJson(Map json) => TakeProfit( @@ -1640,7 +1584,6 @@ class TakeProfit extends TakeProfitModel { orderAmount, ]; } - /// Tick stream item model class. abstract class TickStreamItemModel { /// Initializes Tick stream item model class . @@ -1664,14 +1607,10 @@ abstract class TickStreamItemModel { class TickStreamItem extends TickStreamItemModel { /// Initializes Tick stream item class. const TickStreamItem({ - DateTime? epoch, - double? tick, - String? tickDisplayValue, - }) : super( - epoch: epoch, - tick: tick, - tickDisplayValue: tickDisplayValue, - ); + super.epoch, + super.tick, + super.tickDisplayValue, + }); /// Creates an instance from JSON. factory TickStreamItem.fromJson(Map json) => TickStreamItem( @@ -1703,7 +1642,6 @@ class TickStreamItem extends TickStreamItemModel { tickDisplayValue: tickDisplayValue ?? this.tickDisplayValue, ); } - /// Transaction ids model class. abstract class TransactionIdsModel { /// Initializes Transaction ids model class . @@ -1723,12 +1661,9 @@ abstract class TransactionIdsModel { class TransactionIds extends TransactionIdsModel { /// Initializes Transaction ids class. const TransactionIds({ - int? buy, - int? sell, - }) : super( - buy: buy, - sell: sell, - ); + super.buy, + super.sell, + }); /// Creates an instance from JSON. factory TransactionIds.fromJson(Map json) => TransactionIds( @@ -1756,7 +1691,6 @@ class TransactionIds extends TransactionIdsModel { sell: sell ?? this.sell, ); } - /// Subscription model class. abstract class SubscriptionModel { /// Initializes Subscription model class . @@ -1772,10 +1706,8 @@ abstract class SubscriptionModel { class Subscription extends SubscriptionModel { /// Initializes Subscription class. const Subscription({ - required String id, - }) : super( - id: id, - ); + required super.id, + }); /// Creates an instance from JSON. factory Subscription.fromJson(Map json) => Subscription( diff --git a/lib/api/response/proposal_response_result.dart b/lib/api/response/proposal_response_result.dart index 2df2317e58..37124d8d5d 100644 --- a/lib/api/response/proposal_response_result.dart +++ b/lib/api/response/proposal_response_result.dart @@ -2,7 +2,7 @@ import 'package:equatable/equatable.dart'; -import 'package:flutter_deriv_api/api/exceptions/contract_operations_exception.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'; import 'package:flutter_deriv_api/api/response/buy_response_result.dart'; @@ -39,12 +39,9 @@ abstract class ProposalResponseModel { class ProposalResponse extends ProposalResponseModel { /// Initializes Proposal response class. const ProposalResponse({ - Proposal? proposal, - Subscription? subscription, - }) : super( - proposal: proposal, - subscription: subscription, - ); + super.proposal, + super.subscription, + }); /// Creates an instance from JSON. factory ProposalResponse.fromJson( @@ -77,7 +74,7 @@ class ProposalResponse extends ProposalResponseModel { /// Gets the price proposal for contract /// /// For parameters information refer to [ProposalRequest] - /// Throws a [ContractOperationException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future fetchPriceForContract( ProposalRequest request, ) async { @@ -86,7 +83,7 @@ class ProposalResponse extends ProposalResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - ContractOperationException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return ProposalResponse.fromJson(response.proposal, response.subscription); @@ -95,7 +92,7 @@ class ProposalResponse extends ProposalResponseModel { /// Gets the price proposal for contract. /// /// For parameters information refer to [ProposalRequest] - /// Throws a [ContractOperationException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Stream subscribePriceForContract( ProposalRequest request, { RequestCompareFunction? comparePredicate, @@ -107,8 +104,7 @@ class ProposalResponse extends ProposalResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - ContractOperationException( - baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return response is ProposalReceive @@ -122,7 +118,7 @@ class ProposalResponse extends ProposalResponseModel { /// Unsubscribes from price proposal subscription. /// - /// Throws a [ContractOperationException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error Future unsubscribeProposal() async { if (subscription == null) { return null; @@ -134,7 +130,7 @@ class ProposalResponse extends ProposalResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - ContractOperationException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return ForgetResponse.fromJson(response.forget); @@ -142,7 +138,7 @@ class ProposalResponse extends ProposalResponseModel { /// Unsubscribes all proposal subscriptions. /// - /// Throws a [ContractOperationException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future unsubscribeAllProposal() async { final ForgetAllReceive response = await _api.unsubscribeAll(method: ForgetStreamType.proposal); @@ -150,7 +146,7 @@ class ProposalResponse extends ProposalResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - ContractOperationException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return ForgetAllResponse.fromJson(response.forgetAll); @@ -158,7 +154,7 @@ class ProposalResponse extends ProposalResponseModel { /// Buys this proposal contract with [price] specified. /// - /// Throws a [ContractOperationException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error Future buy({double? price}) => BuyResponse.buyMethod(BuyRequest( buy: proposal?.id, price: price ?? proposal?.askPrice, @@ -166,7 +162,7 @@ class ProposalResponse extends ProposalResponseModel { /// Buys this proposal contract with [price] specified and subscribes to it. /// - /// Throws a [ContractOperationException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error Stream buyAndSubscribe({double? price}) => BuyResponse.buyAndSubscribe(BuyRequest( buy: proposal?.id, @@ -183,7 +179,6 @@ class ProposalResponse extends ProposalResponseModel { subscription: subscription ?? this.subscription, ); } - /// Proposal model class. abstract class ProposalModel extends Equatable { /// Initializes Proposal model class . @@ -201,6 +196,7 @@ abstract class ProposalModel extends Equatable { this.commission, this.contractDetails, this.dateExpiry, + this.displayNumberOfContracts, this.limitOrder, this.maxStake, this.minStake, @@ -241,25 +237,28 @@ abstract class ProposalModel extends Equatable { /// Commission changed in percentage (%). final double? commission; - /// Contains contract information. (Only applicable for accumulator). + /// Contains contract information. final ContractDetails? contractDetails; /// The end date of the contract. final DateTime? dateExpiry; + /// [Only for vanilla or turbos options] The implied number of contracts + final String? displayNumberOfContracts; + /// Contains limit order information. (Only applicable for contract with limit order). final LimitOrder? limitOrder; - /// [Only for vanilla options] Maximum stakes allowed + /// [Only for vanilla or turbos options] Maximum stakes allowed final double? maxStake; - /// [Only for vanilla options] Minimum stakes allowed + /// [Only for vanilla or turbos options] Minimum stakes allowed final double? minStake; /// [Only for lookback trades] Multiplier applies when calculating the final payoff for each type of lookback. e.g. (Exit spot - Lowest historical price) * multiplier = Payout final double? multiplier; - /// [Only for vanilla options] The implied number of contracts + /// [Only for vanilla or turbos options] The implied number of contracts final double? numberOfContracts; } @@ -267,44 +266,26 @@ abstract class ProposalModel extends Equatable { class Proposal extends ProposalModel { /// Initializes Proposal class. const Proposal({ - required double askPrice, - required DateTime dateStart, - required String displayValue, - required String id, - required String longcode, - required double payout, - required double spot, - required DateTime spotTime, - List? barrierChoices, - Cancellation? cancellation, - double? commission, - ContractDetails? contractDetails, - DateTime? dateExpiry, - LimitOrder? limitOrder, - double? maxStake, - double? minStake, - double? multiplier, - double? numberOfContracts, - }) : super( - askPrice: askPrice, - dateStart: dateStart, - displayValue: displayValue, - id: id, - longcode: longcode, - payout: payout, - spot: spot, - spotTime: spotTime, - barrierChoices: barrierChoices, - cancellation: cancellation, - commission: commission, - contractDetails: contractDetails, - dateExpiry: dateExpiry, - limitOrder: limitOrder, - maxStake: maxStake, - minStake: minStake, - multiplier: multiplier, - numberOfContracts: numberOfContracts, - ); + required super.askPrice, + required super.dateStart, + required super.displayValue, + required super.id, + required super.longcode, + required super.payout, + required super.spot, + required super.spotTime, + super.barrierChoices, + super.cancellation, + super.commission, + super.contractDetails, + super.dateExpiry, + super.displayNumberOfContracts, + super.limitOrder, + super.maxStake, + super.minStake, + super.multiplier, + super.numberOfContracts, + }); /// Creates an instance from JSON. factory Proposal.fromJson(Map json) => Proposal( @@ -331,6 +312,7 @@ class Proposal extends ProposalModel { ? null : ContractDetails.fromJson(json['contract_details']), dateExpiry: getDateTime(json['date_expiry']), + displayNumberOfContracts: json['display_number_of_contracts'], limitOrder: json['limit_order'] == null ? null : LimitOrder.fromJson(json['limit_order']), @@ -367,6 +349,7 @@ class Proposal extends ProposalModel { resultMap['contract_details'] = contractDetails!.toJson(); } resultMap['date_expiry'] = getSecondsSinceEpochDateTime(dateExpiry); + resultMap['display_number_of_contracts'] = displayNumberOfContracts; if (limitOrder != null) { resultMap['limit_order'] = limitOrder!.toJson(); } @@ -393,6 +376,7 @@ class Proposal extends ProposalModel { double? commission, ContractDetails? contractDetails, DateTime? dateExpiry, + String? displayNumberOfContracts, LimitOrder? limitOrder, double? maxStake, double? minStake, @@ -413,6 +397,8 @@ class Proposal extends ProposalModel { commission: commission ?? this.commission, contractDetails: contractDetails ?? this.contractDetails, dateExpiry: dateExpiry ?? this.dateExpiry, + displayNumberOfContracts: + displayNumberOfContracts ?? this.displayNumberOfContracts, limitOrder: limitOrder ?? this.limitOrder, maxStake: maxStake ?? this.maxStake, minStake: minStake ?? this.minStake, @@ -432,7 +418,6 @@ class Proposal extends ProposalModel { limitOrder, ]; } - /// Cancellation model class. abstract class CancellationModel extends Equatable { /// Initializes Cancellation model class . @@ -452,12 +437,9 @@ abstract class CancellationModel extends Equatable { class Cancellation extends CancellationModel { /// Initializes Cancellation class. const Cancellation({ - double? askPrice, - DateTime? dateExpiry, - }) : super( - askPrice: askPrice, - dateExpiry: dateExpiry, - ); + super.askPrice, + super.dateExpiry, + }); /// Creates an instance from JSON. factory Cancellation.fromJson(Map json) => Cancellation( @@ -492,11 +474,12 @@ class Cancellation extends CancellationModel { dateExpiry, ]; } - /// Contract details model class. abstract class ContractDetailsModel { /// Initializes Contract details model class . const ContractDetailsModel({ + this.barrier, + this.barrierSpotDistance, this.highBarrier, this.lastTickEpoch, this.lowBarrier, @@ -506,6 +489,12 @@ abstract class ContractDetailsModel { this.ticksStayedIn, }); + /// Barrier of the contract. + final String? barrier; + + /// Absolute difference between high/low barrier and spot + final String? barrierSpotDistance; + /// High barrier calculated based on current spot final String? highBarrier; @@ -532,26 +521,22 @@ abstract class ContractDetailsModel { class ContractDetails extends ContractDetailsModel { /// Initializes Contract details class. const ContractDetails({ - String? highBarrier, - DateTime? lastTickEpoch, - String? lowBarrier, - double? maximumPayout, - int? maximumTicks, - double? tickSizeBarrier, - List? ticksStayedIn, - }) : super( - highBarrier: highBarrier, - lastTickEpoch: lastTickEpoch, - lowBarrier: lowBarrier, - maximumPayout: maximumPayout, - maximumTicks: maximumTicks, - tickSizeBarrier: tickSizeBarrier, - ticksStayedIn: ticksStayedIn, - ); + super.barrier, + super.barrierSpotDistance, + super.highBarrier, + super.lastTickEpoch, + super.lowBarrier, + super.maximumPayout, + super.maximumTicks, + super.tickSizeBarrier, + super.ticksStayedIn, + }); /// Creates an instance from JSON. factory ContractDetails.fromJson(Map json) => ContractDetails( + barrier: json['barrier'], + barrierSpotDistance: json['barrier_spot_distance'], highBarrier: json['high_barrier'], lastTickEpoch: getDateTime(json['last_tick_epoch']), lowBarrier: json['low_barrier'], @@ -571,6 +556,8 @@ class ContractDetails extends ContractDetailsModel { Map toJson() { final Map resultMap = {}; + resultMap['barrier'] = barrier; + resultMap['barrier_spot_distance'] = barrierSpotDistance; resultMap['high_barrier'] = highBarrier; resultMap['last_tick_epoch'] = getSecondsSinceEpochDateTime(lastTickEpoch); resultMap['low_barrier'] = lowBarrier; @@ -590,6 +577,8 @@ class ContractDetails extends ContractDetailsModel { /// Creates a copy of instance with given parameters. ContractDetails copyWith({ + String? barrier, + String? barrierSpotDistance, String? highBarrier, DateTime? lastTickEpoch, String? lowBarrier, @@ -599,6 +588,8 @@ class ContractDetails extends ContractDetailsModel { List? ticksStayedIn, }) => ContractDetails( + barrier: barrier ?? this.barrier, + barrierSpotDistance: barrierSpotDistance ?? this.barrierSpotDistance, highBarrier: highBarrier ?? this.highBarrier, lastTickEpoch: lastTickEpoch ?? this.lastTickEpoch, lowBarrier: lowBarrier ?? this.lowBarrier, @@ -608,7 +599,6 @@ class ContractDetails extends ContractDetailsModel { ticksStayedIn: ticksStayedIn ?? this.ticksStayedIn, ); } - /// Limit order model class. abstract class LimitOrderModel extends Equatable { /// Initializes Limit order model class . @@ -632,14 +622,10 @@ abstract class LimitOrderModel extends Equatable { class LimitOrder extends LimitOrderModel { /// Initializes Limit order class. const LimitOrder({ - StopLoss? stopLoss, - StopOut? stopOut, - TakeProfit? takeProfit, - }) : super( - stopLoss: stopLoss, - stopOut: stopOut, - takeProfit: takeProfit, - ); + super.stopLoss, + super.stopOut, + super.takeProfit, + }); /// Creates an instance from JSON. factory LimitOrder.fromJson(Map json) => LimitOrder( @@ -691,7 +677,6 @@ class LimitOrder extends LimitOrderModel { takeProfit, ]; } - /// Stop loss model class. abstract class StopLossModel extends Equatable { /// Initializes Stop loss model class . @@ -719,16 +704,11 @@ abstract class StopLossModel extends Equatable { class StopLoss extends StopLossModel { /// Initializes Stop loss class. const StopLoss({ - String? displayName, - double? orderAmount, - DateTime? orderDate, - String? value, - }) : super( - displayName: displayName, - orderAmount: orderAmount, - orderDate: orderDate, - value: value, - ); + super.displayName, + super.orderAmount, + super.orderDate, + super.value, + }); /// Creates an instance from JSON. factory StopLoss.fromJson(Map json) => StopLoss( @@ -771,7 +751,6 @@ class StopLoss extends StopLossModel { orderAmount, ]; } - /// Stop out model class. abstract class StopOutModel extends Equatable { /// Initializes Stop out model class . @@ -799,16 +778,11 @@ abstract class StopOutModel extends Equatable { class StopOut extends StopOutModel { /// Initializes Stop out class. const StopOut({ - String? displayName, - double? orderAmount, - DateTime? orderDate, - String? value, - }) : super( - displayName: displayName, - orderAmount: orderAmount, - orderDate: orderDate, - value: value, - ); + super.displayName, + super.orderAmount, + super.orderDate, + super.value, + }); /// Creates an instance from JSON. factory StopOut.fromJson(Map json) => StopOut( @@ -851,7 +825,6 @@ class StopOut extends StopOutModel { orderAmount, ]; } - /// Take profit model class. abstract class TakeProfitModel extends Equatable { /// Initializes Take profit model class . @@ -879,16 +852,11 @@ abstract class TakeProfitModel extends Equatable { class TakeProfit extends TakeProfitModel { /// Initializes Take profit class. const TakeProfit({ - String? displayName, - double? orderAmount, - DateTime? orderDate, - String? value, - }) : super( - displayName: displayName, - orderAmount: orderAmount, - orderDate: orderDate, - value: value, - ); + super.displayName, + super.orderAmount, + super.orderDate, + super.value, + }); /// Creates an instance from JSON. factory TakeProfit.fromJson(Map json) => TakeProfit( @@ -931,7 +899,6 @@ class TakeProfit extends TakeProfitModel { orderAmount, ]; } - /// Subscription model class. abstract class SubscriptionModel { /// Initializes Subscription model class . @@ -947,10 +914,8 @@ abstract class SubscriptionModel { class Subscription extends SubscriptionModel { /// Initializes Subscription class. const Subscription({ - required String id, - }) : super( - id: id, - ); + required super.id, + }); /// Creates an instance from JSON. factory Subscription.fromJson(Map json) => Subscription( diff --git a/lib/api/response/reality_check_response_result.dart b/lib/api/response/reality_check_response_result.dart index 53a719a58a..e2e438b247 100644 --- a/lib/api/response/reality_check_response_result.dart +++ b/lib/api/response/reality_check_response_result.dart @@ -58,7 +58,7 @@ class RealityCheckResponse extends RealityCheckResponseModel { /// A `reality check` means a display of time elapsed since the session began, and associated client profit/loss. /// The reality check facility is a regulatory requirement for certain landing companies. /// For parameters information refer to [RealityCheckRequest]. - /// Throws a [RealityCheckException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future check([ RealityCheckRequest? request, ]) async { @@ -69,7 +69,7 @@ class RealityCheckResponse extends RealityCheckResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - RealityCheckException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return RealityCheckResponse.fromJson(response.realityCheck); diff --git a/lib/api/response/reset_password_response_result.dart b/lib/api/response/reset_password_response_result.dart index bbfdbf6f90..12100483f2 100644 --- a/lib/api/response/reset_password_response_result.dart +++ b/lib/api/response/reset_password_response_result.dart @@ -58,7 +58,7 @@ class ResetPasswordResponse extends ResetPasswordResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - UserException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return ResetPasswordResponse.fromJson(response?.resetPassword); diff --git a/lib/api/response/residence_list_response_result.dart b/lib/api/response/residence_list_response_result.dart index 17aa6b3cfd..81bd209701 100644 --- a/lib/api/response/residence_list_response_result.dart +++ b/lib/api/response/residence_list_response_result.dart @@ -25,10 +25,8 @@ abstract class ResidenceListResponseModel { class ResidenceListResponse extends ResidenceListResponseModel { /// Initializes Residence list response class. const ResidenceListResponse({ - List? residenceList, - }) : super( - residenceList: residenceList, - ); + super.residenceList, + }); /// Creates an instance from JSON. factory ResidenceListResponse.fromJson( @@ -63,7 +61,7 @@ class ResidenceListResponse extends ResidenceListResponseModel { /// Gets Residence list for the given [ResidenceListRequest] /// - /// Throws a [ResidenceException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future fetchResidenceList([ ResidenceListRequest? request, ]) async { @@ -74,7 +72,7 @@ class ResidenceListResponse extends ResidenceListResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - ResidenceException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return ResidenceListResponse.fromJson(response.residenceList); @@ -88,7 +86,6 @@ class ResidenceListResponse extends ResidenceListResponseModel { residenceList: residenceList ?? this.residenceList, ); } - /// Residence list item model class. abstract class ResidenceListItemModel { /// Initializes Residence list item model class . @@ -128,22 +125,14 @@ abstract class ResidenceListItemModel { class ResidenceListItem extends ResidenceListItemModel { /// Initializes Residence list item class. const ResidenceListItem({ - String? disabled, - Identity? identity, - String? phoneIdd, - String? selected, - String? text, - List? tinFormat, - String? value, - }) : super( - disabled: disabled, - identity: identity, - phoneIdd: phoneIdd, - selected: selected, - text: text, - tinFormat: tinFormat, - value: value, - ); + super.disabled, + super.identity, + super.phoneIdd, + super.selected, + super.text, + super.tinFormat, + super.value, + }); /// Creates an instance from JSON. factory ResidenceListItem.fromJson(Map json) => @@ -208,7 +197,6 @@ class ResidenceListItem extends ResidenceListItemModel { value: value ?? this.value, ); } - /// Identity model class. abstract class IdentityModel { /// Initializes Identity model class . @@ -224,10 +212,8 @@ abstract class IdentityModel { class Identity extends IdentityModel { /// Initializes Identity class. const Identity({ - Services? services, - }) : super( - services: services, - ); + super.services, + }); /// Creates an instance from JSON. factory Identity.fromJson(Map json) => Identity( @@ -255,7 +241,6 @@ class Identity extends IdentityModel { services: services ?? this.services, ); } - /// Services model class. abstract class ServicesModel { /// Initializes Services model class . @@ -275,12 +260,9 @@ abstract class ServicesModel { class Services extends ServicesModel { /// Initializes Services class. const Services({ - Idv? idv, - Onfido? onfido, - }) : super( - idv: idv, - onfido: onfido, - ); + super.idv, + super.onfido, + }); /// Creates an instance from JSON. factory Services.fromJson(Map json) => Services( @@ -312,7 +294,6 @@ class Services extends ServicesModel { onfido: onfido ?? this.onfido, ); } - /// Idv model class. abstract class IdvModel { /// Initializes Idv model class . @@ -336,14 +317,10 @@ abstract class IdvModel { class Idv extends IdvModel { /// Initializes Idv class. const Idv({ - Map? documentsSupported, - bool? hasVisualSample, - bool? isCountrySupported, - }) : super( - documentsSupported: documentsSupported, - hasVisualSample: hasVisualSample, - isCountrySupported: isCountrySupported, - ); + super.documentsSupported, + super.hasVisualSample, + super.isCountrySupported, + }); /// Creates an instance from JSON. factory Idv.fromJson(Map json) => Idv( @@ -383,15 +360,18 @@ class Idv extends IdvModel { isCountrySupported: isCountrySupported ?? this.isCountrySupported, ); } - /// Documents supported property model class. abstract class DocumentsSupportedPropertyModel { /// Initializes Documents supported property model class . const DocumentsSupportedPropertyModel({ + this.additional, this.displayName, this.format, }); + /// [Optional] Additional input required from the user + final Additional? additional; + /// The localized display name final String? displayName; @@ -403,16 +383,17 @@ abstract class DocumentsSupportedPropertyModel { class DocumentsSupportedProperty extends DocumentsSupportedPropertyModel { /// Initializes Documents supported property class. const DocumentsSupportedProperty({ - String? displayName, - String? format, - }) : super( - displayName: displayName, - format: format, - ); + super.additional, + super.displayName, + super.format, + }); /// Creates an instance from JSON. factory DocumentsSupportedProperty.fromJson(Map json) => DocumentsSupportedProperty( + additional: json['additional'] == null + ? null + : Additional.fromJson(json['additional']), displayName: json['display_name'], format: json['format'], ); @@ -421,6 +402,9 @@ class DocumentsSupportedProperty extends DocumentsSupportedPropertyModel { Map toJson() { final Map resultMap = {}; + if (additional != null) { + resultMap['additional'] = additional!.toJson(); + } resultMap['display_name'] = displayName; resultMap['format'] = format; @@ -429,15 +413,65 @@ class DocumentsSupportedProperty extends DocumentsSupportedPropertyModel { /// Creates a copy of instance with given parameters. DocumentsSupportedProperty copyWith({ + Additional? additional, String? displayName, String? format, }) => DocumentsSupportedProperty( + additional: additional ?? this.additional, displayName: displayName ?? this.displayName, format: format ?? this.format, ); } +/// Additional model class. +abstract class AdditionalModel { + /// Initializes Additional model class . + const AdditionalModel({ + this.displayName, + this.format, + }); + /// The localized display name + final String? displayName; + + /// [Optional] Regex pattern to validate documents + final String? format; +} + +/// Additional class. +class Additional extends AdditionalModel { + /// Initializes Additional class. + const Additional({ + super.displayName, + super.format, + }); + + /// Creates an instance from JSON. + factory Additional.fromJson(Map json) => Additional( + displayName: json['display_name'], + format: json['format'], + ); + + /// Converts an instance to JSON. + Map toJson() { + final Map resultMap = {}; + + resultMap['display_name'] = displayName; + resultMap['format'] = format; + + return resultMap; + } + + /// Creates a copy of instance with given parameters. + Additional copyWith({ + String? displayName, + String? format, + }) => + Additional( + displayName: displayName ?? this.displayName, + format: format ?? this.format, + ); +} /// Onfido model class. abstract class OnfidoModel { /// Initializes Onfido model class . @@ -458,13 +492,9 @@ abstract class OnfidoModel { class Onfido extends OnfidoModel { /// Initializes Onfido class. const Onfido({ - Map? - documentsSupported, - bool? isCountrySupported, - }) : super( - documentsSupported: documentsSupported, - isCountrySupported: isCountrySupported, - ); + super.documentsSupported, + super.isCountrySupported, + }); /// Creates an instance from JSON. factory Onfido.fromJson(Map json) => Onfido( @@ -503,7 +533,6 @@ class Onfido extends OnfidoModel { isCountrySupported: isCountrySupported ?? this.isCountrySupported, ); } - /// Documents supported documents supported property model class. abstract class DocumentsSupportedDocumentsSupportedPropertyModel { /// Initializes Documents supported documents supported property model class . @@ -524,12 +553,9 @@ class DocumentsSupportedDocumentsSupportedProperty extends DocumentsSupportedDocumentsSupportedPropertyModel { /// Initializes Documents supported documents supported property class. const DocumentsSupportedDocumentsSupportedProperty({ - String? displayName, - String? format, - }) : super( - displayName: displayName, - format: format, - ); + super.displayName, + super.format, + }); /// Creates an instance from JSON. factory DocumentsSupportedDocumentsSupportedProperty.fromJson( diff --git a/lib/api/response/revoke_oauth_app_response_result.dart b/lib/api/response/revoke_oauth_app_response_result.dart index c37c883105..ab6cda2c65 100644 --- a/lib/api/response/revoke_oauth_app_response_result.dart +++ b/lib/api/response/revoke_oauth_app_response_result.dart @@ -52,7 +52,7 @@ class RevokeOauthAppResponse extends RevokeOauthAppResponseModel { /// Revokes access of a particular app. /// /// For parameters information refer to [RevokeOauthAppRequest]. - /// Throws an [AppException] if API response contains an error + /// Throws an [BaseAPIException] if API response contains an error static Future revokeOauthApplication( RevokeOauthAppRequest request, ) async { @@ -61,7 +61,7 @@ class RevokeOauthAppResponse extends RevokeOauthAppResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - AppException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return RevokeOauthAppResponse.fromJson(response.revokeOauthApp); diff --git a/lib/api/response/sell_response_result.dart b/lib/api/response/sell_response_result.dart index c7950c4531..8bf308af2c 100644 --- a/lib/api/response/sell_response_result.dart +++ b/lib/api/response/sell_response_result.dart @@ -56,14 +56,14 @@ class SellResponse extends SellResponseModel { /// Sells a contract with parameters specified in [SellRequest]. /// - /// Throws a [ContractOperationException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future sellContract(SellRequest request) async { final SellReceive response = await _api.call(request: request); checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - ContractOperationException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return SellResponse.fromJson(response.sell); @@ -71,7 +71,7 @@ class SellResponse extends SellResponseModel { /// tries to sell any expired contracts and returns the number of sold contracts as [SellExpiredContractModel]. /// - /// Throws [ContractOperationException] if API response contains an error + /// Throws [BaseAPIException] if API response contains an error static Future sellExpiredContracts([ SellExpiredRequest? request, ]) async { @@ -82,7 +82,7 @@ class SellResponse extends SellResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - ContractOperationException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return SellExpiredResponse.fromJson(response.sellExpired); diff --git a/lib/api/response/service_token_response_result.dart b/lib/api/response/service_token_response_result.dart index 69be61aaf3..89450d7139 100644 --- a/lib/api/response/service_token_response_result.dart +++ b/lib/api/response/service_token_response_result.dart @@ -26,10 +26,8 @@ abstract class ServiceTokenResponseModel { class ServiceTokenResponse extends ServiceTokenResponseModel { /// Initializes Service token response class. const ServiceTokenResponse({ - ServiceToken? serviceToken, - }) : super( - serviceToken: serviceToken, - ); + super.serviceToken, + }); /// Creates an instance from JSON. factory ServiceTokenResponse.fromJson( @@ -58,7 +56,7 @@ class ServiceTokenResponse extends ServiceTokenResponseModel { /// /// Retrieves the authorization token for the specified service. /// For parameters information refer to [ServiceTokenRequest]. - /// Throws a [APITokenException] if API response contains an error. + /// Throws a [BaseAPIException] if API response contains an error. static Future getServiceTokenRaw( ServiceTokenRequest request, ) async { @@ -67,7 +65,7 @@ class ServiceTokenResponse extends ServiceTokenResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - APITokenException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return response; @@ -77,7 +75,7 @@ class ServiceTokenResponse extends ServiceTokenResponseModel { /// /// Retrieves the authorization token for the specified service. /// For parameters information refer to [ServiceTokenRequest]. - /// Throws a [APITokenException] if API response contains an error. + /// Throws a [BaseAPIException] if API response contains an error. static Future getServiceToken( ServiceTokenRequest request, ) async { @@ -94,12 +92,12 @@ class ServiceTokenResponse extends ServiceTokenResponseModel { serviceToken: serviceToken ?? this.serviceToken, ); } - /// Service token model class. abstract class ServiceTokenModel { /// Initializes Service token model class . const ServiceTokenModel({ this.banxa, + this.ctrader, this.dxtrade, this.onfido, this.pandats, @@ -110,13 +108,16 @@ abstract class ServiceTokenModel { /// Banxa order data. final Banxa? banxa; + /// CTrader data. + final Ctrader? ctrader; + /// Deriv X data. final Dxtrade? dxtrade; /// Onfido data. final Onfido? onfido; - /// pandats data. + /// Deriv EZ data. final Pandats? pandats; /// Sendbird data. @@ -130,24 +131,20 @@ abstract class ServiceTokenModel { class ServiceToken extends ServiceTokenModel { /// Initializes Service token class. const ServiceToken({ - Banxa? banxa, - Dxtrade? dxtrade, - Onfido? onfido, - Pandats? pandats, - Sendbird? sendbird, - Wyre? wyre, - }) : super( - banxa: banxa, - dxtrade: dxtrade, - onfido: onfido, - pandats: pandats, - sendbird: sendbird, - wyre: wyre, - ); + super.banxa, + super.ctrader, + super.dxtrade, + super.onfido, + super.pandats, + super.sendbird, + super.wyre, + }); /// Creates an instance from JSON. factory ServiceToken.fromJson(Map json) => ServiceToken( banxa: json['banxa'] == null ? null : Banxa.fromJson(json['banxa']), + ctrader: + json['ctrader'] == null ? null : Ctrader.fromJson(json['ctrader']), dxtrade: json['dxtrade'] == null ? null : Dxtrade.fromJson(json['dxtrade']), onfido: json['onfido'] == null ? null : Onfido.fromJson(json['onfido']), @@ -166,6 +163,9 @@ class ServiceToken extends ServiceTokenModel { if (banxa != null) { resultMap['banxa'] = banxa!.toJson(); } + if (ctrader != null) { + resultMap['ctrader'] = ctrader!.toJson(); + } if (dxtrade != null) { resultMap['dxtrade'] = dxtrade!.toJson(); } @@ -188,6 +188,7 @@ class ServiceToken extends ServiceTokenModel { /// Creates a copy of instance with given parameters. ServiceToken copyWith({ Banxa? banxa, + Ctrader? ctrader, Dxtrade? dxtrade, Onfido? onfido, Pandats? pandats, @@ -196,6 +197,7 @@ class ServiceToken extends ServiceTokenModel { }) => ServiceToken( banxa: banxa ?? this.banxa, + ctrader: ctrader ?? this.ctrader, dxtrade: dxtrade ?? this.dxtrade, onfido: onfido ?? this.onfido, pandats: pandats ?? this.pandats, @@ -203,7 +205,6 @@ class ServiceToken extends ServiceTokenModel { wyre: wyre ?? this.wyre, ); } - /// Banxa model class. abstract class BanxaModel { /// Initializes Banxa model class . @@ -227,14 +228,10 @@ abstract class BanxaModel { class Banxa extends BanxaModel { /// Initializes Banxa class. const Banxa({ - String? token, - String? url, - String? urlIframe, - }) : super( - token: token, - url: url, - urlIframe: urlIframe, - ); + super.token, + super.url, + super.urlIframe, + }); /// Creates an instance from JSON. factory Banxa.fromJson(Map json) => Banxa( @@ -266,7 +263,46 @@ class Banxa extends BanxaModel { urlIframe: urlIframe ?? this.urlIframe, ); } +/// Ctrader model class. +abstract class CtraderModel { + /// Initializes Ctrader model class . + const CtraderModel({ + this.token, + }); + + /// CTrader One Time token + final String? token; +} + +/// Ctrader class. +class Ctrader extends CtraderModel { + /// Initializes Ctrader class. + const Ctrader({ + super.token, + }); + + /// Creates an instance from JSON. + factory Ctrader.fromJson(Map json) => Ctrader( + token: json['token'], + ); + + /// Converts an instance to JSON. + Map toJson() { + final Map resultMap = {}; + + resultMap['token'] = token; + return resultMap; + } + + /// Creates a copy of instance with given parameters. + Ctrader copyWith({ + String? token, + }) => + Ctrader( + token: token ?? this.token, + ); +} /// Dxtrade model class. abstract class DxtradeModel { /// Initializes Dxtrade model class . @@ -282,10 +318,8 @@ abstract class DxtradeModel { class Dxtrade extends DxtradeModel { /// Initializes Dxtrade class. const Dxtrade({ - String? token, - }) : super( - token: token, - ); + super.token, + }); /// Creates an instance from JSON. factory Dxtrade.fromJson(Map json) => Dxtrade( @@ -309,7 +343,6 @@ class Dxtrade extends DxtradeModel { token: token ?? this.token, ); } - /// Onfido model class. abstract class OnfidoModel { /// Initializes Onfido model class . @@ -325,10 +358,8 @@ abstract class OnfidoModel { class Onfido extends OnfidoModel { /// Initializes Onfido class. const Onfido({ - String? token, - }) : super( - token: token, - ); + super.token, + }); /// Creates an instance from JSON. factory Onfido.fromJson(Map json) => Onfido( @@ -352,7 +383,6 @@ class Onfido extends OnfidoModel { token: token ?? this.token, ); } - /// Pandats model class. abstract class PandatsModel { /// Initializes Pandats model class . @@ -360,7 +390,7 @@ abstract class PandatsModel { this.token, }); - /// Pandats token. + /// Deriv EZ SSO token final String? token; } @@ -368,10 +398,8 @@ abstract class PandatsModel { class Pandats extends PandatsModel { /// Initializes Pandats class. const Pandats({ - String? token, - }) : super( - token: token, - ); + super.token, + }); /// Creates an instance from JSON. factory Pandats.fromJson(Map json) => Pandats( @@ -395,7 +423,6 @@ class Pandats extends PandatsModel { token: token ?? this.token, ); } - /// Sendbird model class. abstract class SendbirdModel { /// Initializes Sendbird model class . @@ -419,14 +446,10 @@ abstract class SendbirdModel { class Sendbird extends SendbirdModel { /// Initializes Sendbird class. const Sendbird({ - String? appId, - DateTime? expiryTime, - String? token, - }) : super( - appId: appId, - expiryTime: expiryTime, - token: token, - ); + super.appId, + super.expiryTime, + super.token, + }); /// Creates an instance from JSON. factory Sendbird.fromJson(Map json) => Sendbird( @@ -458,7 +481,6 @@ class Sendbird extends SendbirdModel { token: token ?? this.token, ); } - /// Wyre model class. abstract class WyreModel { /// Initializes Wyre model class . @@ -478,12 +500,9 @@ abstract class WyreModel { class Wyre extends WyreModel { /// Initializes Wyre class. const Wyre({ - String? token, - String? url, - }) : super( - token: token, - url: url, - ); + super.token, + super.url, + }); /// Creates an instance from JSON. factory Wyre.fromJson(Map json) => Wyre( diff --git a/lib/api/response/set_account_currency_response_result.dart b/lib/api/response/set_account_currency_response_result.dart index 162d16114a..e468ea9aa2 100644 --- a/lib/api/response/set_account_currency_response_result.dart +++ b/lib/api/response/set_account_currency_response_result.dart @@ -53,7 +53,7 @@ class SetAccountCurrencyResponse extends SetAccountCurrencyResponseModel { /// /// Please note that account currency can only be set once, and then can never be changed. /// For parameters information refer to [SetAccountCurrencyRequest]. - /// Throws an [AccountCurrencyException] if API response contains an error + /// Throws an [BaseAPIException] if API response contains an error static Future setCurrency( SetAccountCurrencyRequest request, ) async { @@ -63,7 +63,7 @@ class SetAccountCurrencyResponse extends SetAccountCurrencyResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - AccountCurrencyException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return SetAccountCurrencyResponse.fromJson(response.setAccountCurrency); diff --git a/lib/api/response/set_financial_assessment_response_result.dart b/lib/api/response/set_financial_assessment_response_result.dart index f5574aae3a..24f0b02bb8 100644 --- a/lib/api/response/set_financial_assessment_response_result.dart +++ b/lib/api/response/set_financial_assessment_response_result.dart @@ -59,7 +59,7 @@ class SetFinancialAssessmentResponse /// understand the risks involved with binary options trading. /// /// For parameters information refer to [SetFinancialAssessmentRequest]. - /// Throws a [FinancialAssessmentException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future setAssessment( SetFinancialAssessmentRequest request, ) async { @@ -69,7 +69,7 @@ class SetFinancialAssessmentResponse checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - FinancialAssessmentException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return SetFinancialAssessmentResponse.fromJson( diff --git a/lib/api/response/set_self_exclusion_response_result.dart b/lib/api/response/set_self_exclusion_response_result.dart index d778d02380..5e6e1857d6 100644 --- a/lib/api/response/set_self_exclusion_response_result.dart +++ b/lib/api/response/set_self_exclusion_response_result.dart @@ -52,7 +52,7 @@ class SetSelfExclusionResponse extends SetSelfExclusionResponseModel { /// Sets Self-Exclusion (this call should be used in conjunction with [fetchSelfExclusion]) /// /// For parameters information refer to [SetSelfExclusionRequest]. - /// Throws a [SelfExclusionException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future setSelfExclusionMethod( SetSelfExclusionRequest request) async { final SetSelfExclusionReceive response = await _api.call(request: request); @@ -60,7 +60,7 @@ class SetSelfExclusionResponse extends SetSelfExclusionResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - SelfExclusionException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return SetSelfExclusionResponse.fromJson(response.setSelfExclusion); diff --git a/lib/api/response/set_settings_response_result.dart b/lib/api/response/set_settings_response_result.dart index 36199363d0..a48625a2c4 100644 --- a/lib/api/response/set_settings_response_result.dart +++ b/lib/api/response/set_settings_response_result.dart @@ -51,7 +51,7 @@ class SetSettingsResponse extends SetSettingsResponseModel { /// Changes the user's settings with parameters specified as [SetSettingsRequest] /// - /// Throws an [AccountSettingsException] if API response contains an error + /// Throws an [BaseAPIException] if API response contains an error static Future changeAccountSetting( SetSettingsRequest request, ) async { @@ -60,7 +60,7 @@ class SetSettingsResponse extends SetSettingsResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - AccountSettingsException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return SetSettingsResponse(setSettings: response.setSettings ?? 0); diff --git a/lib/api/response/statement_response_result.dart b/lib/api/response/statement_response_result.dart index 2c4bd3cec2..c5b60f4ebb 100644 --- a/lib/api/response/statement_response_result.dart +++ b/lib/api/response/statement_response_result.dart @@ -55,14 +55,14 @@ class StatementResponse extends StatementResponseModel { /// Retrieves a summary of account transactions, according to given search criteria. /// /// For parameters information refer to [StatementRequest]. - /// Throws a [StatementException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future fetch(StatementRequest request) async { final StatementReceive response = await _api.call(request: request); checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - StatementException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return StatementResponse.fromJson(response.statement); diff --git a/lib/api/response/states_list_response_result.dart b/lib/api/response/states_list_response_result.dart index 0482ec3ed3..bab5ab4094 100644 --- a/lib/api/response/states_list_response_result.dart +++ b/lib/api/response/states_list_response_result.dart @@ -63,7 +63,7 @@ class StatesListResponse extends StatesListResponseModel { /// Gets the list of states for the given [StatesListRequest] /// - /// Throws a [StateException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future fetchStatesList( StatesListRequest request) async { final StatesListReceive response = await _api.call(request: request); @@ -71,7 +71,7 @@ class StatesListResponse extends StatesListResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - StateException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return StatesListResponse.fromJson(response.statesList); diff --git a/lib/api/response/ticks_history_response_result.dart b/lib/api/response/ticks_history_response_result.dart index af6c13e6d5..6f5ad2d9db 100644 --- a/lib/api/response/ticks_history_response_result.dart +++ b/lib/api/response/ticks_history_response_result.dart @@ -104,7 +104,7 @@ class TicksHistoryResponse extends TicksHistoryResponseModel { /// Gets the [TickHistory] for the given [symbol] in [request] /// - /// Throws a [TickException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future fetchTickHistory( TicksHistoryRequest request, ) async { @@ -113,7 +113,7 @@ class TicksHistoryResponse extends TicksHistoryResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - TickException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return TicksHistoryResponse.fromJson(response.candles, response.history, @@ -122,7 +122,7 @@ class TicksHistoryResponse extends TicksHistoryResponseModel { /// Gets ticks history and its stream /// - /// Throws [TickException] if API response contains an error + /// Throws [BaseAPIException] if API response contains an error static Future fetchTicksAndSubscribe( TicksHistoryRequest request, { RequestCompareFunction? comparePredicate, @@ -136,7 +136,7 @@ class TicksHistoryResponse extends TicksHistoryResponseModel { checkException( response: firstResponse, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - TickException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); if (firstResponse is TicksHistoryReceive) { return TickHistorySubscription( @@ -150,7 +150,7 @@ class TicksHistoryResponse extends TicksHistoryResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - TickException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return response is TicksReceive diff --git a/lib/api/response/ticks_response_result.dart b/lib/api/response/ticks_response_result.dart index 86a322574f..d689bceb68 100644 --- a/lib/api/response/ticks_response_result.dart +++ b/lib/api/response/ticks_response_result.dart @@ -71,7 +71,7 @@ class TicksResponse extends TicksResponseModel { /// Subscribes to a tick for given [TickRequest] /// - /// Throws [TickException] if API response contains an error + /// Throws [BaseAPIException] if API response contains an error static Stream subscribeTick( TicksRequest tickRequest, { RequestCompareFunction? comparePredicate, @@ -83,7 +83,7 @@ class TicksResponse extends TicksResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - TickException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return response is TicksReceive @@ -97,7 +97,7 @@ class TicksResponse extends TicksResponseModel { /// Unsubscribes all ticks. /// - /// Throws a [TickException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future unsubscribeAllTicks() async { final ForgetAllReceive response = await _api.unsubscribeAll(method: ForgetStreamType.ticks); @@ -105,7 +105,7 @@ class TicksResponse extends TicksResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - TickException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return ForgetAllResponse.fromJson(response.forgetAll); diff --git a/lib/api/response/time_response_result.dart b/lib/api/response/time_response_result.dart index 0fd05e0ffc..08a3227a67 100644 --- a/lib/api/response/time_response_result.dart +++ b/lib/api/response/time_response_result.dart @@ -61,7 +61,7 @@ class TimeResponse extends TimeResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - ServerTimeException(), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return response; diff --git a/lib/api/response/tnc_approval_response_result.dart b/lib/api/response/tnc_approval_response_result.dart index e439792bd0..1966a1926e 100644 --- a/lib/api/response/tnc_approval_response_result.dart +++ b/lib/api/response/tnc_approval_response_result.dart @@ -52,7 +52,7 @@ class TncApprovalResponse extends TncApprovalResponseModel { /// Approve the latest version of terms and conditions. /// /// For parameters information refer to [TncApprovalRequest]. - /// Throws a [UserException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future verify( TncApprovalRequest request, ) async { @@ -61,7 +61,7 @@ class TncApprovalResponse extends TncApprovalResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - UserException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return TncApprovalResponse.fromJson(response.tncApproval); diff --git a/lib/api/response/topup_virtual_response_result.dart b/lib/api/response/topup_virtual_response_result.dart index df28ba593c..fb843a85b6 100644 --- a/lib/api/response/topup_virtual_response_result.dart +++ b/lib/api/response/topup_virtual_response_result.dart @@ -56,7 +56,7 @@ class TopupVirtualResponse extends TopupVirtualResponseModel { /// Topes up the virtual-money's account balance becomes when it becomes low. /// /// For parameters information refer to [TopupVirtualRequest]. - /// Throws a [TopUpVirtualException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future topUp([ TopupVirtualRequest? request, ]) async { @@ -67,7 +67,7 @@ class TopupVirtualResponse extends TopupVirtualResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - TopUpVirtualException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return TopupVirtualResponse.fromJson(response.topupVirtual); diff --git a/lib/api/response/trading_durations_response_result.dart b/lib/api/response/trading_durations_response_result.dart index 0b3b7a6ca8..9cc7dd36aa 100644 --- a/lib/api/response/trading_durations_response_result.dart +++ b/lib/api/response/trading_durations_response_result.dart @@ -65,7 +65,7 @@ class TradingDurationsResponse extends TradingDurationsResponseModel { /// /// If the user is logged in, only the assets available for that user's landing company will be returned. /// For parameters information refer to [TradingDurationsRequest]. - /// Throws a [TradingException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future fetchTradingDurations( TradingDurationsRequest request, ) async { @@ -74,7 +74,7 @@ class TradingDurationsResponse extends TradingDurationsResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - TradingException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return TradingDurationsResponse.fromJson(response.tradingDurations); diff --git a/lib/api/response/trading_platform_accounts_response_result.dart b/lib/api/response/trading_platform_accounts_response_result.dart index b019f395e6..a73ddb45c2 100644 --- a/lib/api/response/trading_platform_accounts_response_result.dart +++ b/lib/api/response/trading_platform_accounts_response_result.dart @@ -24,10 +24,8 @@ class TradingPlatformAccountsResponse extends TradingPlatformAccountsResponseModel { /// Initializes Trading platform accounts response class. const TradingPlatformAccountsResponse({ - List? tradingPlatformAccounts, - }) : super( - tradingPlatformAccounts: tradingPlatformAccounts, - ); + super.tradingPlatformAccounts, + }); /// Creates an instance from JSON. factory TradingPlatformAccountsResponse.fromJson( @@ -64,7 +62,7 @@ class TradingPlatformAccountsResponse /// /// Get list of Trading Platform accounts for client. /// For parameters information refer to [TradingPlatformAccountsRequest]. - /// Throws a [TradingPlatformException] if API response contains an error. + /// Throws a [BaseAPIException] if API response contains an error. static Future getAccounts( TradingPlatformAccountsRequest request, ) async { @@ -74,7 +72,7 @@ class TradingPlatformAccountsResponse checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - TradingPlatformException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return TradingPlatformAccountsResponse.fromJson( @@ -168,6 +166,7 @@ enum MarketTypeEnum { final Map platformEnumMapper = { "dxtrade": PlatformEnum.dxtrade, "mt5": PlatformEnum.mt5, + "ctrader": PlatformEnum.ctrader, }; /// Platform Enum. @@ -177,6 +176,9 @@ enum PlatformEnum { /// mt5. mt5, + + /// ctrader. + ctrader, } /// EnvironmentEnum mapper. @@ -204,6 +206,7 @@ final Map subAccountTypeEnumMapper = { "financial": SubAccountTypeEnum.financial, "financial_stp": SubAccountTypeEnum.financialStp, + "swap_free": SubAccountTypeEnum.swapFree, }; /// SubAccountType Enum. @@ -213,8 +216,10 @@ enum SubAccountTypeEnum { /// financial_stp. financialStp, -} + /// swap_free. + swapFree, +} /// Trading platform accounts item model class. abstract class TradingPlatformAccountsItemModel { /// Initializes Trading platform accounts item model class . @@ -298,44 +303,25 @@ abstract class TradingPlatformAccountsItemModel { class TradingPlatformAccountsItem extends TradingPlatformAccountsItemModel { /// Initializes Trading platform accounts item class. const TradingPlatformAccountsItem({ - String? accountId, - AccountTypeEnum? accountType, - double? balance, - String? country, - String? currency, - String? displayBalance, - String? email, - int? enabled, - String? group, - LandingCompanyShortEnum? landingCompanyShort, - double? leverage, - String? login, - MarketTypeEnum? marketType, - String? name, - PlatformEnum? platform, - String? server, - ServerInfo? serverInfo, - SubAccountTypeEnum? subAccountType, - }) : super( - accountId: accountId, - accountType: accountType, - balance: balance, - country: country, - currency: currency, - displayBalance: displayBalance, - email: email, - enabled: enabled, - group: group, - landingCompanyShort: landingCompanyShort, - leverage: leverage, - login: login, - marketType: marketType, - name: name, - platform: platform, - server: server, - serverInfo: serverInfo, - subAccountType: subAccountType, - ); + super.accountId, + super.accountType, + super.balance, + super.country, + super.currency, + super.displayBalance, + super.email, + super.enabled, + super.group, + super.landingCompanyShort, + super.leverage, + super.login, + super.marketType, + super.name, + super.platform, + super.server, + super.serverInfo, + super.subAccountType, + }); /// Creates an instance from JSON. factory TradingPlatformAccountsItem.fromJson(Map json) => @@ -457,7 +443,6 @@ class TradingPlatformAccountsItem extends TradingPlatformAccountsItemModel { subAccountType: subAccountType ?? this.subAccountType, ); } - /// Server info model class. abstract class ServerInfoModel { /// Initializes Server info model class . @@ -481,14 +466,10 @@ abstract class ServerInfoModel { class ServerInfo extends ServerInfoModel { /// Initializes Server info class. const ServerInfo({ - EnvironmentEnum? environment, - Geolocation? geolocation, - String? id, - }) : super( - environment: environment, - geolocation: geolocation, - id: id, - ); + super.environment, + super.geolocation, + super.id, + }); /// Creates an instance from JSON. factory ServerInfo.fromJson(Map json) => ServerInfo( @@ -529,7 +510,6 @@ class ServerInfo extends ServerInfoModel { id: id ?? this.id, ); } - /// Geolocation model class. abstract class GeolocationModel { /// Initializes Geolocation model class . @@ -543,13 +523,13 @@ abstract class GeolocationModel { /// Internal server grouping. final String? group; - /// Sever location. + /// Server location. final String? location; - /// Sever region. + /// Server region. final String? region; - /// Sever sequence. + /// Server sequence. final int? sequence; } @@ -557,16 +537,11 @@ abstract class GeolocationModel { class Geolocation extends GeolocationModel { /// Initializes Geolocation class. const Geolocation({ - String? group, - String? location, - String? region, - int? sequence, - }) : super( - group: group, - location: location, - region: region, - sequence: sequence, - ); + super.group, + super.location, + super.region, + super.sequence, + }); /// Creates an instance from JSON. factory Geolocation.fromJson(Map json) => Geolocation( diff --git a/lib/api/response/trading_platform_asset_listing_response_result.dart b/lib/api/response/trading_platform_asset_listing_response_result.dart new file mode 100644 index 0000000000..2f5f36c8cd --- /dev/null +++ b/lib/api/response/trading_platform_asset_listing_response_result.dart @@ -0,0 +1,274 @@ +// ignore_for_file: prefer_single_quotes, unnecessary_import, unused_import + +import 'package:equatable/equatable.dart'; + +import 'package:flutter_deriv_api/helpers/helpers.dart'; + +/// Trading platform asset listing response model class. +abstract class TradingPlatformAssetListingResponseModel { + /// Initializes Trading platform asset listing response model class . + const TradingPlatformAssetListingResponseModel({ + this.tradingPlatformAssetListing, + this.subscription, + }); + + /// Containing Trading asset objects. + final Map? + tradingPlatformAssetListing; + + /// For subscription requests only. + final Subscription? subscription; +} + +/// Trading platform asset listing response class. +class TradingPlatformAssetListingResponse + extends TradingPlatformAssetListingResponseModel { + /// Initializes Trading platform asset listing response class. + const TradingPlatformAssetListingResponse({ + super.tradingPlatformAssetListing, + super.subscription, + }); + + /// Creates an instance from JSON. + factory TradingPlatformAssetListingResponse.fromJson( + dynamic tradingPlatformAssetListingJson, + dynamic subscriptionJson, + ) => + TradingPlatformAssetListingResponse( + tradingPlatformAssetListing: tradingPlatformAssetListingJson == null + ? null + : Map.fromEntries( + tradingPlatformAssetListingJson.entries.map< + MapEntry>( + (MapEntry entry) => + MapEntry( + entry.key, + TradingPlatformAssetListingProperty.fromJson( + entry.value)))), + subscription: subscriptionJson == null + ? null + : Subscription.fromJson(subscriptionJson), + ); + + /// Converts an instance to JSON. + Map toJson() { + final Map resultMap = {}; + + resultMap['trading_platform_asset_listing'] = tradingPlatformAssetListing; + if (subscription != null) { + resultMap['subscription'] = subscription!.toJson(); + } + + return resultMap; + } + + /// Creates a copy of instance with given parameters. + TradingPlatformAssetListingResponse copyWith({ + Map? + tradingPlatformAssetListing, + Subscription? subscription, + }) => + TradingPlatformAssetListingResponse( + tradingPlatformAssetListing: + tradingPlatformAssetListing ?? this.tradingPlatformAssetListing, + subscription: subscription ?? this.subscription, + ); +} +/// Trading platform asset listing property model class. +abstract class TradingPlatformAssetListingPropertyModel { + /// Initializes Trading platform asset listing property model class . + const TradingPlatformAssetListingPropertyModel({ + this.assets, + }); + + /// MT5 assets. + final List? assets; +} + +/// Trading platform asset listing property class. +class TradingPlatformAssetListingProperty + extends TradingPlatformAssetListingPropertyModel { + /// Initializes Trading platform asset listing property class. + const TradingPlatformAssetListingProperty({ + super.assets, + }); + + /// Creates an instance from JSON. + factory TradingPlatformAssetListingProperty.fromJson( + Map json) => + TradingPlatformAssetListingProperty( + assets: json['assets'] == null + ? null + : List.from( + json['assets']?.map( + (dynamic item) => AssetsItem.fromJson(item), + ), + ), + ); + + /// Converts an instance to JSON. + Map toJson() { + final Map resultMap = {}; + + if (assets != null) { + resultMap['assets'] = assets! + .map( + (AssetsItem item) => item.toJson(), + ) + .toList(); + } + + return resultMap; + } + + /// Creates a copy of instance with given parameters. + TradingPlatformAssetListingProperty copyWith({ + List? assets, + }) => + TradingPlatformAssetListingProperty( + assets: assets ?? this.assets, + ); +} +/// Assets item model class. +abstract class AssetsItemModel { + /// Initializes Assets item model class . + const AssetsItemModel({ + this.ask, + this.bid, + this.dayPercentageChange, + this.displayOrder, + this.market, + this.shortcode, + this.spread, + this.symbol, + }); + + /// Ask price of asset. + final double? ask; + + /// Bid price of asset. + final double? bid; + + /// 1 day percentage change of price. + final String? dayPercentageChange; + + /// Display order of asset. + final double? displayOrder; + + /// Market type of asset. + final String? market; + + /// The asset shortcode. + final String? shortcode; + + /// Spread of asset. + final double? spread; + + /// Asset symbol. + final String? symbol; +} + +/// Assets item class. +class AssetsItem extends AssetsItemModel { + /// Initializes Assets item class. + const AssetsItem({ + super.ask, + super.bid, + super.dayPercentageChange, + super.displayOrder, + super.market, + super.shortcode, + super.spread, + super.symbol, + }); + + /// Creates an instance from JSON. + factory AssetsItem.fromJson(Map json) => AssetsItem( + ask: getDouble(json['ask']), + bid: getDouble(json['bid']), + dayPercentageChange: json['day_percentage_change'], + displayOrder: getDouble(json['display_order']), + market: json['market'], + shortcode: json['shortcode'], + spread: getDouble(json['spread']), + symbol: json['symbol'], + ); + + /// Converts an instance to JSON. + Map toJson() { + final Map resultMap = {}; + + resultMap['ask'] = ask; + resultMap['bid'] = bid; + resultMap['day_percentage_change'] = dayPercentageChange; + resultMap['display_order'] = displayOrder; + resultMap['market'] = market; + resultMap['shortcode'] = shortcode; + resultMap['spread'] = spread; + resultMap['symbol'] = symbol; + + return resultMap; + } + + /// Creates a copy of instance with given parameters. + AssetsItem copyWith({ + double? ask, + double? bid, + String? dayPercentageChange, + double? displayOrder, + String? market, + String? shortcode, + double? spread, + String? symbol, + }) => + AssetsItem( + ask: ask ?? this.ask, + bid: bid ?? this.bid, + dayPercentageChange: dayPercentageChange ?? this.dayPercentageChange, + displayOrder: displayOrder ?? this.displayOrder, + market: market ?? this.market, + shortcode: shortcode ?? this.shortcode, + spread: spread ?? this.spread, + symbol: symbol ?? this.symbol, + ); +} +/// Subscription model class. +abstract class SubscriptionModel { + /// Initializes Subscription model class . + const SubscriptionModel({ + required this.id, + }); + + /// A per-connection unique identifier. Can be passed to the `forget` API call to unsubscribe. + final String id; +} + +/// Subscription class. +class Subscription extends SubscriptionModel { + /// Initializes Subscription class. + const Subscription({ + required super.id, + }); + + /// Creates an instance from JSON. + factory Subscription.fromJson(Map json) => Subscription( + id: json['id'], + ); + + /// Converts an instance to JSON. + Map toJson() { + final Map resultMap = {}; + + resultMap['id'] = id; + + return resultMap; + } + + /// Creates a copy of instance with given parameters. + Subscription copyWith({ + String? id, + }) => + Subscription( + id: id ?? this.id, + ); +} diff --git a/lib/api/response/trading_platform_available_accounts_response_result.dart b/lib/api/response/trading_platform_available_accounts_response_result.dart index a1a4afc9f2..57817492b9 100644 --- a/lib/api/response/trading_platform_available_accounts_response_result.dart +++ b/lib/api/response/trading_platform_available_accounts_response_result.dart @@ -21,11 +21,8 @@ class TradingPlatformAvailableAccountsResponse extends TradingPlatformAvailableAccountsResponseModel { /// Initializes Trading platform available accounts response class. const TradingPlatformAvailableAccountsResponse({ - List? - tradingPlatformAvailableAccounts, - }) : super( - tradingPlatformAvailableAccounts: tradingPlatformAvailableAccounts, - ); + super.tradingPlatformAvailableAccounts, + }); /// Creates an instance from JSON. factory TradingPlatformAvailableAccountsResponse.fromJson( @@ -70,11 +67,30 @@ class TradingPlatformAvailableAccountsResponse ); } +/// LinkableLandingCompaniesItemEnum mapper. +final Map + linkableLandingCompaniesItemEnumMapper = + { + "svg": LinkableLandingCompaniesItemEnum.svg, + "maltainvest": LinkableLandingCompaniesItemEnum.maltainvest, +}; + +/// LinkableLandingCompaniesItem Enum. +enum LinkableLandingCompaniesItemEnum { + /// svg. + svg, + + /// maltainvest. + maltainvest, +} + /// MarketTypeEnum mapper. final Map marketTypeEnumMapper = { "financial": MarketTypeEnum.financial, + "synthetic": MarketTypeEnum.synthetic, "gaming": MarketTypeEnum.gaming, + "all": MarketTypeEnum.all, }; /// MarketType Enum. @@ -82,14 +98,21 @@ enum MarketTypeEnum { /// financial. financial, + /// synthetic. + synthetic, + /// gaming. gaming, + + /// all. + all, } /// SubAccountTypeEnum mapper. final Map subAccountTypeEnumMapper = { "standard": SubAccountTypeEnum.standard, + "swap_free": SubAccountTypeEnum.swapFree, "stp": SubAccountTypeEnum.stp, }; @@ -98,6 +121,9 @@ enum SubAccountTypeEnum { /// standard. standard, + /// swap_free. + swapFree, + /// stp. stp, } @@ -105,6 +131,7 @@ enum SubAccountTypeEnum { abstract class TradingPlatformAvailableAccountsItemModel { /// Initializes Trading platform available accounts item model class . const TradingPlatformAvailableAccountsItemModel({ + this.linkableLandingCompanies, this.marketType, this.name, this.requirements, @@ -112,6 +139,9 @@ abstract class TradingPlatformAvailableAccountsItemModel { this.subAccountType, }); + /// A list of Deriv landing companies that can work with this account type + final List? linkableLandingCompanies; + /// The type of market tradable by this account final MarketTypeEnum? marketType; @@ -133,23 +163,27 @@ class TradingPlatformAvailableAccountsItem extends TradingPlatformAvailableAccountsItemModel { /// Initializes Trading platform available accounts item class. const TradingPlatformAvailableAccountsItem({ - MarketTypeEnum? marketType, - String? name, - Requirements? requirements, - String? shortcode, - SubAccountTypeEnum? subAccountType, - }) : super( - marketType: marketType, - name: name, - requirements: requirements, - shortcode: shortcode, - subAccountType: subAccountType, - ); + super.linkableLandingCompanies, + super.marketType, + super.name, + super.requirements, + super.shortcode, + super.subAccountType, + }); /// Creates an instance from JSON. factory TradingPlatformAvailableAccountsItem.fromJson( Map json) => TradingPlatformAvailableAccountsItem( + linkableLandingCompanies: json['linkable_landing_companies'] == null + ? null + : List.from( + json['linkable_landing_companies']?.map( + (dynamic item) => item == null + ? null + : linkableLandingCompaniesItemEnumMapper[item], + ), + ), marketType: json['market_type'] == null ? null : marketTypeEnumMapper[json['market_type']], @@ -167,6 +201,19 @@ class TradingPlatformAvailableAccountsItem Map toJson() { final Map resultMap = {}; + if (linkableLandingCompanies != null) { + resultMap['linkable_landing_companies'] = linkableLandingCompanies! + .map( + (LinkableLandingCompaniesItemEnum item) => + linkableLandingCompaniesItemEnumMapper.entries + .firstWhere( + (MapEntry + entry) => + entry.value == item) + .key, + ) + .toList(); + } resultMap['market_type'] = marketTypeEnumMapper.entries .firstWhere((MapEntry entry) => entry.value == marketType) @@ -186,6 +233,7 @@ class TradingPlatformAvailableAccountsItem /// Creates a copy of instance with given parameters. TradingPlatformAvailableAccountsItem copyWith({ + List? linkableLandingCompanies, MarketTypeEnum? marketType, String? name, Requirements? requirements, @@ -193,6 +241,8 @@ class TradingPlatformAvailableAccountsItem SubAccountTypeEnum? subAccountType, }) => TradingPlatformAvailableAccountsItem( + linkableLandingCompanies: + linkableLandingCompanies ?? this.linkableLandingCompanies, marketType: marketType ?? this.marketType, name: name ?? this.name, requirements: requirements ?? this.requirements, @@ -227,16 +277,11 @@ abstract class RequirementsModel { class Requirements extends RequirementsModel { /// Initializes Requirements class. const Requirements({ - AfterFirstDeposit? afterFirstDeposit, - Compliance? compliance, - List? signup, - List? withdrawal, - }) : super( - afterFirstDeposit: afterFirstDeposit, - compliance: compliance, - signup: signup, - withdrawal: withdrawal, - ); + super.afterFirstDeposit, + super.compliance, + super.signup, + super.withdrawal, + }); /// Creates an instance from JSON. factory Requirements.fromJson(Map json) => Requirements( @@ -319,10 +364,8 @@ abstract class AfterFirstDepositModel { class AfterFirstDeposit extends AfterFirstDepositModel { /// Initializes After first deposit class. const AfterFirstDeposit({ - List? financialAssessment, - }) : super( - financialAssessment: financialAssessment, - ); + super.financialAssessment, + }); /// Creates an instance from JSON. factory AfterFirstDeposit.fromJson(Map json) => @@ -378,12 +421,9 @@ abstract class ComplianceModel { class Compliance extends ComplianceModel { /// Initializes Compliance class. const Compliance({ - List? mt5, - List? taxInformation, - }) : super( - mt5: mt5, - taxInformation: taxInformation, - ); + super.mt5, + super.taxInformation, + }); /// Creates an instance from JSON. factory Compliance.fromJson(Map json) => Compliance( diff --git a/lib/api/response/trading_platform_deposit_response_result.dart b/lib/api/response/trading_platform_deposit_response_result.dart index f462d7abcb..685817be5c 100644 --- a/lib/api/response/trading_platform_deposit_response_result.dart +++ b/lib/api/response/trading_platform_deposit_response_result.dart @@ -16,7 +16,7 @@ abstract class TradingPlatformDepositResponseModel { }); /// Information about deposit transaction, or status of demo account top up. - final dynamic tradingPlatformDeposit; + final Map? tradingPlatformDeposit; } /// Trading platform deposit response class. @@ -24,10 +24,8 @@ class TradingPlatformDepositResponse extends TradingPlatformDepositResponseModel { /// Initializes Trading platform deposit response class. const TradingPlatformDepositResponse({ - dynamic tradingPlatformDeposit, - }) : super( - tradingPlatformDeposit: tradingPlatformDeposit, - ); + super.tradingPlatformDeposit, + }); /// Creates an instance from JSON. factory TradingPlatformDepositResponse.fromJson( @@ -52,7 +50,7 @@ class TradingPlatformDepositResponse /// /// Information about deposit transaction, or status of demo account top up. /// For parameters information refer to [TradingPlatformDepositRequest]. - /// Throws a [TradingPlatformException] if API response contains an error. + /// Throws a [BaseAPIException] if API response contains an error. static Future deposit( TradingPlatformDepositRequest request, ) async { @@ -62,7 +60,7 @@ class TradingPlatformDepositResponse checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - TradingPlatformException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return TradingPlatformDepositResponse.fromJson( @@ -72,7 +70,7 @@ class TradingPlatformDepositResponse /// Creates a copy of instance with given parameters. TradingPlatformDepositResponse copyWith({ - dynamic tradingPlatformDeposit, + Map? tradingPlatformDeposit, }) => TradingPlatformDepositResponse( tradingPlatformDeposit: diff --git a/lib/api/response/trading_platform_new_account_response_result.dart b/lib/api/response/trading_platform_new_account_response_result.dart index 5799db3d69..2d3702e739 100644 --- a/lib/api/response/trading_platform_new_account_response_result.dart +++ b/lib/api/response/trading_platform_new_account_response_result.dart @@ -24,10 +24,8 @@ class TradingPlatformNewAccountResponse extends TradingPlatformNewAccountResponseModel { /// Initializes Trading platform new account response class. const TradingPlatformNewAccountResponse({ - TradingPlatformNewAccount? tradingPlatformNewAccount, - }) : super( - tradingPlatformNewAccount: tradingPlatformNewAccount, - ); + super.tradingPlatformNewAccount, + }); /// Creates an instance from JSON. factory TradingPlatformNewAccountResponse.fromJson( @@ -57,7 +55,7 @@ class TradingPlatformNewAccountResponse /// /// This call creates new Trading account, either demo or real money. /// For parameters information refer to [TradingPlatformNewAccountRequest]. - /// Throws a [TradingPlatformException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error. static Future create( TradingPlatformNewAccountRequest request, ) async { @@ -67,7 +65,7 @@ class TradingPlatformNewAccountResponse checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - TradingPlatformException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return TradingPlatformNewAccountResponse.fromJson( @@ -165,6 +163,7 @@ enum MarketTypeEnum { final Map platformEnumMapper = { "dxtrade": PlatformEnum.dxtrade, "derivez": PlatformEnum.derivez, + "ctrader": PlatformEnum.ctrader, }; /// Platform Enum. @@ -174,6 +173,9 @@ enum PlatformEnum { /// derivez. derivez, + + /// ctrader. + ctrader, } /// SubAccountTypeEnum mapper. @@ -181,6 +183,7 @@ final Map subAccountTypeEnumMapper = { "financial": SubAccountTypeEnum.financial, "financial_stp": SubAccountTypeEnum.financialStp, + "swap_free": SubAccountTypeEnum.swapFree, }; /// SubAccountType Enum. @@ -190,8 +193,10 @@ enum SubAccountTypeEnum { /// financial_stp. financialStp, -} + /// swap_free. + swapFree, +} /// Trading platform new account model class. abstract class TradingPlatformNewAccountModel { /// Initializes Trading platform new account model class . @@ -251,32 +256,19 @@ abstract class TradingPlatformNewAccountModel { class TradingPlatformNewAccount extends TradingPlatformNewAccountModel { /// Initializes Trading platform new account class. const TradingPlatformNewAccount({ - String? accountId, - AccountTypeEnum? accountType, - String? agent, - double? balance, - String? currency, - String? displayBalance, - int? enabled, - LandingCompanyShortEnum? landingCompanyShort, - String? login, - MarketTypeEnum? marketType, - PlatformEnum? platform, - SubAccountTypeEnum? subAccountType, - }) : super( - accountId: accountId, - accountType: accountType, - agent: agent, - balance: balance, - currency: currency, - displayBalance: displayBalance, - enabled: enabled, - landingCompanyShort: landingCompanyShort, - login: login, - marketType: marketType, - platform: platform, - subAccountType: subAccountType, - ); + super.accountId, + super.accountType, + super.agent, + super.balance, + super.currency, + super.displayBalance, + super.enabled, + super.landingCompanyShort, + super.login, + super.marketType, + super.platform, + super.subAccountType, + }); /// Creates an instance from JSON. factory TradingPlatformNewAccount.fromJson(Map json) => diff --git a/lib/api/response/trading_platform_password_change_response_result.dart b/lib/api/response/trading_platform_password_change_response_result.dart index 5009db48f4..e5fb229501 100644 --- a/lib/api/response/trading_platform_password_change_response_result.dart +++ b/lib/api/response/trading_platform_password_change_response_result.dart @@ -20,10 +20,8 @@ class TradingPlatformPasswordChangeResponse extends TradingPlatformPasswordChangeResponseModel { /// Initializes Trading platform password change response class. const TradingPlatformPasswordChangeResponse({ - bool? tradingPlatformPasswordChange, - }) : super( - tradingPlatformPasswordChange: tradingPlatformPasswordChange, - ); + super.tradingPlatformPasswordChange, + }); /// Creates an instance from JSON. factory TradingPlatformPasswordChangeResponse.fromJson( diff --git a/lib/api/response/trading_platform_password_reset_response_result.dart b/lib/api/response/trading_platform_password_reset_response_result.dart index e825b072a7..192f020abf 100644 --- a/lib/api/response/trading_platform_password_reset_response_result.dart +++ b/lib/api/response/trading_platform_password_reset_response_result.dart @@ -19,10 +19,8 @@ class TradingPlatformPasswordResetResponse extends TradingPlatformPasswordResetResponseModel { /// Initializes Trading platform password reset response class. const TradingPlatformPasswordResetResponse({ - bool? tradingPlatformPasswordReset, - }) : super( - tradingPlatformPasswordReset: tradingPlatformPasswordReset, - ); + super.tradingPlatformPasswordReset, + }); /// Creates an instance from JSON. factory TradingPlatformPasswordResetResponse.fromJson( diff --git a/lib/api/response/trading_platform_product_listing_response_result.dart b/lib/api/response/trading_platform_product_listing_response_result.dart index ad32b872ec..c3a202e1f4 100644 --- a/lib/api/response/trading_platform_product_listing_response_result.dart +++ b/lib/api/response/trading_platform_product_listing_response_result.dart @@ -21,11 +21,8 @@ class TradingPlatformProductListingResponse extends TradingPlatformProductListingResponseModel { /// Initializes Trading platform product listing response class. const TradingPlatformProductListingResponse({ - Map? - tradingPlatformProductListing, - }) : super( - tradingPlatformProductListing: tradingPlatformProductListing, - ); + super.tradingPlatformProductListing, + }); /// Creates an instance from JSON. factory TradingPlatformProductListingResponse.fromJson( @@ -92,16 +89,11 @@ class TradingPlatformProductListingProperty extends TradingPlatformProductListingPropertyModel { /// Initializes Trading platform product listing property class. const TradingPlatformProductListingProperty({ - List? availableMarkets, - List? availableTradeTypes, - String? name, - List? productList, - }) : super( - availableMarkets: availableMarkets, - availableTradeTypes: availableTradeTypes, - name: name, - productList: productList, - ); + super.availableMarkets, + super.availableTradeTypes, + super.name, + super.productList, + }); /// Creates an instance from JSON. factory TradingPlatformProductListingProperty.fromJson( @@ -206,18 +198,12 @@ abstract class ProductListItemModel { class ProductListItem extends ProductListItemModel { /// Initializes Product list item class. const ProductListItem({ - List? availableAccountTypes, - List? availableTradeTypes, - Market? market, - Submarket? submarket, - Symbol? symbol, - }) : super( - availableAccountTypes: availableAccountTypes, - availableTradeTypes: availableTradeTypes, - market: market, - submarket: submarket, - symbol: symbol, - ); + super.availableAccountTypes, + super.availableTradeTypes, + super.market, + super.submarket, + super.symbol, + }); /// Creates an instance from JSON. factory ProductListItem.fromJson(Map json) => @@ -310,12 +296,9 @@ abstract class MarketModel { class Market extends MarketModel { /// Initializes Market class. const Market({ - String? displayName, - String? name, - }) : super( - displayName: displayName, - name: name, - ); + super.displayName, + super.name, + }); /// Creates an instance from JSON. factory Market.fromJson(Map json) => Market( @@ -362,12 +345,9 @@ abstract class SubmarketModel { class Submarket extends SubmarketModel { /// Initializes Submarket class. const Submarket({ - String? displayName, - String? name, - }) : super( - displayName: displayName, - name: name, - ); + super.displayName, + super.name, + }); /// Creates an instance from JSON. factory Submarket.fromJson(Map json) => Submarket( @@ -414,12 +394,9 @@ abstract class SymbolModel { class Symbol extends SymbolModel { /// Initializes Symbol class. const Symbol({ - String? displayName, - String? name, - }) : super( - displayName: displayName, - name: name, - ); + super.displayName, + super.name, + }); /// Creates an instance from JSON. factory Symbol.fromJson(Map json) => Symbol( diff --git a/lib/api/response/trading_platform_withdrawal_response_result.dart b/lib/api/response/trading_platform_withdrawal_response_result.dart index 7afc588b40..e15ca38b05 100644 --- a/lib/api/response/trading_platform_withdrawal_response_result.dart +++ b/lib/api/response/trading_platform_withdrawal_response_result.dart @@ -20,10 +20,8 @@ class TradingPlatformWithdrawalResponse extends TradingPlatformWithdrawalResponseModel { /// Initializes Trading platform withdrawal response class. const TradingPlatformWithdrawalResponse({ - TradingPlatformWithdrawal? tradingPlatformWithdrawal, - }) : super( - tradingPlatformWithdrawal: tradingPlatformWithdrawal, - ); + super.tradingPlatformWithdrawal, + }); /// Creates an instance from JSON. factory TradingPlatformWithdrawalResponse.fromJson( @@ -71,10 +69,8 @@ abstract class TradingPlatformWithdrawalModel { class TradingPlatformWithdrawal extends TradingPlatformWithdrawalModel { /// Initializes Trading platform withdrawal class. const TradingPlatformWithdrawal({ - int? transactionId, - }) : super( - transactionId: transactionId, - ); + super.transactionId, + }); /// Creates an instance from JSON. factory TradingPlatformWithdrawal.fromJson(Map json) => diff --git a/lib/api/response/trading_servers_response_result.dart b/lib/api/response/trading_servers_response_result.dart index 78d5524eed..8807252094 100644 --- a/lib/api/response/trading_servers_response_result.dart +++ b/lib/api/response/trading_servers_response_result.dart @@ -64,7 +64,7 @@ class TradingServersResponse extends TradingServersResponseModel { /// Get the list of servers for platform. Currently, only mt5 is supported /// /// For parameters information refer to [TradingServersRequest]. - /// Throws a [TradingException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future fetchTradingServers( TradingServersRequest request, ) async { @@ -73,7 +73,7 @@ class TradingServersResponse extends TradingServersResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - TradingException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return TradingServersResponse.fromJson(response.tradingServers); diff --git a/lib/api/response/trading_times_response_result.dart b/lib/api/response/trading_times_response_result.dart index 17f939da08..6c4af9d1b0 100644 --- a/lib/api/response/trading_times_response_result.dart +++ b/lib/api/response/trading_times_response_result.dart @@ -56,7 +56,7 @@ class TradingTimesResponse extends TradingTimesResponseModel { /// Receives a list of market opening times for a given date. /// /// For parameters information refer to [TradingTimesRequest]. - /// Throws a [TradingException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future fetchTradingTimes( TradingTimesRequest request, ) async { @@ -65,7 +65,7 @@ class TradingTimesResponse extends TradingTimesResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - TradingException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return TradingTimesResponse.fromJson(response.tradingTimes); diff --git a/lib/api/response/transaction_response_result.dart b/lib/api/response/transaction_response_result.dart index c81c36bc08..0d97e9a495 100644 --- a/lib/api/response/transaction_response_result.dart +++ b/lib/api/response/transaction_response_result.dart @@ -75,7 +75,7 @@ class TransactionResponse extends TransactionResponseModel { /// Subscribes to account's transactions /// - /// Throws a [TransactionsException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Stream subscribeTransactions({ RequestCompareFunction? comparePredicate, }) => @@ -88,7 +88,7 @@ class TransactionResponse extends TransactionResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - TransactionsException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return response is TransactionReceive @@ -101,7 +101,7 @@ class TransactionResponse extends TransactionResponseModel { /// Unsubscribes from transaction subscription. /// - /// Throws a [TransactionsException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error Future unsubscribeTransaction() async { if (subscription == null) { return null; @@ -113,7 +113,7 @@ class TransactionResponse extends TransactionResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - TransactionsException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return ForgetResponse.fromJson(response.forget); @@ -121,7 +121,7 @@ class TransactionResponse extends TransactionResponseModel { /// Unsubscribes all transaction subscriptions. /// - /// Throws a [TransactionsException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future unsubscribeAllTransaction() async { final ForgetAllReceive response = await _api.unsubscribeAll(method: ForgetStreamType.transaction); @@ -129,7 +129,7 @@ class TransactionResponse extends TransactionResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - TransactionsException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return ForgetAllResponse.fromJson(response.forgetAll); diff --git a/lib/api/response/transfer_between_accounts_response_result.dart b/lib/api/response/transfer_between_accounts_response_result.dart index 945857f7e2..301a58247e 100644 --- a/lib/api/response/transfer_between_accounts_response_result.dart +++ b/lib/api/response/transfer_between_accounts_response_result.dart @@ -42,18 +42,12 @@ class TransferBetweenAccountsResponse extends TransferBetweenAccountsResponseModel { /// Initializes Transfer between accounts response class. const TransferBetweenAccountsResponse({ - bool? transferBetweenAccounts, - List? accounts, - String? clientToFullName, - String? clientToLoginid, - int? transactionId, - }) : super( - transferBetweenAccounts: transferBetweenAccounts, - accounts: accounts, - clientToFullName: clientToFullName, - clientToLoginid: clientToLoginid, - transactionId: transactionId, - ); + super.transferBetweenAccounts, + super.accounts, + super.clientToFullName, + super.clientToLoginid, + super.transactionId, + }); /// Creates an instance from JSON. factory TransferBetweenAccountsResponse.fromJson( @@ -103,7 +97,7 @@ class TransferBetweenAccountsResponse /// Transfer funds between your fiat and crypto currency accounts (for a fee). /// Please note that account_from should be same as current authorized account. /// For parameters information refer to [TransferBetweenAccountsRequest]. - /// Throws a [TransferException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future transfer( TransferBetweenAccountsRequest request, ) async { @@ -113,7 +107,7 @@ class TransferBetweenAccountsResponse checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - TransferException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return TransferBetweenAccountsResponse.fromJson( @@ -151,6 +145,7 @@ final Map accountTypeEnumMapper = "dxtrade": AccountTypeEnum.dxtrade, "derivez": AccountTypeEnum.derivez, "binary": AccountTypeEnum.binary, + "ctrader": AccountTypeEnum.ctrader, }; /// AccountType Enum. @@ -172,6 +167,9 @@ enum AccountTypeEnum { /// binary. binary, + + /// ctrader. + ctrader, } /// MarketTypeEnum mapper. @@ -193,7 +191,6 @@ enum MarketTypeEnum { /// all. all, } - /// Accounts item model class. abstract class AccountsItemModel { /// Initializes Accounts item model class . @@ -241,26 +238,16 @@ abstract class AccountsItemModel { class AccountsItem extends AccountsItemModel { /// Initializes Accounts item class. const AccountsItem({ - AccountTypeEnum? accountType, - String? balance, - String? currency, - bool? demoAccount, - String? derivezGroup, - String? loginid, - MarketTypeEnum? marketType, - String? mt5Group, - String? status, - }) : super( - accountType: accountType, - balance: balance, - currency: currency, - demoAccount: demoAccount, - derivezGroup: derivezGroup, - loginid: loginid, - marketType: marketType, - mt5Group: mt5Group, - status: status, - ); + super.accountType, + super.balance, + super.currency, + super.demoAccount, + super.derivezGroup, + super.loginid, + super.marketType, + super.mt5Group, + super.status, + }); /// Creates an instance from JSON. factory AccountsItem.fromJson(Map json) => AccountsItem( diff --git a/lib/api/response/verify_email_response_result.dart b/lib/api/response/verify_email_response_result.dart index 235532ddc0..03468dfd66 100644 --- a/lib/api/response/verify_email_response_result.dart +++ b/lib/api/response/verify_email_response_result.dart @@ -53,7 +53,7 @@ class VerifyEmailResponse extends VerifyEmailResponseModel { /// /// The system will send an email to the address containing a security code for verification. /// For parameters information refer to [VerifyEmailRequest]. - /// Throws a [UserException] if API response contains an error + /// Throws a [BaseAPIException] if API response contains an error static Future verify( VerifyEmailRequest request, ) async { @@ -62,7 +62,7 @@ class VerifyEmailResponse extends VerifyEmailResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - UserException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return VerifyEmailResponse.fromJson(response.verifyEmail); diff --git a/lib/api/response/wallet_migration_response_extended.dart b/lib/api/response/wallet_migration_response_extended.dart new file mode 100644 index 0000000000..28b1aa2203 --- /dev/null +++ b/lib/api/response/wallet_migration_response_extended.dart @@ -0,0 +1,57 @@ +import 'package:deriv_dependency_injector/dependency_injector.dart'; +import 'package:flutter_deriv_api/api/exceptions/exceptions.dart'; +import 'package:flutter_deriv_api/basic_api/generated/wallet_migration_receive.dart'; +import 'package:flutter_deriv_api/basic_api/generated/wallet_migration_send.dart'; +import 'package:flutter_deriv_api/helpers/helpers.dart'; +import 'package:flutter_deriv_api/services/connection/api_manager/base_api.dart'; + +import 'wallet_migration_response_result.dart'; + +/// The extended version of the [WalletMigrationResponse] class to implement +/// the API call methods. +class WalletMigrationResponseExtended extends WalletMigrationResponse { + static final BaseAPI _api = Injector()(); + + /// Initiates the migration process to wallet. can also check the status of + /// the migration or reset it if it has failed for any reason. + /// + /// [request] is the request object. For its `walletMigration` field, you can + /// set the following values: + /// - `start` to initiate the migration process. + /// - `state` to check the status of the migration. + /// - `reset` to reset the migration process. + static Future fetchWalletMigration({ + required WalletMigrationRequest request, + }) async { + final WalletMigrationReceive response = await _api.call(request: request); + + checkException( + response: response, + exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => + BaseAPIException(baseExceptionModel: baseExceptionModel), + ); + + return WalletMigrationResponse.fromJson(response.walletMigration); + } + + /// Starts the user's migration process to wallet. + static Future startMigration() => fetchWalletMigration( + request: const WalletMigrationRequest( + walletMigration: 'start', + ), + ); + + /// Resets the user's migration process to wallet. + static Future resetMigration() => fetchWalletMigration( + request: const WalletMigrationRequest( + walletMigration: 'reset', + ), + ); + + /// Checks the status of the user's migration process to wallet. + static Future checkStatus() => fetchWalletMigration( + request: const WalletMigrationRequest( + walletMigration: 'state', + ), + ); +} diff --git a/lib/api/response/wallet_migration_response_result.dart b/lib/api/response/wallet_migration_response_result.dart new file mode 100644 index 0000000000..ebe3e04e10 --- /dev/null +++ b/lib/api/response/wallet_migration_response_result.dart @@ -0,0 +1,417 @@ +// ignore_for_file: prefer_single_quotes, unnecessary_import, unused_import + +import 'package:equatable/equatable.dart'; + +import 'package:flutter_deriv_api/helpers/helpers.dart'; + +/// Wallet migration response model class. +abstract class WalletMigrationResponseModel { + /// Initializes Wallet migration response model class . + const WalletMigrationResponseModel({ + this.walletMigration, + }); + + /// The information regarding wallet migration state + final WalletMigration? walletMigration; +} + +/// Wallet migration response class. +class WalletMigrationResponse extends WalletMigrationResponseModel { + /// Initializes Wallet migration response class. + const WalletMigrationResponse({ + super.walletMigration, + }); + + /// Creates an instance from JSON. + factory WalletMigrationResponse.fromJson( + dynamic walletMigrationJson, + ) => + WalletMigrationResponse( + walletMigration: walletMigrationJson == null + ? null + : WalletMigration.fromJson(walletMigrationJson), + ); + + /// Converts an instance to JSON. + Map toJson() { + final Map resultMap = {}; + + if (walletMigration != null) { + resultMap['wallet_migration'] = walletMigration!.toJson(); + } + + return resultMap; + } + + /// Creates a copy of instance with given parameters. + WalletMigrationResponse copyWith({ + WalletMigration? walletMigration, + }) => + WalletMigrationResponse( + walletMigration: walletMigration ?? this.walletMigration, + ); +} + +/// AccountCategoryEnum mapper. +final Map accountCategoryEnumMapper = + { + "wallet": AccountCategoryEnum.wallet, +}; + +/// AccountCategory Enum. +enum AccountCategoryEnum { + /// wallet. + wallet, +} + +/// LinkAccountsItemAccountCategoryEnum mapper. +final Map + linkAccountsItemAccountCategoryEnumMapper = + { + "trading": LinkAccountsItemAccountCategoryEnum.trading, +}; + +/// AccountCategory Enum. +enum LinkAccountsItemAccountCategoryEnum { + /// trading. + trading, +} + +/// AccountTypeEnum mapper. +final Map accountTypeEnumMapper = + { + "standard": AccountTypeEnum.standard, + "mt5": AccountTypeEnum.mt5, + "dxtrade": AccountTypeEnum.dxtrade, + "derivez": AccountTypeEnum.derivez, + "ctrader": AccountTypeEnum.ctrader, +}; + +/// AccountType Enum. +enum AccountTypeEnum { + /// standard. + standard, + + /// mt5. + mt5, + + /// dxtrade. + dxtrade, + + /// derivez. + derivez, + + /// ctrader. + ctrader, +} + +/// PlatformEnum mapper. +final Map platformEnumMapper = { + "dtrade": PlatformEnum.dtrade, + "mt5": PlatformEnum.mt5, + "dxtrade": PlatformEnum.dxtrade, + "derivez": PlatformEnum.derivez, + "ctrader": PlatformEnum.ctrader, +}; + +/// Platform Enum. +enum PlatformEnum { + /// dtrade. + dtrade, + + /// mt5. + mt5, + + /// dxtrade. + dxtrade, + + /// derivez. + derivez, + + /// ctrader. + ctrader, +} + +/// AccountListItemPlatformEnum mapper. +final Map + accountListItemPlatformEnumMapper = { + "dwallet": AccountListItemPlatformEnum.dwallet, +}; + +/// Platform Enum. +enum AccountListItemPlatformEnum { + /// dwallet. + dwallet, +} + +/// StateEnum mapper. +final Map stateEnumMapper = { + "ineligible": StateEnum.ineligible, + "eligible": StateEnum.eligible, + "in_progress": StateEnum.inProgress, + "migrated": StateEnum.migrated, + "failed": StateEnum.failed, +}; + +/// State Enum. +enum StateEnum { + /// ineligible. + ineligible, + + /// eligible. + eligible, + + /// in_progress. + inProgress, + + /// migrated. + migrated, + + /// failed. + failed, +} +/// Wallet migration model class. +abstract class WalletMigrationModel { + /// Initializes Wallet migration model class . + const WalletMigrationModel({ + required this.state, + this.accountList, + }); + + /// Current state of migration process + final StateEnum state; + + /// [Optional] This field is only presented when state is eligible. It contains a list of accounts that are eligible for migration and provide information what wallets are going to be created + final List? accountList; +} + +/// Wallet migration class. +class WalletMigration extends WalletMigrationModel { + /// Initializes Wallet migration class. + const WalletMigration({ + required super.state, + super.accountList, + }); + + /// Creates an instance from JSON. + factory WalletMigration.fromJson(Map json) => + WalletMigration( + state: stateEnumMapper[json['state']]!, + accountList: json['account_list'] == null + ? null + : List.from( + json['account_list']?.map( + (dynamic item) => AccountListItem.fromJson(item), + ), + ), + ); + + /// Converts an instance to JSON. + Map toJson() { + final Map resultMap = {}; + + resultMap['state'] = stateEnumMapper.entries + .firstWhere((MapEntry entry) => entry.value == state) + .key; + if (accountList != null) { + resultMap['account_list'] = accountList! + .map( + (AccountListItem item) => item.toJson(), + ) + .toList(); + } + + return resultMap; + } + + /// Creates a copy of instance with given parameters. + WalletMigration copyWith({ + StateEnum? state, + List? accountList, + }) => + WalletMigration( + state: state ?? this.state, + accountList: accountList ?? this.accountList, + ); +} +/// Account list item model class. +abstract class AccountListItemModel { + /// Initializes Account list item model class . + const AccountListItemModel({ + required this.platform, + required this.linkAccounts, + required this.landingCompanyShort, + required this.currency, + required this.accountType, + required this.accountCategory, + }); + + /// The platform of the account + final AccountListItemPlatformEnum platform; + + /// The list of accounts that will be linked to this wallet account + final List linkAccounts; + + /// The landing company short code of the account + final String landingCompanyShort; + + /// The currency of the account + final String currency; + + /// The type of the account + final String accountType; + + /// The category of the account + final AccountCategoryEnum accountCategory; +} + +/// Account list item class. +class AccountListItem extends AccountListItemModel { + /// Initializes Account list item class. + const AccountListItem({ + required super.accountCategory, + required super.accountType, + required super.currency, + required super.landingCompanyShort, + required super.linkAccounts, + required super.platform, + }); + + /// Creates an instance from JSON. + factory AccountListItem.fromJson(Map json) => + AccountListItem( + accountCategory: accountCategoryEnumMapper[json['account_category']]!, + accountType: json['account_type'], + currency: json['currency'], + landingCompanyShort: json['landing_company_short'], + linkAccounts: List.from( + json['link_accounts'].map( + (dynamic item) => LinkAccountsItem.fromJson(item), + ), + ), + platform: accountListItemPlatformEnumMapper[json['platform']]!, + ); + + /// Converts an instance to JSON. + Map toJson() { + final Map resultMap = {}; + + resultMap['account_category'] = accountCategoryEnumMapper.entries + .firstWhere((MapEntry entry) => + entry.value == accountCategory) + .key; + resultMap['account_type'] = accountType; + resultMap['currency'] = currency; + resultMap['landing_company_short'] = landingCompanyShort; + resultMap['link_accounts'] = linkAccounts + .map( + (LinkAccountsItem item) => item.toJson(), + ) + .toList(); + + resultMap['platform'] = accountListItemPlatformEnumMapper.entries + .firstWhere((MapEntry entry) => + entry.value == platform) + .key; + + return resultMap; + } + + /// Creates a copy of instance with given parameters. + AccountListItem copyWith({ + AccountCategoryEnum? accountCategory, + String? accountType, + String? currency, + String? landingCompanyShort, + List? linkAccounts, + AccountListItemPlatformEnum? platform, + }) => + AccountListItem( + accountCategory: accountCategory ?? this.accountCategory, + accountType: accountType ?? this.accountType, + currency: currency ?? this.currency, + landingCompanyShort: landingCompanyShort ?? this.landingCompanyShort, + linkAccounts: linkAccounts ?? this.linkAccounts, + platform: platform ?? this.platform, + ); +} +/// Link accounts item model class. +abstract class LinkAccountsItemModel { + /// Initializes Link accounts item model class . + const LinkAccountsItemModel({ + required this.platform, + required this.loginid, + required this.accountType, + required this.accountCategory, + }); + + /// The platform of the account + final PlatformEnum platform; + + /// The loginid of the account + final String loginid; + + /// The type of the account + final AccountTypeEnum accountType; + + /// The category of the account + final LinkAccountsItemAccountCategoryEnum accountCategory; +} + +/// Link accounts item class. +class LinkAccountsItem extends LinkAccountsItemModel { + /// Initializes Link accounts item class. + const LinkAccountsItem({ + required super.accountCategory, + required super.accountType, + required super.loginid, + required super.platform, + }); + + /// Creates an instance from JSON. + factory LinkAccountsItem.fromJson(Map json) => + LinkAccountsItem( + accountCategory: linkAccountsItemAccountCategoryEnumMapper[ + json['account_category']]!, + accountType: accountTypeEnumMapper[json['account_type']]!, + loginid: json['loginid'], + platform: platformEnumMapper[json['platform']]!, + ); + + /// Converts an instance to JSON. + Map toJson() { + final Map resultMap = {}; + + resultMap['account_category'] = linkAccountsItemAccountCategoryEnumMapper + .entries + .firstWhere( + (MapEntry entry) => + entry.value == accountCategory) + .key; + resultMap['account_type'] = accountTypeEnumMapper.entries + .firstWhere((MapEntry entry) => + entry.value == accountType) + .key; + resultMap['loginid'] = loginid; + resultMap['platform'] = platformEnumMapper.entries + .firstWhere( + (MapEntry entry) => entry.value == platform) + .key; + + return resultMap; + } + + /// Creates a copy of instance with given parameters. + LinkAccountsItem copyWith({ + LinkAccountsItemAccountCategoryEnum? accountCategory, + AccountTypeEnum? accountType, + String? loginid, + PlatformEnum? platform, + }) => + LinkAccountsItem( + accountCategory: accountCategory ?? this.accountCategory, + accountType: accountType ?? this.accountType, + loginid: loginid ?? this.loginid, + platform: platform ?? this.platform, + ); +} diff --git a/lib/api/response/website_status_response_result.dart b/lib/api/response/website_status_response_result.dart index d7641881f2..9b30d661b8 100644 --- a/lib/api/response/website_status_response_result.dart +++ b/lib/api/response/website_status_response_result.dart @@ -36,12 +36,9 @@ abstract class WebsiteStatusResponseModel { class WebsiteStatusResponse extends WebsiteStatusResponseModel { /// Initializes Website status response class. const WebsiteStatusResponse({ - WebsiteStatus? websiteStatus, - Subscription? subscription, - }) : super( - websiteStatus: websiteStatus, - subscription: subscription, - ); + super.websiteStatus, + super.subscription, + }); /// Creates an instance from JSON. factory WebsiteStatusResponse.fromJson( @@ -76,7 +73,7 @@ class WebsiteStatusResponse extends WebsiteStatusResponseModel { /// Gets Website status. /// /// For parameters information refer to [WebsiteStatusRequest]. - /// Throws a [WebsiteStatusException] if API response contains an error. + /// Throws a [BaseAPIException] if API response contains an error. static Future fetchWebsiteStatusRaw([ WebsiteStatusRequest? request, ]) async { @@ -87,7 +84,7 @@ class WebsiteStatusResponse extends WebsiteStatusResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - WebsiteStatusException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return response; @@ -95,7 +92,7 @@ class WebsiteStatusResponse extends WebsiteStatusResponseModel { /// Subscribes to website status. /// - /// Throws a [WebsiteStatusException] if API response contains an error. + /// Throws a [BaseAPIException] if API response contains an error. static Stream subscribeWebsiteStatusRaw( WebsiteStatusRequest request, { RequestCompareFunction? comparePredicate, @@ -107,7 +104,7 @@ class WebsiteStatusResponse extends WebsiteStatusResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - WebsiteStatusException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return response is WebsiteStatusReceive ? response : null; @@ -116,7 +113,7 @@ class WebsiteStatusResponse extends WebsiteStatusResponseModel { /// Unsubscribes from website status. /// - /// Throws an [WebsiteStatusException] if the API response contains an error. + /// Throws an [BaseAPIException] if the API response contains an error. Future unsubscribeWebsiteStatusRaw() async { if (subscription == null) { return null; @@ -128,7 +125,7 @@ class WebsiteStatusResponse extends WebsiteStatusResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - WebsiteStatusException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return response; @@ -136,7 +133,7 @@ class WebsiteStatusResponse extends WebsiteStatusResponseModel { /// Unsubscribes all website status subscriptions. /// - /// Throws an [WebsiteStatusException] if the API response contains an error. + /// Throws an [BaseAPIException] if the API response contains an error. static Future unsubscribeAllWebsiteStatusRaw() async { final ForgetAllReceive response = await _api.unsubscribeAll(method: ForgetStreamType.websiteStatus); @@ -144,7 +141,7 @@ class WebsiteStatusResponse extends WebsiteStatusResponseModel { checkException( response: response, exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => - WebsiteStatusException(baseExceptionModel: baseExceptionModel), + BaseAPIException(baseExceptionModel: baseExceptionModel), ); return response; @@ -152,7 +149,7 @@ class WebsiteStatusResponse extends WebsiteStatusResponseModel { /// Gets Website status. /// - /// Throws an [WebsiteStatusException] if the API response contains an error. + /// Throws an [BaseAPIException] if the API response contains an error. static Future fetchWebsiteStatus([ WebsiteStatusRequest? request, ]) async { @@ -183,7 +180,7 @@ class WebsiteStatusResponse extends WebsiteStatusResponseModel { /// Unsubscribes from website status. /// - /// Throws an [WebsiteStatusException] if the API response contains an error. + /// Throws an [BaseAPIException] if the API response contains an error. Future unsubscribeWebsiteStatus() async { final ForgetReceive? response = await unsubscribeWebsiteStatusRaw(); @@ -192,7 +189,7 @@ class WebsiteStatusResponse extends WebsiteStatusResponseModel { /// Unsubscribes all website status subscriptions. /// - /// Throws an [WebsiteStatusException] if the API response contains an error. + /// Throws an [BaseAPIException] if the API response contains an error. static Future unsubscribeAllWebsiteStatus() async { final ForgetAllReceive response = await unsubscribeAllWebsiteStatusRaw(); @@ -284,13 +281,13 @@ enum SiteStatusEnum { /// updating. updating, } - /// Website status model class. abstract class WebsiteStatusModel { /// Initializes Website status model class . const WebsiteStatusModel({ required this.currenciesConfig, required this.apiCallLimits, + this.brokerCodes, this.clientsCountry, this.dxtradeStatus, this.message, @@ -308,6 +305,9 @@ abstract class WebsiteStatusModel { /// Maximum number of API calls during specified period of time. final ApiCallLimits apiCallLimits; + /// List of all available broker codes. + final List? brokerCodes; + /// Country code of connected IP final String? clientsCountry; @@ -340,30 +340,19 @@ abstract class WebsiteStatusModel { class WebsiteStatus extends WebsiteStatusModel { /// Initializes Website status class. const WebsiteStatus({ - required ApiCallLimits apiCallLimits, - required Map currenciesConfig, - String? clientsCountry, - DxtradeStatus? dxtradeStatus, - String? message, - Mt5Status? mt5Status, - P2pConfig? p2pConfig, - PaymentAgents? paymentAgents, - SiteStatusEnum? siteStatus, - List? supportedLanguages, - String? termsConditionsVersion, - }) : super( - apiCallLimits: apiCallLimits, - currenciesConfig: currenciesConfig, - clientsCountry: clientsCountry, - dxtradeStatus: dxtradeStatus, - message: message, - mt5Status: mt5Status, - p2pConfig: p2pConfig, - paymentAgents: paymentAgents, - siteStatus: siteStatus, - supportedLanguages: supportedLanguages, - termsConditionsVersion: termsConditionsVersion, - ); + required super.apiCallLimits, + required super.currenciesConfig, + super.brokerCodes, + super.clientsCountry, + super.dxtradeStatus, + super.message, + super.mt5Status, + super.p2pConfig, + super.paymentAgents, + super.siteStatus, + super.supportedLanguages, + super.termsConditionsVersion, + }); /// Creates an instance from JSON. factory WebsiteStatus.fromJson(Map json) => WebsiteStatus( @@ -375,6 +364,13 @@ class WebsiteStatus extends WebsiteStatusModel { (MapEntry entry) => MapEntry(entry.key, CurrenciesConfigProperty.fromJson(entry.value)))), + brokerCodes: json['broker_codes'] == null + ? null + : List.from( + json['broker_codes']?.map( + (dynamic item) => item, + ), + ), clientsCountry: json['clients_country'], dxtradeStatus: json['dxtrade_status'] == null ? null @@ -409,6 +405,13 @@ class WebsiteStatus extends WebsiteStatusModel { resultMap['api_call_limits'] = apiCallLimits.toJson(); resultMap['currencies_config'] = currenciesConfig; + if (brokerCodes != null) { + resultMap['broker_codes'] = brokerCodes! + .map( + (String item) => item, + ) + .toList(); + } resultMap['clients_country'] = clientsCountry; if (dxtradeStatus != null) { resultMap['dxtrade_status'] = dxtradeStatus!.toJson(); @@ -443,6 +446,7 @@ class WebsiteStatus extends WebsiteStatusModel { WebsiteStatus copyWith({ ApiCallLimits? apiCallLimits, Map? currenciesConfig, + List? brokerCodes, String? clientsCountry, DxtradeStatus? dxtradeStatus, String? message, @@ -456,6 +460,7 @@ class WebsiteStatus extends WebsiteStatusModel { WebsiteStatus( apiCallLimits: apiCallLimits ?? this.apiCallLimits, currenciesConfig: currenciesConfig ?? this.currenciesConfig, + brokerCodes: brokerCodes ?? this.brokerCodes, clientsCountry: clientsCountry ?? this.clientsCountry, dxtradeStatus: dxtradeStatus ?? this.dxtradeStatus, message: message ?? this.message, @@ -468,7 +473,6 @@ class WebsiteStatus extends WebsiteStatusModel { termsConditionsVersion ?? this.termsConditionsVersion, ); } - /// Api call limits model class. abstract class ApiCallLimitsModel { /// Initializes Api call limits model class . @@ -496,16 +500,11 @@ abstract class ApiCallLimitsModel { class ApiCallLimits extends ApiCallLimitsModel { /// Initializes Api call limits class. const ApiCallLimits({ - required MaxProposalSubscription maxProposalSubscription, - required MaxRequestesGeneral maxRequestesGeneral, - required MaxRequestsOutcome maxRequestsOutcome, - required MaxRequestsPricing maxRequestsPricing, - }) : super( - maxProposalSubscription: maxProposalSubscription, - maxRequestesGeneral: maxRequestesGeneral, - maxRequestsOutcome: maxRequestsOutcome, - maxRequestsPricing: maxRequestsPricing, - ); + required super.maxProposalSubscription, + required super.maxRequestesGeneral, + required super.maxRequestsOutcome, + required super.maxRequestsPricing, + }); /// Creates an instance from JSON. factory ApiCallLimits.fromJson(Map json) => ApiCallLimits( @@ -549,7 +548,6 @@ class ApiCallLimits extends ApiCallLimitsModel { maxRequestsPricing: maxRequestsPricing ?? this.maxRequestsPricing, ); } - /// Max proposal subscription model class. abstract class MaxProposalSubscriptionModel { /// Initializes Max proposal subscription model class . @@ -569,12 +567,9 @@ abstract class MaxProposalSubscriptionModel { class MaxProposalSubscription extends MaxProposalSubscriptionModel { /// Initializes Max proposal subscription class. const MaxProposalSubscription({ - required String appliesTo, - required double max, - }) : super( - appliesTo: appliesTo, - max: max, - ); + required super.appliesTo, + required super.max, + }); /// Creates an instance from JSON. factory MaxProposalSubscription.fromJson(Map json) => @@ -603,7 +598,6 @@ class MaxProposalSubscription extends MaxProposalSubscriptionModel { max: max ?? this.max, ); } - /// Max requestes general model class. abstract class MaxRequestesGeneralModel { /// Initializes Max requestes general model class . @@ -627,14 +621,10 @@ abstract class MaxRequestesGeneralModel { class MaxRequestesGeneral extends MaxRequestesGeneralModel { /// Initializes Max requestes general class. const MaxRequestesGeneral({ - required String appliesTo, - required double hourly, - required double minutely, - }) : super( - appliesTo: appliesTo, - hourly: hourly, - minutely: minutely, - ); + required super.appliesTo, + required super.hourly, + required super.minutely, + }); /// Creates an instance from JSON. factory MaxRequestesGeneral.fromJson(Map json) => @@ -667,7 +657,6 @@ class MaxRequestesGeneral extends MaxRequestesGeneralModel { minutely: minutely ?? this.minutely, ); } - /// Max requests outcome model class. abstract class MaxRequestsOutcomeModel { /// Initializes Max requests outcome model class . @@ -691,14 +680,10 @@ abstract class MaxRequestsOutcomeModel { class MaxRequestsOutcome extends MaxRequestsOutcomeModel { /// Initializes Max requests outcome class. const MaxRequestsOutcome({ - required String appliesTo, - required double hourly, - required double minutely, - }) : super( - appliesTo: appliesTo, - hourly: hourly, - minutely: minutely, - ); + required super.appliesTo, + required super.hourly, + required super.minutely, + }); /// Creates an instance from JSON. factory MaxRequestsOutcome.fromJson(Map json) => @@ -731,7 +716,6 @@ class MaxRequestsOutcome extends MaxRequestsOutcomeModel { minutely: minutely ?? this.minutely, ); } - /// Max requests pricing model class. abstract class MaxRequestsPricingModel { /// Initializes Max requests pricing model class . @@ -755,14 +739,10 @@ abstract class MaxRequestsPricingModel { class MaxRequestsPricing extends MaxRequestsPricingModel { /// Initializes Max requests pricing class. const MaxRequestsPricing({ - required String appliesTo, - required double hourly, - required double minutely, - }) : super( - appliesTo: appliesTo, - hourly: hourly, - minutely: minutely, - ); + required super.appliesTo, + required super.hourly, + required super.minutely, + }); /// Creates an instance from JSON. factory MaxRequestsPricing.fromJson(Map json) => @@ -795,7 +775,6 @@ class MaxRequestsPricing extends MaxRequestsPricingModel { minutely: minutely ?? this.minutely, ); } - /// Currencies config property model class. abstract class CurrenciesConfigPropertyModel { /// Initializes Currencies config property model class . @@ -839,24 +818,15 @@ abstract class CurrenciesConfigPropertyModel { class CurrenciesConfigProperty extends CurrenciesConfigPropertyModel { /// Initializes Currencies config property class. const CurrenciesConfigProperty({ - required double fractionalDigits, - required double isDepositSuspended, - required double isSuspended, - required double isWithdrawalSuspended, - required double stakeDefault, - required TransferBetweenAccounts transferBetweenAccounts, - required TypeEnum type, - String? name, - }) : super( - fractionalDigits: fractionalDigits, - isDepositSuspended: isDepositSuspended, - isSuspended: isSuspended, - isWithdrawalSuspended: isWithdrawalSuspended, - stakeDefault: stakeDefault, - transferBetweenAccounts: transferBetweenAccounts, - type: type, - name: name, - ); + required super.fractionalDigits, + required super.isDepositSuspended, + required super.isSuspended, + required super.isWithdrawalSuspended, + required super.stakeDefault, + required super.transferBetweenAccounts, + required super.type, + super.name, + }); /// Creates an instance from JSON. factory CurrenciesConfigProperty.fromJson(Map json) => @@ -915,13 +885,13 @@ class CurrenciesConfigProperty extends CurrenciesConfigPropertyModel { name: name ?? this.name, ); } - /// Transfer between accounts model class. abstract class TransferBetweenAccountsModel { /// Initializes Transfer between accounts model class . const TransferBetweenAccountsModel({ required this.limits, required this.fees, + this.limitsCtrader, this.limitsDerivez, this.limitsDxtrade, this.limitsMt5, @@ -933,6 +903,9 @@ abstract class TransferBetweenAccountsModel { /// The fee that applies for transfer between accounts with different types of currencies. final Map fees; + /// Range of allowed amount for transfer between ctrader accounts. + final Map? limitsCtrader; + /// Range of allowed amount for transfer between derivez accounts. final Map? limitsDerivez; @@ -947,18 +920,13 @@ abstract class TransferBetweenAccountsModel { class TransferBetweenAccounts extends TransferBetweenAccountsModel { /// Initializes Transfer between accounts class. const TransferBetweenAccounts({ - required Map fees, - required Limits limits, - Map? limitsDerivez, - Map? limitsDxtrade, - Map? limitsMt5, - }) : super( - fees: fees, - limits: limits, - limitsDerivez: limitsDerivez, - limitsDxtrade: limitsDxtrade, - limitsMt5: limitsMt5, - ); + required super.fees, + required super.limits, + super.limitsCtrader, + super.limitsDerivez, + super.limitsDxtrade, + super.limitsMt5, + }); /// Creates an instance from JSON. factory TransferBetweenAccounts.fromJson(Map json) => @@ -968,6 +936,7 @@ class TransferBetweenAccounts extends TransferBetweenAccountsModel { .map>((MapEntry entry) => MapEntry(entry.key, getDouble(entry.value)!))), limits: Limits.fromJson(json['limits']), + limitsCtrader: json['limits_ctrader'], limitsDerivez: json['limits_derivez'], limitsDxtrade: json['limits_dxtrade'], limitsMt5: json['limits_mt5'], @@ -980,6 +949,7 @@ class TransferBetweenAccounts extends TransferBetweenAccountsModel { resultMap['fees'] = fees; resultMap['limits'] = limits.toJson(); + resultMap['limits_ctrader'] = limitsCtrader; resultMap['limits_derivez'] = limitsDerivez; resultMap['limits_dxtrade'] = limitsDxtrade; resultMap['limits_mt5'] = limitsMt5; @@ -991,6 +961,7 @@ class TransferBetweenAccounts extends TransferBetweenAccountsModel { TransferBetweenAccounts copyWith({ Map? fees, Limits? limits, + Map? limitsCtrader, Map? limitsDerivez, Map? limitsDxtrade, Map? limitsMt5, @@ -998,12 +969,12 @@ class TransferBetweenAccounts extends TransferBetweenAccountsModel { TransferBetweenAccounts( fees: fees ?? this.fees, limits: limits ?? this.limits, + limitsCtrader: limitsCtrader ?? this.limitsCtrader, limitsDerivez: limitsDerivez ?? this.limitsDerivez, limitsDxtrade: limitsDxtrade ?? this.limitsDxtrade, limitsMt5: limitsMt5 ?? this.limitsMt5, ); } - /// Limits model class. abstract class LimitsModel { /// Initializes Limits model class . @@ -1023,12 +994,9 @@ abstract class LimitsModel { class Limits extends LimitsModel { /// Initializes Limits class. const Limits({ - required double min, - double? max, - }) : super( - min: min, - max: max, - ); + required super.min, + super.max, + }); /// Creates an instance from JSON. factory Limits.fromJson(Map json) => Limits( @@ -1056,7 +1024,6 @@ class Limits extends LimitsModel { max: max ?? this.max, ); } - /// Dxtrade status model class. abstract class DxtradeStatusModel { /// Initializes Dxtrade status model class . @@ -1080,14 +1047,10 @@ abstract class DxtradeStatusModel { class DxtradeStatus extends DxtradeStatusModel { /// Initializes Dxtrade status class. const DxtradeStatus({ - int? all, - int? demo, - int? real, - }) : super( - all: all, - demo: demo, - real: real, - ); + super.all, + super.demo, + super.real, + }); /// Creates an instance from JSON. factory DxtradeStatus.fromJson(Map json) => DxtradeStatus( @@ -1119,7 +1082,6 @@ class DxtradeStatus extends DxtradeStatusModel { real: real ?? this.real, ); } - /// Mt5 status model class. abstract class Mt5StatusModel { /// Initializes Mt5 status model class . @@ -1139,12 +1101,9 @@ abstract class Mt5StatusModel { class Mt5Status extends Mt5StatusModel { /// Initializes Mt5 status class. const Mt5Status({ - List? demo, - List? real, - }) : super( - demo: demo, - real: real, - ); + super.demo, + super.real, + }); /// Creates an instance from JSON. factory Mt5Status.fromJson(Map json) => Mt5Status( @@ -1196,7 +1155,6 @@ class Mt5Status extends Mt5StatusModel { real: real ?? this.real, ); } - /// P2p config model class. abstract class P2pConfigModel { /// Initializes P2p config model class . @@ -1214,10 +1172,12 @@ abstract class P2pConfigModel { required this.fixedRateAdverts, required this.featureLevel, required this.disabled, + required this.crossBorderAdsEnabled, required this.cancellationLimit, required this.cancellationGracePeriod, required this.cancellationCountPeriod, required this.cancellationBlockDuration, + required this.blockTrade, required this.advertsActiveLimit, this.advertsArchivePeriod, this.fixedRateAdvertsEndDate, @@ -1263,6 +1223,9 @@ abstract class P2pConfigModel { /// When `true`, the P2P service is unavailable. final bool disabled; + /// When `false`, only exchanges in local currency are allowed for P2P advertiser. + final bool crossBorderAdsEnabled; + /// A buyer will be temporarily barred after marking this number of cancellations within cancellation_period. final int cancellationLimit; @@ -1275,6 +1238,9 @@ abstract class P2pConfigModel { /// A buyer will be blocked for this duration after exceeding the cancellation limit, in hours. final int cancellationBlockDuration; + /// Block trading settings + final BlockTrade blockTrade; + /// Maximum number of active ads allowed by an advertiser per currency pair and advert type (buy or sell). final int advertsActiveLimit; @@ -1292,58 +1258,40 @@ abstract class P2pConfigModel { class P2pConfig extends P2pConfigModel { /// Initializes P2p config class. const P2pConfig({ - required int advertsActiveLimit, - required int cancellationBlockDuration, - required int cancellationCountPeriod, - required int cancellationGracePeriod, - required int cancellationLimit, - required bool disabled, - required int featureLevel, - required FixedRateAdvertsEnum fixedRateAdverts, - required FloatRateAdvertsEnum floatRateAdverts, - required double floatRateOffsetLimit, - required List localCurrencies, - required double maximumAdvertAmount, - required double maximumOrderAmount, - required int orderDailyLimit, - required int orderPaymentPeriod, - required bool paymentMethodsEnabled, - required double reviewPeriod, - required List supportedCurrencies, - int? advertsArchivePeriod, - String? fixedRateAdvertsEndDate, - String? overrideExchangeRate, - }) : super( - advertsActiveLimit: advertsActiveLimit, - cancellationBlockDuration: cancellationBlockDuration, - cancellationCountPeriod: cancellationCountPeriod, - cancellationGracePeriod: cancellationGracePeriod, - cancellationLimit: cancellationLimit, - disabled: disabled, - featureLevel: featureLevel, - fixedRateAdverts: fixedRateAdverts, - floatRateAdverts: floatRateAdverts, - floatRateOffsetLimit: floatRateOffsetLimit, - localCurrencies: localCurrencies, - maximumAdvertAmount: maximumAdvertAmount, - maximumOrderAmount: maximumOrderAmount, - orderDailyLimit: orderDailyLimit, - orderPaymentPeriod: orderPaymentPeriod, - paymentMethodsEnabled: paymentMethodsEnabled, - reviewPeriod: reviewPeriod, - supportedCurrencies: supportedCurrencies, - advertsArchivePeriod: advertsArchivePeriod, - fixedRateAdvertsEndDate: fixedRateAdvertsEndDate, - overrideExchangeRate: overrideExchangeRate, - ); + required super.advertsActiveLimit, + required super.blockTrade, + required super.cancellationBlockDuration, + required super.cancellationCountPeriod, + required super.cancellationGracePeriod, + required super.cancellationLimit, + required super.crossBorderAdsEnabled, + required super.disabled, + required super.featureLevel, + required super.fixedRateAdverts, + required super.floatRateAdverts, + required super.floatRateOffsetLimit, + required super.localCurrencies, + required super.maximumAdvertAmount, + required super.maximumOrderAmount, + required super.orderDailyLimit, + required super.orderPaymentPeriod, + required super.paymentMethodsEnabled, + required super.reviewPeriod, + required super.supportedCurrencies, + super.advertsArchivePeriod, + super.fixedRateAdvertsEndDate, + super.overrideExchangeRate, + }); /// Creates an instance from JSON. factory P2pConfig.fromJson(Map json) => P2pConfig( advertsActiveLimit: json['adverts_active_limit'], + blockTrade: BlockTrade.fromJson(json['block_trade']), cancellationBlockDuration: json['cancellation_block_duration'], cancellationCountPeriod: json['cancellation_count_period'], cancellationGracePeriod: json['cancellation_grace_period'], cancellationLimit: json['cancellation_limit'], + crossBorderAdsEnabled: getBool(json['cross_border_ads_enabled'])!, disabled: getBool(json['disabled'])!, featureLevel: json['feature_level'], fixedRateAdverts: @@ -1377,10 +1325,13 @@ class P2pConfig extends P2pConfigModel { final Map resultMap = {}; resultMap['adverts_active_limit'] = advertsActiveLimit; + resultMap['block_trade'] = blockTrade.toJson(); + resultMap['cancellation_block_duration'] = cancellationBlockDuration; resultMap['cancellation_count_period'] = cancellationCountPeriod; resultMap['cancellation_grace_period'] = cancellationGracePeriod; resultMap['cancellation_limit'] = cancellationLimit; + resultMap['cross_border_ads_enabled'] = crossBorderAdsEnabled; resultMap['disabled'] = disabled; resultMap['feature_level'] = featureLevel; resultMap['fixed_rate_adverts'] = fixedRateAdvertsEnumMapper.entries @@ -1420,10 +1371,12 @@ class P2pConfig extends P2pConfigModel { /// Creates a copy of instance with given parameters. P2pConfig copyWith({ int? advertsActiveLimit, + BlockTrade? blockTrade, int? cancellationBlockDuration, int? cancellationCountPeriod, int? cancellationGracePeriod, int? cancellationLimit, + bool? crossBorderAdsEnabled, bool? disabled, int? featureLevel, FixedRateAdvertsEnum? fixedRateAdverts, @@ -1443,6 +1396,7 @@ class P2pConfig extends P2pConfigModel { }) => P2pConfig( advertsActiveLimit: advertsActiveLimit ?? this.advertsActiveLimit, + blockTrade: blockTrade ?? this.blockTrade, cancellationBlockDuration: cancellationBlockDuration ?? this.cancellationBlockDuration, cancellationCountPeriod: @@ -1450,6 +1404,8 @@ class P2pConfig extends P2pConfigModel { cancellationGracePeriod: cancellationGracePeriod ?? this.cancellationGracePeriod, cancellationLimit: cancellationLimit ?? this.cancellationLimit, + crossBorderAdsEnabled: + crossBorderAdsEnabled ?? this.crossBorderAdsEnabled, disabled: disabled ?? this.disabled, featureLevel: featureLevel ?? this.featureLevel, fixedRateAdverts: fixedRateAdverts ?? this.fixedRateAdverts, @@ -1470,7 +1426,55 @@ class P2pConfig extends P2pConfigModel { overrideExchangeRate: overrideExchangeRate ?? this.overrideExchangeRate, ); } +/// Block trade model class. +abstract class BlockTradeModel { + /// Initializes Block trade model class . + const BlockTradeModel({ + this.disabled, + this.maximumAdvertAmount, + }); + + /// When `true`, Block trading is unavailable. + final bool? disabled; + + /// Maximum amount of a block trade advert, in USD. + final double? maximumAdvertAmount; +} + +/// Block trade class. +class BlockTrade extends BlockTradeModel { + /// Initializes Block trade class. + const BlockTrade({ + super.disabled, + super.maximumAdvertAmount, + }); + + /// Creates an instance from JSON. + factory BlockTrade.fromJson(Map json) => BlockTrade( + disabled: getBool(json['disabled']), + maximumAdvertAmount: getDouble(json['maximum_advert_amount']), + ); + /// Converts an instance to JSON. + Map toJson() { + final Map resultMap = {}; + + resultMap['disabled'] = disabled; + resultMap['maximum_advert_amount'] = maximumAdvertAmount; + + return resultMap; + } + + /// Creates a copy of instance with given parameters. + BlockTrade copyWith({ + bool? disabled, + double? maximumAdvertAmount, + }) => + BlockTrade( + disabled: disabled ?? this.disabled, + maximumAdvertAmount: maximumAdvertAmount ?? this.maximumAdvertAmount, + ); +} /// Local currencies item model class. abstract class LocalCurrenciesItemModel { /// Initializes Local currencies item model class . @@ -1498,16 +1502,11 @@ abstract class LocalCurrenciesItemModel { class LocalCurrenciesItem extends LocalCurrenciesItemModel { /// Initializes Local currencies item class. const LocalCurrenciesItem({ - required String displayName, - required bool hasAdverts, - required String symbol, - int? isDefault, - }) : super( - displayName: displayName, - hasAdverts: hasAdverts, - symbol: symbol, - isDefault: isDefault, - ); + required super.displayName, + required super.hasAdverts, + required super.symbol, + super.isDefault, + }); /// Creates an instance from JSON. factory LocalCurrenciesItem.fromJson(Map json) => @@ -1544,7 +1543,6 @@ class LocalCurrenciesItem extends LocalCurrenciesItemModel { isDefault: isDefault ?? this.isDefault, ); } - /// Payment agents model class. abstract class PaymentAgentsModel { /// Initializes Payment agents model class . @@ -1560,10 +1558,8 @@ abstract class PaymentAgentsModel { class PaymentAgents extends PaymentAgentsModel { /// Initializes Payment agents class. const PaymentAgents({ - required Map initialDepositPerCountry, - }) : super( - initialDepositPerCountry: initialDepositPerCountry, - ); + required super.initialDepositPerCountry, + }); /// Creates an instance from JSON. factory PaymentAgents.fromJson(Map json) => PaymentAgents( @@ -1592,7 +1588,6 @@ class PaymentAgents extends PaymentAgentsModel { initialDepositPerCountry ?? this.initialDepositPerCountry, ); } - /// Subscription model class. abstract class SubscriptionModel { /// Initializes Subscription model class . @@ -1608,10 +1603,8 @@ abstract class SubscriptionModel { class Subscription extends SubscriptionModel { /// Initializes Subscription class. const Subscription({ - required String id, - }) : super( - id: id, - ); + required super.id, + }); /// Creates an instance from JSON. factory Subscription.fromJson(Map json) => Subscription( diff --git a/lib/basic_api/generated/authorize_receive.dart b/lib/basic_api/generated/authorize_receive.dart index b40f4887df..6a2dea5963 100644 --- a/lib/basic_api/generated/authorize_receive.dart +++ b/lib/basic_api/generated/authorize_receive.dart @@ -9,16 +9,11 @@ class AuthorizeReceive extends Response { /// Initialize AuthorizeReceive. const AuthorizeReceive({ this.authorize, - Map? echoReq, - Map? error, - String? msgType, - int? reqId, - }) : super( - echoReq: echoReq, - error: error, - msgType: msgType, - reqId: reqId, - ); + super.echoReq, + super.error, + super.msgType, + super.reqId, + }); /// Creates an instance from JSON. factory AuthorizeReceive.fromJson(Map json) => diff --git a/lib/basic_api/generated/authorize_send.dart b/lib/basic_api/generated/authorize_send.dart index 31ecf87105..15c237dbd3 100644 --- a/lib/basic_api/generated/authorize_send.dart +++ b/lib/basic_api/generated/authorize_send.dart @@ -10,13 +10,10 @@ class AuthorizeRequest extends Request { const AuthorizeRequest({ this.addToLoginHistory, required this.authorize, - Map? passthrough, - int? reqId, - }) : super( - msgType: 'authorize', - passthrough: passthrough, - reqId: reqId, - ); + super.msgType = 'authorize', + super.passthrough, + super.reqId, + }); /// Creates an instance from JSON. factory AuthorizeRequest.fromJson(Map json) => diff --git a/lib/basic_api/generated/available_accounts_receive.dart b/lib/basic_api/generated/available_accounts_receive.dart new file mode 100644 index 0000000000..e0d69942b7 --- /dev/null +++ b/lib/basic_api/generated/available_accounts_receive.dart @@ -0,0 +1,61 @@ +/// Generated automatically from flutter_deriv_api|lib/basic_api/generated/available_accounts_receive.json. + +// ignore_for_file: always_put_required_named_parameters_first + +import '../response.dart'; + +/// Available accounts receive class. +class AvailableAccountsReceive extends Response { + /// Initialize AvailableAccountsReceive. + const AvailableAccountsReceive({ + this.availableAccounts, + super.echoReq, + super.error, + super.msgType, + super.reqId, + }); + + /// Creates an instance from JSON. + factory AvailableAccountsReceive.fromJson(Map json) => + AvailableAccountsReceive( + availableAccounts: json['available_accounts'] as Map?, + echoReq: json['echo_req'] as Map?, + error: json['error'] as Map?, + msgType: json['msg_type'] as String?, + reqId: json['req_id'] as int?, + ); + + /// Returns list of accounts that are available to be created - limited to wallets and can be extended + final Map? availableAccounts; + + /// Converts this instance to JSON + @override + Map toJson() => { + 'available_accounts': availableAccounts, + 'echo_req': echoReq, + 'error': error, + 'msg_type': msgType, + 'req_id': reqId, + }; + + /// Creates a copy of instance with given parameters + @override + AvailableAccountsReceive copyWith({ + Map? availableAccounts, + Map? echoReq, + Map? error, + String? msgType, + int? reqId, + }) => + AvailableAccountsReceive( + availableAccounts: availableAccounts ?? this.availableAccounts, + echoReq: echoReq ?? this.echoReq, + error: error ?? this.error, + msgType: msgType ?? this.msgType, + reqId: reqId ?? this.reqId, + ); + + /// Override equatable class. + @override + List get props => []; +} diff --git a/lib/basic_api/generated/available_accounts_send.dart b/lib/basic_api/generated/available_accounts_send.dart new file mode 100644 index 0000000000..a1bfe8fc4a --- /dev/null +++ b/lib/basic_api/generated/available_accounts_send.dart @@ -0,0 +1,76 @@ +/// Generated automatically from flutter_deriv_api|lib/basic_api/generated/available_accounts_send.json. + +// ignore_for_file: always_put_required_named_parameters_first + +import '../request.dart'; + +/// Available accounts request class. +class AvailableAccountsRequest extends Request { + /// Initialize AvailableAccountsRequest. + const AvailableAccountsRequest({ + this.availableAccounts = true, + required this.categories, + this.loginid, + super.msgType = 'available_accounts', + super.passthrough, + super.reqId, + }); + + /// Creates an instance from JSON. + factory AvailableAccountsRequest.fromJson(Map json) => + AvailableAccountsRequest( + availableAccounts: json['available_accounts'] == null + ? null + : json['available_accounts'] == 1, + categories: (json['categories'] as List?) + ?.map((dynamic item) => item as String) + .toList(), + loginid: json['loginid'] as String?, + passthrough: json['passthrough'] as Map?, + reqId: json['req_id'] as int?, + ); + + /// Must be `true` + final bool? availableAccounts; + + /// List of account categories that needs to received. + final List? categories; + + /// [Optional] The login id of the user. If left unspecified, it defaults to the initial authorized token's login id. + final String? loginid; + + /// Converts this instance to JSON + @override + Map toJson() => { + 'available_accounts': availableAccounts == null + ? null + : availableAccounts! + ? 1 + : 0, + 'categories': categories, + 'loginid': loginid, + 'passthrough': passthrough, + 'req_id': reqId, + }; + + /// Creates a copy of instance with given parameters + @override + AvailableAccountsRequest copyWith({ + bool? availableAccounts, + List? categories, + String? loginid, + Map? passthrough, + int? reqId, + }) => + AvailableAccountsRequest( + availableAccounts: availableAccounts ?? this.availableAccounts, + categories: categories ?? this.categories, + loginid: loginid ?? this.loginid, + passthrough: passthrough ?? this.passthrough, + reqId: reqId ?? this.reqId, + ); + + /// Override equatable class. + @override + List get props => []; +} diff --git a/lib/basic_api/generated/get_account_types_receive.dart b/lib/basic_api/generated/get_account_types_receive.dart index 3cded5047b..2542422c26 100644 --- a/lib/basic_api/generated/get_account_types_receive.dart +++ b/lib/basic_api/generated/get_account_types_receive.dart @@ -9,16 +9,11 @@ class GetAccountTypesReceive extends Response { /// Initialize GetAccountTypesReceive. const GetAccountTypesReceive({ this.getAccountTypes, - Map? echoReq, - Map? error, - String? msgType, - int? reqId, - }) : super( - echoReq: echoReq, - error: error, - msgType: msgType, - reqId: reqId, - ); + super.echoReq, + super.error, + super.msgType, + super.reqId, + }); /// Creates an instance from JSON. factory GetAccountTypesReceive.fromJson(Map json) => diff --git a/lib/basic_api/generated/get_account_types_send.dart b/lib/basic_api/generated/get_account_types_send.dart index ec218b33b8..3697fec157 100644 --- a/lib/basic_api/generated/get_account_types_send.dart +++ b/lib/basic_api/generated/get_account_types_send.dart @@ -8,18 +8,17 @@ import '../request.dart'; class GetAccountTypesRequest extends Request { /// Initialize GetAccountTypesRequest. const GetAccountTypesRequest({ + this.company, this.getAccountTypes = true, - Map? passthrough, - int? reqId, - }) : super( - msgType: 'get_account_types', - passthrough: passthrough, - reqId: reqId, - ); + super.msgType = 'get_account_types', + super.passthrough, + super.reqId, + }); /// Creates an instance from JSON. factory GetAccountTypesRequest.fromJson(Map json) => GetAccountTypesRequest( + company: json['company'] as String?, getAccountTypes: json['get_account_types'] == null ? null : json['get_account_types'] == 1, @@ -27,12 +26,16 @@ class GetAccountTypesRequest extends Request { reqId: json['req_id'] as int?, ); + /// [Optional] Set to landing company to get relevant account types. If not set, this defaults to current account landing company + final String? company; + /// Must be `true` final bool? getAccountTypes; /// Converts this instance to JSON @override Map toJson() => { + 'company': company, 'get_account_types': getAccountTypes == null ? null : getAccountTypes! @@ -45,11 +48,13 @@ class GetAccountTypesRequest extends Request { /// Creates a copy of instance with given parameters @override GetAccountTypesRequest copyWith({ + String? company, bool? getAccountTypes, Map? passthrough, int? reqId, }) => GetAccountTypesRequest( + company: company ?? this.company, getAccountTypes: getAccountTypes ?? this.getAccountTypes, passthrough: passthrough ?? this.passthrough, reqId: reqId ?? this.reqId, diff --git a/lib/basic_api/generated/get_settings_receive.dart b/lib/basic_api/generated/get_settings_receive.dart index 4822730a8d..9cac4c85ae 100644 --- a/lib/basic_api/generated/get_settings_receive.dart +++ b/lib/basic_api/generated/get_settings_receive.dart @@ -9,16 +9,11 @@ class GetSettingsReceive extends Response { /// Initialize GetSettingsReceive. const GetSettingsReceive({ this.getSettings, - Map? echoReq, - Map? error, - String? msgType, - int? reqId, - }) : super( - echoReq: echoReq, - error: error, - msgType: msgType, - reqId: reqId, - ); + super.echoReq, + super.error, + super.msgType, + super.reqId, + }); /// Creates an instance from JSON. factory GetSettingsReceive.fromJson(Map json) => diff --git a/lib/basic_api/generated/get_settings_send.dart b/lib/basic_api/generated/get_settings_send.dart index 3983af76ae..2f8605934c 100644 --- a/lib/basic_api/generated/get_settings_send.dart +++ b/lib/basic_api/generated/get_settings_send.dart @@ -9,13 +9,10 @@ class GetSettingsRequest extends Request { /// Initialize GetSettingsRequest. const GetSettingsRequest({ this.getSettings = true, - Map? passthrough, - int? reqId, - }) : super( - msgType: 'get_settings', - passthrough: passthrough, - reqId: reqId, - ); + super.msgType = 'get_settings', + super.passthrough, + super.reqId, + }); /// Creates an instance from JSON. factory GetSettingsRequest.fromJson(Map json) => diff --git a/lib/basic_api/generated/landing_company_details_send.dart b/lib/basic_api/generated/landing_company_details_send.dart index ad8785a79c..32f70337f5 100644 --- a/lib/basic_api/generated/landing_company_details_send.dart +++ b/lib/basic_api/generated/landing_company_details_send.dart @@ -8,29 +8,32 @@ import '../request.dart'; class LandingCompanyDetailsRequest extends Request { /// Initialize LandingCompanyDetailsRequest. const LandingCompanyDetailsRequest({ + this.country, required this.landingCompanyDetails, - Map? passthrough, - int? reqId, - }) : super( - msgType: 'landing_company_details', - passthrough: passthrough, - reqId: reqId, - ); + super.msgType = 'landing_company_details', + super.passthrough, + super.reqId, + }); /// Creates an instance from JSON. factory LandingCompanyDetailsRequest.fromJson(Map json) => LandingCompanyDetailsRequest( + country: json['country'] as String?, landingCompanyDetails: json['landing_company_details'] as String?, passthrough: json['passthrough'] as Map?, reqId: json['req_id'] as int?, ); + /// [Optional] Will return an extra field `tin_not_mandatory` indicating if the landing company does not require tax identification number for the provided country. + final String? country; + /// Landing company shortcode. final String? landingCompanyDetails; /// Converts this instance to JSON @override Map toJson() => { + 'country': country, 'landing_company_details': landingCompanyDetails, 'passthrough': passthrough, 'req_id': reqId, @@ -39,11 +42,13 @@ class LandingCompanyDetailsRequest extends Request { /// Creates a copy of instance with given parameters @override LandingCompanyDetailsRequest copyWith({ + String? country, String? landingCompanyDetails, Map? passthrough, int? reqId, }) => LandingCompanyDetailsRequest( + country: country ?? this.country, landingCompanyDetails: landingCompanyDetails ?? this.landingCompanyDetails, passthrough: passthrough ?? this.passthrough, diff --git a/lib/basic_api/generated/landing_company_send.dart b/lib/basic_api/generated/landing_company_send.dart index daf7f217f6..df52cef8b9 100644 --- a/lib/basic_api/generated/landing_company_send.dart +++ b/lib/basic_api/generated/landing_company_send.dart @@ -9,13 +9,10 @@ class LandingCompanyRequest extends Request { /// Initialize LandingCompanyRequest. const LandingCompanyRequest({ required this.landingCompany, - Map? passthrough, - int? reqId, - }) : super( - msgType: 'landing_company', - passthrough: passthrough, - reqId: reqId, - ); + super.msgType = 'landing_company', + super.passthrough, + super.reqId, + }); /// Creates an instance from JSON. factory LandingCompanyRequest.fromJson(Map json) => diff --git a/lib/basic_api/generated/link_wallet_receive.dart b/lib/basic_api/generated/link_wallet_receive.dart index c811464302..ecdb3c82c9 100644 --- a/lib/basic_api/generated/link_wallet_receive.dart +++ b/lib/basic_api/generated/link_wallet_receive.dart @@ -9,16 +9,11 @@ class LinkWalletReceive extends Response { /// Initialize LinkWalletReceive. const LinkWalletReceive({ this.linkWallet, - Map? echoReq, - Map? error, - String? msgType, - int? reqId, - }) : super( - echoReq: echoReq, - error: error, - msgType: msgType, - reqId: reqId, - ); + super.echoReq, + super.error, + super.msgType, + super.reqId, + }); /// Creates an instance from JSON. factory LinkWalletReceive.fromJson(Map json) => diff --git a/lib/basic_api/generated/link_wallet_send.dart b/lib/basic_api/generated/link_wallet_send.dart index 5a188dedca..295ac456e9 100644 --- a/lib/basic_api/generated/link_wallet_send.dart +++ b/lib/basic_api/generated/link_wallet_send.dart @@ -11,13 +11,10 @@ class LinkWalletRequest extends Request { required this.clientId, this.linkWallet = true, required this.walletId, - Map? passthrough, - int? reqId, - }) : super( - msgType: 'link_wallet', - passthrough: passthrough, - reqId: reqId, - ); + super.msgType = 'link_wallet', + super.passthrough, + super.reqId, + }); /// Creates an instance from JSON. factory LinkWalletRequest.fromJson(Map json) => diff --git a/lib/basic_api/generated/methods/active_symbols_receive_methods.json b/lib/basic_api/generated/methods/active_symbols_receive_methods.json index e646705a2f..998e66b0de 100644 --- a/lib/basic_api/generated/methods/active_symbols_receive_methods.json +++ b/lib/basic_api/generated/methods/active_symbols_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Gets the list of active symbols.\n ///\n /// For parameters information refer to [ActiveSymbolsRequest].\n /// Throws an [ActiveSymbolsException] if API response contains an error\n static Future fetchActiveSymbols(\n ActiveSymbolsRequest request,\n ) async {\n final ActiveSymbolsReceive response = await _api.call(\n request: request,\n );\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n ActiveSymbolsException(baseExceptionModel: baseExceptionModel),\n );\n\n return ActiveSymbolsResponse.fromJson(response.activeSymbols);\n }", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Gets the list of active symbols.\n ///\n /// For parameters information refer to [ActiveSymbolsRequest].\n /// Throws an [BaseAPIException] if API response contains an error\n static Future fetchActiveSymbols(\n ActiveSymbolsRequest request,\n ) async {\n final ActiveSymbolsReceive response = await _api.call(\n request: request,\n );\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return ActiveSymbolsResponse.fromJson(response.activeSymbols);\n }", "imports": "import 'package:flutter_deriv_api/api/exceptions/exceptions.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/active_symbols_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/active_symbols_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/lib/basic_api/generated/methods/api_token_receive_methods.json b/lib/basic_api/generated/methods/api_token_receive_methods.json index d049c08e5a..fe3e68dee5 100644 --- a/lib/basic_api/generated/methods/api_token_receive_methods.json +++ b/lib/basic_api/generated/methods/api_token_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": " static final BaseAPI _api = Injector()();\n\n /// Creates an API tokens\n ///\n /// [name] is the name of the token.\n /// [scopes] is a list of permission scopes to provide with the token.\n /// [validForCurrentIPOnly] is optional and if you set this parameter during token creation,\n /// then the token created will only work for the IP address that was used to create the token\n /// Throws an [APITokenException] if API response contains an error.\n static Future create({\n required String name,\n required List scopes,\n bool? validForCurrentIPOnly,\n }) async {\n final ApiTokenReceive response = await _api.call(\n request: ApiTokenRequest(\n newToken: name,\n newTokenScopes: getStringListFromEnums(\n scopes), \n validForCurrentIpOnly: validForCurrentIPOnly,\n ),\n );\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n APITokenException(baseExceptionModel: baseExceptionModel),\n );\n\n return ApiTokenResponse.fromJson(response.apiToken);\n }\n\n /// Deletes the [token]\n ///\n /// Throws an [APITokenException] if API response contains an error\n static Future delete({\n required String token,\n }) async {\n final ApiTokenReceive response = await _api.call(\n request: ApiTokenRequest(deleteToken: token),\n );\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n APITokenException(baseExceptionModel: baseExceptionModel),\n );\n\n return ApiTokenResponse.fromJson(response.apiToken);\n }", + "methods": " static final BaseAPI _api = Injector()();\n\n /// Creates an API tokens\n ///\n /// [name] is the name of the token.\n /// [scopes] is a list of permission scopes to provide with the token.\n /// [validForCurrentIPOnly] is optional and if you set this parameter during token creation,\n /// then the token created will only work for the IP address that was used to create the token\n /// Throws an [BaseAPIException] if API response contains an error.\n static Future create({\n required String name,\n required List scopes,\n bool? validForCurrentIPOnly,\n }) async {\n final ApiTokenReceive response = await _api.call(\n request: ApiTokenRequest(\n newToken: name,\n newTokenScopes: getStringListFromEnums(\n scopes), \n validForCurrentIpOnly: validForCurrentIPOnly,\n ),\n );\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return ApiTokenResponse.fromJson(response.apiToken);\n }\n\n /// Deletes the [token]\n ///\n /// Throws an [BaseAPIException] if API response contains an error\n static Future delete({\n required String token,\n }) async {\n final ApiTokenReceive response = await _api.call(\n request: ApiTokenRequest(deleteToken: token),\n );\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return ApiTokenResponse.fromJson(response.apiToken);\n }", "imports": "import 'package:flutter_deriv_api/api/exceptions/exceptions.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/api_token_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/api_token_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/lib/basic_api/generated/methods/app_delete_receive_methods.json b/lib/basic_api/generated/methods/app_delete_receive_methods.json index 1e2f876b5b..fa8703186c 100644 --- a/lib/basic_api/generated/methods/app_delete_receive_methods.json +++ b/lib/basic_api/generated/methods/app_delete_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": " static final BaseAPI _api = Injector()();\n\n /// Deletes the application by appId specified in [AppDeleteRequest.appDelete].\n ///\n /// For parameters information refer to [AppDeleteRequest].\n /// Throws an [AppException] if API response contains an error\n static Future deleteApplication(\n AppDeleteRequest request) async {\n final AppDeleteReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n AppException(baseExceptionModel: baseExceptionModel),\n );\n\n return AppDeleteResponse.fromJson(response.appDelete);\n }", + "methods": " static final BaseAPI _api = Injector()();\n\n /// Deletes the application by appId specified in [AppDeleteRequest.appDelete].\n ///\n /// For parameters information refer to [AppDeleteRequest].\n /// Throws an [BaseAPIException] if API response contains an error\n static Future deleteApplication(\n AppDeleteRequest request) async {\n final AppDeleteReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return AppDeleteResponse.fromJson(response.appDelete);\n }", "imports": "import 'package:flutter_deriv_api/api/exceptions/exceptions.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/app_delete_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/app_delete_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/lib/basic_api/generated/methods/app_get_receive_methods.json b/lib/basic_api/generated/methods/app_get_receive_methods.json index 3266e24af7..f4ec13cb4e 100644 --- a/lib/basic_api/generated/methods/app_get_receive_methods.json +++ b/lib/basic_api/generated/methods/app_get_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Gets the information of the OAuth application specified by [appId] in [request]\n ///\n /// For parameters information refer to [AppGetRequest].\n /// Throws an [AppException] if API response contains an error\n static Future fetchApplicationDetails(\n AppGetRequest request,\n ) async {\n final AppGetReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n AppException(baseExceptionModel: baseExceptionModel),\n );\n\n return AppGetResponse.fromJson(response.appGet);\n }\n\n /// Gets all of the account's OAuth applications.\n ///\n /// For parameters information refer to [AppListRequest].\n /// Throws an [AppException] if API response contains an error\n static Future?> fetchApplicationList(\n AppListRequest request,\n ) async {\n final AppListReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n AppException(baseExceptionModel: baseExceptionModel),\n );\n\n return getListFromMap(\n response.appList,\n itemToTypeCallback: (dynamic item) => AppGetResponse.fromJson(item),\n );\n }\n\n /// Retrieves details of app markup according to criteria specified.\n Future fetchApplicationMarkupDetails({\n required DateTime dateFrom,\n required DateTime dateTo,\n String? clientLoginId,\n bool? description,\n int? limit,\n int? offset,\n String? sort,\n List? sortFields,\n }) =>\n AppMarkupDetailsResponse.fetchApplicationMarkupDetails(\n AppMarkupDetailsRequest(\n appId: appGet?.appId,\n clientLoginid: clientLoginId,\n dateFrom: dateFrom.toString(),\n dateTo: dateTo.toString(),\n description: description,\n limit: limit,\n offset: offset,\n sort: sort,\n sortFields: sortFields,\n ),\n );\n\n /// The request for deleting an application.\n Future deleteApplication() =>\n AppDeleteResponse.deleteApplication(\n AppDeleteRequest(appDelete: appGet?.appId),\n );\n\n /// Register a new Oauth application.\n Future registerApplication(\n {required List scopes}) =>\n AppRegisterResponse.registerApplication(\n AppRegisterRequest(\n appMarkupPercentage: appGet?.appMarkupPercentage,\n appstore: appGet?.appstore,\n github: appGet?.github,\n googleplay: appGet?.googleplay,\n homepage: appGet?.homepage,\n name: appGet?.name,\n redirectUri: appGet?.redirectUri,\n scopes: scopes\n .map((TokenScope scope) => getStringFromEnum(scope))\n .toList(),\n verificationUri: appGet?.verificationUri,\n ),\n );\n\n /// Update application.\n Future updateApplication(\n {required List scopes}) =>\n AppUpdateResponse.updateApplication(\n AppUpdateRequest(\n appMarkupPercentage: appGet?.appMarkupPercentage,\n appUpdate: appGet?.appId,\n appstore: appGet?.appstore,\n github: appGet?.github,\n googleplay: appGet?.googleplay,\n homepage: appGet?.homepage,\n name: appGet?.name,\n redirectUri: appGet?.redirectUri,\n scopes: scopes\n .map((TokenScope scope) => getStringFromEnum(scope))\n .toList(),\n verificationUri: appGet?.verificationUri,\n ),\n );\n\n /// Revoke access of particular app.\n Future revokeOauthApplication() =>\n RevokeOauthAppResponse.revokeOauthApplication(\n RevokeOauthAppRequest(revokeOauthApp: appGet?.appId),\n );", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Gets the information of the OAuth application specified by [appId] in [request]\n ///\n /// For parameters information refer to [AppGetRequest].\n /// Throws an [BaseAPIException] if API response contains an error\n static Future fetchApplicationDetails(\n AppGetRequest request,\n ) async {\n final AppGetReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return AppGetResponse.fromJson(response.appGet);\n }\n\n /// Gets all of the account's OAuth applications.\n ///\n /// For parameters information refer to [AppListRequest].\n /// Throws an [BaseAPIException] if API response contains an error\n static Future?> fetchApplicationList(\n AppListRequest request,\n ) async {\n final AppListReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return getListFromMap(\n response.appList,\n itemToTypeCallback: (dynamic item) => AppGetResponse.fromJson(item),\n );\n }\n\n /// Retrieves details of app markup according to criteria specified.\n Future fetchApplicationMarkupDetails({\n required DateTime dateFrom,\n required DateTime dateTo,\n String? clientLoginId,\n bool? description,\n int? limit,\n int? offset,\n String? sort,\n List? sortFields,\n }) =>\n AppMarkupDetailsResponse.fetchApplicationMarkupDetails(\n AppMarkupDetailsRequest(\n appId: appGet?.appId,\n clientLoginid: clientLoginId,\n dateFrom: dateFrom.toString(),\n dateTo: dateTo.toString(),\n description: description,\n limit: limit,\n offset: offset,\n sort: sort,\n sortFields: sortFields,\n ),\n );\n\n /// The request for deleting an application.\n Future deleteApplication() =>\n AppDeleteResponse.deleteApplication(\n AppDeleteRequest(appDelete: appGet?.appId),\n );\n\n /// Register a new Oauth application.\n Future registerApplication(\n {required List scopes}) =>\n AppRegisterResponse.registerApplication(\n AppRegisterRequest(\n appMarkupPercentage: appGet?.appMarkupPercentage,\n appstore: appGet?.appstore,\n github: appGet?.github,\n googleplay: appGet?.googleplay,\n homepage: appGet?.homepage,\n name: appGet?.name,\n redirectUri: appGet?.redirectUri,\n scopes: scopes\n .map((TokenScope scope) => getStringFromEnum(scope))\n .toList(),\n verificationUri: appGet?.verificationUri,\n ),\n );\n\n /// Update application.\n Future updateApplication(\n {required List scopes}) =>\n AppUpdateResponse.updateApplication(\n AppUpdateRequest(\n appMarkupPercentage: appGet?.appMarkupPercentage,\n appUpdate: appGet?.appId,\n appstore: appGet?.appstore,\n github: appGet?.github,\n googleplay: appGet?.googleplay,\n homepage: appGet?.homepage,\n name: appGet?.name,\n redirectUri: appGet?.redirectUri,\n scopes: scopes\n .map((TokenScope scope) => getStringFromEnum(scope))\n .toList(),\n verificationUri: appGet?.verificationUri,\n ),\n );\n\n /// Revoke access of particular app.\n Future revokeOauthApplication() =>\n RevokeOauthAppResponse.revokeOauthApplication(\n RevokeOauthAppRequest(revokeOauthApp: appGet?.appId),\n );", "imports": "import 'package:flutter_deriv_api/api/exceptions/exceptions.dart';\nimport 'package:flutter_deriv_api/api/models/enums.dart';\nimport 'package:flutter_deriv_api/api/response/app_delete_response_result.dart';\nimport 'package:flutter_deriv_api/api/response/app_markup_details_response_result.dart';\nimport 'package:flutter_deriv_api/api/response/app_register_response_result.dart';\nimport 'package:flutter_deriv_api/api/response/app_update_response_result.dart';\nimport 'package:flutter_deriv_api/api/response/revoke_oauth_app_response_result.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/app_delete_send.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/app_get_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/app_get_send.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/app_list_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/app_list_send.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/app_markup_details_send.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/app_register_send.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/app_update_send.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/revoke_oauth_app_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/lib/basic_api/generated/methods/app_list_receive_methods.json b/lib/basic_api/generated/methods/app_list_receive_methods.json index 75f43c54dc..9bf0f4e612 100644 --- a/lib/basic_api/generated/methods/app_list_receive_methods.json +++ b/lib/basic_api/generated/methods/app_list_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Gets all of the account's OAuth applications.\n ///\n /// For parameters information refer to [AppListRequest].\n /// Throws an [AppException] if API response contains an error\n static Future fetchApplicationList(\n AppListRequest request,\n ) async {\n final AppListReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n AppException(baseExceptionModel: baseExceptionModel),\n );\n\n return AppListResponse.fromJson(response.appList);\n }", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Gets all of the account's OAuth applications.\n ///\n /// For parameters information refer to [AppListRequest].\n /// Throws an [BaseAPIException] if API response contains an error\n static Future fetchApplicationList(\n AppListRequest request,\n ) async {\n final AppListReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return AppListResponse.fromJson(response.appList);\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/app_list_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/app_list_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/lib/basic_api/generated/methods/app_markup_details_receive_methods.json b/lib/basic_api/generated/methods/app_markup_details_receive_methods.json index 07cf2d29e1..a1e44f688c 100644 --- a/lib/basic_api/generated/methods/app_markup_details_receive_methods.json +++ b/lib/basic_api/generated/methods/app_markup_details_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Retrieve details of app markup according to criteria specified.\n ///\n /// For parameters information refer to [AppMarkupDetailsRequest].\n /// Throws an [AppException] if API response contains an error\n static Future fetchApplicationMarkupDetails(\n AppMarkupDetailsRequest request,\n ) async {\n final AppMarkupDetailsReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n AppException(baseExceptionModel: baseExceptionModel),\n );\n\n return AppMarkupDetailsResponse.fromJson(response.appMarkupDetails);\n }", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Retrieve details of app markup according to criteria specified.\n ///\n /// For parameters information refer to [AppMarkupDetailsRequest].\n /// Throws an [BaseAPIException] if API response contains an error\n static Future fetchApplicationMarkupDetails(\n AppMarkupDetailsRequest request,\n ) async {\n final AppMarkupDetailsReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return AppMarkupDetailsResponse.fromJson(response.appMarkupDetails);\n }", "imports": "import 'package:flutter_deriv_api/api/exceptions/exceptions.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/app_markup_details_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/app_markup_details_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/lib/basic_api/generated/methods/app_register_receive_methods.json b/lib/basic_api/generated/methods/app_register_receive_methods.json index 0ec886fd0e..1bb152c27c 100644 --- a/lib/basic_api/generated/methods/app_register_receive_methods.json +++ b/lib/basic_api/generated/methods/app_register_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Registers a new OAuth application.\n ///\n /// For parameters information refer to [AppRegisterRequest].\n /// Throws an [AppException] if API response contains an error\n static Future registerApplication(\n AppRegisterRequest request,\n ) async {\n final AppRegisterReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n AppException(baseExceptionModel: baseExceptionModel),\n );\n\n return AppRegisterResponse.fromJson(response.appRegister);\n }", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Registers a new OAuth application.\n ///\n /// For parameters information refer to [AppRegisterRequest].\n /// Throws an [BaseAPIException] if API response contains an error\n static Future registerApplication(\n AppRegisterRequest request,\n ) async {\n final AppRegisterReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return AppRegisterResponse.fromJson(response.appRegister);\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/app_register_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/app_register_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/lib/basic_api/generated/methods/app_update_receive_methods.json b/lib/basic_api/generated/methods/app_update_receive_methods.json index 82728bc6cd..18827d8be5 100644 --- a/lib/basic_api/generated/methods/app_update_receive_methods.json +++ b/lib/basic_api/generated/methods/app_update_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Updates the application specified in [request].\n ///\n /// For parameters information refer to [AppUpdateRequest].\n /// Throws an [AppException] if API response contains an error\n static Future updateApplication(\n AppUpdateRequest request) async {\n final AppUpdateReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n AppException(baseExceptionModel: baseExceptionModel),\n );\n\n return AppUpdateResponse.fromJson(response.appUpdate);\n }", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Updates the application specified in [request].\n ///\n /// For parameters information refer to [AppUpdateRequest].\n /// Throws an [BaseAPIException] if API response contains an error\n static Future updateApplication(\n AppUpdateRequest request) async {\n final AppUpdateReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return AppUpdateResponse.fromJson(response.appUpdate);\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/app_update_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/app_update_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/lib/basic_api/generated/methods/asset_index_receive_methods.json b/lib/basic_api/generated/methods/asset_index_receive_methods.json index 6a713b8f1f..bd80bf1226 100644 --- a/lib/basic_api/generated/methods/asset_index_receive_methods.json +++ b/lib/basic_api/generated/methods/asset_index_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": " static final BaseAPI _api = Injector()();\n\n /// Retrieves a list of all available underlyings and the corresponding contract types and duration boundaries.\n ///\n /// If the user is logged in, only the assets available for that user's landing company will be returned.\n /// Throws an [AssetIndexException] if API response contains an error\n static Future fetchAssetIndices(\n AssetIndexRequest request,\n ) async {\n final AssetIndexReceive response = await _api.call(\n request: request,\n );\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n AssetIndexException(baseExceptionModel: baseExceptionModel),\n );\n\n return AssetIndexResponse.fromJson(response.assetIndex);\n }", + "methods": " static final BaseAPI _api = Injector()();\n\n /// Retrieves a list of all available underlyings and the corresponding contract types and duration boundaries.\n ///\n /// If the user is logged in, only the assets available for that user's landing company will be returned.\n /// Throws an [BaseAPIException] if API response contains an error\n static Future fetchAssetIndices(\n AssetIndexRequest request,\n ) async {\n final AssetIndexReceive response = await _api.call(\n request: request,\n );\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return AssetIndexResponse.fromJson(response.assetIndex);\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/asset_index_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/asset_index_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/lib/basic_api/generated/methods/authorize_receive_methods.json b/lib/basic_api/generated/methods/authorize_receive_methods.json index c978580ecd..b82623671f 100644 --- a/lib/basic_api/generated/methods/authorize_receive_methods.json +++ b/lib/basic_api/generated/methods/authorize_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()(); \n \n /// Authorizes current WebSocket session to act on behalf of the owner of a given token. \n /// \n /// For parameters information refer to [AuthorizeRequest]. \n /// Throws an [AuthorizeException] if API response contains an error. \n static Future authorizeMethodRaw( \n AuthorizeRequest request, \n ) async { \n final AuthorizeReceive response = await _api.call( \n request: request, \n ); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n AuthorizeException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response; \n } \n \n /// Authorizes current WebSocket session to act on behalf of the owner of a given token. \n /// \n /// For parameters information refer to [AuthorizeRequest]. \n /// Throws an [AuthorizeException] if API response contains an error. \n static Future authorizeMethod( \n AuthorizeRequest request, \n ) async { \n final AuthorizeReceive response = await authorizeMethodRaw(request); \n \n return AuthorizeResponse.fromJson(response.authorize); \n }", + "methods": "static final BaseAPI _api = Injector()(); \n \n /// Authorizes current WebSocket session to act on behalf of the owner of a given token. \n /// \n /// For parameters information refer to [AuthorizeRequest]. \n /// Throws an [BaseAPIException] if API response contains an error. \n static Future authorizeMethodRaw( \n AuthorizeRequest request, \n ) async { \n final AuthorizeReceive response = await _api.call( \n request: request, \n ); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n BaseAPIException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response; \n } \n \n /// Authorizes current WebSocket session to act on behalf of the owner of a given token. \n /// \n /// For parameters information refer to [AuthorizeRequest]. \n /// Throws an [BaseAPIException] if API response contains an error. \n static Future authorizeMethod( \n AuthorizeRequest request, \n ) async { \n final AuthorizeReceive response = await authorizeMethodRaw(request); \n \n return AuthorizeResponse.fromJson(response.authorize); \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/authorize_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/authorize_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/lib/basic_api/generated/methods/available_accounts_receive_methods.json b/lib/basic_api/generated/methods/available_accounts_receive_methods.json new file mode 100644 index 0000000000..640034becf --- /dev/null +++ b/lib/basic_api/generated/methods/available_accounts_receive_methods.json @@ -0,0 +1,4 @@ +{ +"methods": "", +"imports": "import 'package:flutter_deriv_api/helpers/helpers.dart';\n" +} diff --git a/lib/basic_api/generated/methods/balance_receive_methods.json b/lib/basic_api/generated/methods/balance_receive_methods.json index 7ea265903c..db7d99034c 100644 --- a/lib/basic_api/generated/methods/balance_receive_methods.json +++ b/lib/basic_api/generated/methods/balance_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Gets the balance of account\n ///\n /// For parameters info refer to [BalanceRequest]\n /// Throws a [BalanceException] if API response contains an error\n static Future fetchBalance(BalanceRequest request) async {\n final BalanceReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BalanceException(baseExceptionModel: baseExceptionModel),\n );\n\n return BalanceResponse.fromJson(response.balance, response.subscription);\n }\n\n /// Instead of one call [Balance.fetchBalance] gets stream of [Balance]\n ///\n /// Throws a [BalanceException] if API response contains an error\n static Stream subscribeBalance(\n BalanceRequest request, {\n RequestCompareFunction? comparePredicate,\n }) =>\n _api\n .subscribe(request: request, comparePredicate: comparePredicate)!\n .map((Response response) {\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BalanceException(baseExceptionModel: baseExceptionModel),\n );\n\n return response is BalanceReceive\n ? BalanceResponse.fromJson(\n response.balance,\n response.subscription,\n )\n : null;\n });\n\n /// Unsubscribes from balance subscription.\n ///\n /// Throws a [BalanceException] if API response contains an error\n Future unsubscribeBalance() async {\n if (subscription == null) {\n return null;\n }\n\n final ForgetReceive response =\n await _api.unsubscribe(subscriptionId: subscription!.id);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BalanceException(baseExceptionModel: baseExceptionModel),\n );\n\n return ForgetResponse.fromJson(response.forget);\n }\n\n /// Unsubscribes all balance subscriptions.\n ///\n /// Throws a [BalanceException] if API response contains an error\n static Future unsubscribeAllBalance() async {\n final ForgetAllReceive response =\n await _api.unsubscribeAll(method: ForgetStreamType.balance);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BalanceException(baseExceptionModel: baseExceptionModel),\n );\n\n return ForgetAllResponse.fromJson(response.forgetAll);\n }", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Gets the balance of account\n ///\n /// For parameters info refer to [BalanceRequest]\n /// Throws a [BaseAPIException] if API response contains an error\n static Future fetchBalance(BalanceRequest request) async {\n final BalanceReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return BalanceResponse.fromJson(response.balance, response.subscription);\n }\n\n /// Instead of one call [Balance.fetchBalance] gets stream of [Balance]\n ///\n /// Throws a [BaseAPIException] if API response contains an error\n static Stream subscribeBalance(\n BalanceRequest request, {\n RequestCompareFunction? comparePredicate,\n }) =>\n _api\n .subscribe(request: request, comparePredicate: comparePredicate)!\n .map((Response response) {\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return response is BalanceReceive\n ? BalanceResponse.fromJson(\n response.balance,\n response.subscription,\n )\n : null;\n });\n\n /// Unsubscribes from balance subscription.\n ///\n /// Throws a [BaseAPIException] if API response contains an error\n Future unsubscribeBalance() async {\n if (subscription == null) {\n return null;\n }\n\n final ForgetReceive response =\n await _api.unsubscribe(subscriptionId: subscription!.id);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return ForgetResponse.fromJson(response.forget);\n }\n\n /// Unsubscribes all balance subscriptions.\n ///\n /// Throws a [BaseAPIException] if API response contains an error\n static Future unsubscribeAllBalance() async {\n final ForgetAllReceive response =\n await _api.unsubscribeAll(method: ForgetStreamType.balance);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return ForgetAllResponse.fromJson(response.forgetAll);\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/api/models/enums.dart';\nimport 'package:flutter_deriv_api/api/response/forget_all_response_result.dart';\nimport 'package:flutter_deriv_api/api/response/forget_response_result.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/balance_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/balance_send.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/forget_all_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/forget_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/response.dart';\nimport 'package:flutter_deriv_api/helpers/helpers.dart';\nimport 'package:flutter_deriv_api/services/connection/api_manager/base_api.dart';\nimport 'package:flutter_deriv_api/services/connection/call_manager/base_call_manager.dart';\nimport 'package:deriv_dependency_injector/dependency_injector.dart';\n" } diff --git a/lib/basic_api/generated/methods/buy_receive_methods.json b/lib/basic_api/generated/methods/buy_receive_methods.json index 79fab41830..cfd4a6220e 100644 --- a/lib/basic_api/generated/methods/buy_receive_methods.json +++ b/lib/basic_api/generated/methods/buy_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Buys a contract with parameters specified in given [BuyRequest]\n ///\n /// Throws a [ContractOperationException] if API response contains an error\n static Future buyMethod(BuyRequest request) async {\n final BuyReceive response = await _api.call(\n request: request,\n );\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n ContractOperationException(baseExceptionModel: baseExceptionModel),\n );\n\n return BuyResponse.fromJson(response.buy, response.subscription);\n }\n\n /// Buys contract with parameters specified in request and subscribes to it.\n ///\n /// Throws a [ContractOperationException] is API response contains an error\n static Stream buyAndSubscribe(\n BuyRequest request, {\n RequestCompareFunction? comparePredicate,\n }) =>\n _api\n .subscribe(request: request, comparePredicate: comparePredicate)!\n .map(\n (Response response) {\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n ContractOperationException(\n baseExceptionModel: baseExceptionModel),\n );\n return response is ProposalOpenContractReceive\n ? ProposalOpenContractResponse.fromJson(\n response.proposalOpenContract,\n response.subscription,\n )\n : null;\n },\n );\n\n /// Gets the current spot of the this bought contract as [Contract].\n ///\n /// Throws a [ContractOperationException] if API response contains an error\n Future fetchState() =>\n ProposalOpenContractResponse.fetchContractState(\n ProposalOpenContractRequest(\n contractId: buy?.contractId,\n ),\n );\n\n /// Subscribes to this bought contract spot and returns its spot update as [ContractBaseModel].\n ///\n /// Throws a [ContractOperationException] if API response contains an error\n Stream subscribeState({\n RequestCompareFunction? comparePredicate,\n }) =>\n ProposalOpenContractResponse.subscribeContractState(\n ProposalOpenContractRequest(contractId: buy?.contractId),\n comparePredicate: comparePredicate,\n );\n\n /// Updates this contract\n ///\n /// New [stopLoss] value for a contract. To cancel, pass null.\n /// New [takeProfit] value for a contract. To cancel, pass null.\n /// Throws a [ContractOperationException] if API response contains an error\n Future update({\n double? stopLoss,\n double? takeProfit,\n }) =>\n ContractUpdateResponse.updateContract(ContractUpdateRequest(\n contractId: buy?.contractId,\n limitOrder: {\n 'stop_loss': stopLoss,\n 'take_profit': takeProfit,\n },\n ));\n", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Buys a contract with parameters specified in given [BuyRequest]\n ///\n /// Throws a [BaseAPIException] if API response contains an error\n static Future buyMethod(BuyRequest request) async {\n final BuyReceive response = await _api.call(\n request: request,\n );\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return BuyResponse.fromJson(response.buy, response.subscription);\n }\n\n /// Buys contract with parameters specified in request and subscribes to it.\n ///\n /// Throws a [BaseAPIException] is API response contains an error\n static Stream buyAndSubscribe(\n BuyRequest request, {\n RequestCompareFunction? comparePredicate,\n }) =>\n _api\n .subscribe(request: request, comparePredicate: comparePredicate)!\n .map(\n (Response response) {\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(\n baseExceptionModel: baseExceptionModel),\n );\n return response is ProposalOpenContractReceive\n ? ProposalOpenContractResponse.fromJson(\n response.proposalOpenContract,\n response.subscription,\n )\n : null;\n },\n );\n\n /// Gets the current spot of the this bought contract as [Contract].\n ///\n /// Throws a [BaseAPIException] if API response contains an error\n Future fetchState() =>\n ProposalOpenContractResponse.fetchContractState(\n ProposalOpenContractRequest(\n contractId: buy?.contractId,\n ),\n );\n\n /// Subscribes to this bought contract spot and returns its spot update as [ContractBaseModel].\n ///\n /// Throws a [BaseAPIException] if API response contains an error\n Stream subscribeState({\n RequestCompareFunction? comparePredicate,\n }) =>\n ProposalOpenContractResponse.subscribeContractState(\n ProposalOpenContractRequest(contractId: buy?.contractId),\n comparePredicate: comparePredicate,\n );\n\n /// Updates this contract\n ///\n /// New [stopLoss] value for a contract. To cancel, pass null.\n /// New [takeProfit] value for a contract. To cancel, pass null.\n /// Throws a [BaseAPIException] if API response contains an error\n Future update({\n double? stopLoss,\n double? takeProfit,\n }) =>\n ContractUpdateResponse.updateContract(ContractUpdateRequest(\n contractId: buy?.contractId,\n limitOrder: {\n 'stop_loss': stopLoss,\n 'take_profit': takeProfit,\n },\n ));\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/api/response/contract_update_response_result.dart';\nimport 'package:flutter_deriv_api/api/response/proposal_open_contract_response_result.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/buy_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/buy_send.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/contract_update_send.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/proposal_open_contract_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/proposal_open_contract_send.dart';\nimport 'package:flutter_deriv_api/basic_api/response.dart';\nimport 'package:flutter_deriv_api/helpers/helpers.dart';\nimport 'package:flutter_deriv_api/services/connection/api_manager/base_api.dart';\nimport 'package:flutter_deriv_api/services/connection/call_manager/base_call_manager.dart';\nimport 'package:deriv_dependency_injector/dependency_injector.dart';" } diff --git a/lib/basic_api/generated/methods/cancel_receive_methods.json b/lib/basic_api/generated/methods/cancel_receive_methods.json index fc9f61e9ac..532589936d 100644 --- a/lib/basic_api/generated/methods/cancel_receive_methods.json +++ b/lib/basic_api/generated/methods/cancel_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Cancels a contract with parameters specified in [CancelRequest].\n ///\n /// Throws a [ContractOperationException] if API response contains an error\n static Future cancelContract(CancelRequest request) async {\n final CancelReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n ContractOperationException(baseExceptionModel: baseExceptionModel),\n );\n\n return CancelResponse.fromJson(response.cancel);\n }", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Cancels a contract with parameters specified in [CancelRequest].\n ///\n /// Throws a [BaseAPIException] if API response contains an error\n static Future cancelContract(CancelRequest request) async {\n final CancelReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return CancelResponse.fromJson(response.cancel);\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/cancel_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/cancel_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/lib/basic_api/generated/methods/cashier_receive_methods.json b/lib/basic_api/generated/methods/cashier_receive_methods.json index 444a774871..aab5f555a4 100644 --- a/lib/basic_api/generated/methods/cashier_receive_methods.json +++ b/lib/basic_api/generated/methods/cashier_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": " static final BaseAPI _api = Injector()();\n\n /// Gets the cashier URL for given [CashierRequest]\n static Future fetchInformation(\n CashierRequest request,\n ) async {\n final CashierReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n CashierException(baseExceptionModel: baseExceptionModel),\n );\n\n return CashierResponse.fromJson(response.cashier, response.cashier);\n }", + "methods": " static final BaseAPI _api = Injector()();\n\n /// Gets the cashier URL for given [CashierRequest]\n static Future fetchInformation(\n CashierRequest request,\n ) async {\n final CashierReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return CashierResponse.fromJson(response.cashier, response.cashier);\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/cashier_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/cashier_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/lib/basic_api/generated/methods/contract_update_history_receive_methods.json b/lib/basic_api/generated/methods/contract_update_history_receive_methods.json index e15c6a1080..6b14abb64f 100644 --- a/lib/basic_api/generated/methods/contract_update_history_receive_methods.json +++ b/lib/basic_api/generated/methods/contract_update_history_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Gets update history for contract as List of [HistorySpotPriceModel]\n ///\n /// Throws a [ContractOperationException] if API response contains an error\n static Future fetchContractUpdateHistory(\n ContractUpdateHistoryRequest request,\n ) async {\n final ContractUpdateHistoryReceive response =\n await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n ContractOperationException(baseExceptionModel: baseExceptionModel),\n );\n\n return ContractUpdateHistoryResponse.fromJson(\n response.contractUpdateHistory);\n }", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Gets update history for contract as List of [HistorySpotPriceModel]\n ///\n /// Throws a [BaseAPIException] if API response contains an error\n static Future fetchContractUpdateHistory(\n ContractUpdateHistoryRequest request,\n ) async {\n final ContractUpdateHistoryReceive response =\n await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return ContractUpdateHistoryResponse.fromJson(\n response.contractUpdateHistory);\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/contract_update_history_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/contract_update_history_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/lib/basic_api/generated/methods/contract_update_receive_methods.json b/lib/basic_api/generated/methods/contract_update_receive_methods.json index 1c89837acb..a42b9fd17c 100644 --- a/lib/basic_api/generated/methods/contract_update_receive_methods.json +++ b/lib/basic_api/generated/methods/contract_update_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// updates a contract with parameters specified in [ContractUpdateRequest].\n ///\n /// Throws a [ContractOperationException] if API response contains an error\n static Future updateContract(\n ContractUpdateRequest request,\n ) async {\n final ContractUpdateReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n ContractOperationException(baseExceptionModel: baseExceptionModel),\n );\n\n return ContractUpdateResponse.fromJson(response.contractUpdate);\n }", + "methods": "static final BaseAPI _api = Injector()();\n\n /// updates a contract with parameters specified in [ContractUpdateRequest].\n ///\n /// Throws a [BaseAPIException] if API response contains an error\n static Future updateContract(\n ContractUpdateRequest request,\n ) async {\n final ContractUpdateReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return ContractUpdateResponse.fromJson(response.contractUpdate);\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/contract_update_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/contract_update_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/lib/basic_api/generated/methods/contracts_for_receive_methods.json b/lib/basic_api/generated/methods/contracts_for_receive_methods.json index a489b62af2..1be8460b88 100644 --- a/lib/basic_api/generated/methods/contracts_for_receive_methods.json +++ b/lib/basic_api/generated/methods/contracts_for_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Gets available contracts for given symbol in [ContractsForRequest]\n ///\n /// Throws a [ContractsForSymbolException] if API response contains an error\n static Future fetchContractsForSymbol(\n ContractsForRequest request,\n ) async {\n final ContractsForReceive response = await _api.call(\n request: request,\n );\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n ContractsForSymbolException(baseExceptionModel: baseExceptionModel),\n );\n\n return ContractsForResponse.fromJson(response.contractsFor);\n }", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Gets available contracts for given symbol in [ContractsForRequest]\n ///\n /// Throws a [BaseAPIException] if API response contains an error\n static Future fetchContractsForSymbol(\n ContractsForRequest request,\n ) async {\n final ContractsForReceive response = await _api.call(\n request: request,\n );\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return ContractsForResponse.fromJson(response.contractsFor);\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/contracts_for_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/contracts_for_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/lib/basic_api/generated/methods/copy_start_receive_methods.json b/lib/basic_api/generated/methods/copy_start_receive_methods.json index cf00a2b9f6..02ce18a1af 100644 --- a/lib/basic_api/generated/methods/copy_start_receive_methods.json +++ b/lib/basic_api/generated/methods/copy_start_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Starts copy trader bets.\n ///\n /// For parameters information refer to [CopyStartRequest].\n /// Throws a [CopyTradingException] if API response contains an error\n static Future start(CopyStartRequest request) async {\n final CopyStartReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n CopyTradingException(baseExceptionModel: baseExceptionModel),\n );\n\n return CopyStartResponse.fromJson(response.copyStart);\n }", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Starts copy trader bets.\n ///\n /// For parameters information refer to [CopyStartRequest].\n /// Throws a [BaseAPIException] if API response contains an error\n static Future start(CopyStartRequest request) async {\n final CopyStartReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return CopyStartResponse.fromJson(response.copyStart);\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/copy_start_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/copy_start_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/lib/basic_api/generated/methods/copy_stop_receive_methods.json b/lib/basic_api/generated/methods/copy_stop_receive_methods.json index 24f77e0474..3a1675951d 100644 --- a/lib/basic_api/generated/methods/copy_stop_receive_methods.json +++ b/lib/basic_api/generated/methods/copy_stop_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Stops copy trader bets.\n ///\n /// For parameters information refer to [CopyStopRequest].\n /// Throws a [CopyTradingException] if API response contains an error\n static Future stop(CopyStopRequest request) async {\n final CopyStopReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n CopyTradingException(baseExceptionModel: baseExceptionModel),\n );\n\n return CopyStopResponse.fromJson(response.copyStop);\n }", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Stops copy trader bets.\n ///\n /// For parameters information refer to [CopyStopRequest].\n /// Throws a [BaseAPIException] if API response contains an error\n static Future stop(CopyStopRequest request) async {\n final CopyStopReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return CopyStopResponse.fromJson(response.copyStop);\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/copy_stop_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/copy_stop_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/lib/basic_api/generated/methods/copytrading_list_receive_methods.json b/lib/basic_api/generated/methods/copytrading_list_receive_methods.json index 57842468f9..5947c23b93 100644 --- a/lib/basic_api/generated/methods/copytrading_list_receive_methods.json +++ b/lib/basic_api/generated/methods/copytrading_list_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Gets the list of active copiers and/or traders for Copy Trading\n ///\n /// Throws a [CopyTradingException] if API response contains an error\n static Future fetchList([\n CopytradingListRequest? request,\n ]) async {\n final CopytradingListReceive response = await _api.call(\n request: request ?? const CopytradingListRequest(),\n );\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n CopyTradingException(baseExceptionModel: baseExceptionModel),\n );\n\n return CopytradingListResponse.fromJson(response.copytradingList);\n }", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Gets the list of active copiers and/or traders for Copy Trading\n ///\n /// Throws a [BaseAPIException] if API response contains an error\n static Future fetchList([\n CopytradingListRequest? request,\n ]) async {\n final CopytradingListReceive response = await _api.call(\n request: request ?? const CopytradingListRequest(),\n );\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return CopytradingListResponse.fromJson(response.copytradingList);\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/copytrading_list_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/copytrading_list_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/lib/basic_api/generated/methods/copytrading_statistics_receive_methods.json b/lib/basic_api/generated/methods/copytrading_statistics_receive_methods.json index f3a20f20ec..dbf7095e0f 100644 --- a/lib/basic_api/generated/methods/copytrading_statistics_receive_methods.json +++ b/lib/basic_api/generated/methods/copytrading_statistics_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Gets the copy trading statistics for given `traderId` in [request]\n ///\n /// Throws a [CopyTradingException] if API response contains an error\n static Future fetchStatistics(\n CopytradingStatisticsRequest request,\n ) async {\n final CopytradingStatisticsReceive response = await _api.call(\n request: request,\n );\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n CopyTradingException(baseExceptionModel: baseExceptionModel),\n );\n\n return CopytradingStatisticsResponse.fromJson(\n response.copytradingStatistics);\n }", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Gets the copy trading statistics for given `traderId` in [request]\n ///\n /// Throws a [BaseAPIException] if API response contains an error\n static Future fetchStatistics(\n CopytradingStatisticsRequest request,\n ) async {\n final CopytradingStatisticsReceive response = await _api.call(\n request: request,\n );\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return CopytradingStatisticsResponse.fromJson(\n response.copytradingStatistics);\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/copytrading_statistics_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/copytrading_statistics_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/lib/basic_api/generated/methods/exchange_rates_receive_methods.json b/lib/basic_api/generated/methods/exchange_rates_receive_methods.json index 3ee84b9b7e..0d2ecdd8db 100644 --- a/lib/basic_api/generated/methods/exchange_rates_receive_methods.json +++ b/lib/basic_api/generated/methods/exchange_rates_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()(); \n \n /// Retrieves the exchange rates from a base currency to all currencies supported by the system. \n /// \n /// For parameters information refer to [ExchangeRatesRequest]. \n /// Throws an [ExchangeException] if API response contains an error. \n static Future fetchExchangeRatesRaw( \n ExchangeRatesRequest request, \n ) async { \n final ExchangeRatesReceive response = await _api.call(request: request); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n ExchangeException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response; \n } \n \n /// Retrieves the exchange rates from a base currency to all currencies supported by the system. \n /// \n /// For parameters information refer to [ExchangeRatesRequest]. \n /// Throws an [ExchangeException] if API response contains an error. \n static Future fetchExchangeRates( \n ExchangeRatesRequest request, \n ) async { \n final ExchangeRatesReceive response = await fetchExchangeRatesRaw(request); \n \n return ExchangeRates.fromJson(response.exchangeRates!); \n }", + "methods": "static final BaseAPI _api = Injector()(); \n \n /// Retrieves the exchange rates from a base currency to all currencies supported by the system. \n /// \n /// For parameters information refer to [ExchangeRatesRequest]. \n /// Throws an [BaseAPIException] if API response contains an error. \n static Future fetchExchangeRatesRaw( \n ExchangeRatesRequest request, \n ) async { \n final ExchangeRatesReceive response = await _api.call(request: request); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n BaseAPIException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response; \n } \n \n /// Retrieves the exchange rates from a base currency to all currencies supported by the system. \n /// \n /// For parameters information refer to [ExchangeRatesRequest]. \n /// Throws an [BaseAPIException] if API response contains an error. \n static Future fetchExchangeRates( \n ExchangeRatesRequest request, \n ) async { \n final ExchangeRatesReceive response = await fetchExchangeRatesRaw(request); \n \n return ExchangeRates.fromJson(response.exchangeRates!); \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/exchange_rates_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/exchange_rates_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/lib/basic_api/generated/methods/forget_all_receive_methods.json b/lib/basic_api/generated/methods/forget_all_receive_methods.json index 39ac2157fc..fa95b0195b 100644 --- a/lib/basic_api/generated/methods/forget_all_receive_methods.json +++ b/lib/basic_api/generated/methods/forget_all_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Immediately cancels the real-time streams of messages of given type.\n ///\n /// For parameters information refer to [ForgetAllRequest].\n /// Throws a [ForgetException] if API response contains an error\n static Future forgetAllMethod(\n ForgetAllRequest request,\n ) async {\n final ForgetAllReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n ForgetException(baseExceptionModel: baseExceptionModel),\n );\n\n return ForgetAllResponse.fromJson(response.forgetAll);\n }", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Immediately cancels the real-time streams of messages of given type.\n ///\n /// For parameters information refer to [ForgetAllRequest].\n /// Throws a [BaseAPIException] if API response contains an error\n static Future forgetAllMethod(\n ForgetAllRequest request,\n ) async {\n final ForgetAllReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return ForgetAllResponse.fromJson(response.forgetAll);\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/forget_all_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/forget_all_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/lib/basic_api/generated/methods/forget_receive_methods.json b/lib/basic_api/generated/methods/forget_receive_methods.json index cbfed8f9a6..48254d444c 100644 --- a/lib/basic_api/generated/methods/forget_receive_methods.json +++ b/lib/basic_api/generated/methods/forget_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Immediately cancels the real-time stream of messages with a specific id.\n ///\n /// For parameters information refer to [ForgetRequest].\n /// Throws a [ForgetException] if API response contains an error\n static Future forgetMethod(\n ForgetRequest request,\n ) async {\n final ForgetReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n ForgetException(baseExceptionModel: baseExceptionModel),\n );\n\n return ForgetResponse.fromJson(response.forget);\n }", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Immediately cancels the real-time stream of messages with a specific id.\n ///\n /// For parameters information refer to [ForgetRequest].\n /// Throws a [BaseAPIException] if API response contains an error\n static Future forgetMethod(\n ForgetRequest request,\n ) async {\n final ForgetReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return ForgetResponse.fromJson(response.forget);\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/forget_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/forget_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/lib/basic_api/generated/methods/get_account_status_receive_methods.json b/lib/basic_api/generated/methods/get_account_status_receive_methods.json index bdc88ffb2b..712a34feba 100644 --- a/lib/basic_api/generated/methods/get_account_status_receive_methods.json +++ b/lib/basic_api/generated/methods/get_account_status_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()(); \n \n /// Gets the account's status. \n /// \n /// For parameters information refer to [GetAccountStatusRequest]. \n /// Throws an [AccountStatusException] if API response contains an error. \n static Future fetchAccountStatusRaw() async { \n final GetAccountStatusReceive response = await _api.call( \n request: const GetAccountStatusRequest(), \n ); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n AccountStatusException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response; \n } \n \n /// Gets the account's status. \n /// \n /// For parameters information refer to [GetAccountStatusRequest]. \n /// Throws an [AccountStatusException] if API response contains an error. \n static Future fetchAccountStatus() async { \n final GetAccountStatusReceive response = await fetchAccountStatusRaw(); \n \n return GetAccountStatusResponse.fromJson(response.getAccountStatus); \n }", + "methods": "static final BaseAPI _api = Injector()(); \n \n /// Gets the account's status. \n /// \n /// For parameters information refer to [GetAccountStatusRequest]. \n /// Throws an [BaseAPIException] if API response contains an error. \n static Future fetchAccountStatusRaw() async { \n final GetAccountStatusReceive response = await _api.call( \n request: const GetAccountStatusRequest(), \n ); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n BaseAPIException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response; \n } \n \n /// Gets the account's status. \n /// \n /// For parameters information refer to [GetAccountStatusRequest]. \n /// Throws an [BaseAPIException] if API response contains an error. \n static Future fetchAccountStatus() async { \n final GetAccountStatusReceive response = await fetchAccountStatusRaw(); \n \n return GetAccountStatusResponse.fromJson(response.getAccountStatus); \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/get_account_status_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/get_account_status_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/lib/basic_api/generated/methods/get_financial_assessment_receive_methods.json b/lib/basic_api/generated/methods/get_financial_assessment_receive_methods.json index c9ec6289fe..578df28a8f 100644 --- a/lib/basic_api/generated/methods/get_financial_assessment_receive_methods.json +++ b/lib/basic_api/generated/methods/get_financial_assessment_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Gets the financial assessment details.\n ///\n /// The 'financial assessment' is a questionnaire that clients of certain Landing Companies need to complete,\n /// due to regulatory and KYC (know your client) requirements.\n /// Throws a [FinancialAssessmentException] if API response contains an error\n static Future fetchAssessment(\n GetFinancialAssessmentRequest request,\n ) async {\n final GetFinancialAssessmentReceive response =\n await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n FinancialAssessmentException(baseExceptionModel: baseExceptionModel),\n );\n\n return GetFinancialAssessmentResponse.fromJson(response.getFinancialAssessment);\n }\n", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Gets the financial assessment details.\n ///\n /// The 'financial assessment' is a questionnaire that clients of certain Landing Companies need to complete,\n /// due to regulatory and KYC (know your client) requirements.\n /// Throws a [BaseAPIException] if API response contains an error\n static Future fetchAssessment(\n GetFinancialAssessmentRequest request,\n ) async {\n final GetFinancialAssessmentReceive response =\n await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return GetFinancialAssessmentResponse.fromJson(response.getFinancialAssessment);\n }\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/get_financial_assessment_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/get_financial_assessment_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/lib/basic_api/generated/methods/get_limits_receive_methods.json b/lib/basic_api/generated/methods/get_limits_receive_methods.json index dcb770c184..0925e800a7 100644 --- a/lib/basic_api/generated/methods/get_limits_receive_methods.json +++ b/lib/basic_api/generated/methods/get_limits_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Gets the trading and withdrawal limits for logged in account\n ///\n /// Throws an [AccountLimitsException] if API response contains an error\n static Future fetchAccountLimits([\n GetLimitsRequest? request,\n ]) async {\n final GetLimitsReceive response = await _api.call(\n request: request ?? const GetLimitsRequest(),\n );\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n AccountLimitsException(baseExceptionModel: baseExceptionModel),\n );\n\n return GetLimitsResponse.fromJson(response.getLimits);\n }", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Gets the trading and withdrawal limits for logged in account\n ///\n /// Throws an [BaseAPIException] if API response contains an error\n static Future fetchAccountLimits([\n GetLimitsRequest? request,\n ]) async {\n final GetLimitsReceive response = await _api.call(\n request: request ?? const GetLimitsRequest(),\n );\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return GetLimitsResponse.fromJson(response.getLimits);\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/get_limits_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/get_limits_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/lib/basic_api/generated/methods/get_self_exclusion_receive_methods.json b/lib/basic_api/generated/methods/get_self_exclusion_receive_methods.json index 832d790698..30f1d09a66 100644 --- a/lib/basic_api/generated/methods/get_self_exclusion_receive_methods.json +++ b/lib/basic_api/generated/methods/get_self_exclusion_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Allows users to exclude themselves from the website for certain periods of time,\n /// or to set limits on their trading activities.\n ///\n /// This facility is a regulatory requirement for certain Landing Companies.\n /// For parameters information refer to [GetSelfExclusionRequest].\n /// Throws a [SelfExclusionException] if API response contains an error\n static Future fetchSelfExclusion([\n GetSelfExclusionRequest? request,\n ]) async {\n final GetSelfExclusionReceive response = await _api.call(\n request: request ?? const GetSelfExclusionRequest(),\n );\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n SelfExclusionException(baseExceptionModel: baseExceptionModel),\n );\n\n return GetSelfExclusionResponse.fromJson(response.getSelfExclusion);\n }\n\n /// Sets Self-Exclusion (this call should be used in conjunction with [fetchSelfExclusion])\n ///\n /// For parameters information refer to [SetSelfExclusionRequest].\n /// Throws a [SelfExclusionException] if API response contains an error\n static Future setSelfExclusion(SetSelfExclusionRequest request) async {\n final SetSelfExclusionReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n SelfExclusionException(baseExceptionModel: baseExceptionModel),\n );\n\n return getBool(response.setSelfExclusion);\n }\n\n /// Excludes user from the website based this parameters\n ///\n /// (this call should be used in conjunction with [fetchSelfExclusion])\n /// Throws a [SelfExclusionException] if API response contains an error\n Future exclude() async {\n final SetSelfExclusionReceive response = await _api.call(\n request: SetSelfExclusionRequest(\n excludeUntil: getSelfExclusion?.excludeUntil,\n max30dayDeposit: getSelfExclusion?.max30dayDeposit,\n max30dayLosses: getSelfExclusion?.max30dayLosses,\n max30dayTurnover: getSelfExclusion?.max30dayTurnover,\n max7dayDeposit: getSelfExclusion?.max7dayDeposit,\n max7dayLosses: getSelfExclusion?.max7dayLosses,\n max7dayTurnover: getSelfExclusion?.max7dayTurnover,\n maxBalance: getSelfExclusion?.maxBalance,\n maxDeposit: getSelfExclusion?.maxDeposit,\n maxLosses: getSelfExclusion?.maxLosses,\n maxOpenBets: getSelfExclusion?.maxOpenBets,\n maxTurnover: getSelfExclusion?.maxTurnover,\n sessionDurationLimit: getSelfExclusion?.sessionDurationLimit,\n timeoutUntil:\n getSecondsSinceEpochDateTime(getSelfExclusion?.timeoutUntil),\n ),\n );\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n SelfExclusionException(baseExceptionModel: baseExceptionModel),\n );\n\n return getBool(response.setSelfExclusion);\n }", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Allows users to exclude themselves from the website for certain periods of time,\n /// or to set limits on their trading activities.\n ///\n /// This facility is a regulatory requirement for certain Landing Companies.\n /// For parameters information refer to [GetSelfExclusionRequest].\n /// Throws a [BaseAPIException] if API response contains an error\n static Future fetchSelfExclusion([\n GetSelfExclusionRequest? request,\n ]) async {\n final GetSelfExclusionReceive response = await _api.call(\n request: request ?? const GetSelfExclusionRequest(),\n );\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return GetSelfExclusionResponse.fromJson(response.getSelfExclusion);\n }\n\n /// Sets Self-Exclusion (this call should be used in conjunction with [fetchSelfExclusion])\n ///\n /// For parameters information refer to [SetSelfExclusionRequest].\n /// Throws a [BaseAPIException] if API response contains an error\n static Future setSelfExclusion(SetSelfExclusionRequest request) async {\n final SetSelfExclusionReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return getBool(response.setSelfExclusion);\n }\n\n /// Excludes user from the website based this parameters\n ///\n /// (this call should be used in conjunction with [fetchSelfExclusion])\n /// Throws a [BaseAPIException] if API response contains an error\n Future exclude() async {\n final SetSelfExclusionReceive response = await _api.call(\n request: SetSelfExclusionRequest(\n excludeUntil: getSelfExclusion?.excludeUntil,\n max30dayDeposit: getSelfExclusion?.max30dayDeposit,\n max30dayLosses: getSelfExclusion?.max30dayLosses,\n max30dayTurnover: getSelfExclusion?.max30dayTurnover,\n max7dayDeposit: getSelfExclusion?.max7dayDeposit,\n max7dayLosses: getSelfExclusion?.max7dayLosses,\n max7dayTurnover: getSelfExclusion?.max7dayTurnover,\n maxBalance: getSelfExclusion?.maxBalance,\n maxDeposit: getSelfExclusion?.maxDeposit,\n maxLosses: getSelfExclusion?.maxLosses,\n maxOpenBets: getSelfExclusion?.maxOpenBets,\n maxTurnover: getSelfExclusion?.maxTurnover,\n sessionDurationLimit: getSelfExclusion?.sessionDurationLimit,\n timeoutUntil:\n getSecondsSinceEpochDateTime(getSelfExclusion?.timeoutUntil),\n ),\n );\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return getBool(response.setSelfExclusion);\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/get_self_exclusion_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/get_self_exclusion_send.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/set_self_exclusion_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/set_self_exclusion_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/lib/basic_api/generated/methods/get_settings_receive_methods.json b/lib/basic_api/generated/methods/get_settings_receive_methods.json index c54aefd3d9..1d1a36ca9d 100644 --- a/lib/basic_api/generated/methods/get_settings_receive_methods.json +++ b/lib/basic_api/generated/methods/get_settings_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()(); \n \n /// Gets user's settings (email, date of birth, address etc). \n /// \n /// For parameters information refer to [GetSettingsRequest]. \n /// Throws an [AccountSettingsException] if API response contains an error. \n static Future fetchAccountSettingRaw([ \n GetSettingsRequest? request, \n ]) async { \n final GetSettingsReceive response = await _api.call( \n request: request ?? const GetSettingsRequest(), \n ); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n AccountSettingsException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response; \n } \n \n /// Gets user's settings (email, date of birth, address etc). \n /// \n /// For parameters information refer to [GetSettingsRequest]. \n /// Throws an [AccountSettingsException] if API response contains an error. \n static Future changeAccountSettingRaw( \n SetSettingsRequest request, \n ) async { \n final SetSettingsReceive response = await _api.call(request: request); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n AccountSettingsException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response; \n } \n \n /// Gets user's settings (email, date of birth, address etc). \n /// \n /// Throws an [AccountSettingsException] if API response contains an error. \n static Future fetchAccountSetting([ \n GetSettingsRequest? request, \n ]) async { \n final GetSettingsReceive response = await fetchAccountSettingRaw(request); \n \n return GetSettingsResponse.fromJson(response.getSettings); \n } \n \n /// Changes the user's settings with parameters specified as [SetSettingsRequest]. \n /// \n /// Throws an [AccountSettingsException] if API response contains an error. \n static Future changeAccountSetting( \n SetSettingsRequest request, \n ) async { \n final SetSettingsReceive response = await changeAccountSettingRaw(request); \n \n return SetSettingsResponse(setSettings: response.setSettings ?? 0); \n } \n \n /// Changes user's setting \n Future changeSetting({ \n required String secretAnswer, \n required String secretQuestion, \n }) => \n changeAccountSetting( \n SetSettingsRequest( \n accountOpeningReason: getSettings?.accountOpeningReason, \n addressCity: getSettings?.addressCity, \n addressLine1: getSettings?.addressLine1, \n addressLine2: getSettings?.addressLine2, \n addressPostcode: getSettings?.addressPostcode, \n addressState: getSettings?.addressState, \n allowCopiers: getSettings?.allowCopiers, \n citizen: getSettings?.citizen, \n dateOfBirth: getStringFromDateTime(getSettings?.dateOfBirth), \n emailConsent: getSettings?.emailConsent, \n firstName: getSettings?.firstName, \n lastName: getSettings?.lastName, \n phone: getSettings?.phone, \n placeOfBirth: getSettings?.placeOfBirth, \n requestProfessionalStatus: \n getInt(value: getSettings?.requestProfessionalStatus), \n residence: getSettings?.residence, \n salutation: getSettings?.salutation, \n secretAnswer: secretAnswer, \n secretQuestion: secretQuestion, \n taxIdentificationNumber: getSettings?.taxIdentificationNumber, \n taxResidence: getSettings?.taxResidence, \n ), \n );", + "methods": "static final BaseAPI _api = Injector()(); \n \n /// Gets user's settings (email, date of birth, address etc). \n /// \n /// For parameters information refer to [GetSettingsRequest]. \n /// Throws an [BaseAPIException] if API response contains an error. \n static Future fetchAccountSettingRaw([ \n GetSettingsRequest? request, \n ]) async { \n final GetSettingsReceive response = await _api.call( \n request: request ?? const GetSettingsRequest(), \n ); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n BaseAPIException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response; \n } \n \n /// Gets user's settings (email, date of birth, address etc). \n /// \n /// For parameters information refer to [GetSettingsRequest]. \n /// Throws an [BaseAPIException] if API response contains an error. \n static Future changeAccountSettingRaw( \n SetSettingsRequest request, \n ) async { \n final SetSettingsReceive response = await _api.call(request: request); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n BaseAPIException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response; \n } \n \n /// Gets user's settings (email, date of birth, address etc). \n /// \n /// Throws an [BaseAPIException] if API response contains an error. \n static Future fetchAccountSetting([ \n GetSettingsRequest? request, \n ]) async { \n final GetSettingsReceive response = await fetchAccountSettingRaw(request); \n \n return GetSettingsResponse.fromJson(response.getSettings); \n } \n \n /// Changes the user's settings with parameters specified as [SetSettingsRequest]. \n /// \n /// Throws an [BaseAPIException] if API response contains an error. \n static Future changeAccountSetting( \n SetSettingsRequest request, \n ) async { \n final SetSettingsReceive response = await changeAccountSettingRaw(request); \n \n return SetSettingsResponse(setSettings: response.setSettings ?? 0); \n } \n \n /// Changes user's setting \n Future changeSetting({ \n required String secretAnswer, \n required String secretQuestion, \n }) => \n changeAccountSetting( \n SetSettingsRequest( \n accountOpeningReason: getSettings?.accountOpeningReason, \n addressCity: getSettings?.addressCity, \n addressLine1: getSettings?.addressLine1, \n addressLine2: getSettings?.addressLine2, \n addressPostcode: getSettings?.addressPostcode, \n addressState: getSettings?.addressState, \n allowCopiers: getSettings?.allowCopiers, \n citizen: getSettings?.citizen, \n dateOfBirth: getStringFromDateTime(getSettings?.dateOfBirth), \n emailConsent: getSettings?.emailConsent, \n firstName: getSettings?.firstName, \n lastName: getSettings?.lastName, \n phone: getSettings?.phone, \n placeOfBirth: getSettings?.placeOfBirth, \n requestProfessionalStatus: \n getInt(value: getSettings?.requestProfessionalStatus), \n residence: getSettings?.residence, \n salutation: getSettings?.salutation, \n secretAnswer: secretAnswer, \n secretQuestion: secretQuestion, \n taxIdentificationNumber: getSettings?.taxIdentificationNumber, \n taxResidence: getSettings?.taxResidence, \n ), \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/api/response/set_settings_response_result.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/get_settings_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/get_settings_send.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/set_settings_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/set_settings_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/lib/basic_api/generated/methods/landing_company_receive_methods.json b/lib/basic_api/generated/methods/landing_company_receive_methods.json index fd35abb944..62bb7206ea 100644 --- a/lib/basic_api/generated/methods/landing_company_receive_methods.json +++ b/lib/basic_api/generated/methods/landing_company_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Gets landing companies for given [LandingCompanyRequest]\n ///\n /// Throws a [LandingCompanyException] if API response contains an error\n static Future fetchLandingCompanies(\n LandingCompanyRequest request,\n ) async {\n final LandingCompanyReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n LandingCompanyException(baseExceptionModel: baseExceptionModel),\n );\n\n return LandingCompanyResponse.fromJson(response.landingCompany);\n }\n\n /// Gets details of a landing company specified in [LandingCompanyDetailsRequest]\n ///\n /// Throws a [LandingCompanyException] if API response contains an error\n static Future fetchLandingCompanyDetails(\n LandingCompanyDetailsRequest request,\n ) async {\n final LandingCompanyDetailsReceive response = await _api.call(\n request: request,\n );\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n LandingCompanyException(baseExceptionModel: baseExceptionModel),\n );\n\n return LandingCompanyDetailsResponse.fromJson(response.landingCompanyDetails);\n }", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Gets landing companies for given [LandingCompanyRequest]\n ///\n /// Throws a [BaseAPIException] if API response contains an error\n static Future fetchLandingCompanies(\n LandingCompanyRequest request,\n ) async {\n final LandingCompanyReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return LandingCompanyResponse.fromJson(response.landingCompany);\n }\n\n /// Gets details of a landing company specified in [LandingCompanyDetailsRequest]\n ///\n /// Throws a [BaseAPIException] if API response contains an error\n static Future fetchLandingCompanyDetails(\n LandingCompanyDetailsRequest request,\n ) async {\n final LandingCompanyDetailsReceive response = await _api.call(\n request: request,\n );\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return LandingCompanyDetailsResponse.fromJson(response.landingCompanyDetails);\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/api/response/landing_company_details_response_result.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/landing_company_details_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/landing_company_details_send.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/landing_company_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/landing_company_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/lib/basic_api/generated/methods/login_history_receive_methods.json b/lib/basic_api/generated/methods/login_history_receive_methods.json index a4d5c69049..d2791fd5ea 100644 --- a/lib/basic_api/generated/methods/login_history_receive_methods.json +++ b/lib/basic_api/generated/methods/login_history_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Retrieves a summary of login history for user.\n ///\n /// For parameters information refer to [LoginHistory].\n /// Throws an [AuthorizeException] if API response contains an error\n static Future fetchHistory([\n LoginHistoryRequest? request,\n ]) async {\n final LoginHistoryReceive response = await _api.call(\n request: request ?? const LoginHistoryRequest(limit: 10),\n );\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n AuthorizeException(baseExceptionModel: baseExceptionModel),\n );\n\n return LoginHistoryResponse.fromJson(response.loginHistory);\n }", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Retrieves a summary of login history for user.\n ///\n /// For parameters information refer to [LoginHistory].\n /// Throws an [BaseAPIException] if API response contains an error\n static Future fetchHistory([\n LoginHistoryRequest? request,\n ]) async {\n final LoginHistoryReceive response = await _api.call(\n request: request ?? const LoginHistoryRequest(limit: 10),\n );\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return LoginHistoryResponse.fromJson(response.loginHistory);\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/login_history_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/login_history_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/lib/basic_api/generated/methods/logout_receive_methods.json b/lib/basic_api/generated/methods/logout_receive_methods.json index f50d699826..22088f521a 100644 --- a/lib/basic_api/generated/methods/logout_receive_methods.json +++ b/lib/basic_api/generated/methods/logout_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()(); \n \n /// Logs out from the web-socket's session. \n /// \n /// For parameters information refer to [LogoutRequest]. \n /// Throws an [AuthorizeException] if API response contains an error. \n static Future logoutMethodRaw([LogoutRequest? request]) async { \n final LogoutReceive response = \n await _api.call(request: request ?? const LogoutRequest()); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n AuthorizeException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response; \n } \n \n /// Logs out from the web-socket's session. \n /// \n /// For parameters information refer to [LogoutRequest]. \n /// Throws an [AuthorizeException] if API response contains an error. \n static Future logoutMethod([LogoutRequest? request]) async { \n final LogoutReceive response = await logoutMethodRaw(request); \n \n return LogoutResponse.fromJson(response.logout); \n }", + "methods": "static final BaseAPI _api = Injector()(); \n \n /// Logs out from the web-socket's session. \n /// \n /// For parameters information refer to [LogoutRequest]. \n /// Throws an [BaseAPIException] if API response contains an error. \n static Future logoutMethodRaw([LogoutRequest? request]) async { \n final LogoutReceive response = \n await _api.call(request: request ?? const LogoutRequest()); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n BaseAPIException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response; \n } \n \n /// Logs out from the web-socket's session. \n /// \n /// For parameters information refer to [LogoutRequest]. \n /// Throws an [BaseAPIException] if API response contains an error. \n static Future logoutMethod([LogoutRequest? request]) async { \n final LogoutReceive response = await logoutMethodRaw(request); \n \n return LogoutResponse.fromJson(response.logout); \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/logout_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/logout_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/lib/basic_api/generated/methods/mt5_deposit_receive_methods.json b/lib/basic_api/generated/methods/mt5_deposit_receive_methods.json index 5a4cc52268..68bcdc56b5 100644 --- a/lib/basic_api/generated/methods/mt5_deposit_receive_methods.json +++ b/lib/basic_api/generated/methods/mt5_deposit_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Allows deposit into MT5 account from binary account.\n ///\n /// For parameters information refer to [Mt5DepositRequest].\n /// Throws a [MT5Exception] if API response contains an error\n static Future deposit(Mt5DepositRequest request) async {\n final Mt5DepositReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n MT5Exception(baseExceptionModel: baseExceptionModel),\n );\n\n return Mt5DepositResponse.fromJson(\n response.mt5Deposit,\n response.binaryTransactionId,\n );\n }", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Allows deposit into MT5 account from binary account.\n ///\n /// For parameters information refer to [Mt5DepositRequest].\n /// Throws a [BaseAPIException] if API response contains an error\n static Future deposit(Mt5DepositRequest request) async {\n final Mt5DepositReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return Mt5DepositResponse.fromJson(\n response.mt5Deposit,\n response.binaryTransactionId,\n );\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/mt5_deposit_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/mt5_deposit_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/lib/basic_api/generated/methods/mt5_get_settings_receive_methods.json b/lib/basic_api/generated/methods/mt5_get_settings_receive_methods.json index f8b9e3c160..5f5328cc7d 100644 --- a/lib/basic_api/generated/methods/mt5_get_settings_receive_methods.json +++ b/lib/basic_api/generated/methods/mt5_get_settings_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Gets MT5 user account settings.\n ///\n /// For parameters information refer to [Mt5GetSettingsRequest].\n /// Throws a [MT5Exception] if API response contains an error\n static Future fetchSettings(\n Mt5GetSettingsRequest request,\n ) async {\n final Mt5GetSettingsReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n MT5Exception(baseExceptionModel: baseExceptionModel),\n );\n\n return Mt5GetSettingsResponse.fromJson(response.mt5GetSettings);\n }", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Gets MT5 user account settings.\n ///\n /// For parameters information refer to [Mt5GetSettingsRequest].\n /// Throws a [BaseAPIException] if API response contains an error\n static Future fetchSettings(\n Mt5GetSettingsRequest request,\n ) async {\n final Mt5GetSettingsReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return Mt5GetSettingsResponse.fromJson(response.mt5GetSettings);\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/mt5_get_settings_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/mt5_get_settings_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/lib/basic_api/generated/methods/mt5_login_list_receive_methods.json b/lib/basic_api/generated/methods/mt5_login_list_receive_methods.json index f771371b7e..44512b8880 100644 --- a/lib/basic_api/generated/methods/mt5_login_list_receive_methods.json +++ b/lib/basic_api/generated/methods/mt5_login_list_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Gets the list of MT5 accounts for client.\n ///\n /// For parameters information refer to [Mt5LoginListRequest].\n /// Throws a [MT5Exception] if API response contains an error\n static Future fetchLoginList(\n Mt5LoginListRequest request,\n ) async {\n final Mt5LoginListReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n MT5Exception(baseExceptionModel: baseExceptionModel),\n );\n\n return Mt5LoginListResponse.fromJson(response.mt5LoginList);\n }", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Gets the list of MT5 accounts for client.\n ///\n /// For parameters information refer to [Mt5LoginListRequest].\n /// Throws a [BaseAPIException] if API response contains an error\n static Future fetchLoginList(\n Mt5LoginListRequest request,\n ) async {\n final Mt5LoginListReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return Mt5LoginListResponse.fromJson(response.mt5LoginList);\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/mt5_login_list_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/mt5_login_list_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/lib/basic_api/generated/methods/mt5_new_account_receive_methods.json b/lib/basic_api/generated/methods/mt5_new_account_receive_methods.json index de572eecd3..72de8ac590 100644 --- a/lib/basic_api/generated/methods/mt5_new_account_receive_methods.json +++ b/lib/basic_api/generated/methods/mt5_new_account_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Creates new MT5 user, either demo or real money user.\n ///\n /// For parameters information refer to [Mt5NewAccountRequest].\n /// Throws a [MT5Exception] if API response contains an error\n static Future createNewAccount(\n Mt5NewAccountRequest request,\n ) async {\n final Mt5NewAccountReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n MT5Exception(baseExceptionModel: baseExceptionModel),\n );\n\n return Mt5NewAccountResponse.fromJson(response.mt5NewAccount);\n }\n\n /// Allows deposit into MT5 account from binary account.\n ///\n /// Throws a [MT5Exception] if API response contains an error\n Future deposit({\n required double amount,\n required String fromBinary,\n }) =>\n Mt5DepositResponse.deposit(\n Mt5DepositRequest(\n amount: amount,\n fromBinary: fromBinary,\n toMt5: mt5NewAccount?.login,\n ),\n );\n\n /// Changes password of the MT5 account.\n ///\n /// Throws a [MT5Exception] if API response contains an error\n Future changePassword({\n required String newPassword,\n required String oldPassword,\n required PasswordType passwordType,\n }) =>\n Mt5PasswordChangeResponse.changePassword(\n Mt5PasswordChangeRequest(\n login: mt5NewAccount?.login,\n newPassword: newPassword,\n oldPassword: oldPassword,\n passwordType: getStringFromEnum(passwordType),\n ),\n );\n\n /// Validates the main password for the MT5 user.\n ///\n /// Throws a [MT5Exception] if API response contains an error\n Future checkPassword({\n required String password,\n required PasswordType passwordType,\n }) =>\n Mt5PasswordCheckResponse.checkPassword(\n Mt5PasswordCheckRequest(\n login: mt5NewAccount?.login,\n password: password,\n passwordType: getStringFromEnum(passwordType),\n ),\n );\n\n /// Resets the password of MT5 account.\n ///\n /// Throws a [MT5Exception] if API response contains an error\n Future resetPassword({\n required String newPassword,\n required PasswordType passwordType,\n required String verificationCode,\n }) =>\n Mt5PasswordResetResponse.resetPassword(\n Mt5PasswordResetRequest(\n login: mt5NewAccount?.login,\n newPassword: newPassword,\n passwordType: getStringFromEnum(passwordType),\n verificationCode: verificationCode,\n ),\n );\n\n /// Gets the MT5 user account settings.\n ///\n /// Throws a [MT5Exception] if API response contains an error\n Future fetchSettings() =>\n Mt5GetSettingsResponse.fetchSettings(\n Mt5GetSettingsRequest(login: mt5NewAccount?.login));\n\n /// Allows withdrawal from MT5 account to Binary account.\n ///\n /// Throws a [MT5Exception] if API response contains an error\n Future withdraw({\n required double amount,\n required String toBinary,\n }) =>\n Mt5WithdrawalResponse.withdraw(\n Mt5WithdrawalRequest(\n amount: amount,\n fromMt5: mt5NewAccount?.login,\n toBinary: toBinary,\n ),\n );", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Creates new MT5 user, either demo or real money user.\n ///\n /// For parameters information refer to [Mt5NewAccountRequest].\n /// Throws a [BaseAPIException] if API response contains an error\n static Future createNewAccount(\n Mt5NewAccountRequest request,\n ) async {\n final Mt5NewAccountReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return Mt5NewAccountResponse.fromJson(response.mt5NewAccount);\n }\n\n /// Allows deposit into MT5 account from binary account.\n ///\n /// Throws a [BaseAPIException] if API response contains an error\n Future deposit({\n required double amount,\n required String fromBinary,\n }) =>\n Mt5DepositResponse.deposit(\n Mt5DepositRequest(\n amount: amount,\n fromBinary: fromBinary,\n toMt5: mt5NewAccount?.login,\n ),\n );\n\n /// Changes password of the MT5 account.\n ///\n /// Throws a [BaseAPIException] if API response contains an error\n Future changePassword({\n required String newPassword,\n required String oldPassword,\n required PasswordType passwordType,\n }) =>\n Mt5PasswordChangeResponse.changePassword(\n Mt5PasswordChangeRequest(\n login: mt5NewAccount?.login,\n newPassword: newPassword,\n oldPassword: oldPassword,\n passwordType: getStringFromEnum(passwordType),\n ),\n );\n\n /// Validates the main password for the MT5 user.\n ///\n /// Throws a [BaseAPIException] if API response contains an error\n Future checkPassword({\n required String password,\n required PasswordType passwordType,\n }) =>\n Mt5PasswordCheckResponse.checkPassword(\n Mt5PasswordCheckRequest(\n login: mt5NewAccount?.login,\n password: password,\n passwordType: getStringFromEnum(passwordType),\n ),\n );\n\n /// Resets the password of MT5 account.\n ///\n /// Throws a [BaseAPIException] if API response contains an error\n Future resetPassword({\n required String newPassword,\n required PasswordType passwordType,\n required String verificationCode,\n }) =>\n Mt5PasswordResetResponse.resetPassword(\n Mt5PasswordResetRequest(\n login: mt5NewAccount?.login,\n newPassword: newPassword,\n passwordType: getStringFromEnum(passwordType),\n verificationCode: verificationCode,\n ),\n );\n\n /// Gets the MT5 user account settings.\n ///\n /// Throws a [BaseAPIException] if API response contains an error\n Future fetchSettings() =>\n Mt5GetSettingsResponse.fetchSettings(\n Mt5GetSettingsRequest(login: mt5NewAccount?.login));\n\n /// Allows withdrawal from MT5 account to Binary account.\n ///\n /// Throws a [BaseAPIException] if API response contains an error\n Future withdraw({\n required double amount,\n required String toBinary,\n }) =>\n Mt5WithdrawalResponse.withdraw(\n Mt5WithdrawalRequest(\n amount: amount,\n fromMt5: mt5NewAccount?.login,\n toBinary: toBinary,\n ),\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/api/models/enums.dart';\nimport 'package:flutter_deriv_api/api/response/mt5_deposit_response_result.dart';\nimport 'package:flutter_deriv_api/api/response/mt5_get_settings_response_result.dart';\nimport 'package:flutter_deriv_api/api/response/mt5_password_change_response_result.dart';\nimport 'package:flutter_deriv_api/api/response/mt5_password_check_response_result.dart';\nimport 'package:flutter_deriv_api/api/response/mt5_password_reset_response_result.dart';\nimport 'package:flutter_deriv_api/api/response/mt5_withdrawal_response_result.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/mt5_deposit_send.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/mt5_get_settings_send.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/mt5_new_account_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/mt5_new_account_send.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/mt5_password_change_send.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/mt5_password_check_send.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/mt5_password_reset_send.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/mt5_withdrawal_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/lib/basic_api/generated/methods/mt5_password_change_receive_methods.json b/lib/basic_api/generated/methods/mt5_password_change_receive_methods.json index b8242c6dc4..3ec33261a9 100644 --- a/lib/basic_api/generated/methods/mt5_password_change_receive_methods.json +++ b/lib/basic_api/generated/methods/mt5_password_change_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Changes the password of the MT5 account.\n ///\n /// For parameters information refer to [Mt5PasswordChangeRequest].\n /// Throws a [MT5Exception] if API response contains an error\n static Future changePassword(\n Mt5PasswordChangeRequest request,\n ) async {\n final Mt5PasswordChangeReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n MT5Exception(baseExceptionModel: baseExceptionModel),\n );\n\n return Mt5PasswordChangeResponse.fromJson(response.mt5PasswordChange);\n }", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Changes the password of the MT5 account.\n ///\n /// For parameters information refer to [Mt5PasswordChangeRequest].\n /// Throws a [BaseAPIException] if API response contains an error\n static Future changePassword(\n Mt5PasswordChangeRequest request,\n ) async {\n final Mt5PasswordChangeReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return Mt5PasswordChangeResponse.fromJson(response.mt5PasswordChange);\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/mt5_password_change_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/mt5_password_change_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/lib/basic_api/generated/methods/mt5_password_check_receive_methods.json b/lib/basic_api/generated/methods/mt5_password_check_receive_methods.json index 338d2adcca..37fced0811 100644 --- a/lib/basic_api/generated/methods/mt5_password_check_receive_methods.json +++ b/lib/basic_api/generated/methods/mt5_password_check_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": " static final BaseAPI _api = Injector()();\n\n /// Validates the main password for the MT5 user.\n ///\n /// For parameters information refer to [Mt5PasswordCheckRequest].\n /// Throws a [MT5Exception] if API response contains an error\n static Future checkPassword(\n Mt5PasswordCheckRequest request) async {\n final Mt5PasswordCheckReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n MT5Exception(baseExceptionModel: baseExceptionModel),\n );\n\n return Mt5PasswordCheckResponse.fromJson(response.mt5PasswordCheck);\n }", + "methods": " static final BaseAPI _api = Injector()();\n\n /// Validates the main password for the MT5 user.\n ///\n /// For parameters information refer to [Mt5PasswordCheckRequest].\n /// Throws a [BaseAPIException] if API response contains an error\n static Future checkPassword(\n Mt5PasswordCheckRequest request) async {\n final Mt5PasswordCheckReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return Mt5PasswordCheckResponse.fromJson(response.mt5PasswordCheck);\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/mt5_password_check_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/mt5_password_check_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/lib/basic_api/generated/methods/mt5_password_reset_receive_methods.json b/lib/basic_api/generated/methods/mt5_password_reset_receive_methods.json index 4ac6345815..313455c694 100644 --- a/lib/basic_api/generated/methods/mt5_password_reset_receive_methods.json +++ b/lib/basic_api/generated/methods/mt5_password_reset_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Resets the password of MT5 account.\n ///\n /// For parameters information refer to [Mt5PasswordResetRequest].\n /// Throws a [MT5Exception] if API response contains an error\n static Future resetPassword(\n Mt5PasswordResetRequest request,\n ) async {\n final Mt5PasswordResetReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n MT5Exception(baseExceptionModel: baseExceptionModel),\n );\n\n return Mt5PasswordResetResponse.fromJson(response.mt5PasswordReset);\n }", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Resets the password of MT5 account.\n ///\n /// For parameters information refer to [Mt5PasswordResetRequest].\n /// Throws a [BaseAPIException] if API response contains an error\n static Future resetPassword(\n Mt5PasswordResetRequest request,\n ) async {\n final Mt5PasswordResetReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return Mt5PasswordResetResponse.fromJson(response.mt5PasswordReset);\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/mt5_password_reset_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/mt5_password_reset_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/lib/basic_api/generated/methods/mt5_withdrawal_receive_methods.json b/lib/basic_api/generated/methods/mt5_withdrawal_receive_methods.json index ab2b385cb4..d331066cf3 100644 --- a/lib/basic_api/generated/methods/mt5_withdrawal_receive_methods.json +++ b/lib/basic_api/generated/methods/mt5_withdrawal_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Allows withdrawal from MT5 account to Binary account.\n ///\n /// For parameters information refer to [Mt5WithdrawalRequest].\n /// Throws a [MT5Exception] if API response contains an error\n static Future withdraw(\n Mt5WithdrawalRequest request,\n ) async {\n final Mt5WithdrawalReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n MT5Exception(baseExceptionModel: baseExceptionModel),\n );\n\n return Mt5WithdrawalResponse.fromJson(\n response.mt5Withdrawal,\n response.binaryTransactionId,\n );\n }", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Allows withdrawal from MT5 account to Binary account.\n ///\n /// For parameters information refer to [Mt5WithdrawalRequest].\n /// Throws a [BaseAPIException] if API response contains an error\n static Future withdraw(\n Mt5WithdrawalRequest request,\n ) async {\n final Mt5WithdrawalReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return Mt5WithdrawalResponse.fromJson(\n response.mt5Withdrawal,\n response.binaryTransactionId,\n );\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/mt5_withdrawal_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/mt5_withdrawal_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/lib/basic_api/generated/methods/new_account_real_receive_methods.json b/lib/basic_api/generated/methods/new_account_real_receive_methods.json index e54b0370ad..9acffcad3d 100644 --- a/lib/basic_api/generated/methods/new_account_real_receive_methods.json +++ b/lib/basic_api/generated/methods/new_account_real_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Opens a new real account.\n ///\n /// For parameters information refer to [NewAccountRealRequest].\n /// Throws a [NewAccountException] ifAP\n static Future openNewRealAccount(\n NewAccountRealRequest request,\n ) async {\n final NewAccountRealReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n NewAccountException(baseExceptionModel: baseExceptionModel),\n );\n\n return NewAccountRealResponse.fromJson(response.newAccountReal);\n }", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Opens a new real account.\n ///\n /// For parameters information refer to [NewAccountRealRequest].\n /// Throws a [BaseAPIException] ifAP\n static Future openNewRealAccount(\n NewAccountRealRequest request,\n ) async {\n final NewAccountRealReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return NewAccountRealResponse.fromJson(response.newAccountReal);\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/new_account_real_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/new_account_real_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/lib/basic_api/generated/methods/new_account_virtual_receive_methods.json b/lib/basic_api/generated/methods/new_account_virtual_receive_methods.json index a5e6695b8c..b095060dab 100644 --- a/lib/basic_api/generated/methods/new_account_virtual_receive_methods.json +++ b/lib/basic_api/generated/methods/new_account_virtual_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Opens a new virtual account.\n ///\n /// For parameters information refer to [NewAccountVirtualRequest].\n /// Throws a [NewAccountException] if API response contains an error\n static Future openNewVirtualAccount(\n NewAccountVirtualRequest request,\n ) async {\n final NewAccountVirtualReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n NewAccountException(baseExceptionModel: baseExceptionModel),\n );\n\n return NewAccountVirtualResponse.fromJson(response.newAccountVirtual);\n }", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Opens a new virtual account.\n ///\n /// For parameters information refer to [NewAccountVirtualRequest].\n /// Throws a [BaseAPIException] if API response contains an error\n static Future openNewVirtualAccount(\n NewAccountVirtualRequest request,\n ) async {\n final NewAccountVirtualReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return NewAccountVirtualResponse.fromJson(response.newAccountVirtual);\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/new_account_virtual_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/new_account_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/lib/basic_api/generated/methods/oauth_apps_receive_methods.json b/lib/basic_api/generated/methods/oauth_apps_receive_methods.json index 410222195f..4906abfe66 100644 --- a/lib/basic_api/generated/methods/oauth_apps_receive_methods.json +++ b/lib/basic_api/generated/methods/oauth_apps_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Gets oauth application that used for the authorized account.\n ///\n /// Throws an [AppException] if API response contains an error\n static Future fetchOauthApps([\n OauthAppsRequest? request,\n ]) async {\n final OauthAppsReceive response = await _api.call(\n request: request ?? const OauthAppsRequest(),\n );\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n AppException(baseExceptionModel: baseExceptionModel),\n );\n\n return OauthAppsResponse.fromJson(response.oauthApps);\n }", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Gets oauth application that used for the authorized account.\n ///\n /// Throws an [BaseAPIException] if API response contains an error\n static Future fetchOauthApps([\n OauthAppsRequest? request,\n ]) async {\n final OauthAppsReceive response = await _api.call(\n request: request ?? const OauthAppsRequest(),\n );\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return OauthAppsResponse.fromJson(response.oauthApps);\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/oauth_apps_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/oauth_apps_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/lib/basic_api/generated/methods/p2p_advert_create_receive_methods.json b/lib/basic_api/generated/methods/p2p_advert_create_receive_methods.json index 505e5ec077..289d4406f0 100644 --- a/lib/basic_api/generated/methods/p2p_advert_create_receive_methods.json +++ b/lib/basic_api/generated/methods/p2p_advert_create_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Creates a P2P (peer to peer) advert. Can only be used by an approved P2P advertiser.\n ///\n /// For parameters information refer to [P2pAdvertCreateRequest].\n /// Throws a [P2PAdvertException] if API response contains an error\n static Future createAdvert(\n P2pAdvertCreateRequest request,\n ) async {\n final P2pAdvertCreateReceive response = await createAdvertRaw(request);\n\n return P2pAdvertCreateResponse.fromJson(response.p2pAdvertCreate);\n }\n\n /// Creates a P2P (peer to peer) advert. Can only be used by an approved P2P advertiser.\n ///\n /// For parameters information refer to [P2pAdvertCreateRequest].\n /// Throws a [P2PAdvertException] if API response contains an error\n static Future createAdvertRaw(\n P2pAdvertCreateRequest request,\n ) async {\n final P2pAdvertCreateReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n P2PAdvertException(baseExceptionModel: baseExceptionModel),\n );\n\n return response;\n }", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Creates a P2P (peer to peer) advert. Can only be used by an approved P2P advertiser.\n ///\n /// For parameters information refer to [P2pAdvertCreateRequest].\n /// Throws a [BaseAPIException] if API response contains an error\n static Future createAdvert(\n P2pAdvertCreateRequest request,\n ) async {\n final P2pAdvertCreateReceive response = await createAdvertRaw(request);\n\n return P2pAdvertCreateResponse.fromJson(response.p2pAdvertCreate);\n }\n\n /// Creates a P2P (peer to peer) advert. Can only be used by an approved P2P advertiser.\n ///\n /// For parameters information refer to [P2pAdvertCreateRequest].\n /// Throws a [BaseAPIException] if API response contains an error\n static Future createAdvertRaw(\n P2pAdvertCreateRequest request,\n ) async {\n final P2pAdvertCreateReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return response;\n }", "imports": "import 'package:flutter_deriv_api/api/exceptions/p2p_advert_exception.dart';\nimport 'package:flutter_deriv_api/api/models/base_exception_model.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/p2p_advert_create_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/p2p_advert_create_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/lib/basic_api/generated/methods/p2p_advert_info_receive_methods.json b/lib/basic_api/generated/methods/p2p_advert_info_receive_methods.json index ed9fe72e9a..f802837575 100644 --- a/lib/basic_api/generated/methods/p2p_advert_info_receive_methods.json +++ b/lib/basic_api/generated/methods/p2p_advert_info_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Retrieves information about a P2P (peer to peer) advert.\n ///\n /// For parameters information refer to [P2pAdvertInfoRequest].\n /// Throws a [P2PAdvertException] if API response contains an error\n static Future fetchAdvert(\n P2pAdvertInfoRequest request,\n ) async {\n final P2pAdvertInfoReceive response = await fetchAdvertRaw(request);\n\n return P2pAdvertInfoResponse.fromJson(\n response.p2pAdvertInfo, response.subscription);\n }\n\n /// Retrieves information about a P2P (peer to peer) advert.\n ///\n /// For parameters information refer to [P2pAdvertInfoRequest].\n /// Throws a [P2PAdvertException] if API response contains an error\n static Future fetchAdvertRaw(\n P2pAdvertInfoRequest request,\n ) async {\n final P2pAdvertInfoReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n P2PAdvertException(baseExceptionModel: baseExceptionModel),\n );\n\n return response;\n }\n\n /// Updates a P2P (peer to peer) advert. Can only be used by the advertiser.\n ///\n /// [delete] to permanently delete the advert\n /// [isActive] to activate or deactivate the advert\n /// Throws a [P2PAdvertException] if API response contains an error\n Future update({\n bool? delete,\n bool? isActive,\n }) =>\n P2pAdvertUpdateResponse.updateAdvert(\n P2pAdvertUpdateRequest(\n id: p2pAdvertInfo?.id,\n delete: delete ?? false,\n isActive: isActive ?? p2pAdvertInfo?.isActive,\n ),\n );\n\n /// Updates a P2P (peer to peer) advert. Can only be used by the advertiser.\n ///\n /// [delete] to permanently delete the advert\n /// [isActive] to activate or deactivate the advert\n /// Throws a [P2PAdvertException] if API response contains an error\n Future updateRaw({\n bool? delete,\n bool? isActive,\n }) =>\n P2pAdvertUpdateResponse.updateAdvertRaw(\n P2pAdvertUpdateRequest(\n id: p2pAdvertInfo?.id,\n delete: delete ?? false,\n isActive: isActive ?? p2pAdvertInfo?.isActive,\n ),\n );\n\n /// Deletes permanently a P2P (peer to peer) advert. Can only be used by the advertiser.\n ///\n /// Throws a [P2PAdvertException] if API response contains an error\n Future delete() => update(delete: true);\n\n /// Deletes permanently a P2P (peer to peer) advert. Can only be used by the advertiser.\n ///\n /// Throws a [P2PAdvertException] if API response contains an error\n Future deleteRaw() => updateRaw(delete: true);\n\n /// Activates a P2P (peer to peer) advert. Can only be used by the advertiser.\n ///\n /// Throws a [P2PAdvertException] if API response contains an error\n Future activate() async => update(isActive: true);\n\n /// Activates a P2P (peer to peer) advert. Can only be used by the advertiser.\n ///\n /// Throws a [P2PAdvertException] if API response contains an error\n Future activateRaw() async =>\n updateRaw(isActive: true);\n\n /// Deactivates a P2P (peer to peer) advert. Can only be used by the advertiser.\n ///\n /// Throws a [P2PAdvertException] if API response contains an error\n Future deactivate() async => update(isActive: false);\n\n /// Deactivates a P2P (peer to peer) advert. Can only be used by the advertiser.\n ///\n /// Throws a [P2PAdvertException] if API response contains an error\n Future deactivateRaw() async =>\n updateRaw(isActive: false);\n\n /// Creates order on this advert.\n ///\n /// [amount] is the amount of currency to be bought or sold.\n /// [contactInfo] is seller contact information. Only applicable for [OrderType.sell].\n /// [paymentInfo] is payment instructions. Only applicable for [OrderType.sell].\n /// Throws [P2POrderException] if API response contains an error.\n Future createOrder({\n required double amount,\n String? contactInfo,\n String? paymentInfo,\n }) =>\n P2pOrderCreateResponse.create(\n P2pOrderCreateRequest(\n advertId: p2pAdvertInfo?.id,\n amount: amount,\n contactInfo: contactInfo,\n paymentInfo: paymentInfo,\n paymentMethodIds: const [],\n ),\n );\n\n /// Creates order on this advert.\n ///\n /// [amount] is the amount of currency to be bought or sold.\n /// [contactInfo] is seller contact information. Only applicable for [OrderType.sell].\n /// [paymentInfo] is payment instructions. Only applicable for [OrderType.sell].\n /// Throws [P2POrderException] if API response contains an error.\n Future createOrderRaw({\n required double amount,\n String? contactInfo,\n String? paymentInfo,\n }) =>\n P2pOrderCreateResponse.createRaw(\n P2pOrderCreateRequest(\n advertId: p2pAdvertInfo?.id,\n amount: amount,\n contactInfo: contactInfo,\n paymentInfo: paymentInfo,\n paymentMethodIds: const [],\n ),\n );", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Retrieves information about a P2P (peer to peer) advert.\n ///\n /// For parameters information refer to [P2pAdvertInfoRequest].\n /// Throws a [BaseAPIException] if API response contains an error\n static Future fetchAdvert(\n P2pAdvertInfoRequest request,\n ) async {\n final P2pAdvertInfoReceive response = await fetchAdvertRaw(request);\n\n return P2pAdvertInfoResponse.fromJson(\n response.p2pAdvertInfo, response.subscription);\n }\n\n /// Retrieves information about a P2P (peer to peer) advert.\n ///\n /// For parameters information refer to [P2pAdvertInfoRequest].\n /// Throws a [BaseAPIException] if API response contains an error\n static Future fetchAdvertRaw(\n P2pAdvertInfoRequest request,\n ) async {\n final P2pAdvertInfoReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return response;\n }\n\n /// Updates a P2P (peer to peer) advert. Can only be used by the advertiser.\n ///\n /// [delete] to permanently delete the advert\n /// [isActive] to activate or deactivate the advert\n /// Throws a [BaseAPIException] if API response contains an error\n Future update({\n bool? delete,\n bool? isActive,\n }) =>\n P2pAdvertUpdateResponse.updateAdvert(\n P2pAdvertUpdateRequest(\n id: p2pAdvertInfo?.id,\n delete: delete ?? false,\n isActive: isActive ?? p2pAdvertInfo?.isActive,\n ),\n );\n\n /// Updates a P2P (peer to peer) advert. Can only be used by the advertiser.\n ///\n /// [delete] to permanently delete the advert\n /// [isActive] to activate or deactivate the advert\n /// Throws a [BaseAPIException] if API response contains an error\n Future updateRaw({\n bool? delete,\n bool? isActive,\n }) =>\n P2pAdvertUpdateResponse.updateAdvertRaw(\n P2pAdvertUpdateRequest(\n id: p2pAdvertInfo?.id,\n delete: delete ?? false,\n isActive: isActive ?? p2pAdvertInfo?.isActive,\n ),\n );\n\n /// Deletes permanently a P2P (peer to peer) advert. Can only be used by the advertiser.\n ///\n /// Throws a [BaseAPIException] if API response contains an error\n Future delete() => update(delete: true);\n\n /// Deletes permanently a P2P (peer to peer) advert. Can only be used by the advertiser.\n ///\n /// Throws a [BaseAPIException] if API response contains an error\n Future deleteRaw() => updateRaw(delete: true);\n\n /// Activates a P2P (peer to peer) advert. Can only be used by the advertiser.\n ///\n /// Throws a [BaseAPIException] if API response contains an error\n Future activate() async => update(isActive: true);\n\n /// Activates a P2P (peer to peer) advert. Can only be used by the advertiser.\n ///\n /// Throws a [BaseAPIException] if API response contains an error\n Future activateRaw() async =>\n updateRaw(isActive: true);\n\n /// Deactivates a P2P (peer to peer) advert. Can only be used by the advertiser.\n ///\n /// Throws a [BaseAPIException] if API response contains an error\n Future deactivate() async => update(isActive: false);\n\n /// Deactivates a P2P (peer to peer) advert. Can only be used by the advertiser.\n ///\n /// Throws a [BaseAPIException] if API response contains an error\n Future deactivateRaw() async =>\n updateRaw(isActive: false);\n\n /// Creates order on this advert.\n ///\n /// [amount] is the amount of currency to be bought or sold.\n /// [contactInfo] is seller contact information. Only applicable for [OrderType.sell].\n /// [paymentInfo] is payment instructions. Only applicable for [OrderType.sell].\n /// Throws [BaseAPIException] if API response contains an error.\n Future createOrder({\n required double amount,\n String? contactInfo,\n String? paymentInfo,\n }) =>\n P2pOrderCreateResponse.create(\n P2pOrderCreateRequest(\n advertId: p2pAdvertInfo?.id,\n amount: amount,\n contactInfo: contactInfo,\n paymentInfo: paymentInfo,\n paymentMethodIds: const [],\n ),\n );\n\n /// Creates order on this advert.\n ///\n /// [amount] is the amount of currency to be bought or sold.\n /// [contactInfo] is seller contact information. Only applicable for [OrderType.sell].\n /// [paymentInfo] is payment instructions. Only applicable for [OrderType.sell].\n /// Throws [BaseAPIException] if API response contains an error.\n Future createOrderRaw({\n required double amount,\n String? contactInfo,\n String? paymentInfo,\n }) =>\n P2pOrderCreateResponse.createRaw(\n P2pOrderCreateRequest(\n advertId: p2pAdvertInfo?.id,\n amount: amount,\n contactInfo: contactInfo,\n paymentInfo: paymentInfo,\n paymentMethodIds: const [],\n ),\n );", "imports": "import 'package:flutter_deriv_api/api/exceptions/exceptions.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/p2p_payment_methods_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/p2p_payment_methods_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';\nimport 'package:flutter_deriv_api/api/models/base_exception_model.dart';\nimport 'package:flutter_deriv_api/api/response/p2p_advert_update_response_result.dart';\nimport 'package:flutter_deriv_api/api/response/p2p_order_create_response_result.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/p2p_advert_info_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/p2p_advert_info_send.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/p2p_advert_update_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/p2p_advert_update_send.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/p2p_order_create_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/p2p_order_create_send.dart';" } diff --git a/lib/basic_api/generated/methods/p2p_advert_list_receive_methods.json b/lib/basic_api/generated/methods/p2p_advert_list_receive_methods.json index 70657825fe..daebd9dca1 100644 --- a/lib/basic_api/generated/methods/p2p_advert_list_receive_methods.json +++ b/lib/basic_api/generated/methods/p2p_advert_list_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Returns available adverts.\n ///\n /// For parameters information refer to [P2pAdvertListRequest].\n /// Throws a [P2PAdvertException] if API response contains an error\n static Future fetchAdvertList(\n P2pAdvertListRequest request,\n ) async {\n final P2pAdvertListReceive response = await fetchAdvertListRaw(request);\n\n return P2pAdvertListResponse.fromJson(response.p2pAdvertList);\n }\n\n /// Returns available adverts.\n ///\n /// For parameters information refer to [P2pAdvertListRequest].\n /// Throws a [P2PAdvertException] if API response contains an error\n static Future fetchAdvertListRaw(\n P2pAdvertListRequest request,\n ) async {\n final P2pAdvertListReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n P2PAdvertException(baseExceptionModel: baseExceptionModel),\n );\n\n return response;\n }", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Returns available adverts.\n ///\n /// For parameters information refer to [P2pAdvertListRequest].\n /// Throws a [BaseAPIException] if API response contains an error\n static Future fetchAdvertList(\n P2pAdvertListRequest request,\n ) async {\n final P2pAdvertListReceive response = await fetchAdvertListRaw(request);\n\n return P2pAdvertListResponse.fromJson(response.p2pAdvertList);\n }\n\n /// Returns available adverts.\n ///\n /// For parameters information refer to [P2pAdvertListRequest].\n /// Throws a [BaseAPIException] if API response contains an error\n static Future fetchAdvertListRaw(\n P2pAdvertListRequest request,\n ) async {\n final P2pAdvertListReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return response;\n }", "imports": "import 'package:flutter_deriv_api/api/exceptions/p2p_advert_exception.dart';\nimport 'package:flutter_deriv_api/api/models/base_exception_model.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/p2p_advert_list_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/p2p_advert_list_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/lib/basic_api/generated/methods/p2p_advert_update_receive_methods.json b/lib/basic_api/generated/methods/p2p_advert_update_receive_methods.json index c1e214b6fe..f376f3a98b 100644 --- a/lib/basic_api/generated/methods/p2p_advert_update_receive_methods.json +++ b/lib/basic_api/generated/methods/p2p_advert_update_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Updates a P2P (peer to peer) advert. Can only be used by the advertiser.\n ///\n /// For parameters information refer to [P2pAdvertUpdateRequest].\n /// Throws a [P2PAdvertException] if API response contains an error\n static Future updateAdvert(\n P2pAdvertUpdateRequest request,\n ) async {\n final P2pAdvertUpdateReceive response = await updateAdvertRaw(request);\n\n return P2pAdvertUpdateResponse.fromJson(response.p2pAdvertUpdate);\n }\n\n /// Updates a P2P (peer to peer) advert. Can only be used by the advertiser.\n ///\n /// For parameters information refer to [P2pAdvertUpdateRequest].\n /// Throws a [P2PAdvertException] if API response contains an error\n static Future updateAdvertRaw(\n P2pAdvertUpdateRequest request,\n ) async {\n final P2pAdvertUpdateReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n P2PAdvertException(baseExceptionModel: baseExceptionModel),\n );\n\n return response;\n }", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Updates a P2P (peer to peer) advert. Can only be used by the advertiser.\n ///\n /// For parameters information refer to [P2pAdvertUpdateRequest].\n /// Throws a [BaseAPIException] if API response contains an error\n static Future updateAdvert(\n P2pAdvertUpdateRequest request,\n ) async {\n final P2pAdvertUpdateReceive response = await updateAdvertRaw(request);\n\n return P2pAdvertUpdateResponse.fromJson(response.p2pAdvertUpdate);\n }\n\n /// Updates a P2P (peer to peer) advert. Can only be used by the advertiser.\n ///\n /// For parameters information refer to [P2pAdvertUpdateRequest].\n /// Throws a [BaseAPIException] if API response contains an error\n static Future updateAdvertRaw(\n P2pAdvertUpdateRequest request,\n ) async {\n final P2pAdvertUpdateReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return response;\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/p2p_advert_update_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/p2p_advert_update_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/lib/basic_api/generated/methods/p2p_advertiser_adverts_receive_methods.json b/lib/basic_api/generated/methods/p2p_advertiser_adverts_receive_methods.json index a333189fff..e0c60aff10 100644 --- a/lib/basic_api/generated/methods/p2p_advertiser_adverts_receive_methods.json +++ b/lib/basic_api/generated/methods/p2p_advertiser_adverts_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Returns all P2P (peer to peer) adverts created by the authorized client.\n /// Can only be used by a registered P2P advertiser.\n /// For parameters information refer to [P2pAdvertiserAdvertsRequest].\n static Future fetchAdvertiserAdverts(\n P2pAdvertiserAdvertsRequest request,\n ) async {\n final P2pAdvertiserAdvertsReceive response =\n await fetchAdvertiserAdvertsRaw(request);\n\n return P2pAdvertiserAdvertsResponse.fromJson(response.p2pAdvertiserAdverts);\n }\n\n /// Returns all P2P (peer to peer) adverts created by the authorized client.\n /// Can only be used by a registered P2P advertiser.\n /// For parameters information refer to [P2pAdvertiserAdvertsRequest].\n static Future fetchAdvertiserAdvertsRaw(\n P2pAdvertiserAdvertsRequest request,\n ) async {\n final P2pAdvertiserAdvertsReceive response =\n await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n P2PAdvertiserException(baseExceptionModel: baseExceptionModel),\n );\n\n return response;\n }", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Returns all P2P (peer to peer) adverts created by the authorized client.\n /// Can only be used by a registered P2P advertiser.\n /// For parameters information refer to [P2pAdvertiserAdvertsRequest].\n static Future fetchAdvertiserAdverts(\n P2pAdvertiserAdvertsRequest request,\n ) async {\n final P2pAdvertiserAdvertsReceive response =\n await fetchAdvertiserAdvertsRaw(request);\n\n return P2pAdvertiserAdvertsResponse.fromJson(response.p2pAdvertiserAdverts);\n }\n\n /// Returns all P2P (peer to peer) adverts created by the authorized client.\n /// Can only be used by a registered P2P advertiser.\n /// For parameters information refer to [P2pAdvertiserAdvertsRequest].\n static Future fetchAdvertiserAdvertsRaw(\n P2pAdvertiserAdvertsRequest request,\n ) async {\n final P2pAdvertiserAdvertsReceive response =\n await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return response;\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/p2p_advertiser_adverts_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/p2p_advertiser_adverts_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/lib/basic_api/generated/methods/p2p_advertiser_create_receive_methods.json b/lib/basic_api/generated/methods/p2p_advertiser_create_receive_methods.json index 08ca259654..253fe61c3f 100644 --- a/lib/basic_api/generated/methods/p2p_advertiser_create_receive_methods.json +++ b/lib/basic_api/generated/methods/p2p_advertiser_create_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()(); \n \n /// Registers the client as a P2P (peer to peer) advertiser. \n /// For parameters information refer to [P2pAdvertiserCreateRequest]. \n static Future createAdvertiser( \n P2pAdvertiserCreateRequest request, \n ) async { \n final P2pAdvertiserCreateReceive response = \n await createAdvertiserRaw(request); \n \n return P2pAdvertiserCreateResponse.fromJson( \n response.p2pAdvertiserCreate, response.subscription); \n } \n \n /// Registers the client as a P2P (peer to peer) advertiser. \n /// For parameters information refer to [P2pAdvertiserCreateRequest]. \n static Future createAdvertiserRaw( \n P2pAdvertiserCreateRequest request, \n ) async { \n final P2pAdvertiserCreateReceive response = await _api.call( \n request: request.copyWith(subscribe: false), \n ); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n P2PAdvertiserException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response; \n } \n \n /// Registers the client as a P2P (peer to peer) advertiser. \n /// For parameters information refer to [P2pAdvertiserCreateRequest]. \n static Stream createAdvertiserAndSubscribe( \n P2pAdvertiserCreateRequest request, { \n RequestCompareFunction? comparePredicate, \n }) => \n createAdvertiserAndSubscribeRaw( \n request, \n comparePredicate: comparePredicate, \n ).map( \n (P2pAdvertiserCreateReceive? response) => response == null \n ? null \n : P2pAdvertiserCreateResponse.fromJson( \n response.p2pAdvertiserCreate, \n response.subscription, \n ), \n ); \n \n /// Registers the client as a P2P (peer to peer) advertiser. \n /// For parameters information refer to [P2pAdvertiserCreateRequest]. \n static Stream createAdvertiserAndSubscribeRaw( \n P2pAdvertiserCreateRequest request, { \n RequestCompareFunction? comparePredicate, \n }) => \n _api \n .subscribe(request: request, comparePredicate: comparePredicate)! \n .map( \n (Response response) { \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n P2PAdvertiserException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response is P2pAdvertiserCreateReceive ? response : null; \n }, \n );", + "methods": "static final BaseAPI _api = Injector()(); \n \n /// Registers the client as a P2P (peer to peer) advertiser. \n /// For parameters information refer to [P2pAdvertiserCreateRequest]. \n static Future createAdvertiser( \n P2pAdvertiserCreateRequest request, \n ) async { \n final P2pAdvertiserCreateReceive response = \n await createAdvertiserRaw(request); \n \n return P2pAdvertiserCreateResponse.fromJson( \n response.p2pAdvertiserCreate, response.subscription); \n } \n \n /// Registers the client as a P2P (peer to peer) advertiser. \n /// For parameters information refer to [P2pAdvertiserCreateRequest]. \n static Future createAdvertiserRaw( \n P2pAdvertiserCreateRequest request, \n ) async { \n final P2pAdvertiserCreateReceive response = await _api.call( \n request: request.copyWith(subscribe: false), \n ); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n BaseAPIException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response; \n } \n \n /// Registers the client as a P2P (peer to peer) advertiser. \n /// For parameters information refer to [P2pAdvertiserCreateRequest]. \n static Stream createAdvertiserAndSubscribe( \n P2pAdvertiserCreateRequest request, { \n RequestCompareFunction? comparePredicate, \n }) => \n createAdvertiserAndSubscribeRaw( \n request, \n comparePredicate: comparePredicate, \n ).map( \n (P2pAdvertiserCreateReceive? response) => response == null \n ? null \n : P2pAdvertiserCreateResponse.fromJson( \n response.p2pAdvertiserCreate, \n response.subscription, \n ), \n ); \n \n /// Registers the client as a P2P (peer to peer) advertiser. \n /// For parameters information refer to [P2pAdvertiserCreateRequest]. \n static Stream createAdvertiserAndSubscribeRaw( \n P2pAdvertiserCreateRequest request, { \n RequestCompareFunction? comparePredicate, \n }) => \n _api \n .subscribe(request: request, comparePredicate: comparePredicate)! \n .map( \n (Response response) { \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n BaseAPIException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response is P2pAdvertiserCreateReceive ? response : null; \n }, \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/p2p_advertiser_create_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/p2p_advertiser_create_send.dart';\nimport 'package:flutter_deriv_api/basic_api/response.dart';\nimport 'package:flutter_deriv_api/helpers/helpers.dart';\nimport 'package:flutter_deriv_api/services/connection/api_manager/base_api.dart';\nimport 'package:flutter_deriv_api/services/connection/call_manager/base_call_manager.dart';\nimport 'package:deriv_dependency_injector/dependency_injector.dart';\n" } diff --git a/lib/basic_api/generated/methods/p2p_advertiser_info_receive_methods.json b/lib/basic_api/generated/methods/p2p_advertiser_info_receive_methods.json index 80dc0a9c03..ebff4791a0 100644 --- a/lib/basic_api/generated/methods/p2p_advertiser_info_receive_methods.json +++ b/lib/basic_api/generated/methods/p2p_advertiser_info_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()(); \n \n /// Retrieves information about a P2P (peer to peer) advertiser. \n /// \n /// For parameters information refer to [P2pAdvertiserInfoRequest]. \n /// Throws a [P2PAdvertiserException] if API response contains an error. \n static Future fetchAdvertiserInformation( \n P2pAdvertiserInfoRequest request, \n ) async { \n final P2pAdvertiserInfoReceive response = \n await fetchAdvertiserInformationRaw(request); \n \n return P2pAdvertiserInfoResponse.fromJson( \n response.p2pAdvertiserInfo, response.subscription); \n } \n \n /// Retrieves information about a P2P (peer to peer) advertiser. \n /// \n /// For parameters information refer to [P2pAdvertiserInfoRequest]. \n /// Throws a [P2PAdvertiserException] if API response contains an error. \n static Future fetchAdvertiserInformationRaw( \n P2pAdvertiserInfoRequest request, \n ) async { \n final P2pAdvertiserInfoReceive response = await _api.call( \n request: request.copyWith(subscribe: false), \n ); \n \n return response; \n } \n \n /// Subscribes to information about a P2P (peer to peer) advertiser. \n /// For parameters information refer to [P2pAdvertiserInfoRequest]. \n static Stream subscribeAdvertiserInformation( \n P2pAdvertiserInfoRequest request, { \n RequestCompareFunction? comparePredicate, \n }) => \n subscribeAdvertiserInformationRaw( \n request, \n comparePredicate: comparePredicate, \n ).map( \n (P2pAdvertiserInfoReceive? response) => response == null \n ? null \n : P2pAdvertiserInfoResponse.fromJson( \n response.p2pAdvertiserInfo, \n response.subscription, \n ), \n ); \n \n /// Subscribes to information about a P2P (peer to peer) advertiser. \n /// For parameters information refer to [P2pAdvertiserInfoRequest]. \n static Stream subscribeAdvertiserInformationRaw( \n P2pAdvertiserInfoRequest request, { \n RequestCompareFunction? comparePredicate, \n }) => \n _api \n .subscribe(request: request, comparePredicate: comparePredicate)! \n .map( \n (Response response) { \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n P2PAdvertiserException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response is P2pAdvertiserInfoReceive ? response : null; \n }, \n ); \n \n /// Unsubscribes from P2P (peer to peer) advertiser information. \n /// \n /// Throws a [P2PAdvertiserException] if API response contains an error. \n Future unsubscribeAdvertiser() async { \n if (subscription == null) { \n return null; \n } \n \n final ForgetReceive response = \n await _api.unsubscribe(subscriptionId: subscription!.id); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n P2PAdvertiserException(baseExceptionModel: baseExceptionModel), \n ); \n \n return ForgetResponse.fromJson(response.forget); \n } \n \n /// Unsubscribes all P2P (peer to peer) advertisers. \n /// \n /// Throws a [P2PAdvertiserException] if API response contains an error. \n static Future unsubscribeAllAdvertiser() async { \n final ForgetAllReceive response = \n await _api.unsubscribeAll(method: ForgetStreamType.p2pAdvertiser); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n P2PAdvertiserException(baseExceptionModel: baseExceptionModel), \n ); \n \n return ForgetAllResponse.fromJson(response.forgetAll); \n }", + "methods": "static final BaseAPI _api = Injector()(); \n \n /// Retrieves information about a P2P (peer to peer) advertiser. \n /// \n /// For parameters information refer to [P2pAdvertiserInfoRequest]. \n /// Throws a [BaseAPIException] if API response contains an error. \n static Future fetchAdvertiserInformation( \n P2pAdvertiserInfoRequest request, \n ) async { \n final P2pAdvertiserInfoReceive response = \n await fetchAdvertiserInformationRaw(request); \n \n return P2pAdvertiserInfoResponse.fromJson( \n response.p2pAdvertiserInfo, response.subscription); \n } \n \n /// Retrieves information about a P2P (peer to peer) advertiser. \n /// \n /// For parameters information refer to [P2pAdvertiserInfoRequest]. \n /// Throws a [BaseAPIException] if API response contains an error. \n static Future fetchAdvertiserInformationRaw( \n P2pAdvertiserInfoRequest request, \n ) async { \n final P2pAdvertiserInfoReceive response = await _api.call( \n request: request.copyWith(subscribe: false), \n ); \n \n return response; \n } \n \n /// Subscribes to information about a P2P (peer to peer) advertiser. \n /// For parameters information refer to [P2pAdvertiserInfoRequest]. \n static Stream subscribeAdvertiserInformation( \n P2pAdvertiserInfoRequest request, { \n RequestCompareFunction? comparePredicate, \n }) => \n subscribeAdvertiserInformationRaw( \n request, \n comparePredicate: comparePredicate, \n ).map( \n (P2pAdvertiserInfoReceive? response) => response == null \n ? null \n : P2pAdvertiserInfoResponse.fromJson( \n response.p2pAdvertiserInfo, \n response.subscription, \n ), \n ); \n \n /// Subscribes to information about a P2P (peer to peer) advertiser. \n /// For parameters information refer to [P2pAdvertiserInfoRequest]. \n static Stream subscribeAdvertiserInformationRaw( \n P2pAdvertiserInfoRequest request, { \n RequestCompareFunction? comparePredicate, \n }) => \n _api \n .subscribe(request: request, comparePredicate: comparePredicate)! \n .map( \n (Response response) { \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n BaseAPIException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response is P2pAdvertiserInfoReceive ? response : null; \n }, \n ); \n \n /// Unsubscribes from P2P (peer to peer) advertiser information. \n /// \n /// Throws a [BaseAPIException] if API response contains an error. \n Future unsubscribeAdvertiser() async { \n if (subscription == null) { \n return null; \n } \n \n final ForgetReceive response = \n await _api.unsubscribe(subscriptionId: subscription!.id); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n BaseAPIException(baseExceptionModel: baseExceptionModel), \n ); \n \n return ForgetResponse.fromJson(response.forget); \n } \n \n /// Unsubscribes all P2P (peer to peer) advertisers. \n /// \n /// Throws a [BaseAPIException] if API response contains an error. \n static Future unsubscribeAllAdvertiser() async { \n final ForgetAllReceive response = \n await _api.unsubscribeAll(method: ForgetStreamType.p2pAdvertiser); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n BaseAPIException(baseExceptionModel: baseExceptionModel), \n ); \n \n return ForgetAllResponse.fromJson(response.forgetAll); \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/api/models/enums.dart';\nimport 'package:flutter_deriv_api/api/response/forget_all_response_result.dart';\nimport 'package:flutter_deriv_api/api/response/forget_response_result.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/forget_all_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/forget_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/p2p_advertiser_info_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/p2p_advertiser_info_send.dart';\nimport 'package:flutter_deriv_api/basic_api/response.dart';\nimport 'package:flutter_deriv_api/helpers/helpers.dart';\nimport 'package:flutter_deriv_api/services/connection/api_manager/base_api.dart';\nimport 'package:flutter_deriv_api/services/connection/call_manager/base_call_manager.dart';\nimport 'package:deriv_dependency_injector/dependency_injector.dart';\n" } diff --git a/lib/basic_api/generated/methods/p2p_advertiser_list_receive_methods.json b/lib/basic_api/generated/methods/p2p_advertiser_list_receive_methods.json index 631dd05928..be58dbd598 100644 --- a/lib/basic_api/generated/methods/p2p_advertiser_list_receive_methods.json +++ b/lib/basic_api/generated/methods/p2p_advertiser_list_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()(); \n \n /// Returns P2P advertiser list. \n /// \n /// For parameters information refer to [P2pAdvertiserListRequest]. \n static Future fetchAdvertiserListRaw( \n P2pAdvertiserListRequest request, \n ) async { \n final P2pAdvertiserListReceive response = await _api.call(request: request); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n P2PAdvertiserException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response; \n } \n \n /// Returns P2P advertiser list. \n /// \n /// For parameters information refer to [P2pAdvertiserListRequest]. \n static Future fetchAdvertiserList( \n P2pAdvertiserListRequest request, \n ) async { \n final P2pAdvertiserListReceive response = \n await fetchAdvertiserListRaw(request); \n \n return P2pAdvertiserListResponse.fromJson(response.p2pAdvertiserList); \n }", + "methods": "static final BaseAPI _api = Injector()(); \n \n /// Returns P2P advertiser list. \n /// \n /// For parameters information refer to [P2pAdvertiserListRequest]. \n static Future fetchAdvertiserListRaw( \n P2pAdvertiserListRequest request, \n ) async { \n final P2pAdvertiserListReceive response = await _api.call(request: request); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n BaseAPIException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response; \n } \n \n /// Returns P2P advertiser list. \n /// \n /// For parameters information refer to [P2pAdvertiserListRequest]. \n static Future fetchAdvertiserList( \n P2pAdvertiserListRequest request, \n ) async { \n final P2pAdvertiserListReceive response = \n await fetchAdvertiserListRaw(request); \n \n return P2pAdvertiserListResponse.fromJson(response.p2pAdvertiserList); \n }", "imports": "import 'package:flutter_deriv_api/api/exceptions/exceptions.dart'; \nimport 'package:flutter_deriv_api/basic_api/generated/api.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';" } diff --git a/lib/basic_api/generated/methods/p2p_advertiser_payment_methods_receive_methods.json b/lib/basic_api/generated/methods/p2p_advertiser_payment_methods_receive_methods.json index 416f5ef7bc..3b177ab7ff 100644 --- a/lib/basic_api/generated/methods/p2p_advertiser_payment_methods_receive_methods.json +++ b/lib/basic_api/generated/methods/p2p_advertiser_payment_methods_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()(); \n \n /// Manage or list P2P advertiser payment methods. \n /// \n /// For parameters information refer to [P2pAdvertiserPaymentMethodsRequest]. \n /// Throws an [P2PAdvertiserException] if API response contains an error. \n static Future fetchMethodsRaw( \n P2pAdvertiserPaymentMethodsRequest request, \n ) async { \n final P2pAdvertiserPaymentMethodsReceive response = \n await _api.call(request: request); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n P2PAdvertiserException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response; \n } \n \n /// Manage or list P2P advertiser payment methods. \n /// \n /// For parameters information refer to [P2pAdvertiserPaymentMethodsRequest]. \n /// Throws an [P2PAdvertiserException] if API response contains an error. \n static Future fetchMethods( \n P2pAdvertiserPaymentMethodsRequest request, \n ) async { \n final P2pAdvertiserPaymentMethodsReceive response = \n await fetchMethodsRaw(request); \n \n return P2pAdvertiserPaymentMethodsResponse.fromJson( \n response.p2pAdvertiserPaymentMethods, \n ); \n }", + "methods": "static final BaseAPI _api = Injector()(); \n \n /// Manage or list P2P advertiser payment methods. \n /// \n /// For parameters information refer to [P2pAdvertiserPaymentMethodsRequest]. \n /// Throws an [BaseAPIException] if API response contains an error. \n static Future fetchMethodsRaw( \n P2pAdvertiserPaymentMethodsRequest request, \n ) async { \n final P2pAdvertiserPaymentMethodsReceive response = \n await _api.call(request: request); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n BaseAPIException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response; \n } \n \n /// Manage or list P2P advertiser payment methods. \n /// \n /// For parameters information refer to [P2pAdvertiserPaymentMethodsRequest]. \n /// Throws an [BaseAPIException] if API response contains an error. \n static Future fetchMethods( \n P2pAdvertiserPaymentMethodsRequest request, \n ) async { \n final P2pAdvertiserPaymentMethodsReceive response = \n await fetchMethodsRaw(request); \n \n return P2pAdvertiserPaymentMethodsResponse.fromJson( \n response.p2pAdvertiserPaymentMethods, \n ); \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/p2p_advertiser_payment_methods_receive.dart'; \nimport 'package:flutter_deriv_api/basic_api/generated/p2p_advertiser_payment_methods_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';" } diff --git a/lib/basic_api/generated/methods/p2p_advertiser_relations_receive_methods.json b/lib/basic_api/generated/methods/p2p_advertiser_relations_receive_methods.json index 787fff5736..e6c65c6f75 100644 --- a/lib/basic_api/generated/methods/p2p_advertiser_relations_receive_methods.json +++ b/lib/basic_api/generated/methods/p2p_advertiser_relations_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()(); \n \n /// Updates and returns favourite and blocked advertisers of the current user. \n /// \n /// For parameters information refer to [P2pAdvertiserRelationsRequest]. \n /// Throws an [P2PAdvertiserException] if API response contains an error. \n static Future fetchRaw( \n P2pAdvertiserRelationsRequest request, \n ) async { \n final P2pAdvertiserRelationsReceive response = \n await _api.call(request: request); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n P2PAdvertiserException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response; \n } \n \n /// Updates and returns favourite and blocked advertisers of the current user. \n /// \n /// For parameters information refer to [P2pAdvertiserRelationsRequest]. \n /// Throws an [P2PAdvertiserException] if API response contains an error. \n static Future fetch( \n P2pAdvertiserRelationsRequest request, \n ) async { \n final P2pAdvertiserRelationsReceive response = await fetchRaw(request); \n \n return P2pAdvertiserRelationsResponse.fromJson( \n response.p2pAdvertiserRelations); \n }", + "methods": "static final BaseAPI _api = Injector()(); \n \n /// Updates and returns favourite and blocked advertisers of the current user. \n /// \n /// For parameters information refer to [P2pAdvertiserRelationsRequest]. \n /// Throws an [BaseAPIException] if API response contains an error. \n static Future fetchRaw( \n P2pAdvertiserRelationsRequest request, \n ) async { \n final P2pAdvertiserRelationsReceive response = \n await _api.call(request: request); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n BaseAPIException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response; \n } \n \n /// Updates and returns favourite and blocked advertisers of the current user. \n /// \n /// For parameters information refer to [P2pAdvertiserRelationsRequest]. \n /// Throws an [BaseAPIException] if API response contains an error. \n static Future fetch( \n P2pAdvertiserRelationsRequest request, \n ) async { \n final P2pAdvertiserRelationsReceive response = await fetchRaw(request); \n \n return P2pAdvertiserRelationsResponse.fromJson( \n response.p2pAdvertiserRelations); \n }", "imports": "import 'package:flutter_deriv_api/api/exceptions/exceptions.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/p2p_advertiser_relations_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/p2p_advertiser_relations_send.dart';\n\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/lib/basic_api/generated/methods/p2p_advertiser_update_receive_methods.json b/lib/basic_api/generated/methods/p2p_advertiser_update_receive_methods.json index 98f52e3fba..02c3216d1a 100644 --- a/lib/basic_api/generated/methods/p2p_advertiser_update_receive_methods.json +++ b/lib/basic_api/generated/methods/p2p_advertiser_update_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Updates the information of the P2P (peer to peer) advertiser for the current account.\n /// Can only be used by an approved P2P advertiser.\n /// For parameters information refer to [P2pAdvertiserUpdateRequest].\n static Future updateAdvertiser(\n P2pAdvertiserUpdateRequest request,\n ) async {\n final P2pAdvertiserUpdateReceive response =\n await updateAdvertiserRaw(request);\n\n return P2pAdvertiserUpdateResponse.fromJson(response.p2pAdvertiserUpdate);\n }\n\n /// Updates the information of the P2P (peer to peer) advertiser for the current account.\n /// Can only be used by an approved P2P advertiser.\n /// For parameters information refer to [P2pAdvertiserUpdateRequest].\n static Future updateAdvertiserRaw(\n P2pAdvertiserUpdateRequest request,\n ) async {\n final P2pAdvertiserUpdateReceive response =\n await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n P2PAdvertiserException(baseExceptionModel: baseExceptionModel),\n );\n\n return response;\n }", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Updates the information of the P2P (peer to peer) advertiser for the current account.\n /// Can only be used by an approved P2P advertiser.\n /// For parameters information refer to [P2pAdvertiserUpdateRequest].\n static Future updateAdvertiser(\n P2pAdvertiserUpdateRequest request,\n ) async {\n final P2pAdvertiserUpdateReceive response =\n await updateAdvertiserRaw(request);\n\n return P2pAdvertiserUpdateResponse.fromJson(response.p2pAdvertiserUpdate);\n }\n\n /// Updates the information of the P2P (peer to peer) advertiser for the current account.\n /// Can only be used by an approved P2P advertiser.\n /// For parameters information refer to [P2pAdvertiserUpdateRequest].\n static Future updateAdvertiserRaw(\n P2pAdvertiserUpdateRequest request,\n ) async {\n final P2pAdvertiserUpdateReceive response =\n await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return response;\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/p2p_advertiser_update_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/p2p_advertiser_update_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/lib/basic_api/generated/methods/p2p_chat_create_receive_methods.json b/lib/basic_api/generated/methods/p2p_chat_create_receive_methods.json index 017b23a569..8292489322 100644 --- a/lib/basic_api/generated/methods/p2p_chat_create_receive_methods.json +++ b/lib/basic_api/generated/methods/p2p_chat_create_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Creates a P2P (peer to peer) chat for the specified order.\n ///\n /// For parameters information refer to [P2pChatCreateRequest].\n /// Throws a [P2PException] if API response contains an error\n static Future createChat(\n P2pChatCreateRequest request,\n ) async {\n final P2pChatCreateReceive response = await createChatRaw(request);\n\n return P2pChatCreateResponse.fromJson(response.p2pChatCreate);\n }\n\n /// Creates a P2P (peer to peer) chat for the specified order.\n ///\n /// For parameters information refer to [P2pChatCreateRequest].\n /// Throws a [P2PException] if API response contains an error\n static Future createChatRaw(\n P2pChatCreateRequest request,\n ) async {\n final P2pChatCreateReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n P2PChatException(baseExceptionModel: baseExceptionModel),\n );\n\n return response;\n }", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Creates a P2P (peer to peer) chat for the specified order.\n ///\n /// For parameters information refer to [P2pChatCreateRequest].\n /// Throws a [P2PException] if API response contains an error\n static Future createChat(\n P2pChatCreateRequest request,\n ) async {\n final P2pChatCreateReceive response = await createChatRaw(request);\n\n return P2pChatCreateResponse.fromJson(response.p2pChatCreate);\n }\n\n /// Creates a P2P (peer to peer) chat for the specified order.\n ///\n /// For parameters information refer to [P2pChatCreateRequest].\n /// Throws a [P2PException] if API response contains an error\n static Future createChatRaw(\n P2pChatCreateRequest request,\n ) async {\n final P2pChatCreateReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return response;\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/p2p_chat_create_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/p2p_chat_create_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/lib/basic_api/generated/methods/p2p_order_cancel_receive_methods.json b/lib/basic_api/generated/methods/p2p_order_cancel_receive_methods.json index e7ee333345..1d84f329e0 100644 --- a/lib/basic_api/generated/methods/p2p_order_cancel_receive_methods.json +++ b/lib/basic_api/generated/methods/p2p_order_cancel_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()(); \n \n /// Cancel a P2P order. \n /// \n /// For parameters information refer to [P2pOrderCancelRequest]. \n /// Throws a [P2POrderException] if API response contains an error. \n static Future cancelOrderRaw( \n P2pOrderCancelRequest request, \n ) async { \n final P2pOrderCancelReceive response = await _api.call(request: request); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n P2POrderException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response; \n } \n \n /// Cancel a P2P order. \n /// \n /// For parameters information refer to [P2pOrderCancelRequest]. \n /// Throws a [P2POrderException] if API response contains an error. \n static Future cancelOrder( \n P2pOrderCancelRequest request, \n ) async { \n final P2pOrderCancelReceive response = await cancelOrderRaw(request); \n \n return P2pOrderCancelResponse.fromJson(response.p2pOrderCancel); \n }", + "methods": "static final BaseAPI _api = Injector()(); \n \n /// Cancel a P2P order. \n /// \n /// For parameters information refer to [P2pOrderCancelRequest]. \n /// Throws a [BaseAPIException] if API response contains an error. \n static Future cancelOrderRaw( \n P2pOrderCancelRequest request, \n ) async { \n final P2pOrderCancelReceive response = await _api.call(request: request); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n BaseAPIException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response; \n } \n \n /// Cancel a P2P order. \n /// \n /// For parameters information refer to [P2pOrderCancelRequest]. \n /// Throws a [BaseAPIException] if API response contains an error. \n static Future cancelOrder( \n P2pOrderCancelRequest request, \n ) async { \n final P2pOrderCancelReceive response = await cancelOrderRaw(request); \n \n return P2pOrderCancelResponse.fromJson(response.p2pOrderCancel); \n }", "imports": "import 'package:flutter_deriv_api/api/exceptions/exceptions.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/p2p_order_cancel_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/p2p_order_cancel_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/lib/basic_api/generated/methods/p2p_order_confirm_receive_methods.json b/lib/basic_api/generated/methods/p2p_order_confirm_receive_methods.json index 32c7af8324..693e3a02a6 100644 --- a/lib/basic_api/generated/methods/p2p_order_confirm_receive_methods.json +++ b/lib/basic_api/generated/methods/p2p_order_confirm_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()(); \n \n /// Cancel a P2P order confirm. \n /// \n /// For parameters information refer to [P2pOrderConfirmRequest]. \n /// Throws an [P2POrderException] if API response contains an error. \n static Future confirmOrderRaw( \n P2pOrderConfirmRequest request, \n ) async { \n final P2pOrderConfirmReceive response = await _api.call(request: request); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n P2POrderException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response; \n } \n \n /// Cancel a P2P order confirm. \n /// \n /// For parameters information refer to [P2pOrderConfirmRequest]. \n /// Throws an [P2POrderException] if API response contains an error. \n static Future confirmOrder( \n P2pOrderConfirmRequest request, \n ) async { \n final P2pOrderConfirmReceive response = await confirmOrderRaw(request); \n \n return P2pOrderConfirmResponse.fromJson(response.p2pOrderConfirm); \n }", + "methods": "static final BaseAPI _api = Injector()(); \n \n /// Cancel a P2P order confirm. \n /// \n /// For parameters information refer to [P2pOrderConfirmRequest]. \n /// Throws an [BaseAPIException] if API response contains an error. \n static Future confirmOrderRaw( \n P2pOrderConfirmRequest request, \n ) async { \n final P2pOrderConfirmReceive response = await _api.call(request: request); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n BaseAPIException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response; \n } \n \n /// Cancel a P2P order confirm. \n /// \n /// For parameters information refer to [P2pOrderConfirmRequest]. \n /// Throws an [BaseAPIException] if API response contains an error. \n static Future confirmOrder( \n P2pOrderConfirmRequest request, \n ) async { \n final P2pOrderConfirmReceive response = await confirmOrderRaw(request); \n \n return P2pOrderConfirmResponse.fromJson(response.p2pOrderConfirm); \n }", "imports": "import 'package:flutter_deriv_api/api/exceptions/exceptions.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/p2p_order_confirm_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/p2p_order_confirm_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/lib/basic_api/generated/methods/p2p_order_create_receive_methods.json b/lib/basic_api/generated/methods/p2p_order_create_receive_methods.json index 77922b9180..6eec513313 100644 --- a/lib/basic_api/generated/methods/p2p_order_create_receive_methods.json +++ b/lib/basic_api/generated/methods/p2p_order_create_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()(); \n \n /// Creates order with parameters specified in [P2pOrderCreateRequest] \n static Future create( \n P2pOrderCreateRequest request) async { \n final P2pOrderCreateReceive response = await createRaw(request); \n \n return P2pOrderCreateResponse.fromJson( \n response.p2pOrderCreate, response.subscription); \n } \n \n /// Creates order with parameters specified in [P2pOrderCreateRequest] \n static Future createRaw( \n P2pOrderCreateRequest request) async { \n final P2pOrderCreateReceive response = await _api.call(request: request); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n P2POrderException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response; \n } \n \n /// Creates order and subscribes to the result with parameters specified in [P2pOrderCreateRequest] \n /// \n /// Throws a [P2POrderException] if API response contains an error \n static Stream createAndSubscribe( \n P2pOrderCreateRequest request, { \n RequestCompareFunction? comparePredicate, \n }) => \n createAndSubscribeRaw( \n request, \n comparePredicate: comparePredicate, \n ).map( \n (P2pOrderCreateReceive? response) => response == null \n ? null \n : P2pOrderCreateResponse.fromJson( \n response.p2pOrderCreate, \n response.subscription, \n ), \n ); \n \n /// Creates order and subscribes to the result with parameters specified in [P2pOrderCreateRequest] \n /// \n /// Throws a [P2POrderException] if API response contains an error \n static Stream createAndSubscribeRaw( \n P2pOrderCreateRequest request, { \n RequestCompareFunction? comparePredicate, \n }) => \n _api.subscribe(request: request, comparePredicate: comparePredicate)!.map( \n (Response response) { \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n P2POrderException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response is P2pOrderCreateReceive ? response : null; \n }, \n );", + "methods": "static final BaseAPI _api = Injector()(); \n \n /// Creates order with parameters specified in [P2pOrderCreateRequest] \n static Future create( \n P2pOrderCreateRequest request) async { \n final P2pOrderCreateReceive response = await createRaw(request); \n \n return P2pOrderCreateResponse.fromJson( \n response.p2pOrderCreate, response.subscription); \n } \n \n /// Creates order with parameters specified in [P2pOrderCreateRequest] \n static Future createRaw( \n P2pOrderCreateRequest request) async { \n final P2pOrderCreateReceive response = await _api.call(request: request); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n BaseAPIException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response; \n } \n \n /// Creates order and subscribes to the result with parameters specified in [P2pOrderCreateRequest] \n /// \n /// Throws a [BaseAPIException] if API response contains an error \n static Stream createAndSubscribe( \n P2pOrderCreateRequest request, { \n RequestCompareFunction? comparePredicate, \n }) => \n createAndSubscribeRaw( \n request, \n comparePredicate: comparePredicate, \n ).map( \n (P2pOrderCreateReceive? response) => response == null \n ? null \n : P2pOrderCreateResponse.fromJson( \n response.p2pOrderCreate, \n response.subscription, \n ), \n ); \n \n /// Creates order and subscribes to the result with parameters specified in [P2pOrderCreateRequest] \n /// \n /// Throws a [BaseAPIException] if API response contains an error \n static Stream createAndSubscribeRaw( \n P2pOrderCreateRequest request, { \n RequestCompareFunction? comparePredicate, \n }) => \n _api.subscribe(request: request, comparePredicate: comparePredicate)!.map( \n (Response response) { \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n BaseAPIException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response is P2pOrderCreateReceive ? response : null; \n }, \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/p2p_order_create_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/p2p_order_create_send.dart';\nimport 'package:flutter_deriv_api/basic_api/response.dart';\nimport 'package:flutter_deriv_api/helpers/helpers.dart';\nimport 'package:flutter_deriv_api/services/connection/api_manager/base_api.dart';\nimport 'package:flutter_deriv_api/services/connection/call_manager/base_call_manager.dart';\nimport 'package:deriv_dependency_injector/dependency_injector.dart';\n" } diff --git a/lib/basic_api/generated/methods/p2p_order_dispute_receive_methods.json b/lib/basic_api/generated/methods/p2p_order_dispute_receive_methods.json index 700b484b7a..7a11ad0cd9 100644 --- a/lib/basic_api/generated/methods/p2p_order_dispute_receive_methods.json +++ b/lib/basic_api/generated/methods/p2p_order_dispute_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()(); \n \n /// Cancel a P2P order dispute. \n /// \n /// For parameters information refer to [P2pOrderDisputeRequest]. \n /// Throws an [P2POrderException] if API response contains an error. \n static Future disputeOrderRaw( \n P2pOrderDisputeRequest request, \n ) async { \n final P2pOrderDisputeReceive response = await _api.call(request: request); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n P2POrderException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response; \n } \n \n /// Cancel a P2P order dispute. \n /// \n /// For parameters information refer to [P2pOrderDisputeRequest]. \n /// Throws an [P2POrderException] if API response contains an error. \n static Future disputeOrder( \n P2pOrderDisputeRequest request, \n ) async { \n final P2pOrderDisputeReceive response = await disputeOrderRaw(request); \n \n return P2pOrderDisputeResponse.fromJson(response.p2pOrderDispute); \n }", + "methods": "static final BaseAPI _api = Injector()(); \n \n /// Cancel a P2P order dispute. \n /// \n /// For parameters information refer to [P2pOrderDisputeRequest]. \n /// Throws an [BaseAPIException] if API response contains an error. \n static Future disputeOrderRaw( \n P2pOrderDisputeRequest request, \n ) async { \n final P2pOrderDisputeReceive response = await _api.call(request: request); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n BaseAPIException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response; \n } \n \n /// Cancel a P2P order dispute. \n /// \n /// For parameters information refer to [P2pOrderDisputeRequest]. \n /// Throws an [BaseAPIException] if API response contains an error. \n static Future disputeOrder( \n P2pOrderDisputeRequest request, \n ) async { \n final P2pOrderDisputeReceive response = await disputeOrderRaw(request); \n \n return P2pOrderDisputeResponse.fromJson(response.p2pOrderDispute); \n }", "imports": "import 'package:flutter_deriv_api/api/exceptions/exceptions.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/p2p_order_dispute_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/p2p_order_dispute_send.dart';\n\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/lib/basic_api/generated/methods/p2p_order_info_receive_methods.json b/lib/basic_api/generated/methods/p2p_order_info_receive_methods.json index 3f207b231c..0e10499db4 100644 --- a/lib/basic_api/generated/methods/p2p_order_info_receive_methods.json +++ b/lib/basic_api/generated/methods/p2p_order_info_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()(); \n \n /// Gets order with parameters specified in [P2pOrderInfoRequest] \n /// \n /// Throws a [P2POrderException] if API response contains an error \n static Future fetchOrder( \n P2pOrderInfoRequest request) async { \n final P2pOrderInfoReceive response = await fetchOrderRaw(request); \n \n return P2pOrderInfoResponse.fromJson( \n response.p2pOrderInfo, response.subscription); \n } \n \n /// Gets order with parameters specified in [P2pOrderInfoRequest] \n /// \n /// Throws a [P2POrderException] if API response contains an error \n static Future fetchOrderRaw( \n P2pOrderInfoRequest request) async { \n final P2pOrderInfoReceive response = await _api.call(request: request); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n P2POrderException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response; \n } \n \n /// Subscribes to this order \n Stream subscribe({ \n RequestCompareFunction? comparePredicate, \n }) => \n subscribeOrder( \n P2pOrderInfoRequest(id: p2pOrderInfo?.id), \n comparePredicate: comparePredicate, \n ); \n \n /// Subscribes to this order \n Stream subscribeRaw({ \n RequestCompareFunction? comparePredicate, \n }) => \n subscribeOrderRaw( \n P2pOrderInfoRequest(id: p2pOrderInfo?.id), \n comparePredicate: comparePredicate, \n ); \n \n /// Subscribes to order with parameters specified in [P2pOrderInfoRequest] \n /// \n /// Throws a [P2POrderException] if API response contains an error \n static Stream subscribeOrder( \n P2pOrderInfoRequest request, { \n RequestCompareFunction? comparePredicate, \n }) => \n subscribeOrderRaw( \n request, \n comparePredicate: comparePredicate, \n ).map( \n (P2pOrderInfoReceive? response) => response == null \n ? null \n : P2pOrderInfoResponse.fromJson( \n response.p2pOrderInfo, \n response.subscription, \n ), \n ); \n \n /// Subscribes to order with parameters specified in [P2pOrderInfoRequest] \n /// \n /// Throws a [P2POrderException] if API response contains an error \n static Stream subscribeOrderRaw( \n P2pOrderInfoRequest request, { \n RequestCompareFunction? comparePredicate, \n }) => \n _api \n .subscribe(request: request, comparePredicate: comparePredicate)! \n .map( \n (Response response) { \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n P2POrderException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response is P2pOrderInfoReceive ? response : null; \n }, \n ); \n \n /// Unsubscribes from order subscription. \n /// \n /// Throws a [P2POrderException] if API response contains an error \n Future unsubscribeOrder() async { \n if (subscription == null) { \n return null; \n } \n \n final ForgetReceive response = \n await _api.unsubscribe(subscriptionId: subscription!.id); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n P2POrderException(baseExceptionModel: baseExceptionModel), \n ); \n \n return ForgetResponse.fromJson(response.forget); \n } \n \n /// Unsubscribes all order subscriptions (Subscriptions to a single order or list). \n /// \n /// Throws a [P2POrderException] if API response contains an error \n static Future unsubscribeAllOrder() async { \n final ForgetAllReceive response = \n await _api.unsubscribeAll(method: ForgetStreamType.p2pOrder); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n P2POrderException(baseExceptionModel: baseExceptionModel), \n ); \n \n return ForgetAllResponse.fromJson(response.forgetAll); \n } \n \n /// Cancels this order \n /// \n /// Returns an order with updated status if successful. \n /// Throws a [P2POrderException] if API response contains an error \n Future cancel() async { \n final P2pOrderCancelReceive response = await cancelRaw(); \n return P2pOrderCancelResponse.fromJson(response.p2pOrderCancel); \n } \n \n /// Cancels this order \n /// \n /// Returns an order with updated status if successful. \n /// Throws a [P2POrderException] if API response contains an error \n Future cancelRaw() async { \n final P2pOrderCancelReceive response = \n await _api.call(request: P2pOrderCancelRequest(id: p2pOrderInfo?.id)); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n P2POrderException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response; \n } \n \n /// Confirms this order \n /// \n /// Returns an order with updated status if successful. \n /// Throws a [P2POrderException] if API response contains an error \n Future confirm() async { \n final P2pOrderConfirmReceive response = await confirmRaw(); \n \n return P2pOrderConfirmResponse.fromJson(response.p2pOrderConfirm); \n } \n \n /// Confirms this order \n /// \n /// Returns an order with updated status if successful. \n /// Throws a [P2POrderException] if API response contains an error \n Future confirmRaw() async { \n final P2pOrderConfirmReceive response = \n await _api.call(request: P2pOrderConfirmRequest(id: p2pOrderInfo?.id)); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n P2POrderException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response; \n }", + "methods": "static final BaseAPI _api = Injector()(); \n \n /// Gets order with parameters specified in [P2pOrderInfoRequest] \n /// \n /// Throws a [BaseAPIException] if API response contains an error \n static Future fetchOrder( \n P2pOrderInfoRequest request) async { \n final P2pOrderInfoReceive response = await fetchOrderRaw(request); \n \n return P2pOrderInfoResponse.fromJson( \n response.p2pOrderInfo, response.subscription); \n } \n \n /// Gets order with parameters specified in [P2pOrderInfoRequest] \n /// \n /// Throws a [BaseAPIException] if API response contains an error \n static Future fetchOrderRaw( \n P2pOrderInfoRequest request) async { \n final P2pOrderInfoReceive response = await _api.call(request: request); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n BaseAPIException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response; \n } \n \n /// Subscribes to this order \n Stream subscribe({ \n RequestCompareFunction? comparePredicate, \n }) => \n subscribeOrder( \n P2pOrderInfoRequest(id: p2pOrderInfo?.id), \n comparePredicate: comparePredicate, \n ); \n \n /// Subscribes to this order \n Stream subscribeRaw({ \n RequestCompareFunction? comparePredicate, \n }) => \n subscribeOrderRaw( \n P2pOrderInfoRequest(id: p2pOrderInfo?.id), \n comparePredicate: comparePredicate, \n ); \n \n /// Subscribes to order with parameters specified in [P2pOrderInfoRequest] \n /// \n /// Throws a [BaseAPIException] if API response contains an error \n static Stream subscribeOrder( \n P2pOrderInfoRequest request, { \n RequestCompareFunction? comparePredicate, \n }) => \n subscribeOrderRaw( \n request, \n comparePredicate: comparePredicate, \n ).map( \n (P2pOrderInfoReceive? response) => response == null \n ? null \n : P2pOrderInfoResponse.fromJson( \n response.p2pOrderInfo, \n response.subscription, \n ), \n ); \n \n /// Subscribes to order with parameters specified in [P2pOrderInfoRequest] \n /// \n /// Throws a [BaseAPIException] if API response contains an error \n static Stream subscribeOrderRaw( \n P2pOrderInfoRequest request, { \n RequestCompareFunction? comparePredicate, \n }) => \n _api \n .subscribe(request: request, comparePredicate: comparePredicate)! \n .map( \n (Response response) { \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n BaseAPIException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response is P2pOrderInfoReceive ? response : null; \n }, \n ); \n \n /// Unsubscribes from order subscription. \n /// \n /// Throws a [BaseAPIException] if API response contains an error \n Future unsubscribeOrder() async { \n if (subscription == null) { \n return null; \n } \n \n final ForgetReceive response = \n await _api.unsubscribe(subscriptionId: subscription!.id); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n BaseAPIException(baseExceptionModel: baseExceptionModel), \n ); \n \n return ForgetResponse.fromJson(response.forget); \n } \n \n /// Unsubscribes all order subscriptions (Subscriptions to a single order or list). \n /// \n /// Throws a [BaseAPIException] if API response contains an error \n static Future unsubscribeAllOrder() async { \n final ForgetAllReceive response = \n await _api.unsubscribeAll(method: ForgetStreamType.p2pOrder); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n BaseAPIException(baseExceptionModel: baseExceptionModel), \n ); \n \n return ForgetAllResponse.fromJson(response.forgetAll); \n } \n \n /// Cancels this order \n /// \n /// Returns an order with updated status if successful. \n /// Throws a [BaseAPIException] if API response contains an error \n Future cancel() async { \n final P2pOrderCancelReceive response = await cancelRaw(); \n return P2pOrderCancelResponse.fromJson(response.p2pOrderCancel); \n } \n \n /// Cancels this order \n /// \n /// Returns an order with updated status if successful. \n /// Throws a [BaseAPIException] if API response contains an error \n Future cancelRaw() async { \n final P2pOrderCancelReceive response = \n await _api.call(request: P2pOrderCancelRequest(id: p2pOrderInfo?.id)); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n BaseAPIException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response; \n } \n \n /// Confirms this order \n /// \n /// Returns an order with updated status if successful. \n /// Throws a [BaseAPIException] if API response contains an error \n Future confirm() async { \n final P2pOrderConfirmReceive response = await confirmRaw(); \n \n return P2pOrderConfirmResponse.fromJson(response.p2pOrderConfirm); \n } \n \n /// Confirms this order \n /// \n /// Returns an order with updated status if successful. \n /// Throws a [BaseAPIException] if API response contains an error \n Future confirmRaw() async { \n final P2pOrderConfirmReceive response = \n await _api.call(request: P2pOrderConfirmRequest(id: p2pOrderInfo?.id)); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n BaseAPIException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response; \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/api/models/enums.dart';\nimport 'package:flutter_deriv_api/api/response/forget_all_response_result.dart';\nimport 'package:flutter_deriv_api/api/response/forget_response_result.dart';\nimport 'package:flutter_deriv_api/api/response/p2p_order_cancel_response_result.dart';\nimport 'package:flutter_deriv_api/api/response/p2p_order_confirm_response_result.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/forget_all_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/forget_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/p2p_order_cancel_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/p2p_order_cancel_send.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/p2p_order_confirm_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/p2p_order_confirm_send.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/p2p_order_info_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/p2p_order_info_send.dart';\nimport 'package:flutter_deriv_api/basic_api/response.dart';\nimport 'package:flutter_deriv_api/helpers/helpers.dart';\nimport 'package:flutter_deriv_api/services/connection/api_manager/base_api.dart';\nimport 'package:flutter_deriv_api/services/connection/call_manager/base_call_manager.dart';\nimport 'package:deriv_dependency_injector/dependency_injector.dart';\n" } diff --git a/lib/basic_api/generated/methods/p2p_order_list_receive_methods.json b/lib/basic_api/generated/methods/p2p_order_list_receive_methods.json index f15c62e2ab..72c9bb33f6 100644 --- a/lib/basic_api/generated/methods/p2p_order_list_receive_methods.json +++ b/lib/basic_api/generated/methods/p2p_order_list_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()(); \n \n /// Gets the list of [P2POrder] with parameters specified in [P2pOrderListRequest] \n static Future fetchOrderList([ \n P2pOrderListRequest? request, \n ]) async { \n final P2pOrderListReceive response = \n await fetchOrderListRaw(request ?? const P2pOrderListRequest()); \n \n return P2pOrderListResponse.fromJson( \n response.p2pOrderList, response.subscription); \n } \n \n /// Gets the list of [P2POrder] with parameters specified in [P2pOrderListRequest] \n static Future fetchOrderListRaw([ \n P2pOrderListRequest? request, \n ]) async { \n final P2pOrderListReceive response = await _api.call( \n request: request ?? const P2pOrderListRequest(), \n ); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n P2POrderException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response; \n } \n \n /// Subscribes to the list of [P2POrder] with parameters specified in [P2pOrderListRequest] \n static Stream subscribeOrderList({ \n P2pOrderListRequest? request, \n RequestCompareFunction? comparePredicate, \n }) => \n subscribeOrderListRaw( \n request: request, \n comparePredicate: comparePredicate, \n ).map( \n (P2pOrderListReceive? response) => response == null \n ? null \n : P2pOrderListResponse.fromJson( \n response.p2pOrderList, \n response.subscription, \n ), \n ); \n \n /// Subscribes to the list of [P2POrder] with parameters specified in [P2pOrderListRequest] \n static Stream subscribeOrderListRaw({ \n P2pOrderListRequest? request, \n RequestCompareFunction? comparePredicate, \n }) => \n _api \n .subscribe( \n request: request ?? const P2pOrderListRequest(), \n comparePredicate: comparePredicate, \n )! \n .map( \n (Response response) { \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n P2POrderException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response is P2pOrderListReceive ? response : null; \n }, \n ); \n \n /// Unsubscribes from order list subscription. \n /// \n /// Throws a [P2POrderException] if API response contains an error \n Future unsubscribeOrderList() async { \n if (subscription == null) { \n return null; \n } \n \n final ForgetReceive response = \n await _api.unsubscribe(subscriptionId: subscription!.id); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n P2POrderException(baseExceptionModel: baseExceptionModel), \n ); \n \n return ForgetResponse.fromJson(response.forget); \n } \n \n /// Unsubscribes from all order subscriptions (Subscriptions to a single order or list). \n /// \n /// Throws a [P2POrderException] if API response contains an error \n static Future unsubscribeAllOrder() => \n P2pOrderInfoResponse.unsubscribeAllOrder();", + "methods": "static final BaseAPI _api = Injector()(); \n \n /// Gets the list of [P2POrder] with parameters specified in [P2pOrderListRequest] \n static Future fetchOrderList([ \n P2pOrderListRequest? request, \n ]) async { \n final P2pOrderListReceive response = \n await fetchOrderListRaw(request ?? const P2pOrderListRequest()); \n \n return P2pOrderListResponse.fromJson( \n response.p2pOrderList, response.subscription); \n } \n \n /// Gets the list of [P2POrder] with parameters specified in [P2pOrderListRequest] \n static Future fetchOrderListRaw([ \n P2pOrderListRequest? request, \n ]) async { \n final P2pOrderListReceive response = await _api.call( \n request: request ?? const P2pOrderListRequest(), \n ); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n BaseAPIException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response; \n } \n \n /// Subscribes to the list of [P2POrder] with parameters specified in [P2pOrderListRequest] \n static Stream subscribeOrderList({ \n P2pOrderListRequest? request, \n RequestCompareFunction? comparePredicate, \n }) => \n subscribeOrderListRaw( \n request: request, \n comparePredicate: comparePredicate, \n ).map( \n (P2pOrderListReceive? response) => response == null \n ? null \n : P2pOrderListResponse.fromJson( \n response.p2pOrderList, \n response.subscription, \n ), \n ); \n \n /// Subscribes to the list of [P2POrder] with parameters specified in [P2pOrderListRequest] \n static Stream subscribeOrderListRaw({ \n P2pOrderListRequest? request, \n RequestCompareFunction? comparePredicate, \n }) => \n _api \n .subscribe( \n request: request ?? const P2pOrderListRequest(), \n comparePredicate: comparePredicate, \n )! \n .map( \n (Response response) { \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n BaseAPIException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response is P2pOrderListReceive ? response : null; \n }, \n ); \n \n /// Unsubscribes from order list subscription. \n /// \n /// Throws a [BaseAPIException] if API response contains an error \n Future unsubscribeOrderList() async { \n if (subscription == null) { \n return null; \n } \n \n final ForgetReceive response = \n await _api.unsubscribe(subscriptionId: subscription!.id); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n BaseAPIException(baseExceptionModel: baseExceptionModel), \n ); \n \n return ForgetResponse.fromJson(response.forget); \n } \n \n /// Unsubscribes from all order subscriptions (Subscriptions to a single order or list). \n /// \n /// Throws a [BaseAPIException] if API response contains an error \n static Future unsubscribeAllOrder() => \n P2pOrderInfoResponse.unsubscribeAllOrder();", "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/api/response/forget_all_response_result.dart';\nimport 'package:flutter_deriv_api/api/response/forget_response_result.dart';\nimport 'package:flutter_deriv_api/api/response/p2p_order_info_response_result.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/forget_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/p2p_order_list_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/p2p_order_list_send.dart';\nimport 'package:flutter_deriv_api/basic_api/response.dart';\nimport 'package:flutter_deriv_api/helpers/helpers.dart';\nimport 'package:flutter_deriv_api/services/connection/api_manager/base_api.dart';\nimport 'package:flutter_deriv_api/services/connection/call_manager/base_call_manager.dart';\nimport 'package:deriv_dependency_injector/dependency_injector.dart';\n" } diff --git a/lib/basic_api/generated/methods/p2p_order_review_receive_methods.json b/lib/basic_api/generated/methods/p2p_order_review_receive_methods.json index e29c2f7700..b8d4150601 100644 --- a/lib/basic_api/generated/methods/p2p_order_review_receive_methods.json +++ b/lib/basic_api/generated/methods/p2p_order_review_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()(); \n \n /// Cancel a P2P order review. \n /// \n /// For parameters information refer to [P2pOrderReviewReceive]. \n /// Throws an [P2POrderException] if API response contains an error. \n static Future reviewOrderRaw( \n P2pOrderReviewRequest request, \n ) async { \n final P2pOrderReviewReceive response = await _api.call(request: request); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n P2POrderException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response; \n } \n \n /// Cancel a P2P order review. \n /// \n /// For parameters information refer to [P2pOrderReviewReceive]. \n /// Throws an [P2POrderException] if API response contains an error. \n static Future reviewOrder( \n P2pOrderReviewRequest request, \n ) async { \n final P2pOrderReviewReceive response = await reviewOrderRaw(request); \n \n return P2pOrderReviewResponse.fromJson(response.p2pOrderReview); \n }", + "methods": "static final BaseAPI _api = Injector()(); \n \n /// Cancel a P2P order review. \n /// \n /// For parameters information refer to [P2pOrderReviewReceive]. \n /// Throws an [BaseAPIException] if API response contains an error. \n static Future reviewOrderRaw( \n P2pOrderReviewRequest request, \n ) async { \n final P2pOrderReviewReceive response = await _api.call(request: request); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n BaseAPIException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response; \n } \n \n /// Cancel a P2P order review. \n /// \n /// For parameters information refer to [P2pOrderReviewReceive]. \n /// Throws an [BaseAPIException] if API response contains an error. \n static Future reviewOrder( \n P2pOrderReviewRequest request, \n ) async { \n final P2pOrderReviewReceive response = await reviewOrderRaw(request); \n \n return P2pOrderReviewResponse.fromJson(response.p2pOrderReview); \n }", "imports": "import 'package:flutter_deriv_api/api/exceptions/exceptions.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/p2p_order_review_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/p2p_order_review_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/lib/basic_api/generated/methods/p2p_payment_methods_receive_methods.json b/lib/basic_api/generated/methods/p2p_payment_methods_receive_methods.json index bc1a072bf7..7a8d29a94f 100644 --- a/lib/basic_api/generated/methods/p2p_payment_methods_receive_methods.json +++ b/lib/basic_api/generated/methods/p2p_payment_methods_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// List all P2P payment methods.\n static Future fetch(\n P2pPaymentMethodsRequest request,\n ) async {\n final P2pPaymentMethodsReceive response = await fetchRaw(request);\n\n return P2pPaymentMethodsResponse.fromJson(response.p2pPaymentMethods);\n }\n\n /// Dispute a P2P order.\n static Future fetchRaw(\n P2pPaymentMethodsRequest request,\n ) async {\n final P2pPaymentMethodsReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n P2POrderException(baseExceptionModel: baseExceptionModel),\n );\n\n return response;\n }\n", + "methods": "static final BaseAPI _api = Injector()();\n\n /// List all P2P payment methods.\n static Future fetch(\n P2pPaymentMethodsRequest request,\n ) async {\n final P2pPaymentMethodsReceive response = await fetchRaw(request);\n\n return P2pPaymentMethodsResponse.fromJson(response.p2pPaymentMethods);\n }\n\n /// Dispute a P2P order.\n static Future fetchRaw(\n P2pPaymentMethodsRequest request,\n ) async {\n final P2pPaymentMethodsReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return response;\n }\n", "imports": "import 'package:flutter_deriv_api/api/exceptions/exceptions.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/p2p_payment_methods_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/p2p_payment_methods_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/lib/basic_api/generated/methods/payment_methods_receive_methods.json b/lib/basic_api/generated/methods/payment_methods_receive_methods.json index 5b2d80943c..4dcfb2e577 100644 --- a/lib/basic_api/generated/methods/payment_methods_receive_methods.json +++ b/lib/basic_api/generated/methods/payment_methods_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Get List of available payment methods for a given country.\n ///\n /// For parameters information refer to [PaymentMethodsRequest].\n /// Throws an [PaymentException] if API response contains an error\n static Future updateApplication(\n PaymentMethodsRequest request) async {\n final PaymentMethodsReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n PaymentException(baseExceptionModel: baseExceptionModel),\n );\n\n return PaymentMethodsResponse.fromJson(response.paymentMethods);\n }", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Get List of available payment methods for a given country.\n ///\n /// For parameters information refer to [PaymentMethodsRequest].\n /// Throws an [BaseAPIException] if API response contains an error\n static Future updateApplication(\n PaymentMethodsRequest request) async {\n final PaymentMethodsReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return PaymentMethodsResponse.fromJson(response.paymentMethods);\n }", "imports": "import 'package:flutter_deriv_api/api/exceptions/exceptions.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/payment_methods_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/payment_methods_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/lib/basic_api/generated/methods/paymentagent_list_receive_methods.json b/lib/basic_api/generated/methods/paymentagent_list_receive_methods.json index 766ad67d39..f5961026c8 100644 --- a/lib/basic_api/generated/methods/paymentagent_list_receive_methods.json +++ b/lib/basic_api/generated/methods/paymentagent_list_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Returns a list of Payment Agents for a given country for a given currency.\n ///\n /// For parameters information refer to [PaymentagentListRequest].\n /// Throws a [PaymentAgentException] if API response contains an error\n static Future fetch(\n PaymentagentListRequest request,\n ) async {\n final PaymentagentListReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n PaymentAgentException(baseExceptionModel: baseExceptionModel),\n );\n\n return PaymentagentListResponse.fromJson(response.paymentagentList);\n }", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Returns a list of Payment Agents for a given country for a given currency.\n ///\n /// For parameters information refer to [PaymentagentListRequest].\n /// Throws a [BaseAPIException] if API response contains an error\n static Future fetch(\n PaymentagentListRequest request,\n ) async {\n final PaymentagentListReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return PaymentagentListResponse.fromJson(response.paymentagentList);\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/paymentagent_list_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/paymentagent_list_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/lib/basic_api/generated/methods/paymentagent_transfer_receive_methods.json b/lib/basic_api/generated/methods/paymentagent_transfer_receive_methods.json index 6e06444b27..9dff97eea9 100644 --- a/lib/basic_api/generated/methods/paymentagent_transfer_receive_methods.json +++ b/lib/basic_api/generated/methods/paymentagent_transfer_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": " static final BaseAPI _api = Injector()();\n\n /// Payment Agent Transfer.\n ///\n /// This call is available only to accounts that are approved payment agents.\n /// For parameters information refer to [PaymentagentTransferRequest].\n /// Throws a [PaymentAgentException] if API response contains an error\n static Future transfer(\n PaymentagentTransferRequest request,\n ) async {\n final PaymentagentTransferReceive response =\n await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n PaymentAgentException(baseExceptionModel: baseExceptionModel),\n );\n\n return PaymentagentTransferResponse.fromJson(\n response.paymentagentTransfer,\n response.clientToFullName,\n response.clientToLoginid,\n response.transactionId);\n }", + "methods": " static final BaseAPI _api = Injector()();\n\n /// Payment Agent Transfer.\n ///\n /// This call is available only to accounts that are approved payment agents.\n /// For parameters information refer to [PaymentagentTransferRequest].\n /// Throws a [BaseAPIException] if API response contains an error\n static Future transfer(\n PaymentagentTransferRequest request,\n ) async {\n final PaymentagentTransferReceive response =\n await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return PaymentagentTransferResponse.fromJson(\n response.paymentagentTransfer,\n response.clientToFullName,\n response.clientToLoginid,\n response.transactionId);\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/paymentagent_transfer_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/paymentagent_transfer_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/lib/basic_api/generated/methods/paymentagent_withdraw_receive_methods.json b/lib/basic_api/generated/methods/paymentagent_withdraw_receive_methods.json index ffd735469a..179aae739a 100644 --- a/lib/basic_api/generated/methods/paymentagent_withdraw_receive_methods.json +++ b/lib/basic_api/generated/methods/paymentagent_withdraw_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Initiates a withdrawal to an approved payment agent.\n ///\n /// For parameters information refer to [PaymentagentWithdrawRequest].\n /// Throws a [PaymentAgentException] if API response contains an error\n static Future withdraw(\n PaymentagentWithdrawRequest request,\n ) async {\n final PaymentagentWithdrawReceive response =\n await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n PaymentAgentException(baseExceptionModel: baseExceptionModel),\n );\n\n return PaymentagentWithdrawResponse.fromJson(response.paymentagentWithdraw,\n response.paymentagentName, response.transactionId);\n }", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Initiates a withdrawal to an approved payment agent.\n ///\n /// For parameters information refer to [PaymentagentWithdrawRequest].\n /// Throws a [BaseAPIException] if API response contains an error\n static Future withdraw(\n PaymentagentWithdrawRequest request,\n ) async {\n final PaymentagentWithdrawReceive response =\n await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return PaymentagentWithdrawResponse.fromJson(response.paymentagentWithdraw,\n response.paymentagentName, response.transactionId);\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/paymentagent_withdraw_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/paymentagent_withdraw_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/lib/basic_api/generated/methods/payout_currencies_receive_methods.json b/lib/basic_api/generated/methods/payout_currencies_receive_methods.json index 62e48234d2..49182aad7f 100644 --- a/lib/basic_api/generated/methods/payout_currencies_receive_methods.json +++ b/lib/basic_api/generated/methods/payout_currencies_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Retrieves a list of available option payout currencies.\n ///\n /// If a user is logged in, only the currencies available for the account will be returned.\n /// Throws a [PayoutCurrencyException] if API response contains a error\n static Future fetchPayoutCurrencies([\n PayoutCurrenciesRequest? request,\n ]) async {\n final PayoutCurrenciesReceive response = await _api.call(\n request: request ?? const PayoutCurrenciesRequest(),\n );\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n PayoutCurrencyException(baseExceptionModel: baseExceptionModel),\n );\n\n return PayoutCurrenciesResponse.fromJson(response.payoutCurrencies);\n }", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Retrieves a list of available option payout currencies.\n ///\n /// If a user is logged in, only the currencies available for the account will be returned.\n /// Throws a [BaseAPIException] if API response contains a error\n static Future fetchPayoutCurrencies([\n PayoutCurrenciesRequest? request,\n ]) async {\n final PayoutCurrenciesReceive response = await _api.call(\n request: request ?? const PayoutCurrenciesRequest(),\n );\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return PayoutCurrenciesResponse.fromJson(response.payoutCurrencies);\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/payout_currencies_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/payout_currencies_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/lib/basic_api/generated/methods/ping_receive_methods.json b/lib/basic_api/generated/methods/ping_receive_methods.json index 5d224f797e..eb588e24af 100644 --- a/lib/basic_api/generated/methods/ping_receive_methods.json +++ b/lib/basic_api/generated/methods/ping_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()(); \n \n /// Requests the ping request to the server. \n /// \n /// Mostly used to test the connection or to keep it alive. \n /// Throws a [PingException] if API response contains an error. \n static Future pingMethodRaw([PingRequest? request]) async { \n final PingReceive response = await _api.call( \n request: request ?? const PingRequest(), \n ); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n PingException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response; \n } \n \n /// Requests the ping request to the server. \n /// \n /// Mostly used to test the connection or to keep it alive. \n /// Throws a [PingException] if API response contains an error. \n static Future pingMethod([PingRequest? request]) async { \n final PingReceive response = await pingMethodRaw(request); \n \n return PingResponse.fromJson(response.ping); \n }", + "methods": "static final BaseAPI _api = Injector()(); \n \n /// Requests the ping request to the server. \n /// \n /// Mostly used to test the connection or to keep it alive. \n /// Throws a [BaseAPIException] if API response contains an error. \n static Future pingMethodRaw([PingRequest? request]) async { \n final PingReceive response = await _api.call( \n request: request ?? const PingRequest(), \n ); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n BaseAPIException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response; \n } \n \n /// Requests the ping request to the server. \n /// \n /// Mostly used to test the connection or to keep it alive. \n /// Throws a [BaseAPIException] if API response contains an error. \n static Future pingMethod([PingRequest? request]) async { \n final PingReceive response = await pingMethodRaw(request); \n \n return PingResponse.fromJson(response.ping); \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/ping_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/ping_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/lib/basic_api/generated/methods/portfolio_receive_methods.json b/lib/basic_api/generated/methods/portfolio_receive_methods.json index 8dde2b3e3e..a7ad0b98a5 100644 --- a/lib/basic_api/generated/methods/portfolio_receive_methods.json +++ b/lib/basic_api/generated/methods/portfolio_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Gets the portfolio fo logged-in account\n ///\n /// Throws a [PortfolioException] if API response contains an error\n static Future fetchPortfolio(PortfolioRequest request) async {\n final PortfolioReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n PortfolioException(baseExceptionModel: baseExceptionModel),\n );\n\n return PortfolioResponse.fromJson(response.portfolio);\n }", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Gets the portfolio fo logged-in account\n ///\n /// Throws a [BaseAPIException] if API response contains an error\n static Future fetchPortfolio(PortfolioRequest request) async {\n final PortfolioReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return PortfolioResponse.fromJson(response.portfolio);\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/portfolio_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/portfolio_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/lib/basic_api/generated/methods/profit_table_receive_methods.json b/lib/basic_api/generated/methods/profit_table_receive_methods.json index d55634ab78..e6272cee20 100644 --- a/lib/basic_api/generated/methods/profit_table_receive_methods.json +++ b/lib/basic_api/generated/methods/profit_table_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Retrieves a summary of account Profit Table, according to given search criteria.\n ///\n /// For parameters information refer to [ProfitTableRequest].\n /// Throws a [ProfitTableException] if API response contains an error\n static Future fetch(ProfitTableRequest request) async {\n final ProfitTableReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n ProfitTableException(baseExceptionModel: baseExceptionModel),\n );\n\n return ProfitTableResponse.fromJson(response.profitTable);\n }", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Retrieves a summary of account Profit Table, according to given search criteria.\n ///\n /// For parameters information refer to [ProfitTableRequest].\n /// Throws a [BaseAPIException] if API response contains an error\n static Future fetch(ProfitTableRequest request) async {\n final ProfitTableReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return ProfitTableResponse.fromJson(response.profitTable);\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/profit_table_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/profit_table_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';" } diff --git a/lib/basic_api/generated/methods/proposal_open_contract_receive_methods.json b/lib/basic_api/generated/methods/proposal_open_contract_receive_methods.json index 616dccef5b..e1233d9798 100644 --- a/lib/basic_api/generated/methods/proposal_open_contract_receive_methods.json +++ b/lib/basic_api/generated/methods/proposal_open_contract_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Gets the current spot of the the bought contract specified in [ProposalOpenContractRequest]\n ///\n /// Throws a [ContractOperationException] if API response contains any error\n static Future fetchContractState(\n ProposalOpenContractRequest request,\n ) async {\n final ProposalOpenContractReceive response = await _api.call(\n request: request,\n );\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n ContractOperationException(baseExceptionModel: baseExceptionModel),\n );\n\n return ProposalOpenContractResponse.fromJson(\n response.proposalOpenContract, response.subscription);\n }\n\n /// Subscribes to the bought contract state specified in [ProposalOpenContractRequest]\n ///\n /// Throws a [ContractOperationException] if API response contains an error\n static Stream subscribeContractState(\n ProposalOpenContractRequest request, {\n RequestCompareFunction? comparePredicate,\n }) =>\n _api\n .subscribe(request: request, comparePredicate: comparePredicate)!\n .map(\n (Response response) {\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n ContractOperationException(\n baseExceptionModel: baseExceptionModel),\n );\n\n return response is ProposalOpenContractReceive\n ? ProposalOpenContractResponse.fromJson(\n response.proposalOpenContract,\n response.subscription,\n )\n : null;\n },\n );\n\n /// Unsubscribes from open contract subscription.\n ///\n /// Throws a [ContractOperationException] if API response contains an error\n Future unsubscribeOpenContract() async {\n if (subscription == null) {\n return null;\n }\n\n final ForgetReceive response =\n await _api.unsubscribe(subscriptionId: subscription!.id);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n ContractOperationException(baseExceptionModel: baseExceptionModel),\n );\n\n return ForgetResponse.fromJson(response.forget);\n }\n\n /// Unsubscribes all open contract subscriptions.\n ///\n /// Throws a [ContractOperationException] if API response contains an error\n static Future unsubscribeAllOpenContract() async {\n final ForgetAllReceive response = await _api.unsubscribeAll(\n method: ForgetStreamType.proposalOpenContract,\n );\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n ContractOperationException(baseExceptionModel: baseExceptionModel),\n );\n\n return ForgetAllResponse.fromJson(response.forgetAll);\n }\n\n /// Sells this contract.\n ///\n /// [price] is the Minimum price at which to sell the contract,\n /// Default be 0 for 'sell at market'.\n /// Throws a [ContractOperationException] if API response contains an error\n static Future sell(\n {required int contractId, double price = 0}) =>\n SellResponse.sellContract(SellRequest(sell: contractId, price: price));\n\n /// Cancels this contract\n ///\n /// Throws a [ContractOperationException] if API response contains an error\n static Future cancel(int contractId) =>\n CancelResponse.cancelContract(CancelRequest(cancel: contractId));\n", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Gets the current spot of the the bought contract specified in [ProposalOpenContractRequest]\n ///\n /// Throws a [BaseAPIException] if API response contains any error\n static Future fetchContractState(\n ProposalOpenContractRequest request,\n ) async {\n final ProposalOpenContractReceive response = await _api.call(\n request: request,\n );\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return ProposalOpenContractResponse.fromJson(\n response.proposalOpenContract, response.subscription);\n }\n\n /// Subscribes to the bought contract state specified in [ProposalOpenContractRequest]\n ///\n /// Throws a [BaseAPIException] if API response contains an error\n static Stream subscribeContractState(\n ProposalOpenContractRequest request, {\n RequestCompareFunction? comparePredicate,\n }) =>\n _api\n .subscribe(request: request, comparePredicate: comparePredicate)!\n .map(\n (Response response) {\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(\n baseExceptionModel: baseExceptionModel),\n );\n\n return response is ProposalOpenContractReceive\n ? ProposalOpenContractResponse.fromJson(\n response.proposalOpenContract,\n response.subscription,\n )\n : null;\n },\n );\n\n /// Unsubscribes from open contract subscription.\n ///\n /// Throws a [BaseAPIException] if API response contains an error\n Future unsubscribeOpenContract() async {\n if (subscription == null) {\n return null;\n }\n\n final ForgetReceive response =\n await _api.unsubscribe(subscriptionId: subscription!.id);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return ForgetResponse.fromJson(response.forget);\n }\n\n /// Unsubscribes all open contract subscriptions.\n ///\n /// Throws a [BaseAPIException] if API response contains an error\n static Future unsubscribeAllOpenContract() async {\n final ForgetAllReceive response = await _api.unsubscribeAll(\n method: ForgetStreamType.proposalOpenContract,\n );\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return ForgetAllResponse.fromJson(response.forgetAll);\n }\n\n /// Sells this contract.\n ///\n /// [price] is the Minimum price at which to sell the contract,\n /// Default be 0 for 'sell at market'.\n /// Throws a [BaseAPIException] if API response contains an error\n static Future sell(\n {required int contractId, double price = 0}) =>\n SellResponse.sellContract(SellRequest(sell: contractId, price: price));\n\n /// Cancels this contract\n ///\n /// Throws a [BaseAPIException] if API response contains an error\n static Future cancel(int contractId) =>\n CancelResponse.cancelContract(CancelRequest(cancel: contractId));\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/api/models/enums.dart';\nimport 'package:flutter_deriv_api/api/response/cancel_response_result.dart';\nimport 'package:flutter_deriv_api/api/response/forget_all_response_result.dart';\nimport 'package:flutter_deriv_api/api/response/forget_response_result.dart';\nimport 'package:flutter_deriv_api/api/response/sell_response_result.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/cancel_send.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/forget_all_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/forget_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/proposal_open_contract_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/proposal_open_contract_send.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/sell_send.dart';\nimport 'package:flutter_deriv_api/basic_api/response.dart';\nimport 'package:flutter_deriv_api/helpers/helpers.dart';\nimport 'package:flutter_deriv_api/services/connection/api_manager/base_api.dart';\nimport 'package:flutter_deriv_api/services/connection/call_manager/base_call_manager.dart';\nimport 'package:deriv_dependency_injector/dependency_injector.dart';" } diff --git a/lib/basic_api/generated/methods/proposal_receive_methods.json b/lib/basic_api/generated/methods/proposal_receive_methods.json index d5b8582ec9..37ce13363b 100644 --- a/lib/basic_api/generated/methods/proposal_receive_methods.json +++ b/lib/basic_api/generated/methods/proposal_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": " static final BaseAPI _api = Injector()();\n\n /// Gets the price proposal for contract\n ///\n /// For parameters information refer to [ProposalRequest]\n /// Throws a [ContractOperationException] if API response contains an error\n static Future fetchPriceForContract(\n ProposalRequest request,\n ) async {\n final ProposalReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n ContractOperationException(baseExceptionModel: baseExceptionModel),\n );\n\n return ProposalResponse.fromJson(response.proposal, response.subscription);\n }\n\n /// Gets the price proposal for contract.\n ///\n /// For parameters information refer to [ProposalRequest]\n /// Throws a [ContractOperationException] if API response contains an error\n static Stream subscribePriceForContract(\n ProposalRequest request, {\n RequestCompareFunction? comparePredicate,\n }) =>\n _api\n .subscribe(request: request, comparePredicate: comparePredicate)!\n .map(\n (Response response) {\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n ContractOperationException(\n baseExceptionModel: baseExceptionModel),\n );\n\n return response is ProposalReceive\n ? ProposalResponse.fromJson(\n response.proposal,\n response.subscription,\n )\n : null;\n },\n );\n\n /// Unsubscribes from price proposal subscription.\n ///\n /// Throws a [ContractOperationException] if API response contains an error\n Future unsubscribeProposal() async {\n if (subscription == null) {\n return null;\n }\n\n final ForgetReceive response =\n await _api.unsubscribe(subscriptionId: subscription!.id);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n ContractOperationException(baseExceptionModel: baseExceptionModel),\n );\n\n return ForgetResponse.fromJson(response.forget);\n }\n\n /// Unsubscribes all proposal subscriptions.\n ///\n /// Throws a [ContractOperationException] if API response contains an error\n static Future unsubscribeAllProposal() async {\n final ForgetAllReceive response =\n await _api.unsubscribeAll(method: ForgetStreamType.proposal);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n ContractOperationException(baseExceptionModel: baseExceptionModel),\n );\n\n return ForgetAllResponse.fromJson(response.forgetAll);\n }\n\n /// Buys this proposal contract with [price] specified.\n ///\n /// Throws a [ContractOperationException] if API response contains an error\n Future buy({double? price}) => BuyResponse.buyMethod(BuyRequest(\n buy: proposal?.id,\n price: price ?? proposal?.askPrice,\n ));\n\n /// Buys this proposal contract with [price] specified and subscribes to it.\n ///\n /// Throws a [ContractOperationException] if API response contains an error\n Stream buyAndSubscribe({double? price}) =>\n BuyResponse.buyAndSubscribe(BuyRequest(\n buy: proposal?.id,\n price: price ?? proposal?.askPrice,\n ));", - "imports": "import 'package:flutter_deriv_api/api/exceptions/contract_operations_exception.dart';\nimport 'package:flutter_deriv_api/api/models/base_exception_model.dart';\nimport 'package:flutter_deriv_api/api/models/enums.dart';\nimport 'package:flutter_deriv_api/api/response/buy_response_result.dart';\nimport 'package:flutter_deriv_api/api/response/forget_all_response_result.dart';\nimport 'package:flutter_deriv_api/api/response/forget_response_result.dart';\nimport 'package:flutter_deriv_api/api/response/proposal_open_contract_response_result.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/buy_send.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/forget_all_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/forget_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/proposal_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/proposal_send.dart';\nimport 'package:flutter_deriv_api/basic_api/response.dart';\nimport 'package:flutter_deriv_api/helpers/helpers.dart';\nimport 'package:flutter_deriv_api/services/connection/api_manager/base_api.dart';\nimport 'package:flutter_deriv_api/services/connection/call_manager/base_call_manager.dart';\nimport 'package:deriv_dependency_injector/dependency_injector.dart';\n" + "methods": " static final BaseAPI _api = Injector()();\n\n /// Gets the price proposal for contract\n ///\n /// For parameters information refer to [ProposalRequest]\n /// Throws a [BaseAPIException] if API response contains an error\n static Future fetchPriceForContract(\n ProposalRequest request,\n ) async {\n final ProposalReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return ProposalResponse.fromJson(response.proposal, response.subscription);\n }\n\n /// Gets the price proposal for contract.\n ///\n /// For parameters information refer to [ProposalRequest]\n /// Throws a [BaseAPIException] if API response contains an error\n static Stream subscribePriceForContract(\n ProposalRequest request, {\n RequestCompareFunction? comparePredicate,\n }) =>\n _api\n .subscribe(request: request, comparePredicate: comparePredicate)!\n .map(\n (Response response) {\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(\n baseExceptionModel: baseExceptionModel),\n );\n\n return response is ProposalReceive\n ? ProposalResponse.fromJson(\n response.proposal,\n response.subscription,\n )\n : null;\n },\n );\n\n /// Unsubscribes from price proposal subscription.\n ///\n /// Throws a [BaseAPIException] if API response contains an error\n Future unsubscribeProposal() async {\n if (subscription == null) {\n return null;\n }\n\n final ForgetReceive response =\n await _api.unsubscribe(subscriptionId: subscription!.id);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return ForgetResponse.fromJson(response.forget);\n }\n\n /// Unsubscribes all proposal subscriptions.\n ///\n /// Throws a [BaseAPIException] if API response contains an error\n static Future unsubscribeAllProposal() async {\n final ForgetAllReceive response =\n await _api.unsubscribeAll(method: ForgetStreamType.proposal);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return ForgetAllResponse.fromJson(response.forgetAll);\n }\n\n /// Buys this proposal contract with [price] specified.\n ///\n /// Throws a [BaseAPIException] if API response contains an error\n Future buy({double? price}) => BuyResponse.buyMethod(BuyRequest(\n buy: proposal?.id,\n price: price ?? proposal?.askPrice,\n ));\n\n /// Buys this proposal contract with [price] specified and subscribes to it.\n ///\n /// Throws a [BaseAPIException] if API response contains an error\n Stream buyAndSubscribe({double? price}) =>\n BuyResponse.buyAndSubscribe(BuyRequest(\n buy: proposal?.id,\n price: price ?? proposal?.askPrice,\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/api/models/enums.dart';\nimport 'package:flutter_deriv_api/api/response/buy_response_result.dart';\nimport 'package:flutter_deriv_api/api/response/forget_all_response_result.dart';\nimport 'package:flutter_deriv_api/api/response/forget_response_result.dart';\nimport 'package:flutter_deriv_api/api/response/proposal_open_contract_response_result.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/buy_send.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/forget_all_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/forget_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/proposal_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/proposal_send.dart';\nimport 'package:flutter_deriv_api/basic_api/response.dart';\nimport 'package:flutter_deriv_api/helpers/helpers.dart';\nimport 'package:flutter_deriv_api/services/connection/api_manager/base_api.dart';\nimport 'package:flutter_deriv_api/services/connection/call_manager/base_call_manager.dart';\nimport 'package:deriv_dependency_injector/dependency_injector.dart';\n" } diff --git a/lib/basic_api/generated/methods/reality_check_receive_methods.json b/lib/basic_api/generated/methods/reality_check_receive_methods.json index 47ca76c459..2ac2eb3828 100644 --- a/lib/basic_api/generated/methods/reality_check_receive_methods.json +++ b/lib/basic_api/generated/methods/reality_check_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Retrieves summary of client's trades and account for the reality check facility.\n ///\n /// A `reality check` means a display of time elapsed since the session began, and associated client profit/loss.\n /// The reality check facility is a regulatory requirement for certain landing companies.\n /// For parameters information refer to [RealityCheckRequest].\n /// Throws a [RealityCheckException] if API response contains an error\n static Future check([\n RealityCheckRequest? request,\n ]) async {\n final RealityCheckReceive response = await _api.call(\n request: request ?? const RealityCheckRequest(),\n );\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n RealityCheckException(baseExceptionModel: baseExceptionModel),\n );\n\n return RealityCheckResponse.fromJson(response.realityCheck);\n }", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Retrieves summary of client's trades and account for the reality check facility.\n ///\n /// A `reality check` means a display of time elapsed since the session began, and associated client profit/loss.\n /// The reality check facility is a regulatory requirement for certain landing companies.\n /// For parameters information refer to [RealityCheckRequest].\n /// Throws a [BaseAPIException] if API response contains an error\n static Future check([\n RealityCheckRequest? request,\n ]) async {\n final RealityCheckReceive response = await _api.call(\n request: request ?? const RealityCheckRequest(),\n );\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return RealityCheckResponse.fromJson(response.realityCheck);\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/reality_check_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/reality_check_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/lib/basic_api/generated/methods/reset_password_receive_methods.json b/lib/basic_api/generated/methods/reset_password_receive_methods.json index 590244ce7b..a36e8a1dc9 100644 --- a/lib/basic_api/generated/methods/reset_password_receive_methods.json +++ b/lib/basic_api/generated/methods/reset_password_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Reset the password of User.\n static Future reset(\n ResetPasswordRequest request,\n ) async {\n final ResetPasswordReceive? response =\n await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n UserException(baseExceptionModel: baseExceptionModel),\n );\n\n return ResetPasswordResponse.fromJson(response?.resetPassword);\n }", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Reset the password of User.\n static Future reset(\n ResetPasswordRequest request,\n ) async {\n final ResetPasswordReceive? response =\n await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return ResetPasswordResponse.fromJson(response?.resetPassword);\n }", "imports": "import 'package:flutter_deriv_api/api/exceptions/exceptions.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/reset_password_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/reset_password_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/lib/basic_api/generated/methods/residence_list_receive_methods.json b/lib/basic_api/generated/methods/residence_list_receive_methods.json index 67fae43764..a9a7757c19 100644 --- a/lib/basic_api/generated/methods/residence_list_receive_methods.json +++ b/lib/basic_api/generated/methods/residence_list_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Gets Residence list for the given [ResidenceListRequest]\n ///\n /// Throws a [ResidenceException] if API response contains an error\n static Future fetchResidenceList([\n ResidenceListRequest? request,\n ]) async {\n final ResidenceListReceive response = await _api.call(\n request: request ?? const ResidenceListRequest(),\n );\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n ResidenceException(baseExceptionModel: baseExceptionModel),\n );\n\n return ResidenceListResponse.fromJson(response.residenceList);\n }", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Gets Residence list for the given [ResidenceListRequest]\n ///\n /// Throws a [BaseAPIException] if API response contains an error\n static Future fetchResidenceList([\n ResidenceListRequest? request,\n ]) async {\n final ResidenceListReceive response = await _api.call(\n request: request ?? const ResidenceListRequest(),\n );\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return ResidenceListResponse.fromJson(response.residenceList);\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/residence_list_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/residence_list_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/lib/basic_api/generated/methods/revoke_oauth_app_receive_methods.json b/lib/basic_api/generated/methods/revoke_oauth_app_receive_methods.json index ae92c49d81..4d21132107 100644 --- a/lib/basic_api/generated/methods/revoke_oauth_app_receive_methods.json +++ b/lib/basic_api/generated/methods/revoke_oauth_app_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Revokes access of a particular app.\n ///\n /// For parameters information refer to [RevokeOauthAppRequest].\n /// Throws an [AppException] if API response contains an error\n static Future revokeOauthApplication(\n RevokeOauthAppRequest request,\n ) async {\n final RevokeOauthAppReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n AppException(baseExceptionModel: baseExceptionModel),\n );\n\n return RevokeOauthAppResponse.fromJson(response.revokeOauthApp);\n }\n", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Revokes access of a particular app.\n ///\n /// For parameters information refer to [RevokeOauthAppRequest].\n /// Throws an [BaseAPIException] if API response contains an error\n static Future revokeOauthApplication(\n RevokeOauthAppRequest request,\n ) async {\n final RevokeOauthAppReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return RevokeOauthAppResponse.fromJson(response.revokeOauthApp);\n }\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/revoke_oauth_app_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/revoke_oauth_app_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/lib/basic_api/generated/methods/sell_receive_methods.json b/lib/basic_api/generated/methods/sell_receive_methods.json index 6438523295..423c605eba 100644 --- a/lib/basic_api/generated/methods/sell_receive_methods.json +++ b/lib/basic_api/generated/methods/sell_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Sells a contract with parameters specified in [SellRequest].\n ///\n /// Throws a [ContractOperationException] if API response contains an error\n static Future sellContract(SellRequest request) async {\n final SellReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n ContractOperationException(baseExceptionModel: baseExceptionModel),\n );\n\n return SellResponse.fromJson(response.sell);\n }\n\n /// tries to sell any expired contracts and returns the number of sold contracts as [SellExpiredContractModel].\n ///\n /// Throws [ContractOperationException] if API response contains an error\n static Future sellExpiredContracts([\n SellExpiredRequest? request,\n ]) async {\n final SellExpiredReceive response = await _api.call(\n request: request ?? const SellExpiredRequest(),\n );\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n ContractOperationException(baseExceptionModel: baseExceptionModel),\n );\n\n return SellExpiredResponse.fromJson(response.sellExpired);\n }", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Sells a contract with parameters specified in [SellRequest].\n ///\n /// Throws a [BaseAPIException] if API response contains an error\n static Future sellContract(SellRequest request) async {\n final SellReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return SellResponse.fromJson(response.sell);\n }\n\n /// tries to sell any expired contracts and returns the number of sold contracts as [SellExpiredContractModel].\n ///\n /// Throws [BaseAPIException] if API response contains an error\n static Future sellExpiredContracts([\n SellExpiredRequest? request,\n ]) async {\n final SellExpiredReceive response = await _api.call(\n request: request ?? const SellExpiredRequest(),\n );\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return SellExpiredResponse.fromJson(response.sellExpired);\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/api/response/sell_expired_response_result.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/sell_expired_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/sell_expired_send.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/sell_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/sell_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/lib/basic_api/generated/methods/service_token_receive_methods.json b/lib/basic_api/generated/methods/service_token_receive_methods.json index 03f5b226c9..21349e906c 100644 --- a/lib/basic_api/generated/methods/service_token_receive_methods.json +++ b/lib/basic_api/generated/methods/service_token_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()(); \n \n /// Service Token. \n /// \n /// Retrieves the authorization token for the specified service. \n /// For parameters information refer to [ServiceTokenRequest]. \n /// Throws a [APITokenException] if API response contains an error. \n static Future getServiceTokenRaw( \n ServiceTokenRequest request, \n ) async { \n final ServiceTokenReceive response = await _api.call(request: request); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n APITokenException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response; \n } \n \n /// Service Token. \n /// \n /// Retrieves the authorization token for the specified service. \n /// For parameters information refer to [ServiceTokenRequest]. \n /// Throws a [APITokenException] if API response contains an error. \n static Future getServiceToken( \n ServiceTokenRequest request, \n ) async { \n final ServiceTokenReceive response = await getServiceTokenRaw(request); \n \n return ServiceTokenResponse.fromJson(response.serviceToken); \n }", + "methods": "static final BaseAPI _api = Injector()(); \n \n /// Service Token. \n /// \n /// Retrieves the authorization token for the specified service. \n /// For parameters information refer to [ServiceTokenRequest]. \n /// Throws a [BaseAPIException] if API response contains an error. \n static Future getServiceTokenRaw( \n ServiceTokenRequest request, \n ) async { \n final ServiceTokenReceive response = await _api.call(request: request); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n BaseAPIException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response; \n } \n \n /// Service Token. \n /// \n /// Retrieves the authorization token for the specified service. \n /// For parameters information refer to [ServiceTokenRequest]. \n /// Throws a [BaseAPIException] if API response contains an error. \n static Future getServiceToken( \n ServiceTokenRequest request, \n ) async { \n final ServiceTokenReceive response = await getServiceTokenRaw(request); \n \n return ServiceTokenResponse.fromJson(response.serviceToken); \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/api.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/trading_times_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/trading_times_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/lib/basic_api/generated/methods/set_account_currency_receive_methods.json b/lib/basic_api/generated/methods/set_account_currency_receive_methods.json index ed9b894863..ed8aa437f2 100644 --- a/lib/basic_api/generated/methods/set_account_currency_receive_methods.json +++ b/lib/basic_api/generated/methods/set_account_currency_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Sets the currency of the account, this will be default currency for your account i.e currency for trading, deposit.\n ///\n /// Please note that account currency can only be set once, and then can never be changed.\n /// For parameters information refer to [SetAccountCurrencyRequest].\n /// Throws an [AccountCurrencyException] if API response contains an error\n static Future setCurrency(\n SetAccountCurrencyRequest request,\n ) async {\n final SetAccountCurrencyReceive response =\n await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n AccountCurrencyException(baseExceptionModel: baseExceptionModel),\n );\n\n return SetAccountCurrencyResponse.fromJson(response.setAccountCurrency);\n }", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Sets the currency of the account, this will be default currency for your account i.e currency for trading, deposit.\n ///\n /// Please note that account currency can only be set once, and then can never be changed.\n /// For parameters information refer to [SetAccountCurrencyRequest].\n /// Throws an [BaseAPIException] if API response contains an error\n static Future setCurrency(\n SetAccountCurrencyRequest request,\n ) async {\n final SetAccountCurrencyReceive response =\n await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return SetAccountCurrencyResponse.fromJson(response.setAccountCurrency);\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/set_account_currency_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/set_account_currency_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/lib/basic_api/generated/methods/set_financial_assessment_receive_methods.json b/lib/basic_api/generated/methods/set_financial_assessment_receive_methods.json index 7cf299c229..a2322207a9 100644 --- a/lib/basic_api/generated/methods/set_financial_assessment_receive_methods.json +++ b/lib/basic_api/generated/methods/set_financial_assessment_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Sets the financial assessment details based on the client's answers to\n /// analyze whether they possess the experience and knowledge to\n /// understand the risks involved with binary options trading.\n ///\n /// For parameters information refer to [SetFinancialAssessmentRequest].\n /// Throws a [FinancialAssessmentException] if API response contains an error\n static Future setAssessment(\n SetFinancialAssessmentRequest request,\n ) async {\n final SetFinancialAssessmentReceive response =\n await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n FinancialAssessmentException(baseExceptionModel: baseExceptionModel),\n );\n\n return SetFinancialAssessmentResponse.fromJson(\n response.setFinancialAssessment);\n }", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Sets the financial assessment details based on the client's answers to\n /// analyze whether they possess the experience and knowledge to\n /// understand the risks involved with binary options trading.\n ///\n /// For parameters information refer to [SetFinancialAssessmentRequest].\n /// Throws a [BaseAPIException] if API response contains an error\n static Future setAssessment(\n SetFinancialAssessmentRequest request,\n ) async {\n final SetFinancialAssessmentReceive response =\n await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return SetFinancialAssessmentResponse.fromJson(\n response.setFinancialAssessment);\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/set_financial_assessment_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/set_financial_assessment_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/lib/basic_api/generated/methods/set_self_exclusion_receive_methods.json b/lib/basic_api/generated/methods/set_self_exclusion_receive_methods.json index cf429427d5..ccc56156df 100644 --- a/lib/basic_api/generated/methods/set_self_exclusion_receive_methods.json +++ b/lib/basic_api/generated/methods/set_self_exclusion_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": " static final BaseAPI _api = Injector()();\n\n /// Sets Self-Exclusion (this call should be used in conjunction with [fetchSelfExclusion])\n ///\n /// For parameters information refer to [SetSelfExclusionRequest].\n /// Throws a [SelfExclusionException] if API response contains an error\n static Future setSelfExclusionMethod(\n SetSelfExclusionRequest request) async {\n final SetSelfExclusionReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n SelfExclusionException(baseExceptionModel: baseExceptionModel),\n );\n\n return SetSelfExclusionResponse.fromJson(response.setSelfExclusion);\n }", + "methods": " static final BaseAPI _api = Injector()();\n\n /// Sets Self-Exclusion (this call should be used in conjunction with [fetchSelfExclusion])\n ///\n /// For parameters information refer to [SetSelfExclusionRequest].\n /// Throws a [BaseAPIException] if API response contains an error\n static Future setSelfExclusionMethod(\n SetSelfExclusionRequest request) async {\n final SetSelfExclusionReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return SetSelfExclusionResponse.fromJson(response.setSelfExclusion);\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/set_self_exclusion_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/set_self_exclusion_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/lib/basic_api/generated/methods/set_settings_receive_methods.json b/lib/basic_api/generated/methods/set_settings_receive_methods.json index c59b92b786..d02366eda3 100644 --- a/lib/basic_api/generated/methods/set_settings_receive_methods.json +++ b/lib/basic_api/generated/methods/set_settings_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": " static final BaseAPI _api = Injector()();\n\n /// Changes the user's settings with parameters specified as [SetSettingsRequest]\n ///\n /// Throws an [AccountSettingsException] if API response contains an error\n static Future changeAccountSetting(\n SetSettingsRequest request,\n ) async {\n final SetSettingsReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n AccountSettingsException(baseExceptionModel: baseExceptionModel),\n );\n\n return SetSettingsResponse(setSettings: response.setSettings ?? 0);\n }", + "methods": " static final BaseAPI _api = Injector()();\n\n /// Changes the user's settings with parameters specified as [SetSettingsRequest]\n ///\n /// Throws an [BaseAPIException] if API response contains an error\n static Future changeAccountSetting(\n SetSettingsRequest request,\n ) async {\n final SetSettingsReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return SetSettingsResponse(setSettings: response.setSettings ?? 0);\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/set_settings_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/set_settings_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/lib/basic_api/generated/methods/statement_receive_methods.json b/lib/basic_api/generated/methods/statement_receive_methods.json index 9609d1c7db..0f2d283459 100644 --- a/lib/basic_api/generated/methods/statement_receive_methods.json +++ b/lib/basic_api/generated/methods/statement_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Retrieves a summary of account transactions, according to given search criteria.\n ///\n /// For parameters information refer to [StatementRequest].\n /// Throws a [StatementException] if API response contains an error\n static Future fetch(StatementRequest request) async {\n final StatementReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n StatementException(baseExceptionModel: baseExceptionModel),\n );\n\n return StatementResponse.fromJson(response.statement);\n }", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Retrieves a summary of account transactions, according to given search criteria.\n ///\n /// For parameters information refer to [StatementRequest].\n /// Throws a [BaseAPIException] if API response contains an error\n static Future fetch(StatementRequest request) async {\n final StatementReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return StatementResponse.fromJson(response.statement);\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/statement_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/statement_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/lib/basic_api/generated/methods/states_list_receive_methods.json b/lib/basic_api/generated/methods/states_list_receive_methods.json index 5e6e4eec2c..ed022e9882 100644 --- a/lib/basic_api/generated/methods/states_list_receive_methods.json +++ b/lib/basic_api/generated/methods/states_list_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Gets the list of states for the given [StatesListRequest]\n ///\n /// Throws a [StateException] if API response contains an error\n static Future fetchStatesList(\n StatesListRequest request) async {\n final StatesListReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n StateException(baseExceptionModel: baseExceptionModel),\n );\n\n return StatesListResponse.fromJson(response.statesList);\n }\n", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Gets the list of states for the given [StatesListRequest]\n ///\n /// Throws a [BaseAPIException] if API response contains an error\n static Future fetchStatesList(\n StatesListRequest request) async {\n final StatesListReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return StatesListResponse.fromJson(response.statesList);\n }\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/states_list_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/states_list_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/lib/basic_api/generated/methods/ticks_history_receive_methods.json b/lib/basic_api/generated/methods/ticks_history_receive_methods.json index 2152377889..a75cd72a8a 100644 --- a/lib/basic_api/generated/methods/ticks_history_receive_methods.json +++ b/lib/basic_api/generated/methods/ticks_history_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Gets the [TickHistory] for the given [symbol] in [request]\n ///\n /// Throws a [TickException] if API response contains an error\n static Future fetchTickHistory(\n TicksHistoryRequest request,\n ) async {\n final TicksHistoryReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n TickException(baseExceptionModel: baseExceptionModel),\n );\n\n return TicksHistoryResponse.fromJson(response.candles, response.history,\n response.pipSize, response.subscription);\n }\n\n /// Gets ticks history and its stream\n ///\n /// Throws [TickException] if API response contains an error\n static Future fetchTicksAndSubscribe(\n TicksHistoryRequest request, {\n RequestCompareFunction? comparePredicate,\n bool subscribe = true,\n }) async {\n if (subscribe) {\n final Stream? responseStream =\n _api.subscribe(request: request, comparePredicate: comparePredicate);\n final Response? firstResponse = await responseStream?.first;\n\n checkException(\n response: firstResponse,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n TickException(baseExceptionModel: baseExceptionModel),\n );\n if (firstResponse is TicksHistoryReceive) {\n return TickHistorySubscription(\n tickHistory: TicksHistoryResponse.fromJson(\n firstResponse.candles,\n firstResponse.history,\n firstResponse.pipSize,\n firstResponse.subscription),\n tickStream: responseStream?.map(\n (Response response) {\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n TickException(baseExceptionModel: baseExceptionModel),\n );\n\n return response is TicksReceive\n ? Tick.fromJson(\n response.tick!,\n subscriptionJson: response.subscription,\n )\n : response is OHLCResponse\n ? OHLC.fromJson(\n response.ohlc!,\n subscriptionJson: response.subscription,\n )\n : null;\n },\n ),\n );\n }\n return null;\n } else {\n return TickHistorySubscription(\n tickHistory: await fetchTickHistory(request),\n );\n }\n }", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Gets the [TickHistory] for the given [symbol] in [request]\n ///\n /// Throws a [BaseAPIException] if API response contains an error\n static Future fetchTickHistory(\n TicksHistoryRequest request,\n ) async {\n final TicksHistoryReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return TicksHistoryResponse.fromJson(response.candles, response.history,\n response.pipSize, response.subscription);\n }\n\n /// Gets ticks history and its stream\n ///\n /// Throws [BaseAPIException] if API response contains an error\n static Future fetchTicksAndSubscribe(\n TicksHistoryRequest request, {\n RequestCompareFunction? comparePredicate,\n bool subscribe = true,\n }) async {\n if (subscribe) {\n final Stream? responseStream =\n _api.subscribe(request: request, comparePredicate: comparePredicate);\n final Response? firstResponse = await responseStream?.first;\n\n checkException(\n response: firstResponse,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n if (firstResponse is TicksHistoryReceive) {\n return TickHistorySubscription(\n tickHistory: TicksHistoryResponse.fromJson(\n firstResponse.candles,\n firstResponse.history,\n firstResponse.pipSize,\n firstResponse.subscription),\n tickStream: responseStream?.map(\n (Response response) {\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return response is TicksReceive\n ? Tick.fromJson(\n response.tick!,\n subscriptionJson: response.subscription,\n )\n : response is OHLCResponse\n ? OHLC.fromJson(\n response.ohlc!,\n subscriptionJson: response.subscription,\n )\n : null;\n },\n ),\n );\n }\n return null;\n } else {\n return TickHistorySubscription(\n tickHistory: await fetchTickHistory(request),\n );\n }\n }", "imports": "import 'package:flutter_deriv_api/api/exceptions/exceptions.dart';\nimport 'package:flutter_deriv_api/api/manually/ohlc_response.dart';\nimport 'package:flutter_deriv_api/api/manually/ohlc_response_result.dart';\nimport 'package:flutter_deriv_api/api/manually/tick.dart';\nimport 'package:flutter_deriv_api/api/manually/tick_base.dart';\nimport 'package:flutter_deriv_api/api/manually/tick_history_subscription.dart';\nimport 'package:flutter_deriv_api/api/models/base_exception_model.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/ticks_history_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/ticks_history_send.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/ticks_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/response.dart';\nimport 'package:flutter_deriv_api/helpers/helpers.dart';\nimport 'package:flutter_deriv_api/services/connection/api_manager/base_api.dart';\nimport 'package:flutter_deriv_api/services/connection/call_manager/base_call_manager.dart';\nimport 'package:deriv_dependency_injector/dependency_injector.dart';\n" } diff --git a/lib/basic_api/generated/methods/ticks_receive_methods.json b/lib/basic_api/generated/methods/ticks_receive_methods.json index a987bb1b07..20fe0da606 100644 --- a/lib/basic_api/generated/methods/ticks_receive_methods.json +++ b/lib/basic_api/generated/methods/ticks_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Subscribes to a tick for given [TickRequest]\n ///\n /// Throws [TickException] if API response contains an error\n static Stream subscribeTick(\n TicksRequest tickRequest, {\n RequestCompareFunction? comparePredicate,\n }) =>\n _api\n .subscribe(request: tickRequest, comparePredicate: comparePredicate)!\n .map(\n (Response response) {\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n TickException(baseExceptionModel: baseExceptionModel),\n );\n\n return response is TicksReceive\n ? TicksResponse.fromJson(\n response.tick,\n response.subscription,\n )\n : null;\n },\n );\n\n /// Unsubscribes all ticks.\n ///\n /// Throws a [TickException] if API response contains an error\n static Future unsubscribeAllTicks() async {\n final ForgetAllReceive response =\n await _api.unsubscribeAll(method: ForgetStreamType.ticks);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n TickException(baseExceptionModel: baseExceptionModel),\n );\n\n return ForgetAllResponse.fromJson(response.forgetAll);\n }\n", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Subscribes to a tick for given [TickRequest]\n ///\n /// Throws [BaseAPIException] if API response contains an error\n static Stream subscribeTick(\n TicksRequest tickRequest, {\n RequestCompareFunction? comparePredicate,\n }) =>\n _api\n .subscribe(request: tickRequest, comparePredicate: comparePredicate)!\n .map(\n (Response response) {\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return response is TicksReceive\n ? TicksResponse.fromJson(\n response.tick,\n response.subscription,\n )\n : null;\n },\n );\n\n /// Unsubscribes all ticks.\n ///\n /// Throws a [BaseAPIException] if API response contains an error\n static Future unsubscribeAllTicks() async {\n final ForgetAllReceive response =\n await _api.unsubscribeAll(method: ForgetStreamType.ticks);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return ForgetAllResponse.fromJson(response.forgetAll);\n }\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/api/models/enums.dart';\nimport 'package:flutter_deriv_api/api/response/forget_all_response_result.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/forget_all_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/ticks_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/ticks_send.dart';\nimport 'package:flutter_deriv_api/basic_api/response.dart';\nimport 'package:flutter_deriv_api/helpers/helpers.dart';\nimport 'package:flutter_deriv_api/services/connection/api_manager/base_api.dart';\nimport 'package:flutter_deriv_api/services/connection/call_manager/base_call_manager.dart';\nimport 'package:deriv_dependency_injector/dependency_injector.dart';\n" } diff --git a/lib/basic_api/generated/methods/tnc_approval_receive_methods.json b/lib/basic_api/generated/methods/tnc_approval_receive_methods.json index c46ca7b649..1ec16c492e 100644 --- a/lib/basic_api/generated/methods/tnc_approval_receive_methods.json +++ b/lib/basic_api/generated/methods/tnc_approval_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Approve the latest version of terms and conditions.\n ///\n /// For parameters information refer to [TncApprovalRequest].\n /// Throws a [UserException] if API response contains an error\n static Future verify(\n TncApprovalRequest request,\n ) async {\n final TncApprovalReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n UserException(baseExceptionModel: baseExceptionModel),\n );\n\n return TncApprovalResponse.fromJson(response.tncApproval);\n }", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Approve the latest version of terms and conditions.\n ///\n /// For parameters information refer to [TncApprovalRequest].\n /// Throws a [BaseAPIException] if API response contains an error\n static Future verify(\n TncApprovalRequest request,\n ) async {\n final TncApprovalReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return TncApprovalResponse.fromJson(response.tncApproval);\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/tnc_approval_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/tnc_approval_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/lib/basic_api/generated/methods/topup_virtual_receive_methods.json b/lib/basic_api/generated/methods/topup_virtual_receive_methods.json index e599d98e89..be41a59d85 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 [TopUpVirtualException] 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 TopUpVirtualException(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 ]) 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 }", "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/lib/basic_api/generated/methods/trading_durations_receive_methods.json b/lib/basic_api/generated/methods/trading_durations_receive_methods.json index d66ddc9629..7542190519 100644 --- a/lib/basic_api/generated/methods/trading_durations_receive_methods.json +++ b/lib/basic_api/generated/methods/trading_durations_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Retrieves a list of all available underlyings and the corresponding contract types and trading duration boundaries.\n ///\n /// If the user is logged in, only the assets available for that user's landing company will be returned.\n /// For parameters information refer to [TradingDurationsRequest].\n /// Throws a [TradingException] if API response contains an error\n static Future fetchTradingDurations(\n TradingDurationsRequest request,\n ) async {\n final TradingDurationsReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n TradingException(baseExceptionModel: baseExceptionModel),\n );\n\n return TradingDurationsResponse.fromJson(response.tradingDurations);\n }\n", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Retrieves a list of all available underlyings and the corresponding contract types and trading duration boundaries.\n ///\n /// If the user is logged in, only the assets available for that user's landing company will be returned.\n /// For parameters information refer to [TradingDurationsRequest].\n /// Throws a [BaseAPIException] if API response contains an error\n static Future fetchTradingDurations(\n TradingDurationsRequest request,\n ) async {\n final TradingDurationsReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return TradingDurationsResponse.fromJson(response.tradingDurations);\n }\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/trading_durations_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/trading_durations_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/lib/basic_api/generated/methods/trading_platform_accounts_receive_methods.json b/lib/basic_api/generated/methods/trading_platform_accounts_receive_methods.json index 1e4b46500d..b17a488a9b 100644 --- a/lib/basic_api/generated/methods/trading_platform_accounts_receive_methods.json +++ b/lib/basic_api/generated/methods/trading_platform_accounts_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Trading Platform: Accounts List.\n ///\n /// Get list of Trading Platform accounts for client.\n /// For parameters information refer to [TradingPlatformAccountsRequest].\n /// Throws a [TradingPlatformException] if API response contains an error.\n static Future getAccounts(\n TradingPlatformAccountsRequest request,\n ) async {\n final TradingPlatformAccountsReceive response =\n await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n TradingPlatformException(baseExceptionModel: baseExceptionModel),\n );\n\n return TradingPlatformAccountsResponse.fromJson(\n response.tradingPlatformAccounts,\n );\n }\n", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Trading Platform: Accounts List.\n ///\n /// Get list of Trading Platform accounts for client.\n /// For parameters information refer to [TradingPlatformAccountsRequest].\n /// Throws a [BaseAPIException] if API response contains an error.\n static Future getAccounts(\n TradingPlatformAccountsRequest request,\n ) async {\n final TradingPlatformAccountsReceive response =\n await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return TradingPlatformAccountsResponse.fromJson(\n response.tradingPlatformAccounts,\n );\n }\n", "imports": "import 'package:flutter_deriv_api/api/exceptions/exceptions.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/api.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/lib/basic_api/generated/methods/trading_platform_asset_listing_receive_methods.json b/lib/basic_api/generated/methods/trading_platform_asset_listing_receive_methods.json new file mode 100644 index 0000000000..76f788430c --- /dev/null +++ b/lib/basic_api/generated/methods/trading_platform_asset_listing_receive_methods.json @@ -0,0 +1,4 @@ +{ +"methods": "", +"imports": "import 'package:flutter_deriv_api/helpers/helpers.dart';\n" +} \ No newline at end of file diff --git a/lib/basic_api/generated/methods/trading_platform_deposit_receive_methods.json b/lib/basic_api/generated/methods/trading_platform_deposit_receive_methods.json index 14ad129971..6984a43ff7 100644 --- a/lib/basic_api/generated/methods/trading_platform_deposit_receive_methods.json +++ b/lib/basic_api/generated/methods/trading_platform_deposit_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Trading Platform: Deposit.\n ///\n /// Information about deposit transaction, or status of demo account top up.\n /// For parameters information refer to [TradingPlatformDepositRequest].\n /// Throws a [TradingPlatformException] if API response contains an error.\n static Future deposit(\n TradingPlatformDepositRequest request,\n ) async {\n final TradingPlatformDepositReceive response =\n await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n TradingPlatformException(baseExceptionModel: baseExceptionModel),\n );\n\n return TradingPlatformDepositResponse.fromJson(\n response.tradingPlatformDeposit,\n );\n }\n", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Trading Platform: Deposit.\n ///\n /// Information about deposit transaction, or status of demo account top up.\n /// For parameters information refer to [TradingPlatformDepositRequest].\n /// Throws a [BaseAPIException] if API response contains an error.\n static Future deposit(\n TradingPlatformDepositRequest request,\n ) async {\n final TradingPlatformDepositReceive response =\n await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return TradingPlatformDepositResponse.fromJson(\n response.tradingPlatformDeposit,\n );\n }\n", "imports": "import 'package:flutter_deriv_api/api/exceptions/exceptions.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/api.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/lib/basic_api/generated/methods/trading_platform_new_account_receive_methods.json b/lib/basic_api/generated/methods/trading_platform_new_account_receive_methods.json index d6456cb7c8..37225fd692 100644 --- a/lib/basic_api/generated/methods/trading_platform_new_account_receive_methods.json +++ b/lib/basic_api/generated/methods/trading_platform_new_account_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Trading Platform: New Account (request).\n ///\n /// This call creates new Trading account, either demo or real money.\n /// For parameters information refer to [TradingPlatformNewAccountRequest].\n /// Throws a [TradingPlatformException] if API response contains an error.\n static Future create(\n TradingPlatformNewAccountRequest request,\n ) async {\n final TradingPlatformNewAccountReceive response =\n await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n TradingPlatformException(baseExceptionModel: baseExceptionModel),\n );\n\n return TradingPlatformNewAccountResponse.fromJson(\n response.tradingPlatformNewAccount,\n );\n}", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Trading Platform: New Account (request).\n ///\n /// This call creates new Trading account, either demo or real money.\n /// For parameters information refer to [TradingPlatformNewAccountRequest].\n /// Throws a [BaseAPIException] if API response contains an error.\n static Future create(\n TradingPlatformNewAccountRequest request,\n ) async {\n final TradingPlatformNewAccountReceive response =\n await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return TradingPlatformNewAccountResponse.fromJson(\n response.tradingPlatformNewAccount,\n );\n}", "imports": "import 'package:flutter_deriv_api/api/exceptions/exceptions.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/api.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/lib/basic_api/generated/methods/trading_servers_receive_methods.json b/lib/basic_api/generated/methods/trading_servers_receive_methods.json index 4f54b31644..4ef38ab477 100644 --- a/lib/basic_api/generated/methods/trading_servers_receive_methods.json +++ b/lib/basic_api/generated/methods/trading_servers_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Get the list of servers for platform. Currently, only mt5 is supported\n ///\n /// For parameters information refer to [TradingServersRequest].\n /// Throws a [TradingException] if API response contains an error\n static Future fetchTradingServers(\n TradingServersRequest request,\n ) async {\n final TradingServersReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n TradingException(baseExceptionModel: baseExceptionModel),\n );\n\n return TradingServersResponse.fromJson(response.tradingServers);\n }", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Get the list of servers for platform. Currently, only mt5 is supported\n ///\n /// For parameters information refer to [TradingServersRequest].\n /// Throws a [BaseAPIException] if API response contains an error\n static Future fetchTradingServers(\n TradingServersRequest request,\n ) async {\n final TradingServersReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return TradingServersResponse.fromJson(response.tradingServers);\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/trading_servers_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/trading_servers_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/lib/basic_api/generated/methods/trading_times_receive_methods.json b/lib/basic_api/generated/methods/trading_times_receive_methods.json index 54345f562d..93972a04c9 100644 --- a/lib/basic_api/generated/methods/trading_times_receive_methods.json +++ b/lib/basic_api/generated/methods/trading_times_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Receives a list of market opening times for a given date.\n ///\n /// For parameters information refer to [TradingTimesRequest].\n /// Throws a [TradingException] if API response contains an error\n static Future fetchTradingTimes(\n TradingTimesRequest request,\n ) async {\n final TradingTimesReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n TradingException(baseExceptionModel: baseExceptionModel),\n );\n\n return TradingTimesResponse.fromJson(response.tradingTimes);\n }", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Receives a list of market opening times for a given date.\n ///\n /// For parameters information refer to [TradingTimesRequest].\n /// Throws a [BaseAPIException] if API response contains an error\n static Future fetchTradingTimes(\n TradingTimesRequest request,\n ) async {\n final TradingTimesReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return TradingTimesResponse.fromJson(response.tradingTimes);\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/trading_times_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/trading_times_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/lib/basic_api/generated/methods/transaction_receive_methods.json b/lib/basic_api/generated/methods/transaction_receive_methods.json index 4f6f6118fa..08dd08ca02 100644 --- a/lib/basic_api/generated/methods/transaction_receive_methods.json +++ b/lib/basic_api/generated/methods/transaction_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Subscribes to account's transactions\n ///\n /// Throws a [TransactionsException] if API response contains an error\n static Stream subscribeTransactions({\n RequestCompareFunction? comparePredicate,\n }) =>\n _api\n .subscribe(\n request: const TransactionRequest(),\n comparePredicate: comparePredicate,\n )!\n .map((Response response) {\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n TransactionsException(baseExceptionModel: baseExceptionModel),\n );\n\n return response is TransactionReceive\n ? TransactionResponse.fromJson(\n response.transaction,\n response.subscription,\n )\n : null;\n });\n\n /// Unsubscribes from transaction subscription.\n ///\n /// Throws a [TransactionsException] if API response contains an error\n Future unsubscribeTransaction() async {\n if (subscription == null) {\n return null;\n }\n\n final ForgetReceive response =\n await _api.unsubscribe(subscriptionId: subscription!.id);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n TransactionsException(baseExceptionModel: baseExceptionModel),\n );\n\n return ForgetResponse.fromJson(response.forget);\n }\n\n /// Unsubscribes all transaction subscriptions.\n ///\n /// Throws a [TransactionsException] if API response contains an error\n static Future unsubscribeAllTransaction() async {\n final ForgetAllReceive response =\n await _api.unsubscribeAll(method: ForgetStreamType.transaction);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n TransactionsException(baseExceptionModel: baseExceptionModel),\n );\n\n return ForgetAllResponse.fromJson(response.forgetAll);\n }", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Subscribes to account's transactions\n ///\n /// Throws a [BaseAPIException] if API response contains an error\n static Stream subscribeTransactions({\n RequestCompareFunction? comparePredicate,\n }) =>\n _api\n .subscribe(\n request: const TransactionRequest(),\n comparePredicate: comparePredicate,\n )!\n .map((Response response) {\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return response is TransactionReceive\n ? TransactionResponse.fromJson(\n response.transaction,\n response.subscription,\n )\n : null;\n });\n\n /// Unsubscribes from transaction subscription.\n ///\n /// Throws a [BaseAPIException] if API response contains an error\n Future unsubscribeTransaction() async {\n if (subscription == null) {\n return null;\n }\n\n final ForgetReceive response =\n await _api.unsubscribe(subscriptionId: subscription!.id);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return ForgetResponse.fromJson(response.forget);\n }\n\n /// Unsubscribes all transaction subscriptions.\n ///\n /// Throws a [BaseAPIException] if API response contains an error\n static Future unsubscribeAllTransaction() async {\n final ForgetAllReceive response =\n await _api.unsubscribeAll(method: ForgetStreamType.transaction);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return ForgetAllResponse.fromJson(response.forgetAll);\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/api/models/enums.dart';\nimport 'package:flutter_deriv_api/api/response/forget_all_response_result.dart';\nimport 'package:flutter_deriv_api/api/response/forget_response_result.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/forget_all_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/forget_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/transaction_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/transaction_send.dart';\nimport 'package:flutter_deriv_api/basic_api/response.dart';\nimport 'package:flutter_deriv_api/helpers/helpers.dart';\nimport 'package:flutter_deriv_api/services/connection/api_manager/base_api.dart';\nimport 'package:flutter_deriv_api/services/connection/call_manager/base_call_manager.dart';\nimport 'package:deriv_dependency_injector/dependency_injector.dart';\n" } diff --git a/lib/basic_api/generated/methods/transfer_between_accounts_receive_methods.json b/lib/basic_api/generated/methods/transfer_between_accounts_receive_methods.json index b983f5b292..bbb11fcf51 100644 --- a/lib/basic_api/generated/methods/transfer_between_accounts_receive_methods.json +++ b/lib/basic_api/generated/methods/transfer_between_accounts_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// This call allows transfers between accounts held by a given user.\n ///\n /// Transfer funds between your fiat and crypto currency accounts (for a fee).\n /// Please note that account_from should be same as current authorized account.\n /// For parameters information refer to [TransferBetweenAccountsRequest].\n /// Throws a [TransferException] if API response contains an error\n static Future transfer(\n TransferBetweenAccountsRequest request,\n ) async {\n final TransferBetweenAccountsReceive response =\n await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n TransferException(baseExceptionModel: baseExceptionModel),\n );\n\n return TransferBetweenAccountsResponse.fromJson(\n response.transferBetweenAccounts,\n response.accounts,\n response.clientToFullName,\n response.clientToLoginid,\n response.transactionId);\n }\n", + "methods": "static final BaseAPI _api = Injector()();\n\n /// This call allows transfers between accounts held by a given user.\n ///\n /// Transfer funds between your fiat and crypto currency accounts (for a fee).\n /// Please note that account_from should be same as current authorized account.\n /// For parameters information refer to [TransferBetweenAccountsRequest].\n /// Throws a [BaseAPIException] if API response contains an error\n static Future transfer(\n TransferBetweenAccountsRequest request,\n ) async {\n final TransferBetweenAccountsReceive response =\n await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return TransferBetweenAccountsResponse.fromJson(\n response.transferBetweenAccounts,\n response.accounts,\n response.clientToFullName,\n response.clientToLoginid,\n response.transactionId);\n }\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/transfer_between_accounts_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/transfer_between_accounts_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/lib/basic_api/generated/methods/verify_email_receive_methods.json b/lib/basic_api/generated/methods/verify_email_receive_methods.json index 323f58da9c..115a828e9b 100644 --- a/lib/basic_api/generated/methods/verify_email_receive_methods.json +++ b/lib/basic_api/generated/methods/verify_email_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()();\n\n /// Verifies an email address for various purposes.\n ///\n /// The system will send an email to the address containing a security code for verification.\n /// For parameters information refer to [VerifyEmailRequest].\n /// Throws a [UserException] if API response contains an error\n static Future verify(\n VerifyEmailRequest request,\n ) async {\n final VerifyEmailReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n UserException(baseExceptionModel: baseExceptionModel),\n );\n\n return VerifyEmailResponse.fromJson(response.verifyEmail);\n }", + "methods": "static final BaseAPI _api = Injector()();\n\n /// Verifies an email address for various purposes.\n ///\n /// The system will send an email to the address containing a security code for verification.\n /// For parameters information refer to [VerifyEmailRequest].\n /// Throws a [BaseAPIException] if API response contains an error\n static Future verify(\n VerifyEmailRequest request,\n ) async {\n final VerifyEmailReceive response = await _api.call(request: request);\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return VerifyEmailResponse.fromJson(response.verifyEmail);\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/verify_email_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/verify_email_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/lib/basic_api/generated/methods/wallet_migration_receive_methods.json b/lib/basic_api/generated/methods/wallet_migration_receive_methods.json new file mode 100644 index 0000000000..76f788430c --- /dev/null +++ b/lib/basic_api/generated/methods/wallet_migration_receive_methods.json @@ -0,0 +1,4 @@ +{ +"methods": "", +"imports": "import 'package:flutter_deriv_api/helpers/helpers.dart';\n" +} \ No newline at end of file diff --git a/lib/basic_api/generated/methods/website_status_receive_methods.json b/lib/basic_api/generated/methods/website_status_receive_methods.json index 76c2b5bc7d..91468647d4 100644 --- a/lib/basic_api/generated/methods/website_status_receive_methods.json +++ b/lib/basic_api/generated/methods/website_status_receive_methods.json @@ -1,4 +1,4 @@ { - "methods": "static final BaseAPI _api = Injector()(); \n \n /// Gets Website status. \n /// \n /// For parameters information refer to [WebsiteStatusRequest]. \n /// Throws a [WebsiteStatusException] if API response contains an error. \n static Future fetchWebsiteStatusRaw([ \n WebsiteStatusRequest? request, \n ]) async { \n final WebsiteStatusReceive response = await _api.call( \n request: request ?? const WebsiteStatusRequest(), \n ); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n WebsiteStatusException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response; \n } \n \n /// Subscribes to website status. \n /// \n /// Throws a [WebsiteStatusException] if API response contains an error. \n static Stream subscribeWebsiteStatusRaw( \n WebsiteStatusRequest request, { \n RequestCompareFunction? comparePredicate, \n }) => \n _api \n .subscribe(request: request, comparePredicate: comparePredicate)! \n .map( \n (Response response) { \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n WebsiteStatusException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response is WebsiteStatusReceive ? response : null; \n }, \n ); \n \n /// Unsubscribes from website status. \n /// \n /// Throws an [WebsiteStatusException] if the API response contains an error. \n Future unsubscribeWebsiteStatusRaw() async { \n if (subscription == null) { \n return null; \n } \n \n final ForgetReceive response = \n await _api.unsubscribe(subscriptionId: subscription!.id); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n WebsiteStatusException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response; \n } \n \n /// Unsubscribes all website status subscriptions. \n /// \n /// Throws an [WebsiteStatusException] if the API response contains an error. \n static Future unsubscribeAllWebsiteStatusRaw() async { \n final ForgetAllReceive response = \n await _api.unsubscribeAll(method: ForgetStreamType.websiteStatus); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n WebsiteStatusException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response; \n } \n \n /// Gets Website status. \n /// \n /// Throws an [WebsiteStatusException] if the API response contains an error. \n static Future fetchWebsiteStatus([ \n WebsiteStatusRequest? request, \n ]) async { \n final WebsiteStatusReceive response = await fetchWebsiteStatusRaw(request); \n \n return WebsiteStatusResponse.fromJson( \n response.websiteStatus, \n response.subscription, \n ); \n } \n \n /// Subscribes to website status. \n static Stream subscribeWebsiteStatus( \n WebsiteStatusRequest request, { \n RequestCompareFunction? comparePredicate, \n }) => \n subscribeWebsiteStatusRaw( \n request, \n comparePredicate: comparePredicate, \n ).map( \n (WebsiteStatusReceive? response) => response == null \n ? null \n : WebsiteStatusResponse.fromJson( \n response.websiteStatus, \n response.subscription, \n ), \n ); \n \n /// Unsubscribes from website status. \n /// \n /// Throws an [WebsiteStatusException] if the API response contains an error. \n Future unsubscribeWebsiteStatus() async { \n final ForgetReceive? response = await unsubscribeWebsiteStatusRaw(); \n \n return ForgetResponse.fromJson(response?.forget); \n } \n \n /// Unsubscribes all website status subscriptions. \n /// \n /// Throws an [WebsiteStatusException] if the API response contains an error. \n static Future unsubscribeAllWebsiteStatus() async { \n final ForgetAllReceive response = await unsubscribeAllWebsiteStatusRaw(); \n \n return ForgetAllResponse.fromJson(response.forgetAll); \n }", + "methods": "static final BaseAPI _api = Injector()(); \n \n /// Gets Website status. \n /// \n /// For parameters information refer to [WebsiteStatusRequest]. \n /// Throws a [BaseAPIException] if API response contains an error. \n static Future fetchWebsiteStatusRaw([ \n WebsiteStatusRequest? request, \n ]) async { \n final WebsiteStatusReceive response = await _api.call( \n request: request ?? const WebsiteStatusRequest(), \n ); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n BaseAPIException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response; \n } \n \n /// Subscribes to website status. \n /// \n /// Throws a [BaseAPIException] if API response contains an error. \n static Stream subscribeWebsiteStatusRaw( \n WebsiteStatusRequest request, { \n RequestCompareFunction? comparePredicate, \n }) => \n _api \n .subscribe(request: request, comparePredicate: comparePredicate)! \n .map( \n (Response response) { \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n BaseAPIException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response is WebsiteStatusReceive ? response : null; \n }, \n ); \n \n /// Unsubscribes from website status. \n /// \n /// Throws an [BaseAPIException] if the API response contains an error. \n Future unsubscribeWebsiteStatusRaw() async { \n if (subscription == null) { \n return null; \n } \n \n final ForgetReceive response = \n await _api.unsubscribe(subscriptionId: subscription!.id); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n BaseAPIException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response; \n } \n \n /// Unsubscribes all website status subscriptions. \n /// \n /// Throws an [BaseAPIException] if the API response contains an error. \n static Future unsubscribeAllWebsiteStatusRaw() async { \n final ForgetAllReceive response = \n await _api.unsubscribeAll(method: ForgetStreamType.websiteStatus); \n \n checkException( \n response: response, \n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) => \n BaseAPIException(baseExceptionModel: baseExceptionModel), \n ); \n \n return response; \n } \n \n /// Gets Website status. \n /// \n /// Throws an [BaseAPIException] if the API response contains an error. \n static Future fetchWebsiteStatus([ \n WebsiteStatusRequest? request, \n ]) async { \n final WebsiteStatusReceive response = await fetchWebsiteStatusRaw(request); \n \n return WebsiteStatusResponse.fromJson( \n response.websiteStatus, \n response.subscription, \n ); \n } \n \n /// Subscribes to website status. \n static Stream subscribeWebsiteStatus( \n WebsiteStatusRequest request, { \n RequestCompareFunction? comparePredicate, \n }) => \n subscribeWebsiteStatusRaw( \n request, \n comparePredicate: comparePredicate, \n ).map( \n (WebsiteStatusReceive? response) => response == null \n ? null \n : WebsiteStatusResponse.fromJson( \n response.websiteStatus, \n response.subscription, \n ), \n ); \n \n /// Unsubscribes from website status. \n /// \n /// Throws an [BaseAPIException] if the API response contains an error. \n Future unsubscribeWebsiteStatus() async { \n final ForgetReceive? response = await unsubscribeWebsiteStatusRaw(); \n \n return ForgetResponse.fromJson(response?.forget); \n } \n \n /// Unsubscribes all website status subscriptions. \n /// \n /// Throws an [BaseAPIException] if the API response contains an error. \n static Future unsubscribeAllWebsiteStatus() async { \n final ForgetAllReceive response = await unsubscribeAllWebsiteStatusRaw(); \n \n return ForgetAllResponse.fromJson(response.forgetAll); \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/api/models/enums.dart';\nimport 'package:flutter_deriv_api/api/response/forget_all_response_result.dart';\nimport 'package:flutter_deriv_api/api/response/forget_response_result.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/forget_all_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/forget_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/website_status_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/website_status_send.dart';\nimport 'package:flutter_deriv_api/basic_api/response.dart';\nimport 'package:flutter_deriv_api/helpers/helpers.dart';\nimport 'package:flutter_deriv_api/services/connection/api_manager/base_api.dart';\nimport 'package:flutter_deriv_api/services/connection/call_manager/base_call_manager.dart';\nimport 'package:deriv_dependency_injector/dependency_injector.dart';\n" } diff --git a/lib/basic_api/generated/mt5_new_account_receive.dart b/lib/basic_api/generated/mt5_new_account_receive.dart index 1a035485f0..8a081d4e7d 100644 --- a/lib/basic_api/generated/mt5_new_account_receive.dart +++ b/lib/basic_api/generated/mt5_new_account_receive.dart @@ -9,16 +9,11 @@ class Mt5NewAccountReceive extends Response { /// Initialize Mt5NewAccountReceive. const Mt5NewAccountReceive({ this.mt5NewAccount, - Map? echoReq, - Map? error, - String? msgType, - int? reqId, - }) : super( - echoReq: echoReq, - error: error, - msgType: msgType, - reqId: reqId, - ); + super.echoReq, + super.error, + super.msgType, + super.reqId, + }); /// Creates an instance from JSON. factory Mt5NewAccountReceive.fromJson(Map json) => diff --git a/lib/basic_api/generated/mt5_new_account_send.dart b/lib/basic_api/generated/mt5_new_account_send.dart index ada5e003fe..cf50ed0c55 100644 --- a/lib/basic_api/generated/mt5_new_account_send.dart +++ b/lib/basic_api/generated/mt5_new_account_send.dart @@ -27,14 +27,12 @@ class Mt5NewAccountRequest extends Request { this.phonePassword, this.server, this.state, + this.subAccountCategory, this.zipCode, - Map? passthrough, - int? reqId, - }) : super( - msgType: 'mt5_new_account', - passthrough: passthrough, - reqId: reqId, - ); + super.msgType = 'mt5_new_account', + super.passthrough, + super.reqId, + }); /// Creates an instance from JSON. factory Mt5NewAccountRequest.fromJson(Map json) => @@ -60,6 +58,7 @@ class Mt5NewAccountRequest extends Request { phonePassword: json['phonePassword'] as String?, server: json['server'] as String?, state: json['state'] as String?, + subAccountCategory: json['sub_account_category'] as String?, zipCode: json['zipCode'] as String?, passthrough: json['passthrough'] as Map?, reqId: json['req_id'] as int?, @@ -98,7 +97,7 @@ class Mt5NewAccountRequest extends Request { /// The master password of the account. For validation (Accepts any printable ASCII character. Must be within 8-25 characters, and include numbers, lowercase and uppercase letters. Must not be the same as the user's email address). This field is required. final String? mainPassword; - /// [Optional] To choose whether account is conventional or not. Unavailable for financial_stp MT5_account_type + /// [Optional] To choose whether account is conventional or swap_free. Unavailable for financial_stp MT5_account_type final String? mt5AccountCategory; /// [Optional] Financial: Variable spreads, High leverage. Financial STP: Variable spreads, Medium Leverage, more products. If 'account_type' set to 'financial', setting 'mt5_account_type' is also required. @@ -122,6 +121,9 @@ class Mt5NewAccountRequest extends Request { /// [Optional] User's state (region) of residence. final String? state; + /// [Optional] Indicate the sub account category that we have in the cfd group naming convention. + final String? subAccountCategory; + /// [Optional] User's zip code. final String? zipCode; @@ -155,6 +157,7 @@ class Mt5NewAccountRequest extends Request { 'phonePassword': phonePassword, 'server': server, 'state': state, + 'sub_account_category': subAccountCategory, 'zipCode': zipCode, 'passthrough': passthrough, 'req_id': reqId, @@ -182,6 +185,7 @@ class Mt5NewAccountRequest extends Request { String? phonePassword, String? server, String? state, + String? subAccountCategory, String? zipCode, Map? passthrough, int? reqId, @@ -206,6 +210,7 @@ class Mt5NewAccountRequest extends Request { phonePassword: phonePassword ?? this.phonePassword, server: server ?? this.server, state: state ?? this.state, + subAccountCategory: subAccountCategory ?? this.subAccountCategory, zipCode: zipCode ?? this.zipCode, passthrough: passthrough ?? this.passthrough, reqId: reqId ?? this.reqId, diff --git a/lib/basic_api/generated/mt5_password_change_receive.dart b/lib/basic_api/generated/mt5_password_change_receive.dart index 7aaeed5bf5..20e1a5209e 100644 --- a/lib/basic_api/generated/mt5_password_change_receive.dart +++ b/lib/basic_api/generated/mt5_password_change_receive.dart @@ -9,16 +9,11 @@ class Mt5PasswordChangeReceive extends Response { /// Initialize Mt5PasswordChangeReceive. const Mt5PasswordChangeReceive({ this.mt5PasswordChange, - Map? echoReq, - Map? error, - String? msgType, - int? reqId, - }) : super( - echoReq: echoReq, - error: error, - msgType: msgType, - reqId: reqId, - ); + super.echoReq, + super.error, + super.msgType, + super.reqId, + }); /// Creates an instance from JSON. factory Mt5PasswordChangeReceive.fromJson(Map json) => diff --git a/lib/basic_api/generated/new_account_maltainvest_send.dart b/lib/basic_api/generated/new_account_maltainvest_send.dart index 4ba6436f32..5a3d3b65da 100644 --- a/lib/basic_api/generated/new_account_maltainvest_send.dart +++ b/lib/basic_api/generated/new_account_maltainvest_send.dart @@ -17,45 +17,44 @@ class NewAccountMaltainvestRequest extends Request { this.addressPostcode, this.addressState, this.affiliateToken, - this.binaryOptionsTradingExperience, - this.binaryOptionsTradingFrequency, - this.cfdTradingExperience, - this.cfdTradingFrequency, + required this.cfdExperience, + required this.cfdFrequency, + required this.cfdTradingDefinition, this.citizen, this.clientType, this.currency, required this.dateOfBirth, required this.educationLevel, required this.employmentIndustry, - this.employmentStatus, + required this.employmentStatus, required this.estimatedWorth, required this.firstName, - this.forexTradingExperience, - this.forexTradingFrequency, required this.incomeSource, required this.lastName, + required this.leverageImpactTrading, + required this.leverageTradingHighRiskStopLoss, required this.netIncome, this.newAccountMaltainvest = true, this.nonPepDeclaration, required this.occupation, - this.otherInstrumentsTradingExperience, - this.otherInstrumentsTradingFrequency, this.phone, this.placeOfBirth, + required this.requiredInitialMargin, required this.residence, + required this.riskTolerance, required this.salutation, this.secretAnswer, this.secretQuestion, + required this.sourceOfExperience, this.sourceOfWealth, required this.taxIdentificationNumber, required this.taxResidence, - Map? passthrough, - int? reqId, - }) : super( - msgType: 'new_account_maltainvest', - passthrough: passthrough, - reqId: reqId, - ); + required this.tradingExperienceFinancialInstruments, + required this.tradingFrequencyFinancialInstruments, + super.msgType = 'new_account_maltainvest', + super.passthrough, + super.reqId, + }); /// Creates an instance from JSON. factory NewAccountMaltainvestRequest.fromJson(Map json) => @@ -70,12 +69,9 @@ class NewAccountMaltainvestRequest extends Request { addressPostcode: json['address_postcode'] as String?, addressState: json['address_state'] as String?, affiliateToken: json['affiliate_token'] as String?, - binaryOptionsTradingExperience: - json['binary_options_trading_experience'] as String?, - binaryOptionsTradingFrequency: - json['binary_options_trading_frequency'] as String?, - cfdTradingExperience: json['cfd_trading_experience'] as String?, - cfdTradingFrequency: json['cfd_trading_frequency'] as String?, + cfdExperience: json['cfd_experience'] as String?, + cfdFrequency: json['cfd_frequency'] as String?, + cfdTradingDefinition: json['cfd_trading_definition'] as String?, citizen: json['citizen'] as String?, clientType: json['client_type'] as String?, currency: json['currency'] as String?, @@ -85,29 +81,33 @@ class NewAccountMaltainvestRequest extends Request { employmentStatus: json['employment_status'] as String?, estimatedWorth: json['estimated_worth'] as String?, firstName: json['first_name'] as String?, - forexTradingExperience: json['forex_trading_experience'] as String?, - forexTradingFrequency: json['forex_trading_frequency'] as String?, incomeSource: json['income_source'] as String?, lastName: json['last_name'] as String?, + leverageImpactTrading: json['leverage_impact_trading'] as String?, + leverageTradingHighRiskStopLoss: + json['leverage_trading_high_risk_stop_loss'] as String?, netIncome: json['net_income'] as String?, newAccountMaltainvest: json['new_account_maltainvest'] == null ? null : json['new_account_maltainvest'] == 1, nonPepDeclaration: json['non_pep_declaration'] as int?, occupation: json['occupation'] as String?, - otherInstrumentsTradingExperience: - json['other_instruments_trading_experience'] as String?, - otherInstrumentsTradingFrequency: - json['other_instruments_trading_frequency'] as String?, phone: json['phone'] as String?, placeOfBirth: json['place_of_birth'] as String?, + requiredInitialMargin: json['required_initial_margin'] as String?, residence: json['residence'] as String?, + riskTolerance: json['risk_tolerance'] as String?, salutation: json['salutation'] as String?, secretAnswer: json['secret_answer'] as String?, secretQuestion: json['secret_question'] as String?, + sourceOfExperience: json['source_of_experience'] as String?, sourceOfWealth: json['source_of_wealth'] as String?, taxIdentificationNumber: json['tax_identification_number'] as String?, taxResidence: json['tax_residence'] as String?, + tradingExperienceFinancialInstruments: + json['trading_experience_financial_instruments'] as String?, + tradingFrequencyFinancialInstruments: + json['trading_frequency_financial_instruments'] as String?, passthrough: json['passthrough'] as Map?, reqId: json['req_id'] as int?, ); @@ -139,17 +139,14 @@ class NewAccountMaltainvestRequest extends Request { /// [Optional] Affiliate token, within 32 characters. final String? affiliateToken; - /// [Optional] Binary options trading experience. - final String? binaryOptionsTradingExperience; + /// How much experience do you have in CFD trading? + final String? cfdExperience; - /// [Optional] Binary options trading frequency. - final String? binaryOptionsTradingFrequency; + /// How many CFD trades have you placed in the past 12 months? + final String? cfdFrequency; - /// [Optional] CFDs trading experience. - final String? cfdTradingExperience; - - /// [Optional] CFDs trading frequency. - final String? cfdTradingFrequency; + /// In your understanding, CFD trading allows you to: + final String? cfdTradingDefinition; /// [Optional] Country of legal citizenship, 2-letter country code. Possible value receive from `residence_list` call. final String? citizen; @@ -169,7 +166,7 @@ class NewAccountMaltainvestRequest extends Request { /// Industry of Employment. final String? employmentIndustry; - /// [Optional] Employment Status. + /// Employment Status. final String? employmentStatus; /// Estimated Net Worth. @@ -178,18 +175,18 @@ class NewAccountMaltainvestRequest extends Request { /// Within 2-50 characters, use only letters, spaces, hyphens, full-stops or apostrophes. final String? firstName; - /// [Optional] Forex trading experience. - final String? forexTradingExperience; - - /// [Optional] Forex trading frequency. - final String? forexTradingFrequency; - /// Income Source. final String? incomeSource; /// Within 2-50 characters, use only letters, spaces, hyphens, full-stops or apostrophes. final String? lastName; + /// How does leverage affect CFD trading? + final String? leverageImpactTrading; + + /// Leverage trading is high-risk, so it's a good idea to use risk management features such as stop loss. Stop loss allows you to + final String? leverageTradingHighRiskStopLoss; + /// Net Annual Income. final String? netIncome; @@ -202,21 +199,21 @@ class NewAccountMaltainvestRequest extends Request { /// Occupation. final String? occupation; - /// [Optional] Trading experience in other financial instruments. - final String? otherInstrumentsTradingExperience; - - /// [Optional] Trading frequency in other financial instruments. - final String? otherInstrumentsTradingFrequency; - /// [Optional] Starting with `+` followed by 9-35 digits, hyphens or space. final String? phone; /// [Optional] Place of birth, 2-letter country code. final String? placeOfBirth; + /// When would you be required to pay an initial margin? + final String? requiredInitialMargin; + /// 2-letter country code, possible value receive from `residence_list` call. final String? residence; + /// Do you understand that you could potentially lose 100% of the money you use to trade? + final String? riskTolerance; + /// Accept any value in enum list. final String? salutation; @@ -226,6 +223,9 @@ class NewAccountMaltainvestRequest extends Request { /// [Optional] Accept any value in enum list. final String? secretQuestion; + /// How much knowledge and experience do you have in relation to online trading? + final String? sourceOfExperience; + /// [Optional] Source of wealth. final String? sourceOfWealth; @@ -235,6 +235,12 @@ class NewAccountMaltainvestRequest extends Request { /// Residence for tax purpose. Comma separated iso country code if multiple jurisdictions. Only applicable for real money account. Required for `maltainvest` landing company. final String? taxResidence; + /// How much experience do you have with other financial instruments? + final String? tradingExperienceFinancialInstruments; + + /// How many trades have you placed with other financial instruments in the past 12 months? + final String? tradingFrequencyFinancialInstruments; + /// Converts this instance to JSON @override Map toJson() => { @@ -251,10 +257,9 @@ class NewAccountMaltainvestRequest extends Request { 'address_postcode': addressPostcode, 'address_state': addressState, 'affiliate_token': affiliateToken, - 'binary_options_trading_experience': binaryOptionsTradingExperience, - 'binary_options_trading_frequency': binaryOptionsTradingFrequency, - 'cfd_trading_experience': cfdTradingExperience, - 'cfd_trading_frequency': cfdTradingFrequency, + 'cfd_experience': cfdExperience, + 'cfd_frequency': cfdFrequency, + 'cfd_trading_definition': cfdTradingDefinition, 'citizen': citizen, 'client_type': clientType, 'currency': currency, @@ -264,10 +269,10 @@ class NewAccountMaltainvestRequest extends Request { 'employment_status': employmentStatus, 'estimated_worth': estimatedWorth, 'first_name': firstName, - 'forex_trading_experience': forexTradingExperience, - 'forex_trading_frequency': forexTradingFrequency, 'income_source': incomeSource, 'last_name': lastName, + 'leverage_impact_trading': leverageImpactTrading, + 'leverage_trading_high_risk_stop_loss': leverageTradingHighRiskStopLoss, 'net_income': netIncome, 'new_account_maltainvest': newAccountMaltainvest == null ? null @@ -276,18 +281,22 @@ class NewAccountMaltainvestRequest extends Request { : 0, 'non_pep_declaration': nonPepDeclaration, 'occupation': occupation, - 'other_instruments_trading_experience': - otherInstrumentsTradingExperience, - 'other_instruments_trading_frequency': otherInstrumentsTradingFrequency, 'phone': phone, 'place_of_birth': placeOfBirth, + 'required_initial_margin': requiredInitialMargin, 'residence': residence, + 'risk_tolerance': riskTolerance, 'salutation': salutation, 'secret_answer': secretAnswer, 'secret_question': secretQuestion, + 'source_of_experience': sourceOfExperience, 'source_of_wealth': sourceOfWealth, 'tax_identification_number': taxIdentificationNumber, 'tax_residence': taxResidence, + 'trading_experience_financial_instruments': + tradingExperienceFinancialInstruments, + 'trading_frequency_financial_instruments': + tradingFrequencyFinancialInstruments, 'passthrough': passthrough, 'req_id': reqId, }; @@ -304,10 +313,9 @@ class NewAccountMaltainvestRequest extends Request { String? addressPostcode, String? addressState, String? affiliateToken, - String? binaryOptionsTradingExperience, - String? binaryOptionsTradingFrequency, - String? cfdTradingExperience, - String? cfdTradingFrequency, + String? cfdExperience, + String? cfdFrequency, + String? cfdTradingDefinition, String? citizen, String? clientType, String? currency, @@ -317,25 +325,28 @@ class NewAccountMaltainvestRequest extends Request { String? employmentStatus, String? estimatedWorth, String? firstName, - String? forexTradingExperience, - String? forexTradingFrequency, String? incomeSource, String? lastName, + String? leverageImpactTrading, + String? leverageTradingHighRiskStopLoss, String? netIncome, bool? newAccountMaltainvest, int? nonPepDeclaration, String? occupation, - String? otherInstrumentsTradingExperience, - String? otherInstrumentsTradingFrequency, String? phone, String? placeOfBirth, + String? requiredInitialMargin, String? residence, + String? riskTolerance, String? salutation, String? secretAnswer, String? secretQuestion, + String? sourceOfExperience, String? sourceOfWealth, String? taxIdentificationNumber, String? taxResidence, + String? tradingExperienceFinancialInstruments, + String? tradingFrequencyFinancialInstruments, Map? passthrough, int? reqId, }) => @@ -349,12 +360,9 @@ class NewAccountMaltainvestRequest extends Request { addressPostcode: addressPostcode ?? this.addressPostcode, addressState: addressState ?? this.addressState, affiliateToken: affiliateToken ?? this.affiliateToken, - binaryOptionsTradingExperience: binaryOptionsTradingExperience ?? - this.binaryOptionsTradingExperience, - binaryOptionsTradingFrequency: - binaryOptionsTradingFrequency ?? this.binaryOptionsTradingFrequency, - cfdTradingExperience: cfdTradingExperience ?? this.cfdTradingExperience, - cfdTradingFrequency: cfdTradingFrequency ?? this.cfdTradingFrequency, + cfdExperience: cfdExperience ?? this.cfdExperience, + cfdFrequency: cfdFrequency ?? this.cfdFrequency, + cfdTradingDefinition: cfdTradingDefinition ?? this.cfdTradingDefinition, citizen: citizen ?? this.citizen, clientType: clientType ?? this.clientType, currency: currency ?? this.currency, @@ -364,31 +372,37 @@ class NewAccountMaltainvestRequest extends Request { employmentStatus: employmentStatus ?? this.employmentStatus, estimatedWorth: estimatedWorth ?? this.estimatedWorth, firstName: firstName ?? this.firstName, - forexTradingExperience: - forexTradingExperience ?? this.forexTradingExperience, - forexTradingFrequency: - forexTradingFrequency ?? this.forexTradingFrequency, incomeSource: incomeSource ?? this.incomeSource, lastName: lastName ?? this.lastName, + leverageImpactTrading: + leverageImpactTrading ?? this.leverageImpactTrading, + leverageTradingHighRiskStopLoss: leverageTradingHighRiskStopLoss ?? + this.leverageTradingHighRiskStopLoss, netIncome: netIncome ?? this.netIncome, newAccountMaltainvest: newAccountMaltainvest ?? this.newAccountMaltainvest, nonPepDeclaration: nonPepDeclaration ?? this.nonPepDeclaration, occupation: occupation ?? this.occupation, - otherInstrumentsTradingExperience: otherInstrumentsTradingExperience ?? - this.otherInstrumentsTradingExperience, - otherInstrumentsTradingFrequency: otherInstrumentsTradingFrequency ?? - this.otherInstrumentsTradingFrequency, phone: phone ?? this.phone, placeOfBirth: placeOfBirth ?? this.placeOfBirth, + requiredInitialMargin: + requiredInitialMargin ?? this.requiredInitialMargin, residence: residence ?? this.residence, + riskTolerance: riskTolerance ?? this.riskTolerance, salutation: salutation ?? this.salutation, secretAnswer: secretAnswer ?? this.secretAnswer, secretQuestion: secretQuestion ?? this.secretQuestion, + sourceOfExperience: sourceOfExperience ?? this.sourceOfExperience, sourceOfWealth: sourceOfWealth ?? this.sourceOfWealth, taxIdentificationNumber: taxIdentificationNumber ?? this.taxIdentificationNumber, taxResidence: taxResidence ?? this.taxResidence, + tradingExperienceFinancialInstruments: + tradingExperienceFinancialInstruments ?? + this.tradingExperienceFinancialInstruments, + tradingFrequencyFinancialInstruments: + tradingFrequencyFinancialInstruments ?? + this.tradingFrequencyFinancialInstruments, passthrough: passthrough ?? this.passthrough, reqId: reqId ?? this.reqId, ); diff --git a/lib/basic_api/generated/new_account_real_receive.dart b/lib/basic_api/generated/new_account_real_receive.dart index 17b42b70c8..d45426248e 100644 --- a/lib/basic_api/generated/new_account_real_receive.dart +++ b/lib/basic_api/generated/new_account_real_receive.dart @@ -9,16 +9,11 @@ class NewAccountRealReceive extends Response { /// Initialize NewAccountRealReceive. const NewAccountRealReceive({ this.newAccountReal, - Map? echoReq, - Map? error, - String? msgType, - int? reqId, - }) : super( - echoReq: echoReq, - error: error, - msgType: msgType, - reqId: reqId, - ); + super.echoReq, + super.error, + super.msgType, + super.reqId, + }); /// Creates an instance from JSON. factory NewAccountRealReceive.fromJson(Map json) => diff --git a/lib/basic_api/generated/new_account_real_send.dart b/lib/basic_api/generated/new_account_real_send.dart index b5a3907a2f..80dd7ac8f6 100644 --- a/lib/basic_api/generated/new_account_real_send.dart +++ b/lib/basic_api/generated/new_account_real_send.dart @@ -11,7 +11,7 @@ class NewAccountRealRequest extends Request { this.accountOpeningReason, this.accountTurnover, this.addressCity, - required this.addressLine1, + this.addressLine1, this.addressLine2, this.addressPostcode, this.addressState, @@ -19,26 +19,23 @@ class NewAccountRealRequest extends Request { this.citizen, this.clientType, this.currency, - required this.dateOfBirth, - required this.firstName, - required this.lastName, + this.dateOfBirth, + this.firstName, + this.lastName, this.newAccountReal = true, this.nonPepDeclaration, this.phone, this.placeOfBirth, - required this.residence, + this.residence, this.salutation, this.secretAnswer, this.secretQuestion, this.taxIdentificationNumber, this.taxResidence, - Map? passthrough, - int? reqId, - }) : super( - msgType: 'new_account_real', - passthrough: passthrough, - reqId: reqId, - ); + super.msgType = 'new_account_real', + super.passthrough, + super.reqId, + }); /// Creates an instance from JSON. factory NewAccountRealRequest.fromJson(Map json) => diff --git a/lib/basic_api/generated/new_account_virtual_receive.dart b/lib/basic_api/generated/new_account_virtual_receive.dart index 9edd1cb4f3..6ea7ffd2c5 100644 --- a/lib/basic_api/generated/new_account_virtual_receive.dart +++ b/lib/basic_api/generated/new_account_virtual_receive.dart @@ -9,16 +9,11 @@ class NewAccountVirtualReceive extends Response { /// Initialize NewAccountVirtualReceive. const NewAccountVirtualReceive({ this.newAccountVirtual, - Map? echoReq, - Map? error, - String? msgType, - int? reqId, - }) : super( - echoReq: echoReq, - error: error, - msgType: msgType, - reqId: reqId, - ); + super.echoReq, + super.error, + super.msgType, + super.reqId, + }); /// Creates an instance from JSON. factory NewAccountVirtualReceive.fromJson(Map json) => diff --git a/lib/basic_api/generated/new_account_virtual_send.dart b/lib/basic_api/generated/new_account_virtual_send.dart index fa783d27a5..3a54d5c1bb 100644 --- a/lib/basic_api/generated/new_account_virtual_send.dart +++ b/lib/basic_api/generated/new_account_virtual_send.dart @@ -30,13 +30,10 @@ class NewAccountVirtualRequest extends Request { this.utmSource, this.utmTerm, required this.verificationCode, - Map? passthrough, - int? reqId, - }) : super( - msgType: 'new_account_virtual', - passthrough: passthrough, - reqId: reqId, - ); + super.msgType = 'new_account_virtual', + super.passthrough, + super.reqId, + }); /// Creates an instance from JSON. factory NewAccountVirtualRequest.fromJson(Map json) => diff --git a/lib/basic_api/generated/new_account_wallet_receive.dart b/lib/basic_api/generated/new_account_wallet_receive.dart index 1e85f91e99..2bc0d8a35d 100644 --- a/lib/basic_api/generated/new_account_wallet_receive.dart +++ b/lib/basic_api/generated/new_account_wallet_receive.dart @@ -9,16 +9,11 @@ class NewAccountWalletReceive extends Response { /// Initialize NewAccountWalletReceive. const NewAccountWalletReceive({ this.newAccountWallet, - Map? echoReq, - Map? error, - String? msgType, - int? reqId, - }) : super( - echoReq: echoReq, - error: error, - msgType: msgType, - reqId: reqId, - ); + super.echoReq, + super.error, + super.msgType, + super.reqId, + }); /// Creates an instance from JSON. factory NewAccountWalletReceive.fromJson(Map json) => diff --git a/lib/basic_api/generated/new_account_wallet_send.dart b/lib/basic_api/generated/new_account_wallet_send.dart index c900792269..d252ab36cb 100644 --- a/lib/basic_api/generated/new_account_wallet_send.dart +++ b/lib/basic_api/generated/new_account_wallet_send.dart @@ -8,49 +8,75 @@ import '../request.dart'; class NewAccountWalletRequest extends Request { /// Initialize NewAccountWalletRequest. const NewAccountWalletRequest({ + this.acceptRisk, + this.accountOpeningReason, + required this.accountType, this.addressCity, this.addressLine1, this.addressLine2, this.addressPostcode, this.addressState, + this.citizen, + this.clientType, required this.currency, this.dateOfBirth, + this.financialAssessment, this.firstName, + this.landingCompanyShort, this.lastName, this.newAccountWallet = true, this.nonPepDeclaration, - required this.paymentMethod, this.phone, - Map? passthrough, - int? reqId, - }) : super( - msgType: 'new_account_wallet', - passthrough: passthrough, - reqId: reqId, - ); + this.salutation, + this.taxIdentificationNumber, + this.taxResidence, + super.msgType = 'new_account_wallet', + super.passthrough, + super.reqId, + }); /// Creates an instance from JSON. factory NewAccountWalletRequest.fromJson(Map json) => NewAccountWalletRequest( + acceptRisk: + json['accept_risk'] == null ? null : json['accept_risk'] == 1, + accountOpeningReason: json['account_opening_reason'] as String?, + accountType: json['account_type'] as String?, addressCity: json['address_city'] as String?, addressLine1: json['address_line_1'] as String?, addressLine2: json['address_line_2'] as String?, addressPostcode: json['address_postcode'] as String?, addressState: json['address_state'] as String?, + citizen: json['citizen'] as String?, + clientType: json['client_type'] as String?, currency: json['currency'] as String?, dateOfBirth: json['date_of_birth'] as String?, + financialAssessment: + json['financial_assessment'] as Map?, firstName: json['first_name'] as String?, + landingCompanyShort: json['landing_company_short'] as String?, lastName: json['last_name'] as String?, newAccountWallet: json['new_account_wallet'] == null ? null : json['new_account_wallet'] == 1, nonPepDeclaration: json['non_pep_declaration'] as int?, - paymentMethod: json['payment_method'] as String?, phone: json['phone'] as String?, + salutation: json['salutation'] as String?, + taxIdentificationNumber: json['tax_identification_number'] as String?, + taxResidence: json['tax_residence'] as String?, passthrough: json['passthrough'] as Map?, reqId: json['req_id'] as int?, ); + /// Show whether client has accepted risk disclaimer. + final bool? acceptRisk; + + /// [Optional] Purpose and reason for requesting the account opening. + final String? accountOpeningReason; + + /// To set the wallets type - only doughflow and crptyo wallets are allowed for initial phase, other types will be added later + final String? accountType; + /// [Optional] Within 35 characters. final String? addressCity; @@ -66,15 +92,27 @@ class NewAccountWalletRequest extends Request { /// [Optional] Possible value receive from `states_list` call. final String? addressState; + /// [Optional] Country of legal citizenship, 2-letter country code. Possible value receive from `residence_list` call. + final String? citizen; + + /// [Optional] Indicates whether this is for a client requesting an account with professional status. + final String? clientType; + /// To set currency of the account. List of supported currencies can be acquired with `payout_currencies` call. final String? currency; /// [Optional] Date of birth format: `yyyy-mm-dd`. final String? dateOfBirth; + /// Required for maltainvest + final Map? financialAssessment; + /// [Optional] Within 2-50 characters, use only letters, spaces, hyphens, full-stops or apostrophes. final String? firstName; + /// [Optional] Set the landing company of the wallet. Default value is 'svg' if company not provided + final String? landingCompanyShort; + /// [Optional] Within 2-50 characters, use only letters, spaces, hyphens, full-stops or apostrophes. final String? lastName; @@ -84,23 +122,40 @@ class NewAccountWalletRequest extends Request { /// [Optional] Indicates client's self-declaration of not being a PEP/RCA (Politically Exposed Person/Relatives and Close Associates). final int? nonPepDeclaration; - /// To set method which is used to transfer to/from wallet. - final String? paymentMethod; - /// [Optional] Starting with `+` followed by 8-35 digits, allowing hyphens or space. final String? phone; + /// Accept any value in enum list. + final String? salutation; + + /// Tax identification number. Only applicable for real money account. Required for `maltainvest` landing company. + final String? taxIdentificationNumber; + + /// Residence for tax purpose. Comma separated iso country code if multiple jurisdictions. Only applicable for real money account. Required for `maltainvest` landing company. + final String? taxResidence; + /// Converts this instance to JSON @override Map toJson() => { + 'accept_risk': acceptRisk == null + ? null + : acceptRisk! + ? 1 + : 0, + 'account_opening_reason': accountOpeningReason, + 'account_type': accountType, 'address_city': addressCity, 'address_line_1': addressLine1, 'address_line_2': addressLine2, 'address_postcode': addressPostcode, 'address_state': addressState, + 'citizen': citizen, + 'client_type': clientType, 'currency': currency, 'date_of_birth': dateOfBirth, + 'financial_assessment': financialAssessment, 'first_name': firstName, + 'landing_company_short': landingCompanyShort, 'last_name': lastName, 'new_account_wallet': newAccountWallet == null ? null @@ -108,8 +163,10 @@ class NewAccountWalletRequest extends Request { ? 1 : 0, 'non_pep_declaration': nonPepDeclaration, - 'payment_method': paymentMethod, 'phone': phone, + 'salutation': salutation, + 'tax_identification_number': taxIdentificationNumber, + 'tax_residence': taxResidence, 'passthrough': passthrough, 'req_id': reqId, }; @@ -117,36 +174,55 @@ class NewAccountWalletRequest extends Request { /// Creates a copy of instance with given parameters @override NewAccountWalletRequest copyWith({ + bool? acceptRisk, + String? accountOpeningReason, + String? accountType, String? addressCity, String? addressLine1, String? addressLine2, String? addressPostcode, String? addressState, + String? citizen, + String? clientType, String? currency, String? dateOfBirth, + Map? financialAssessment, String? firstName, + String? landingCompanyShort, String? lastName, bool? newAccountWallet, int? nonPepDeclaration, - String? paymentMethod, String? phone, + String? salutation, + String? taxIdentificationNumber, + String? taxResidence, Map? passthrough, int? reqId, }) => NewAccountWalletRequest( + acceptRisk: acceptRisk ?? this.acceptRisk, + accountOpeningReason: accountOpeningReason ?? this.accountOpeningReason, + accountType: accountType ?? this.accountType, addressCity: addressCity ?? this.addressCity, addressLine1: addressLine1 ?? this.addressLine1, addressLine2: addressLine2 ?? this.addressLine2, addressPostcode: addressPostcode ?? this.addressPostcode, addressState: addressState ?? this.addressState, + citizen: citizen ?? this.citizen, + clientType: clientType ?? this.clientType, currency: currency ?? this.currency, dateOfBirth: dateOfBirth ?? this.dateOfBirth, + financialAssessment: financialAssessment ?? this.financialAssessment, firstName: firstName ?? this.firstName, + landingCompanyShort: landingCompanyShort ?? this.landingCompanyShort, lastName: lastName ?? this.lastName, newAccountWallet: newAccountWallet ?? this.newAccountWallet, nonPepDeclaration: nonPepDeclaration ?? this.nonPepDeclaration, - paymentMethod: paymentMethod ?? this.paymentMethod, phone: phone ?? this.phone, + salutation: salutation ?? this.salutation, + taxIdentificationNumber: + taxIdentificationNumber ?? this.taxIdentificationNumber, + taxResidence: taxResidence ?? this.taxResidence, passthrough: passthrough ?? this.passthrough, reqId: reqId ?? this.reqId, ); diff --git a/lib/basic_api/generated/p2p_advert_create_send.dart b/lib/basic_api/generated/p2p_advert_create_send.dart index 09ad0891d8..e3a405655c 100644 --- a/lib/basic_api/generated/p2p_advert_create_send.dart +++ b/lib/basic_api/generated/p2p_advert_create_send.dart @@ -9,11 +9,13 @@ class P2pAdvertCreateRequest extends Request { /// Initialize P2pAdvertCreateRequest. const P2pAdvertCreateRequest({ required this.amount, + this.blockTrade, this.contactInfo, this.description, this.localCurrency, required this.maxOrderAmount, required this.minOrderAmount, + this.orderExpiryPeriod, this.p2pAdvertCreate = true, this.paymentInfo, this.paymentMethod, @@ -22,23 +24,23 @@ class P2pAdvertCreateRequest extends Request { required this.rate, required this.rateType, required this.type, - Map? passthrough, - int? reqId, - }) : super( - msgType: 'p2p_advert_create', - passthrough: passthrough, - reqId: reqId, - ); + super.msgType = 'p2p_advert_create', + super.passthrough, + super.reqId, + }); /// Creates an instance from JSON. factory P2pAdvertCreateRequest.fromJson(Map json) => P2pAdvertCreateRequest( amount: json['amount'] as num?, + blockTrade: + json['block_trade'] == null ? null : json['block_trade'] == 1, contactInfo: json['contact_info'] as String?, description: json['description'] as String?, localCurrency: json['local_currency'] as String?, maxOrderAmount: json['max_order_amount'] as num?, minOrderAmount: json['min_order_amount'] as num?, + orderExpiryPeriod: json['order_expiry_period'] as int?, p2pAdvertCreate: json['p2p_advert_create'] == null ? null : json['p2p_advert_create'] == 1, @@ -60,6 +62,9 @@ class P2pAdvertCreateRequest extends Request { /// The total amount of the advert, in advertiser's account currency. final num? amount; + /// [Optional] Indicates if this is block trade ad or not. Default: `false`. + final bool? blockTrade; + /// [Optional] Advertiser contact information. final String? contactInfo; @@ -75,6 +80,9 @@ class P2pAdvertCreateRequest extends Request { /// Minimum allowed amount for the orders of this advert, in advertiser's `account_currency`. Should be less than or equal to `max_order_amount`. final num? minOrderAmount; + /// [Optional] Expiry period (seconds) for order created against this ad. + final int? orderExpiryPeriod; + /// Must be `true` final bool? p2pAdvertCreate; @@ -103,11 +111,17 @@ class P2pAdvertCreateRequest extends Request { @override Map toJson() => { 'amount': amount, + 'block_trade': blockTrade == null + ? null + : blockTrade! + ? 1 + : 0, 'contact_info': contactInfo, 'description': description, 'local_currency': localCurrency, 'max_order_amount': maxOrderAmount, 'min_order_amount': minOrderAmount, + 'order_expiry_period': orderExpiryPeriod, 'p2p_advert_create': p2pAdvertCreate == null ? null : p2pAdvertCreate! @@ -128,11 +142,13 @@ class P2pAdvertCreateRequest extends Request { @override P2pAdvertCreateRequest copyWith({ num? amount, + bool? blockTrade, String? contactInfo, String? description, String? localCurrency, num? maxOrderAmount, num? minOrderAmount, + int? orderExpiryPeriod, bool? p2pAdvertCreate, String? paymentInfo, String? paymentMethod, @@ -146,11 +162,13 @@ class P2pAdvertCreateRequest extends Request { }) => P2pAdvertCreateRequest( amount: amount ?? this.amount, + blockTrade: blockTrade ?? this.blockTrade, contactInfo: contactInfo ?? this.contactInfo, description: description ?? this.description, localCurrency: localCurrency ?? this.localCurrency, maxOrderAmount: maxOrderAmount ?? this.maxOrderAmount, minOrderAmount: minOrderAmount ?? this.minOrderAmount, + orderExpiryPeriod: orderExpiryPeriod ?? this.orderExpiryPeriod, p2pAdvertCreate: p2pAdvertCreate ?? this.p2pAdvertCreate, paymentInfo: paymentInfo ?? this.paymentInfo, paymentMethod: paymentMethod ?? this.paymentMethod, diff --git a/lib/basic_api/generated/p2p_advert_update_send.dart b/lib/basic_api/generated/p2p_advert_update_send.dart index 79859f96d5..586a0f2c91 100644 --- a/lib/basic_api/generated/p2p_advert_update_send.dart +++ b/lib/basic_api/generated/p2p_advert_update_send.dart @@ -16,6 +16,7 @@ class P2pAdvertUpdateRequest extends Request { this.localCurrency, this.maxOrderAmount, this.minOrderAmount, + this.orderExpiryPeriod, this.p2pAdvertUpdate = true, this.paymentInfo, this.paymentMethodIds, @@ -23,13 +24,10 @@ class P2pAdvertUpdateRequest extends Request { this.rate, this.rateType, this.remainingAmount, - Map? passthrough, - int? reqId, - }) : super( - msgType: 'p2p_advert_update', - passthrough: passthrough, - reqId: reqId, - ); + super.msgType = 'p2p_advert_update', + super.passthrough, + super.reqId, + }); /// Creates an instance from JSON. factory P2pAdvertUpdateRequest.fromJson(Map json) => @@ -42,6 +40,7 @@ class P2pAdvertUpdateRequest extends Request { localCurrency: json['local_currency'] as String?, maxOrderAmount: json['max_order_amount'] as num?, minOrderAmount: json['min_order_amount'] as num?, + orderExpiryPeriod: json['order_expiry_period'] as int?, p2pAdvertUpdate: json['p2p_advert_update'] == null ? null : json['p2p_advert_update'] == 1, @@ -83,6 +82,9 @@ class P2pAdvertUpdateRequest extends Request { /// [Optional] Minimum allowed amount for the orders of this advert, in advertiser's `account_currency`. Should be less than or equal to `max_order_amount`. final num? minOrderAmount; + /// [Optional] Expiry period (seconds) for order created against this ad. + final int? orderExpiryPeriod; + /// Must be `true` final bool? p2pAdvertUpdate; @@ -123,6 +125,7 @@ class P2pAdvertUpdateRequest extends Request { 'local_currency': localCurrency, 'max_order_amount': maxOrderAmount, 'min_order_amount': minOrderAmount, + 'order_expiry_period': orderExpiryPeriod, 'p2p_advert_update': p2pAdvertUpdate == null ? null : p2pAdvertUpdate! @@ -149,6 +152,7 @@ class P2pAdvertUpdateRequest extends Request { String? localCurrency, num? maxOrderAmount, num? minOrderAmount, + int? orderExpiryPeriod, bool? p2pAdvertUpdate, String? paymentInfo, List? paymentMethodIds, @@ -168,6 +172,7 @@ class P2pAdvertUpdateRequest extends Request { localCurrency: localCurrency ?? this.localCurrency, maxOrderAmount: maxOrderAmount ?? this.maxOrderAmount, minOrderAmount: minOrderAmount ?? this.minOrderAmount, + orderExpiryPeriod: orderExpiryPeriod ?? this.orderExpiryPeriod, p2pAdvertUpdate: p2pAdvertUpdate ?? this.p2pAdvertUpdate, paymentInfo: paymentInfo ?? this.paymentInfo, paymentMethodIds: paymentMethodIds ?? this.paymentMethodIds, diff --git a/lib/basic_api/generated/p2p_order_list_send.dart b/lib/basic_api/generated/p2p_order_list_send.dart index 8dee4a71b1..b340480493 100644 --- a/lib/basic_api/generated/p2p_order_list_send.dart +++ b/lib/basic_api/generated/p2p_order_list_send.dart @@ -10,23 +10,24 @@ class P2pOrderListRequest extends Request { const P2pOrderListRequest({ this.active, this.advertId, + this.dateFrom, + this.dateTo, this.limit, this.offset, this.p2pOrderList = true, this.subscribe, - Map? passthrough, - int? reqId, - }) : super( - msgType: 'p2p_order_list', - passthrough: passthrough, - reqId: reqId, - ); + super.msgType = 'p2p_order_list', + super.passthrough, + super.reqId, + }); /// Creates an instance from JSON. factory P2pOrderListRequest.fromJson(Map json) => P2pOrderListRequest( active: json['active'] as num?, advertId: json['advert_id'] as String?, + dateFrom: json['date_from'] as String?, + dateTo: json['date_to'] as String?, limit: json['limit'] as int?, offset: json['offset'] as int?, p2pOrderList: @@ -42,6 +43,12 @@ class P2pOrderListRequest extends Request { /// [Optional] If present, lists orders applying to a specific advert. final String? advertId; + /// [Optional] Filter the orders created after this date(included) format(epoch or YYYY-MM-DD) + final String? dateFrom; + + /// [Optional] Filter the orders created before this date(included) format(epoch or YYYY-MM-DD) + final String? dateTo; + /// [Optional] Used for paging. final int? limit; @@ -59,6 +66,8 @@ class P2pOrderListRequest extends Request { Map toJson() => { 'active': active, 'advert_id': advertId, + 'date_from': dateFrom, + 'date_to': dateTo, 'limit': limit, 'offset': offset, 'p2p_order_list': p2pOrderList == null @@ -80,6 +89,8 @@ class P2pOrderListRequest extends Request { P2pOrderListRequest copyWith({ num? active, String? advertId, + String? dateFrom, + String? dateTo, int? limit, int? offset, bool? p2pOrderList, @@ -90,6 +101,8 @@ class P2pOrderListRequest extends Request { P2pOrderListRequest( active: active ?? this.active, advertId: advertId ?? this.advertId, + dateFrom: dateFrom ?? this.dateFrom, + dateTo: dateTo ?? this.dateTo, limit: limit ?? this.limit, offset: offset ?? this.offset, p2pOrderList: p2pOrderList ?? this.p2pOrderList, diff --git a/lib/basic_api/generated/profit_table_send.dart b/lib/basic_api/generated/profit_table_send.dart index fca57bf712..320c128fde 100644 --- a/lib/basic_api/generated/profit_table_send.dart +++ b/lib/basic_api/generated/profit_table_send.dart @@ -16,13 +16,10 @@ class ProfitTableRequest extends Request { this.offset, this.profitTable = true, this.sort, - Map? passthrough, - int? reqId, - }) : super( - msgType: 'profit_table', - passthrough: passthrough, - reqId: reqId, - ); + super.msgType = 'profit_table', + super.passthrough, + super.reqId, + }); /// Creates an instance from JSON. factory ProfitTableRequest.fromJson(Map json) => @@ -35,7 +32,7 @@ class ProfitTableRequest extends Request { description: json['description'] == null ? null : json['description'] == 1, limit: json['limit'] as num?, - offset: json['offset'] as num?, + offset: json['offset'] as int?, profitTable: json['profit_table'] == null ? null : json['profit_table'] == 1, sort: json['sort'] as String?, @@ -59,7 +56,7 @@ class ProfitTableRequest extends Request { final num? limit; /// [Optional] Number of transactions to skip. - final num? offset; + final int? offset; /// Must be `true` final bool? profitTable; @@ -98,7 +95,7 @@ class ProfitTableRequest extends Request { String? dateTo, bool? description, num? limit, - num? offset, + int? offset, bool? profitTable, String? sort, Map? passthrough, diff --git a/lib/basic_api/generated/proposal_open_contract_receive.dart b/lib/basic_api/generated/proposal_open_contract_receive.dart index 7f7acba998..8ec54eb880 100644 --- a/lib/basic_api/generated/proposal_open_contract_receive.dart +++ b/lib/basic_api/generated/proposal_open_contract_receive.dart @@ -10,16 +10,11 @@ class ProposalOpenContractReceive extends Response { const ProposalOpenContractReceive({ this.proposalOpenContract, this.subscription, - Map? echoReq, - Map? error, - String? msgType, - int? reqId, - }) : super( - echoReq: echoReq, - error: error, - msgType: msgType, - reqId: reqId, - ); + super.echoReq, + super.error, + super.msgType, + super.reqId, + }); /// Creates an instance from JSON. factory ProposalOpenContractReceive.fromJson(Map json) => diff --git a/lib/basic_api/generated/proposal_open_contract_send.dart b/lib/basic_api/generated/proposal_open_contract_send.dart index 0b38b4afae..e7731bc4fc 100644 --- a/lib/basic_api/generated/proposal_open_contract_send.dart +++ b/lib/basic_api/generated/proposal_open_contract_send.dart @@ -9,20 +9,19 @@ class ProposalOpenContractRequest extends Request { /// Initialize ProposalOpenContractRequest. const ProposalOpenContractRequest({ this.contractId, + this.loginid, this.proposalOpenContract = true, this.subscribe, - Map? passthrough, - int? reqId, - }) : super( - msgType: 'proposal_open_contract', - passthrough: passthrough, - reqId: reqId, - ); + super.msgType = 'proposal_open_contract', + super.passthrough, + super.reqId, + }); /// Creates an instance from JSON. factory ProposalOpenContractRequest.fromJson(Map json) => ProposalOpenContractRequest( contractId: json['contract_id'] as int?, + loginid: json['loginid'] as String?, proposalOpenContract: json['proposal_open_contract'] == null ? null : json['proposal_open_contract'] == 1, @@ -34,6 +33,9 @@ class ProposalOpenContractRequest extends Request { /// [Optional] Contract ID received from a `portfolio` request. If not set, you will receive stream of all open contracts. final int? contractId; + /// [Optional] The login id of the user. If left unspecified, it defaults to the initial authorized token's login id. + final String? loginid; + /// Must be `true` final bool? proposalOpenContract; @@ -44,6 +46,7 @@ class ProposalOpenContractRequest extends Request { @override Map toJson() => { 'contract_id': contractId, + 'loginid': loginid, 'proposal_open_contract': proposalOpenContract == null ? null : proposalOpenContract! @@ -62,6 +65,7 @@ class ProposalOpenContractRequest extends Request { @override ProposalOpenContractRequest copyWith({ int? contractId, + String? loginid, bool? proposalOpenContract, bool? subscribe, Map? passthrough, @@ -69,6 +73,7 @@ class ProposalOpenContractRequest extends Request { }) => ProposalOpenContractRequest( contractId: contractId ?? this.contractId, + loginid: loginid ?? this.loginid, proposalOpenContract: proposalOpenContract ?? this.proposalOpenContract, subscribe: subscribe ?? this.subscribe, passthrough: passthrough ?? this.passthrough, diff --git a/lib/basic_api/generated/proposal_receive.dart b/lib/basic_api/generated/proposal_receive.dart index a7c2bb428c..906279649e 100644 --- a/lib/basic_api/generated/proposal_receive.dart +++ b/lib/basic_api/generated/proposal_receive.dart @@ -10,16 +10,11 @@ class ProposalReceive extends Response { const ProposalReceive({ this.proposal, this.subscription, - Map? echoReq, - Map? error, - String? msgType, - int? reqId, - }) : super( - echoReq: echoReq, - error: error, - msgType: msgType, - reqId: reqId, - ); + super.echoReq, + super.error, + super.msgType, + super.reqId, + }); /// Creates an instance from JSON. factory ProposalReceive.fromJson(Map json) => diff --git a/lib/basic_api/generated/proposal_send.dart b/lib/basic_api/generated/proposal_send.dart index 6d0de27ecb..ce91b2a5e2 100644 --- a/lib/basic_api/generated/proposal_send.dart +++ b/lib/basic_api/generated/proposal_send.dart @@ -22,6 +22,7 @@ class ProposalRequest extends Request { this.durationUnit, this.growthRate, required this.limitOrder, + this.loginid, this.multiplier, this.productType, this.proposal = true, @@ -29,13 +30,10 @@ class ProposalRequest extends Request { this.subscribe, required this.symbol, this.tradingPeriodStart, - Map? passthrough, - int? reqId, - }) : super( - msgType: 'proposal', - passthrough: passthrough, - reqId: reqId, - ); + super.msgType = 'proposal', + super.passthrough, + super.reqId, + }); /// Creates an instance from JSON. factory ProposalRequest.fromJson(Map json) => @@ -54,6 +52,7 @@ class ProposalRequest extends Request { durationUnit: json['duration_unit'] as String?, growthRate: json['growth_rate'] as num?, limitOrder: json['limit_order'] as Map?, + loginid: json['loginid'] as String?, multiplier: json['multiplier'] as num?, productType: json['product_type'] as String?, proposal: json['proposal'] == null ? null : json['proposal'] == 1, @@ -107,6 +106,9 @@ class ProposalRequest extends Request { /// Add an order to close the contract once the order condition is met (only for `MULTUP` and `MULTDOWN` and 'ACCU' contracts). Supported orders: `take_profit`, `stop_loss`. final Map? limitOrder; + /// [Optional] The login id of the user. If left unspecified, it defaults to the initial authorized token's login id. + final String? loginid; + /// [Optional] The multiplier for non-binary options. E.g. lookbacks. final num? multiplier; @@ -145,6 +147,7 @@ class ProposalRequest extends Request { 'duration_unit': durationUnit, 'growth_rate': growthRate, 'limit_order': limitOrder, + 'loginid': loginid, 'multiplier': multiplier, 'product_type': productType, 'proposal': proposal == null @@ -181,6 +184,7 @@ class ProposalRequest extends Request { String? durationUnit, num? growthRate, Map? limitOrder, + String? loginid, num? multiplier, String? productType, bool? proposal, @@ -206,6 +210,7 @@ class ProposalRequest extends Request { durationUnit: durationUnit ?? this.durationUnit, growthRate: growthRate ?? this.growthRate, limitOrder: limitOrder ?? this.limitOrder, + loginid: loginid ?? this.loginid, multiplier: multiplier ?? this.multiplier, productType: productType ?? this.productType, proposal: proposal ?? this.proposal, diff --git a/lib/basic_api/generated/set_settings_receive.dart b/lib/basic_api/generated/set_settings_receive.dart index 7b939e22c4..4cb252c9ad 100644 --- a/lib/basic_api/generated/set_settings_receive.dart +++ b/lib/basic_api/generated/set_settings_receive.dart @@ -9,16 +9,11 @@ class SetSettingsReceive extends Response { /// Initialize SetSettingsReceive. const SetSettingsReceive({ this.setSettings, - Map? echoReq, - Map? error, - String? msgType, - int? reqId, - }) : super( - echoReq: echoReq, - error: error, - msgType: msgType, - reqId: reqId, - ); + super.echoReq, + super.error, + super.msgType, + super.reqId, + }); /// Creates an instance from JSON. factory SetSettingsReceive.fromJson(Map json) => diff --git a/lib/basic_api/generated/set_settings_send.dart b/lib/basic_api/generated/set_settings_send.dart index 443e116b46..80a8e2fad9 100644 --- a/lib/basic_api/generated/set_settings_send.dart +++ b/lib/basic_api/generated/set_settings_send.dart @@ -17,7 +17,9 @@ class SetSettingsRequest extends Request { this.allowCopiers, this.citizen, this.dateOfBirth, + this.dxtradeUserException, this.emailConsent, + this.employmentStatus, this.featureFlag, this.firstName, this.lastName, @@ -34,13 +36,10 @@ class SetSettingsRequest extends Request { this.taxIdentificationNumber, this.taxResidence, this.tradingHub, - Map? passthrough, - int? reqId, - }) : super( - msgType: 'set_settings', - passthrough: passthrough, - reqId: reqId, - ); + super.msgType = 'set_settings', + super.passthrough, + super.reqId, + }); /// Creates an instance from JSON. factory SetSettingsRequest.fromJson(Map json) => @@ -55,8 +54,12 @@ class SetSettingsRequest extends Request { json['allow_copiers'] == null ? null : json['allow_copiers'] == 1, citizen: json['citizen'] as String?, dateOfBirth: json['date_of_birth'] as String?, + dxtradeUserException: json['dxtrade_user_exception'] == null + ? null + : json['dxtrade_user_exception'] == 1, emailConsent: json['email_consent'] == null ? null : json['email_consent'] == 1, + employmentStatus: json['employment_status'] as String?, featureFlag: json['feature_flag'] as Map?, firstName: json['first_name'] as String?, lastName: json['last_name'] as String?, @@ -106,9 +109,15 @@ class SetSettingsRequest extends Request { /// [Optional] Date of birth format: yyyy-mm-dd (can only be changed on unauthenticated svg accounts). final String? dateOfBirth; + /// Boolean value `true` or `false`, indicating if user email belong to dxtrade exception list. + final bool? dxtradeUserException; + /// [Optional] Boolean value `true` or `false`, indicating permission to use email address for any contact which may include marketing final bool? emailConsent; + /// [Optional] Employment Status. + final String? employmentStatus; + /// [Optional] Enable or disable one or multiple features. final Map? featureFlag; @@ -173,11 +182,17 @@ class SetSettingsRequest extends Request { : 0, 'citizen': citizen, 'date_of_birth': dateOfBirth, + 'dxtrade_user_exception': dxtradeUserException == null + ? null + : dxtradeUserException! + ? 1 + : 0, 'email_consent': emailConsent == null ? null : emailConsent! ? 1 : 0, + 'employment_status': employmentStatus, 'feature_flag': featureFlag, 'first_name': firstName, 'last_name': lastName, @@ -218,7 +233,9 @@ class SetSettingsRequest extends Request { bool? allowCopiers, String? citizen, String? dateOfBirth, + bool? dxtradeUserException, bool? emailConsent, + String? employmentStatus, Map? featureFlag, String? firstName, String? lastName, @@ -248,7 +265,9 @@ class SetSettingsRequest extends Request { allowCopiers: allowCopiers ?? this.allowCopiers, citizen: citizen ?? this.citizen, dateOfBirth: dateOfBirth ?? this.dateOfBirth, + dxtradeUserException: dxtradeUserException ?? this.dxtradeUserException, emailConsent: emailConsent ?? this.emailConsent, + employmentStatus: employmentStatus ?? this.employmentStatus, featureFlag: featureFlag ?? this.featureFlag, firstName: firstName ?? this.firstName, lastName: lastName ?? this.lastName, diff --git a/lib/basic_api/generated/statement_receive.dart b/lib/basic_api/generated/statement_receive.dart index 27cc65f1ea..6dffaab987 100644 --- a/lib/basic_api/generated/statement_receive.dart +++ b/lib/basic_api/generated/statement_receive.dart @@ -9,16 +9,11 @@ class StatementReceive extends Response { /// Initialize StatementReceive. const StatementReceive({ this.statement, - Map? echoReq, - Map? error, - String? msgType, - int? reqId, - }) : super( - echoReq: echoReq, - error: error, - msgType: msgType, - reqId: reqId, - ); + super.echoReq, + super.error, + super.msgType, + super.reqId, + }); /// Creates an instance from JSON. factory StatementReceive.fromJson(Map json) => diff --git a/lib/basic_api/generated/statement_send.dart b/lib/basic_api/generated/statement_send.dart index c721380ae6..55b84bbef6 100644 --- a/lib/basic_api/generated/statement_send.dart +++ b/lib/basic_api/generated/statement_send.dart @@ -15,13 +15,10 @@ class StatementRequest extends Request { this.limit, this.offset, this.statement = true, - Map? passthrough, - int? reqId, - }) : super( - msgType: 'statement', - passthrough: passthrough, - reqId: reqId, - ); + super.msgType = 'statement', + super.passthrough, + super.reqId, + }); /// Creates an instance from JSON. factory StatementRequest.fromJson(Map json) => @@ -32,7 +29,7 @@ class StatementRequest extends Request { description: json['description'] == null ? null : json['description'] == 1, limit: json['limit'] as num?, - offset: json['offset'] as num?, + offset: json['offset'] as int?, statement: json['statement'] == null ? null : json['statement'] == 1, passthrough: json['passthrough'] as Map?, reqId: json['req_id'] as int?, @@ -54,7 +51,7 @@ class StatementRequest extends Request { final num? limit; /// [Optional] Number of transactions to skip. - final num? offset; + final int? offset; /// Must be `true` final bool? statement; @@ -89,7 +86,7 @@ class StatementRequest extends Request { int? dateTo, bool? description, num? limit, - num? offset, + int? offset, bool? statement, Map? passthrough, int? reqId, diff --git a/lib/basic_api/generated/trading_durations_receive.dart b/lib/basic_api/generated/trading_durations_receive.dart index 68ce77835d..eed0afb069 100644 --- a/lib/basic_api/generated/trading_durations_receive.dart +++ b/lib/basic_api/generated/trading_durations_receive.dart @@ -9,16 +9,11 @@ class TradingDurationsReceive extends Response { /// Initialize TradingDurationsReceive. const TradingDurationsReceive({ this.tradingDurations, - Map? echoReq, - Map? error, - String? msgType, - int? reqId, - }) : super( - echoReq: echoReq, - error: error, - msgType: msgType, - reqId: reqId, - ); + super.echoReq, + super.error, + super.msgType, + super.reqId, + }); /// Creates an instance from JSON. factory TradingDurationsReceive.fromJson(Map json) => diff --git a/lib/basic_api/generated/trading_durations_send.dart b/lib/basic_api/generated/trading_durations_send.dart index bd9d6d5fb3..2d6fe41186 100644 --- a/lib/basic_api/generated/trading_durations_send.dart +++ b/lib/basic_api/generated/trading_durations_send.dart @@ -8,20 +8,19 @@ import '../request.dart'; class TradingDurationsRequest extends Request { /// Initialize TradingDurationsRequest. const TradingDurationsRequest({ - this.landingCompany, + required this.landingCompany, + this.landingCompanyShort, this.tradingDurations = true, - Map? passthrough, - int? reqId, - }) : super( - msgType: 'trading_durations', - passthrough: passthrough, - reqId: reqId, - ); + super.msgType = 'trading_durations', + super.passthrough, + super.reqId, + }); /// Creates an instance from JSON. factory TradingDurationsRequest.fromJson(Map json) => TradingDurationsRequest( landingCompany: json['landing_company'] as String?, + landingCompanyShort: json['landing_company_short'] as String?, tradingDurations: json['trading_durations'] == null ? null : json['trading_durations'] == 1, @@ -29,9 +28,12 @@ class TradingDurationsRequest extends Request { reqId: json['req_id'] as int?, ); - /// [Optional] If specified, will return only the underlyings for the specified landing company. + /// Deprecated - Replaced by landing_company_short. final String? landingCompany; + /// [Optional] If specified, will return only the underlyings for the specified landing company. + final String? landingCompanyShort; + /// Must be `true` final bool? tradingDurations; @@ -39,6 +41,7 @@ class TradingDurationsRequest extends Request { @override Map toJson() => { 'landing_company': landingCompany, + 'landing_company_short': landingCompanyShort, 'trading_durations': tradingDurations == null ? null : tradingDurations! @@ -52,12 +55,14 @@ class TradingDurationsRequest extends Request { @override TradingDurationsRequest copyWith({ String? landingCompany, + String? landingCompanyShort, bool? tradingDurations, Map? passthrough, int? reqId, }) => TradingDurationsRequest( landingCompany: landingCompany ?? this.landingCompany, + landingCompanyShort: landingCompanyShort ?? this.landingCompanyShort, tradingDurations: tradingDurations ?? this.tradingDurations, passthrough: passthrough ?? this.passthrough, reqId: reqId ?? this.reqId, diff --git a/lib/basic_api/generated/trading_platform_asset_listing_receive.dart b/lib/basic_api/generated/trading_platform_asset_listing_receive.dart new file mode 100644 index 0000000000..281a61aacb --- /dev/null +++ b/lib/basic_api/generated/trading_platform_asset_listing_receive.dart @@ -0,0 +1,72 @@ +/// Generated automatically from flutter_deriv_api|lib/basic_api/generated/trading_platform_asset_listing_receive.json. + +// ignore_for_file: always_put_required_named_parameters_first + +import '../response.dart'; + +/// Trading platform asset listing receive class. +class TradingPlatformAssetListingReceive extends Response { + /// Initialize TradingPlatformAssetListingReceive. + const TradingPlatformAssetListingReceive({ + this.subscription, + this.tradingPlatformAssetListing, + super.echoReq, + super.error, + super.msgType, + super.reqId, + }); + + /// Creates an instance from JSON. + factory TradingPlatformAssetListingReceive.fromJson( + Map json) => + TradingPlatformAssetListingReceive( + subscription: json['subscription'] as Map?, + tradingPlatformAssetListing: + json['trading_platform_asset_listing'] as Map?, + echoReq: json['echo_req'] as Map?, + error: json['error'] as Map?, + msgType: json['msg_type'] as String?, + reqId: json['req_id'] as int?, + ); + + /// For subscription requests only. + final Map? subscription; + + /// Containing Trading asset objects. + final Map? tradingPlatformAssetListing; + + /// Converts this instance to JSON + @override + Map toJson() => { + 'subscription': subscription, + 'trading_platform_asset_listing': tradingPlatformAssetListing, + 'echo_req': echoReq, + 'error': error, + 'msg_type': msgType, + 'req_id': reqId, + }; + + /// Creates a copy of instance with given parameters + @override + TradingPlatformAssetListingReceive copyWith({ + Map? subscription, + Map? tradingPlatformAssetListing, + Map? echoReq, + Map? error, + String? msgType, + int? reqId, + }) => + TradingPlatformAssetListingReceive( + subscription: subscription ?? this.subscription, + tradingPlatformAssetListing: + tradingPlatformAssetListing ?? this.tradingPlatformAssetListing, + echoReq: echoReq ?? this.echoReq, + error: error ?? this.error, + msgType: msgType ?? this.msgType, + reqId: reqId ?? this.reqId, + ); + + /// Override equatable class. + @override + List get props => []; +} diff --git a/lib/basic_api/generated/trading_platform_asset_listing_send.dart b/lib/basic_api/generated/trading_platform_asset_listing_send.dart new file mode 100644 index 0000000000..36d781b2b8 --- /dev/null +++ b/lib/basic_api/generated/trading_platform_asset_listing_send.dart @@ -0,0 +1,97 @@ +/// Generated automatically from flutter_deriv_api|lib/basic_api/generated/trading_platform_asset_listing_send.json. + +// ignore_for_file: always_put_required_named_parameters_first + +import '../request.dart'; + +/// Trading platform asset listing request class. +class TradingPlatformAssetListingRequest extends Request { + /// Initialize TradingPlatformAssetListingRequest. + const TradingPlatformAssetListingRequest({ + required this.platform, + required this.region, + this.subscribe, + this.tradingPlatformAssetListing = true, + required this.type, + super.msgType = 'trading_platform_asset_listing', + super.passthrough, + super.reqId, + }); + + /// Creates an instance from JSON. + factory TradingPlatformAssetListingRequest.fromJson( + Map json) => + TradingPlatformAssetListingRequest( + platform: json['platform'] as String?, + region: json['region'] as String?, + subscribe: json['subscribe'] == null ? null : json['subscribe'] == 1, + tradingPlatformAssetListing: + json['trading_platform_asset_listing'] == null + ? null + : json['trading_platform_asset_listing'] == 1, + type: json['type'] as String?, + passthrough: json['passthrough'] as Map?, + reqId: json['req_id'] as int?, + ); + + /// Trading platform name + final String? platform; + + /// Region be either 'eu' or 'row'. + final String? region; + + /// [Optional] If set to `true`, will send updates whenever asset listing is updated. + final bool? subscribe; + + /// Must be `true` + final bool? tradingPlatformAssetListing; + + /// Can be either 'brief' or 'full'. + final String? type; + + /// Converts this instance to JSON + @override + Map toJson() => { + 'platform': platform, + 'region': region, + 'subscribe': subscribe == null + ? null + : subscribe! + ? 1 + : 0, + 'trading_platform_asset_listing': tradingPlatformAssetListing == null + ? null + : tradingPlatformAssetListing! + ? 1 + : 0, + 'type': type, + 'passthrough': passthrough, + 'req_id': reqId, + }; + + /// Creates a copy of instance with given parameters + @override + TradingPlatformAssetListingRequest copyWith({ + String? platform, + String? region, + bool? subscribe, + bool? tradingPlatformAssetListing, + String? type, + Map? passthrough, + int? reqId, + }) => + TradingPlatformAssetListingRequest( + platform: platform ?? this.platform, + region: region ?? this.region, + subscribe: subscribe ?? this.subscribe, + tradingPlatformAssetListing: + tradingPlatformAssetListing ?? this.tradingPlatformAssetListing, + type: type ?? this.type, + passthrough: passthrough ?? this.passthrough, + reqId: reqId ?? this.reqId, + ); + + /// Override equatable class. + @override + List get props => []; +} diff --git a/lib/basic_api/generated/trading_platform_investor_password_change_send.dart b/lib/basic_api/generated/trading_platform_investor_password_change_send.dart index a3c650ac02..758f7349ab 100644 --- a/lib/basic_api/generated/trading_platform_investor_password_change_send.dart +++ b/lib/basic_api/generated/trading_platform_investor_password_change_send.dart @@ -13,13 +13,10 @@ class TradingPlatformInvestorPasswordChangeRequest extends Request { required this.oldPassword, required this.platform, this.tradingPlatformInvestorPasswordChange = true, - Map? passthrough, - int? reqId, - }) : super( - msgType: 'trading_platform_investor_password_change', - passthrough: passthrough, - reqId: reqId, - ); + super.msgType = 'trading_platform_investor_password_change', + super.passthrough, + super.reqId, + }); /// Creates an instance from JSON. factory TradingPlatformInvestorPasswordChangeRequest.fromJson( diff --git a/lib/basic_api/generated/trading_platform_new_account_receive.dart b/lib/basic_api/generated/trading_platform_new_account_receive.dart index a4b0ebd1d6..3748c05479 100644 --- a/lib/basic_api/generated/trading_platform_new_account_receive.dart +++ b/lib/basic_api/generated/trading_platform_new_account_receive.dart @@ -9,16 +9,11 @@ class TradingPlatformNewAccountReceive extends Response { /// Initialize TradingPlatformNewAccountReceive. const TradingPlatformNewAccountReceive({ this.tradingPlatformNewAccount, - Map? echoReq, - Map? error, - String? msgType, - int? reqId, - }) : super( - echoReq: echoReq, - error: error, - msgType: msgType, - reqId: reqId, - ); + super.echoReq, + super.error, + super.msgType, + super.reqId, + }); /// Creates an instance from JSON. factory TradingPlatformNewAccountReceive.fromJson( diff --git a/lib/basic_api/generated/trading_platform_new_account_send.dart b/lib/basic_api/generated/trading_platform_new_account_send.dart index 26159a3750..bdd7904c45 100644 --- a/lib/basic_api/generated/trading_platform_new_account_send.dart +++ b/lib/basic_api/generated/trading_platform_new_account_send.dart @@ -17,13 +17,10 @@ class TradingPlatformNewAccountRequest extends Request { required this.platform, this.subAccountType, this.tradingPlatformNewAccount = true, - Map? passthrough, - int? reqId, - }) : super( - msgType: 'trading_platform_new_account', - passthrough: passthrough, - reqId: reqId, - ); + super.msgType = 'trading_platform_new_account', + super.passthrough, + super.reqId, + }); /// Creates an instance from JSON. factory TradingPlatformNewAccountRequest.fromJson( @@ -59,7 +56,7 @@ class TradingPlatformNewAccountRequest extends Request { /// Market type final String? marketType; - /// The master password of the account. For validation (Accepts any printable ASCII character. Must be within 8-25 characters, and include numbers, lowercase and uppercase letters. Must not be the same as the user's email address). This field is required. + /// The master password of the account. For validation (Accepts any printable ASCII character. Must be within 8-25 characters, and include numbers, lowercase and uppercase letters. Must not be the same as the user's email address). Only for DXTrade. final String? password; /// Name of trading platform. diff --git a/lib/basic_api/generated/wallet_migration_receive.dart b/lib/basic_api/generated/wallet_migration_receive.dart new file mode 100644 index 0000000000..7f088e5999 --- /dev/null +++ b/lib/basic_api/generated/wallet_migration_receive.dart @@ -0,0 +1,61 @@ +/// Generated automatically from flutter_deriv_api|lib/basic_api/generated/wallet_migration_receive.json. + +// ignore_for_file: always_put_required_named_parameters_first + +import '../response.dart'; + +/// Wallet migration receive class. +class WalletMigrationReceive extends Response { + /// Initialize WalletMigrationReceive. + const WalletMigrationReceive({ + this.walletMigration, + super.echoReq, + super.error, + super.msgType, + super.reqId, + }); + + /// Creates an instance from JSON. + factory WalletMigrationReceive.fromJson(Map json) => + WalletMigrationReceive( + walletMigration: json['wallet_migration'] as Map?, + echoReq: json['echo_req'] as Map?, + error: json['error'] as Map?, + msgType: json['msg_type'] as String?, + reqId: json['req_id'] as int?, + ); + + /// The information regarding wallet migration state + final Map? walletMigration; + + /// Converts this instance to JSON + @override + Map toJson() => { + 'wallet_migration': walletMigration, + 'echo_req': echoReq, + 'error': error, + 'msg_type': msgType, + 'req_id': reqId, + }; + + /// Creates a copy of instance with given parameters + @override + WalletMigrationReceive copyWith({ + Map? walletMigration, + Map? echoReq, + Map? error, + String? msgType, + int? reqId, + }) => + WalletMigrationReceive( + walletMigration: walletMigration ?? this.walletMigration, + echoReq: echoReq ?? this.echoReq, + error: error ?? this.error, + msgType: msgType ?? this.msgType, + reqId: reqId ?? this.reqId, + ); + + /// Override equatable class. + @override + List get props => []; +} diff --git a/lib/basic_api/generated/wallet_migration_send.dart b/lib/basic_api/generated/wallet_migration_send.dart new file mode 100644 index 0000000000..4216d2b22f --- /dev/null +++ b/lib/basic_api/generated/wallet_migration_send.dart @@ -0,0 +1,52 @@ +/// Generated automatically from flutter_deriv_api|lib/basic_api/generated/wallet_migration_send.json. + +// ignore_for_file: always_put_required_named_parameters_first + +import '../request.dart'; + +/// Wallet migration request class. +class WalletMigrationRequest extends Request { + /// Initialize WalletMigrationRequest. + const WalletMigrationRequest({ + required this.walletMigration, + super.msgType = 'wallet_migration', + super.passthrough, + super.reqId, + }); + + /// Creates an instance from JSON. + factory WalletMigrationRequest.fromJson(Map json) => + WalletMigrationRequest( + walletMigration: json['wallet_migration'] as String?, + passthrough: json['passthrough'] as Map?, + reqId: json['req_id'] as int?, + ); + + /// Wallet migration action. + final String? walletMigration; + + /// Converts this instance to JSON + @override + Map toJson() => { + 'wallet_migration': walletMigration, + 'passthrough': passthrough, + 'req_id': reqId, + }; + + /// Creates a copy of instance with given parameters + @override + WalletMigrationRequest copyWith({ + String? walletMigration, + Map? passthrough, + int? reqId, + }) => + WalletMigrationRequest( + walletMigration: walletMigration ?? this.walletMigration, + passthrough: passthrough ?? this.passthrough, + reqId: reqId ?? this.reqId, + ); + + /// Override equatable class. + @override + List get props => []; +} diff --git a/lib/basic_api/helper/response_mapper.helper.dart b/lib/basic_api/helper/response_mapper.helper.dart index 956431bc53..75e71d1dc3 100644 --- a/lib/basic_api/helper/response_mapper.helper.dart +++ b/lib/basic_api/helper/response_mapper.helper.dart @@ -7,7 +7,6 @@ import '../generated/account_closure_receive.dart'; import '../generated/account_security_receive.dart'; import '../generated/account_statistics_receive.dart'; import '../generated/active_symbols_receive.dart'; -import '../generated/affiliate_account_add_receive.dart'; import '../generated/api_token_receive.dart'; import '../generated/app_delete_receive.dart'; import '../generated/app_get_receive.dart'; @@ -18,6 +17,7 @@ import '../generated/app_register_receive.dart'; import '../generated/app_update_receive.dart'; import '../generated/asset_index_receive.dart'; import '../generated/authorize_receive.dart'; +import '../generated/available_accounts_receive.dart'; import '../generated/balance_receive.dart'; import '../generated/buy_contract_for_multiple_accounts_receive.dart'; import '../generated/buy_receive.dart'; @@ -42,7 +42,6 @@ import '../generated/forget_all_receive.dart'; import '../generated/forget_receive.dart'; import '../generated/get_account_status_receive.dart'; import '../generated/get_account_types_receive.dart'; -import '../generated/get_available_accounts_to_transfer_receive.dart'; import '../generated/get_financial_assessment_receive.dart'; import '../generated/get_limits_receive.dart'; import '../generated/get_self_exclusion_receive.dart'; @@ -122,6 +121,7 @@ import '../generated/tnc_approval_receive.dart'; import '../generated/topup_virtual_receive.dart'; import '../generated/trading_durations_receive.dart'; import '../generated/trading_platform_accounts_receive.dart'; +import '../generated/trading_platform_asset_listing_receive.dart'; import '../generated/trading_platform_available_accounts_receive.dart'; import '../generated/trading_platform_deposit_receive.dart'; import '../generated/trading_platform_investor_password_change_receive.dart'; @@ -138,6 +138,7 @@ import '../generated/transfer_between_accounts_receive.dart'; import '../generated/unsubscribe_email_receive.dart'; import '../generated/verify_email_cellxpert_receive.dart'; import '../generated/verify_email_receive.dart'; +import '../generated/wallet_migration_receive.dart'; import '../generated/website_status_receive.dart'; import '../response.dart'; @@ -153,8 +154,6 @@ Response getGeneratedResponse(Map responseMap) { return AccountStatisticsReceive.fromJson(responseMap); case 'active_symbols': return ActiveSymbolsReceive.fromJson(responseMap); - case 'affiliate_account_add': - return AffiliateAccountAddReceive.fromJson(responseMap); case 'api_token': return ApiTokenReceive.fromJson(responseMap); case 'app_delete': @@ -175,6 +174,8 @@ Response getGeneratedResponse(Map responseMap) { return AssetIndexReceive.fromJson(responseMap); case 'authorize': return AuthorizeReceive.fromJson(responseMap); + case 'available_accounts': + return AvailableAccountsReceive.fromJson(responseMap); case 'balance': return BalanceReceive.fromJson(responseMap); case 'buy_contract_for_multiple_accounts': @@ -223,8 +224,6 @@ Response getGeneratedResponse(Map responseMap) { return GetAccountStatusReceive.fromJson(responseMap); case 'get_account_types': return GetAccountTypesReceive.fromJson(responseMap); - case 'get_available_accounts_to_transfer': - return GetAvailableAccountsToTransferReceive.fromJson(responseMap); case 'get_financial_assessment': return GetFinancialAssessmentReceive.fromJson(responseMap); case 'get_limits': @@ -383,6 +382,8 @@ Response getGeneratedResponse(Map responseMap) { return TradingDurationsReceive.fromJson(responseMap); case 'trading_platform_accounts': return TradingPlatformAccountsReceive.fromJson(responseMap); + case 'trading_platform_asset_listing': + return TradingPlatformAssetListingReceive.fromJson(responseMap); case 'trading_platform_available_accounts': return TradingPlatformAvailableAccountsReceive.fromJson(responseMap); case 'trading_platform_deposit': @@ -415,6 +416,8 @@ Response getGeneratedResponse(Map responseMap) { return VerifyEmailCellxpertReceive.fromJson(responseMap); case 'verify_email': return VerifyEmailReceive.fromJson(responseMap); + case 'wallet_migration': + return WalletMigrationReceive.fromJson(responseMap); case 'website_status': return WebsiteStatusReceive.fromJson(responseMap); diff --git a/lib/helpers/miscellaneous_helper.dart b/lib/helpers/miscellaneous_helper.dart index ebf571ab18..73a7c97323 100644 --- a/lib/helpers/miscellaneous_helper.dart +++ b/lib/helpers/miscellaneous_helper.dart @@ -1,12 +1,12 @@ import 'dart:io'; -import 'package:device_info/device_info.dart'; +import 'package:device_info_plus/device_info_plus.dart'; -import 'package:flutter_deriv_api/api/exceptions/api_base_exception.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/basic_api/response.dart'; -import 'package:package_info/package_info.dart'; +import 'package:package_info_plus/package_info_plus.dart'; /// Parses the [url] and gets the endpoint out of it String? parseWebSocketUrl(String? url, {bool isAuthUrl = false}) { @@ -33,7 +33,7 @@ String? parseWebSocketUrl(String? url, {bool isAuthUrl = false}) { /// Checks for existence of error in [response] and throws exception created by [exceptionCreator] void checkException({ Response? response, - APIBaseException Function({BaseExceptionModel? baseExceptionModel})? + BaseAPIException Function({BaseExceptionModel? baseExceptionModel})? exceptionCreator, }) { if (response?.error != null) { diff --git a/lib/services/connection/api_manager/connection_information.dart b/lib/services/connection/api_manager/connection_information.dart index 41820801ec..69a808d69a 100644 --- a/lib/services/connection/api_manager/connection_information.dart +++ b/lib/services/connection/api_manager/connection_information.dart @@ -5,6 +5,7 @@ class ConnectionInformation { required this.appId, required this.brand, required this.endpoint, + required this.authEndpoint, this.language = 'en', }); @@ -17,6 +18,9 @@ class ConnectionInformation { /// API endpoint. final String endpoint; + /// Auth endpoint. + final String authEndpoint; + /// API language. final String language; } diff --git a/lib/services/connection/api_manager/mock_api.dart b/lib/services/connection/api_manager/mock_api.dart index 8f51940748..a18cc41ecd 100644 --- a/lib/services/connection/api_manager/mock_api.dart +++ b/lib/services/connection/api_manager/mock_api.dart @@ -12,6 +12,8 @@ import 'package:flutter_deriv_api/basic_api/response.dart'; import 'package:flutter_deriv_api/services/connection/api_manager/base_api.dart'; import 'package:flutter_deriv_api/services/connection/api_manager/connection_information.dart'; import 'package:flutter_deriv_api/services/connection/api_manager/exceptions/api_manager_exception.dart'; +import 'package:flutter_deriv_api/services/connection/api_manager/mock_data/account/new_account_wallet_response.dart'; +import 'package:flutter_deriv_api/services/connection/api_manager/mock_data/cashier/cashier_payments_response.dart'; import 'package:flutter_deriv_api/services/connection/call_manager/base_call_manager.dart'; import 'package:flutter_deriv_api/services/connection/call_manager/exceptions/call_manager_exception.dart'; @@ -21,6 +23,7 @@ import 'mock_data/account/balance_response.dart'; import 'mock_data/account/copy_trading_list_response.dart'; import 'mock_data/account/copy_trading_statistics_response.dart'; import 'mock_data/account/get_account_status_response.dart'; +import 'mock_data/account/get_account_types_response.dart'; import 'mock_data/account/get_limits_response.dart'; import 'mock_data/account/get_self_exclusion_response.dart'; import 'mock_data/account/get_settings_response.dart'; @@ -106,6 +109,7 @@ import 'mock_data/user/set_financial_assessment_response.dart'; import 'mock_data/user/tnc_approval_response.dart'; import 'mock_data/user/transfer_between_accounts_response.dart'; import 'mock_data/user/verify_email_response.dart'; +import 'mock_data/wallet_migration_response.dart'; /// This class is for handling mock API connection and calling mock APIs class MockAPI extends BaseAPI { @@ -203,6 +207,8 @@ class MockAPI extends BaseAPI { return cancelResponse; case 'cashier': return cashierInformationResponse; + case 'cashier_payments': + return cashierPaymentsResponse; case 'contract_update': return contractUpdateResponse; case 'contract_update_history': @@ -226,6 +232,8 @@ class MockAPI extends BaseAPI { return forgetAllResponse; case 'get_account_status': return getAccountStatusResponse; + case 'get_account_types': + return getAccountTypesResponse; case 'get_financial_assessment': return getFinancialAssessmentResponse; case 'get_limits': @@ -263,6 +271,8 @@ class MockAPI extends BaseAPI { return newAccountRealResponse; case 'new_account_virtual': return newAccountVirtualResponse; + case 'new_account_wallet': + return newAccountWalletResponse; case 'oauth_apps': return oauthAppsResponse; case 'p2p_advert_create': @@ -361,6 +371,8 @@ class MockAPI extends BaseAPI { return verifyEmailResponse; case 'website_status': return websiteStatusResponse; + case 'wallet_migration': + return walletMigrationResponse; default: throw APIManagerException( diff --git a/lib/services/connection/api_manager/mock_data/account/get_account_types_response.dart b/lib/services/connection/api_manager/mock_data/account/get_account_types_response.dart new file mode 100644 index 0000000000..fb7a6146e3 --- /dev/null +++ b/lib/services/connection/api_manager/mock_data/account/get_account_types_response.dart @@ -0,0 +1,153 @@ +/// Mock data for get_account_types response. +const String getAccountTypesResponse = '''{ + "echo_req": { + "get_account_types": 1 + }, + "get_account_types": { + "trading": { + "binary": { + "allowed_wallet_currencies": [ + "AUD", + "BTC", + "ETH", + "EUR", + "GBP", + "LTC", + "USD", + "USDC", + "UST", + "eUSDT", + "tUSDT" + ], + "linkable_to_different_currency": 0, + "linkable_wallet_types": [ + "doughflow", + "crypto", + "p2p", + "paymentagent_client" + ] + }, + "derivez": { + "allowed_wallet_currencies": [ + "AUD", + "EUR", + "GBP", + "USD" + ], + "linkable_to_different_currency": 1, + "linkable_wallet_types": [ + "doughflow", + "p2p", + "paymentagent_client" + ] + }, + "dxtrade": { + "allowed_wallet_currencies": [ + "AUD", + "EUR", + "GBP", + "USD" + ], + "linkable_to_different_currency": 1, + "linkable_wallet_types": [ + "doughflow", + "p2p", + "paymentagent_client" + ] + }, + "mt5": { + "allowed_wallet_currencies": [ + "AUD", + "EUR", + "GBP", + "USD" + ], + "linkable_to_different_currency": 1, + "linkable_wallet_types": [ + "doughflow", + "p2p", + "paymentagent_client" + ] + }, + "standard": { + "allowed_wallet_currencies": [ + "AUD", + "BTC", + "ETH", + "EUR", + "GBP", + "LTC", + "USD", + "USDC", + "UST", + "eUSDT", + "tUSDT" + ], + "linkable_to_different_currency": 0, + "linkable_wallet_types": [ + "doughflow", + "crypto", + "p2p", + "paymentagent_client" + ] + } + }, + "wallet": { + "crypto": { + "currencies": [ + "BTC", + "ETH", + "LTC", + "USDC", + "UST", + "eUSDT", + "tUSDT" + ] + }, + "doughflow": { + "currencies": [ + "AUD", + "EUR", + "GBP", + "USD" + ] + }, + "p2p": { + "currencies": [ + "USD" + ] + }, + "paymentagent": { + "currencies": [ + "AUD", + "BTC", + "ETH", + "EUR", + "GBP", + "LTC", + "USD", + "USDC", + "UST", + "eUSDT", + "tUSDT" + ] + }, + "paymentagent_client": { + "currencies": [ + "AUD", + "BTC", + "ETH", + "EUR", + "GBP", + "LTC", + "USD", + "USDC", + "UST", + "eUSDT", + "tUSDT" + ] + } + } + }, + "msg_type": "get_account_types" +}'''; diff --git a/lib/services/connection/api_manager/mock_data/account/new_account_wallet_response.dart b/lib/services/connection/api_manager/mock_data/account/new_account_wallet_response.dart new file mode 100644 index 0000000000..7d428009ca --- /dev/null +++ b/lib/services/connection/api_manager/mock_data/account/new_account_wallet_response.dart @@ -0,0 +1,16 @@ +/// New account wallet response mock data. +const String newAccountWalletResponse = '''{ + "echo_req": { + "account_type": "crypto", + "currency": "BTC", + "new_account_wallet": 1 + }, + "msg_type": "new_account_wallet", + "new_account_wallet": { + "client_id": "CRW1170", + "currency": "BTC", + "landing_company": "Deriv (SVG) LLC", + "landing_company_shortcode": "svg", + "oauth_token": "DYsMOCKRAqaX23DvpZfmUW" + } +}'''; diff --git a/lib/services/connection/api_manager/mock_data/cashier/cashier_payments_response.dart b/lib/services/connection/api_manager/mock_data/cashier/cashier_payments_response.dart new file mode 100644 index 0000000000..f47489ccce --- /dev/null +++ b/lib/services/connection/api_manager/mock_data/cashier/cashier_payments_response.dart @@ -0,0 +1,27 @@ +import 'package:flutter_deriv_api/api/response/cashier_payments_response_result.dart'; + +/// The mock data for [CashierPaymentsResponse]. +const String cashierPaymentsResponse = ''' +{ + "cashier_payments": { + "crypto": [ + { + "address_hash": "addressHash", + "address_url": "addressUrl", + "id": "id", + "status_code": "CANCELLED", + "status_message": "statusMessage", + "transaction_type": "deposit", + "amount": 1, + "confirmations": 1, + "is_valid_to_cancel": true, + "submit_date": 1695118224, + "transaction_hash": "transactionHash", + "transaction_url": "transactionUrl" + } + ] + }, + "msg_type": "cashier_payments", + "req_id": 681 +} +'''; diff --git a/lib/services/connection/api_manager/mock_data/common/website_status_response.dart b/lib/services/connection/api_manager/mock_data/common/website_status_response.dart index 77ab3b219e..0bc9d3229f 100644 --- a/lib/services/connection/api_manager/mock_data/common/website_status_response.dart +++ b/lib/services/connection/api_manager/mock_data/common/website_status_response.dart @@ -653,6 +653,11 @@ const String websiteStatusResponse = '''{ "cancellation_count_period": 24, "cancellation_grace_period": 15, "cancellation_limit": 3, + "cross_border_ads_enabled": 1, + "block_trade": { + "disabled": false, + "maximum_advert_amount": 3000 + }, "maximum_advert_amount": 3000, "maximum_order_amount": 1000, "order_daily_limit": 200, diff --git a/lib/services/connection/api_manager/mock_data/p2p/p2p_advert_create_response.dart b/lib/services/connection/api_manager/mock_data/p2p/p2p_advert_create_response.dart index 40ee999f43..96d87a6f4a 100644 --- a/lib/services/connection/api_manager/mock_data/p2p/p2p_advert_create_response.dart +++ b/lib/services/connection/api_manager/mock_data/p2p/p2p_advert_create_response.dart @@ -22,6 +22,7 @@ const String p2pAdvertCreateResponse = ''' }, "amount": 100, "amount_display": "100.00", + "block_trade": 1, "contact_info": "Please transfer to account number 1234", "counterparty_type": "buy", "country": "za", @@ -40,6 +41,7 @@ const String p2pAdvertCreateResponse = ''' "max_order_amount_display": "50.00", "min_order_amount": 20, "min_order_amount_display": "20.00", + "order_expiry_period": 3600, "payment_info": "it is a sell order", "payment_method": "bank_transfer", "price": 2.3, diff --git a/lib/services/connection/api_manager/mock_data/p2p/p2p_advert_list_response.dart b/lib/services/connection/api_manager/mock_data/p2p/p2p_advert_list_response.dart index fe0d70be50..e27468536a 100644 --- a/lib/services/connection/api_manager/mock_data/p2p/p2p_advert_list_response.dart +++ b/lib/services/connection/api_manager/mock_data/p2p/p2p_advert_list_response.dart @@ -17,6 +17,7 @@ const String p2pAdvertListResponse = ''' "rating_count" : 0, "is_online": true }, + "block_trade": 1, "counterparty_type": "sell", "country": "za", "created_time": 1589270475, @@ -29,6 +30,7 @@ const String p2pAdvertListResponse = ''' "max_order_amount_limit_display": "100.00", "min_order_amount_limit": 10, "min_order_amount_limit_display": "10.00", + "order_expiry_period": 3600, "payment_method": "bank_transfer", "price": 14500, "price_display": "14500.00", @@ -47,6 +49,7 @@ const String p2pAdvertListResponse = ''' "rating_count" : 0, "is_online": true }, + "block_trade": 1, "counterparty_type": "sell", "country": "za", "created_time": 1589275813, @@ -59,6 +62,7 @@ const String p2pAdvertListResponse = ''' "max_order_amount_limit_display": "100.00", "min_order_amount_limit": 10, "min_order_amount_limit_display": "10.00", + "order_expiry_period": 3600, "payment_method": "bank_transfer", "price": 14500, "price_display": "14500.00", diff --git a/lib/services/connection/api_manager/mock_data/p2p/p2p_order_create_response.dart b/lib/services/connection/api_manager/mock_data/p2p/p2p_order_create_response.dart index c9b03004fb..3cb9f95062 100644 --- a/lib/services/connection/api_manager/mock_data/p2p/p2p_order_create_response.dart +++ b/lib/services/connection/api_manager/mock_data/p2p/p2p_order_create_response.dart @@ -9,8 +9,10 @@ const String p2pOrderCreateResponse = '''{ "p2p_order_create": { "account_currency": "USD", "advert_details": { + "block_trade": 1, "description": "Please contact via whatsapp 1234", "id": "6", + "order_expiry_period": 3600, "payment_method": "bank_transfer", "type": "sell" }, diff --git a/lib/services/connection/api_manager/mock_data/wallet_migration_response.dart b/lib/services/connection/api_manager/mock_data/wallet_migration_response.dart new file mode 100644 index 0000000000..00ed61c8c6 --- /dev/null +++ b/lib/services/connection/api_manager/mock_data/wallet_migration_response.dart @@ -0,0 +1,42 @@ +/// Wallet migration response mock data. +const String walletMigrationResponse = '''{ + "echo_req": { + "wallet_migration": "state" + }, + "msg_type": "wallet_migration", + "wallet_migration": { + "account_list": [ + { + "account_category": "wallet", + "account_type": "virtual", + "currency": "USD", + "landing_company_short": "virtual", + "link_accounts": [ + { + "account_category": "trading", + "account_type": "standard", + "loginid": "VRTC90000164", + "platform": "dtrade" + } + ], + "platform": "dwallet" + }, + { + "account_category": "wallet", + "account_type": "doughflow", + "currency": "USD", + "landing_company_short": "svg", + "link_accounts": [ + { + "account_category": "trading", + "account_type": "standard", + "loginid": "CR90000255", + "platform": "dtrade" + } + ], + "platform": "dwallet" + } + ], + "state": "eligible" + } +}'''; diff --git a/lib/services/connection/http_client/exceptions/http_client_exception.dart b/lib/services/connection/http_client/exceptions/http_client_exception.dart deleted file mode 100644 index ce3bd2759a..0000000000 --- a/lib/services/connection/http_client/exceptions/http_client_exception.dart +++ /dev/null @@ -1,21 +0,0 @@ -/// HTTP Client Exception exception class. -class HTTPClientException implements Exception { - /// Initializes http exception. - HTTPClientException({ - required this.statusCode, - required this.message, - required this.errorCode, - }); - - /// Exception message. - final String message; - - /// Http status code. - final int statusCode; - - /// Http error code. - final String? errorCode; - - @override - String toString() => '$statusCode HTTP Error Ocurred: $message'; -} \ No newline at end of file diff --git a/lib/services/connection/http_client/http_client.dart b/lib/services/connection/http_client/http_client.dart deleted file mode 100644 index e3b3bdf92f..0000000000 --- a/lib/services/connection/http_client/http_client.dart +++ /dev/null @@ -1,43 +0,0 @@ -import 'dart:convert' as convert; - -import 'package:flutter_deriv_api/services/connection/http_client/exceptions/http_client_exception.dart'; -import 'package:http/http.dart' as http; - -/// Singleton class for http requests. -class HttpClient { - /// Initializes http client. - factory HttpClient() => _instance; - - HttpClient._internal(); - - static final HttpClient _instance = HttpClient._internal(); - - /// Http get request. - Future get(String url) async => http.get(Uri.parse(url)); - - /// Http post request. - Future> post({ - required String url, - required Map jsonBody, - Map? headers, - }) async { - final String jsonString = convert.jsonEncode(jsonBody); - - final http.Response response = - await http.post(Uri.parse(url), body: jsonString, headers: headers); - - final Map jsonResponse = convert.jsonDecode(response.body); - - if (response.statusCode ~/ 100 != 2) { - throw HTTPClientException( - errorCode: jsonResponse['error_code'], - statusCode: response.statusCode, - message: jsonResponse.containsKey('message') - ? jsonResponse['message'] - : 'Server Error', - ); - } - - return jsonResponse; - } -} \ No newline at end of file diff --git a/lib/state/connection/connection_cubit.dart b/lib/state/connection/connection_cubit.dart index 4a655bb363..cc8b8d9949 100644 --- a/lib/state/connection/connection_cubit.dart +++ b/lib/state/connection/connection_cubit.dart @@ -32,13 +32,9 @@ class ConnectionCubit extends Cubit { _connectionInformation = connectionInformation; - if (_api is BinaryAPI) { - _setupConnectivityListener(); - } + _connect(_connectionInformation); _startKeepAliveTimer(); - - _connect(_connectionInformation); } final String _key = '${UniqueKey()}'; @@ -71,12 +67,21 @@ class ConnectionCubit extends Cubit { /// Gets endpoint of websocket. static String get endpoint => _connectionInformation.endpoint; + /// Gets auth endpoint of websocket. + static String get authEndpoint => _connectionInformation.authEndpoint; + /// Gets app id of websocket. static String get appId => _connectionInformation.appId; + /// Stream subscription for connectivity. + StreamSubscription? connectivitySubscription; + /// Reconnect to Websocket. - Future reconnect({ConnectionInformation? connectionInformation}) async { - emit(const ConnectionDisconnectedState()); + Future reconnect({ + ConnectionInformation? connectionInformation, + bool isChangingLanguage = false, + }) async { + emit(ConnectionDisconnectedState(isChangingLanguage: isChangingLanguage)); if (connectionInformation != null) { _connectionInformation = connectionInformation; @@ -122,26 +127,30 @@ class ConnectionCubit extends Cubit { } }, ); + + if (_api is BinaryAPI) { + _setupConnectivityListener(); + } } - void _setupConnectivityListener() => - Connectivity().onConnectivityChanged.listen( - (ConnectivityResult status) async { - final bool isConnectedToNetwork = - status == ConnectivityResult.mobile || - status == ConnectivityResult.wifi; - - if (isConnectedToNetwork) { - final bool isConnected = await _ping(); - - if (!isConnected) { - await reconnect(); - } - } else if (status == ConnectivityResult.none) { - emit(const ConnectionDisconnectedState()); + void _setupConnectivityListener() { + connectivitySubscription ??= Connectivity().onConnectivityChanged.listen( + (ConnectivityResult status) async { + final bool isConnectedToNetwork = status == ConnectivityResult.mobile || + status == ConnectivityResult.wifi; + + if (isConnectedToNetwork) { + final bool isConnected = await _ping(); + + if (!isConnected) { + await reconnect(); } - }, - ); + } else if (status == ConnectivityResult.none) { + emit(const ConnectionDisconnectedState()); + } + }, + ); + } void _startKeepAliveTimer() { if (_connectivityTimer == null || !_connectivityTimer!.isActive) { @@ -154,7 +163,6 @@ class ConnectionCubit extends Cubit { try { final PingResponse response = await PingResponse.pingMethod().timeout(_pingTimeout); - return response.ping == PingEnum.pong; } on Exception catch (_) { return false; @@ -164,7 +172,8 @@ class ConnectionCubit extends Cubit { @override Future close() { _connectivityTimer?.cancel(); - + connectivitySubscription?.cancel(); + connectivitySubscription = null; return super.close(); } } diff --git a/lib/state/connection/connection_state.dart b/lib/state/connection/connection_state.dart index 2ca83457c6..6ae26e40a5 100644 --- a/lib/state/connection/connection_state.dart +++ b/lib/state/connection/connection_state.dart @@ -33,7 +33,10 @@ class ConnectionConnectedState extends ConnectionState { /// Connection disconnected state. class ConnectionDisconnectedState extends ConnectionState { /// Initializes [ConnectionDisconnectedState]. - const ConnectionDisconnectedState(); + const ConnectionDisconnectedState({this.isChangingLanguage = false}); + + /// Is the App language changing during connection change + final bool isChangingLanguage; } /// Connection error state. diff --git a/lib/tools/schema_parser/helpers/constructor_helper.dart b/lib/tools/schema_parser/helpers/constructor_helper.dart index 38842d76de..1346bab9a9 100644 --- a/lib/tools/schema_parser/helpers/constructor_helper.dart +++ b/lib/tools/schema_parser/helpers/constructor_helper.dart @@ -23,32 +23,14 @@ StringBuffer _generateConstructor( } for (final SchemaModel model in children) { - final String typePostfix = model.classType == 'dynamic' - ? '' - : model.isRequired - ? '' - : '?'; - result ..write('${model.isRequired ? 'required' : ''} ') ..write( - isSubclass - ? '${model.classType}$typePostfix ${model.fieldName},' - : 'this.${model.fieldName},', + isSubclass ? 'super.${model.fieldName},' : 'this.${model.fieldName},', ); } - if (isSubclass) { - result.write('}) : super('); - - for (final SchemaModel model in children) { - result.write('${model.fieldName}: ${model.fieldName},'); - } - - result.write(');'); - } else { - result.write('});'); - } + result.write('});'); return result; } diff --git a/lib/widgets/snack_bar/snack_bar.dart b/lib/widgets/snack_bar/snack_bar.dart index 04b1ea6fb8..2e110c84eb 100644 --- a/lib/widgets/snack_bar/snack_bar.dart +++ b/lib/widgets/snack_bar/snack_bar.dart @@ -51,7 +51,7 @@ class SnackBarNotification { /// shows appropriate snack bar based on the [position] specified void show() { - WidgetsBinding.instance!.addPostFrameCallback((_) { + WidgetsBinding.instance.addPostFrameCallback((_) { if (position == SnackBarPosition.bottom) { ScaffoldMessenger.of(context).showSnackBar( _buildSnackBar(), diff --git a/lib/widgets/snack_bar/top_snack_bar/top_snack_bar.dart b/lib/widgets/snack_bar/top_snack_bar/top_snack_bar.dart index 3bbff9f37e..cb7baf06a5 100644 --- a/lib/widgets/snack_bar/top_snack_bar/top_snack_bar.dart +++ b/lib/widgets/snack_bar/top_snack_bar/top_snack_bar.dart @@ -55,8 +55,8 @@ class TopSnackBar { /// Adds [_overlayEntry] to the Overlay void addToOverlay() { - WidgetsBinding.instance!.addPostFrameCallback((_) { - Overlay.of(context)!.insert(_overlayEntry); + WidgetsBinding.instance.addPostFrameCallback((_) { + Overlay.of(context).insert(_overlayEntry); snackController.addStatusListener((AnimationStatus status) { if (status == AnimationStatus.dismissed) { _overlayEntry.remove(); diff --git a/lib/widgets/snack_bar/top_snack_bar/top_snack_bar_widget.dart b/lib/widgets/snack_bar/top_snack_bar/top_snack_bar_widget.dart index bef3b82396..7da4440a67 100644 --- a/lib/widgets/snack_bar/top_snack_bar/top_snack_bar_widget.dart +++ b/lib/widgets/snack_bar/top_snack_bar/top_snack_bar_widget.dart @@ -57,7 +57,7 @@ class _TopSnackBarWidgetState extends State { _dismissible = widget.dismissible ?? true; _duration = widget.duration ?? const Duration(seconds: 2); - WidgetsBinding.instance!.addPostFrameCallback((_) => _calculateSizes()); + WidgetsBinding.instance.addPostFrameCallback((_) => _calculateSizes()); widget.snackAnimationController.addListener(() { setState(() {}); diff --git a/pubspec.yaml b/pubspec.yaml index 9fb31c75d3..be7316d9fb 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -7,7 +7,8 @@ homepage: https://developers.binary.com publish_to: "none" environment: - sdk: ">=2.12.0 <3.0.0" + sdk: ">=3.0.0" + flutter: "3.10.2" dependencies: flutter: @@ -19,29 +20,28 @@ dependencies: path: packages/deriv_dependency_injector ref: dev - build: ^2.3.0 - dart_style: ^2.2.1 + build: ^2.3.1 + dart_style: ^2.3.0 equatable: ^2.0.3 - flutter_bloc: ^7.0.0 + flutter_bloc: ^8.1.2 http: ^0.13.4 - intl: ^0.17.0 - meta: ^1.7.0 + intl: ^0.18.0 + meta: ^1.8.0 recase: ^4.0.0 - rxdart: ^0.27.4 - web_socket_channel: ^2.2.0 - collection: ^1.15.0 - device_info: ^2.0.3 - package_info: ^2.0.2 - connectivity_plus: 2.3.9 + rxdart: ^0.27.7 + web_socket_channel: ^2.3.0 + device_info_plus: ^8.1.0 + package_info_plus: ^3.0.3 + connectivity_plus: ^3.0.3 dev_dependencies: flutter_test: sdk: flutter - bloc_test: ^8.0.0 + bloc_test: ^9.1.1 code_builder: ^4.1.0 build_config: ^1.0.0 - build_runner: ^2.1.11 + build_runner: ^2.3.0 build_test: ^2.1.5 json_schema2: ^2.0.2 path: ^1.8.0 diff --git a/test/api/account/get_account_types/get_account_types_test.dart b/test/api/account/get_account_types/get_account_types_test.dart new file mode 100644 index 0000000000..935494e26c --- /dev/null +++ b/test/api/account/get_account_types/get_account_types_test.dart @@ -0,0 +1,75 @@ +import 'package:flutter_deriv_api/api/api_initializer.dart'; +import 'package:flutter_deriv_api/api/response/get_account_types_response_extended.dart'; +import 'package:flutter_deriv_api/api/response/get_account_types_response_result.dart'; +import 'package:flutter_deriv_api/basic_api/generated/api.dart'; +import 'package:flutter_deriv_api/services/connection/api_manager/mock_api.dart'; +import 'package:deriv_dependency_injector/dependency_injector.dart'; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + setUp(() => APIInitializer().initialize(api: MockAPI())); + + tearDown(() => Injector().dispose()); + + test('Get account types API call returns the expected result.', () async { + final GetAccountTypesResponse accountTypesResponse = + await GetAccountTypesResponseExtended.fetchAccountTypes( + request: const GetAccountTypesRequest(), + ); + + expect(accountTypesResponse.getAccountTypes?.trading.length, 5); + expect(accountTypesResponse.getAccountTypes?.wallet.length, 5); + expect(accountTypesResponse.getAccountTypes?.trading['binary'], + isA()); + expect( + accountTypesResponse + .getAccountTypes?.trading['binary']?.linkableWalletTypes.length, + 4, + ); + expect( + accountTypesResponse + .getAccountTypes?.trading['binary']?.linkableWalletTypes.first, + 'doughflow', + ); + expect( + accountTypesResponse + .getAccountTypes?.trading['binary']?.allowedWalletCurrencies.length, + 11, + ); + expect( + accountTypesResponse + .getAccountTypes?.trading['binary']?.allowedWalletCurrencies.first, + 'AUD', + ); + expect( + accountTypesResponse + .getAccountTypes?.trading['derivez']?.linkableWalletTypes.length, + 3, + ); + expect( + accountTypesResponse + .getAccountTypes?.trading['derivez']?.linkableWalletTypes.first, + 'doughflow', + ); + expect( + accountTypesResponse.getAccountTypes?.trading['standard'], + isA(), + ); + expect( + accountTypesResponse.getAccountTypes?.wallet['crypto']?.currencies.length, + 7, + ); + expect( + accountTypesResponse.getAccountTypes?.wallet['crypto']?.currencies.first, + 'BTC', + ); + expect( + accountTypesResponse.getAccountTypes?.wallet['crypto']?.currencies.last, + 'tUSDT', + ); + expect( + accountTypesResponse.getAccountTypes?.wallet['doughflow'], + isA(), + ); + }); +} diff --git a/test/api/account/new_account_wallet/new_account_wallet_test.dart b/test/api/account/new_account_wallet/new_account_wallet_test.dart new file mode 100644 index 0000000000..e3a990eea8 --- /dev/null +++ b/test/api/account/new_account_wallet/new_account_wallet_test.dart @@ -0,0 +1,31 @@ +import 'package:flutter_deriv_api/api/api_initializer.dart'; +import 'package:flutter_deriv_api/api/response/new_account_wallet_response_extended.dart'; +import 'package:flutter_deriv_api/api/response/new_account_wallet_response_result.dart'; +import 'package:flutter_deriv_api/basic_api/generated/api.dart'; +import 'package:flutter_deriv_api/services/connection/api_manager/mock_api.dart'; +import 'package:deriv_dependency_injector/dependency_injector.dart'; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + setUp(() => APIInitializer().initialize(api: MockAPI())); + + tearDown(() => Injector().dispose()); + + test('New account wallet API call returns the expected result.', () async { + final NewAccountWalletResponse newAccountWallet = + await NewAccountWalletResponseExtended.createNewWalletAccount( + request: const NewAccountWalletRequest( + accountType: 'crypto', + currency: 'BTC', + ), + ); + + expect(newAccountWallet.newAccountWallet?.clientId, 'CRW1170'); + expect(newAccountWallet.newAccountWallet?.currency, 'BTC'); + expect(newAccountWallet.newAccountWallet?.clientId, 'CRW1170'); + expect( + newAccountWallet.newAccountWallet?.oauthToken, + 'DYsMOCKRAqaX23DvpZfmUW', + ); + }); +} diff --git a/test/api/account/wallet_migration/wallet_migration_test.dart b/test/api/account/wallet_migration/wallet_migration_test.dart new file mode 100644 index 0000000000..cd8448a4ad --- /dev/null +++ b/test/api/account/wallet_migration/wallet_migration_test.dart @@ -0,0 +1,63 @@ +import 'package:flutter_deriv_api/api/api_initializer.dart'; +import 'package:flutter_deriv_api/api/response/wallet_migration_response_extended.dart'; +import 'package:flutter_deriv_api/api/response/wallet_migration_response_result.dart'; +import 'package:flutter_deriv_api/basic_api/generated/wallet_migration_send.dart'; +import 'package:flutter_deriv_api/services/connection/api_manager/mock_api.dart'; +import 'package:deriv_dependency_injector/dependency_injector.dart'; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + group('Wallet migration', () { + setUpAll(() => APIInitializer().initialize(api: MockAPI())); + + tearDownAll(() => Injector().dispose()); + + test( + 'fetchWalletMigration method returns the expected result.', + () async { + final WalletMigrationResponse response = + await WalletMigrationResponseExtended.fetchWalletMigration( + request: const WalletMigrationRequest(walletMigration: 'state'), + ); + + expect(response.walletMigration?.state, StateEnum.eligible); + expect(response.walletMigration?.accountList?.length, 2); + + final AccountListItem? firstAccount = + response.walletMigration?.accountList?.first; + + expect(firstAccount?.currency, 'USD'); + expect(firstAccount?.platform, AccountListItemPlatformEnum.dwallet); + expect( + firstAccount?.accountCategory, + AccountCategoryEnum.wallet, + ); + expect(firstAccount?.accountType, 'virtual'); + expect(firstAccount?.linkAccounts.length, 1); + }, + ); + + test( + 'checkStatus method returns the expected result.', + () async { + final WalletMigrationResponse response = + await WalletMigrationResponseExtended.checkStatus(); + + expect(response.walletMigration?.state, StateEnum.eligible); + expect(response.walletMigration?.accountList?.length, 2); + + final AccountListItem? firstAccount = + response.walletMigration?.accountList?.first; + + expect(firstAccount?.currency, 'USD'); + expect(firstAccount?.platform, AccountListItemPlatformEnum.dwallet); + expect( + firstAccount?.accountCategory, + AccountCategoryEnum.wallet, + ); + expect(firstAccount?.accountType, 'virtual'); + expect(firstAccount?.linkAccounts.length, 1); + }, + ); + }); +} diff --git a/test/api/cashier/cashier_payments_test.dart b/test/api/cashier/cashier_payments_test.dart new file mode 100644 index 0000000000..28e805c3ec --- /dev/null +++ b/test/api/cashier/cashier_payments_test.dart @@ -0,0 +1,30 @@ +import 'package:deriv_dependency_injector/dependency_injector.dart'; +import 'package:flutter_deriv_api/api/api_initializer.dart'; +import 'package:flutter_deriv_api/api/response/cashier_payments_response_extended.dart'; +import 'package:flutter_deriv_api/api/response/cashier_payments_response_result.dart'; +import 'package:flutter_deriv_api/basic_api/generated/cashier_payments_send.dart'; +import 'package:flutter_deriv_api/services/connection/api_manager/mock_api.dart'; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + setUp(() => APIInitializer().initialize(api: MockAPI())); + + tearDown(() => Injector().dispose()); + + test('Fetch Cashier Payments Test', () async { + final CashierPaymentsResponse response = + await CashierPaymentsResponseExtended.fetchCashierPayments( + request: const CashierPaymentsRequest(), + ); + + expect(response.cashierPayments?.crypto?.length, 1); + expect(response.cashierPayments?.crypto?.first.id, 'id'); + expect(response.cashierPayments?.crypto?.first.statusCode, + StatusCodeEnum.cancelled); + expect( + response + .cashierPayments?.crypto?.first.submitDate?.millisecondsSinceEpoch, + 1695118224000, + ); + }); +} diff --git a/test/api/common/asset_index/asset_index_test.dart b/test/api/common/asset_index/asset_index_test.dart index 05a4bdfa32..013d2fc7ff 100644 --- a/test/api/common/asset_index/asset_index_test.dart +++ b/test/api/common/asset_index/asset_index_test.dart @@ -12,7 +12,8 @@ void main() { test('Fetch Asset Index Test', () async { final AssetIndexResponse assetIndices = - await AssetIndexResponse.fetchAssetIndices(const AssetIndexRequest()); + await AssetIndexResponse.fetchAssetIndices( + const AssetIndexRequest(landingCompany: 'svg')); expect(assetIndices.assetIndex?.length, 1); // expect(assetIndices.assetIndex.first['symbol_code'], 'frxAUDJPY'); diff --git a/test/api/common/trading/trading_duration_test.dart b/test/api/common/trading/trading_duration_test.dart index ede7e756b0..388c6af57e 100644 --- a/test/api/common/trading/trading_duration_test.dart +++ b/test/api/common/trading/trading_duration_test.dart @@ -13,7 +13,7 @@ void main() { test('Fetch Trading Duration Test', () async { final TradingDurationsResponse tradeDuration = await TradingDurationsResponse.fetchTradingDurations( - const TradingDurationsRequest(), + const TradingDurationsRequest(landingCompany: 'svg'), ); expect(tradeDuration.tradingDurations?.length, 8); diff --git a/test/api/exceptions/api_base_exception_test.dart b/test/api/exceptions/api_base_exception_test.dart new file mode 100644 index 0000000000..4ff9f125ba --- /dev/null +++ b/test/api/exceptions/api_base_exception_test.dart @@ -0,0 +1,46 @@ +import 'package:flutter_deriv_api/api/exceptions/exceptions.dart'; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + group('APIBaseException tests =>', () { + test('should return the correct message.', () { + final BaseExceptionModel baseExceptionModel = + BaseExceptionModel(code: 'BAD_REQUEST', message: 'Bad Request'); + final BaseAPIException exception = + BaseAPIException(baseExceptionModel: baseExceptionModel); + + expect(exception.message, 'Bad Request'); + }); + + test('should return the correct code.', () { + final BaseExceptionModel baseExceptionModel = + BaseExceptionModel(code: 'BAD_REQUEST', message: 'Bad Request'); + final BaseAPIException exception = + BaseAPIException(baseExceptionModel: baseExceptionModel); + + expect(exception.code, 'BAD_REQUEST'); + }); + + test('should return the correct details.', () { + final BaseExceptionModel baseExceptionModel = BaseExceptionModel( + code: 'BAD_REQUEST', + message: 'Bad Request', + details: {'key': 'value'}, + ); + final BaseAPIException exception = + BaseAPIException(baseExceptionModel: baseExceptionModel); + + expect(exception.details, {'key': 'value'}); + }); + + test('should return the correct string representation.', () { + final BaseExceptionModel baseExceptionModel = + BaseExceptionModel(code: 'BAD_REQUEST', message: 'Bad Request'); + final BaseAPIException exception = + BaseAPIException(baseExceptionModel: baseExceptionModel); + final String stringRepresentation = '$exception'; + + expect(stringRepresentation, 'Bad Request'); + }); + }); +} diff --git a/test/api/mt5/mt5_account_test.dart b/test/api/mt5/mt5_account_test.dart index ef8d57c8ad..ceaeb5a242 100644 --- a/test/api/mt5/mt5_account_test.dart +++ b/test/api/mt5/mt5_account_test.dart @@ -131,7 +131,7 @@ void main() { ).fetchSettings(); expect(mt5Settings.mt5GetSettings?.address, 'sample address'); - expect(mt5Settings.mt5GetSettings?.balance, '250.0'); + expect(mt5Settings.mt5GetSettings?.balance, 250.0); expect(mt5Settings.mt5GetSettings?.city, 'London'); expect(mt5Settings.mt5GetSettings?.company, 'sample company'); expect(mt5Settings.mt5GetSettings?.country, 'England'); diff --git a/test/api/p2p/p2p_advert/p2p_advert_test.dart b/test/api/p2p/p2p_advert/p2p_advert_test.dart index 631eaee2b7..a9aad382e3 100644 --- a/test/api/p2p/p2p_advert/p2p_advert_test.dart +++ b/test/api/p2p/p2p_advert/p2p_advert_test.dart @@ -1,5 +1,4 @@ -import 'package:flutter_test/flutter_test.dart'; - +import 'package:deriv_dependency_injector/dependency_injector.dart'; import 'package:flutter_deriv_api/api/api_initializer.dart'; import 'package:flutter_deriv_api/api/response/p2p_advert_create_response_result.dart' as advert_create; @@ -14,9 +13,9 @@ import 'package:flutter_deriv_api/api/response/p2p_order_create_response_result. import 'package:flutter_deriv_api/basic_api/generated/p2p_advert_create_send.dart'; import 'package:flutter_deriv_api/basic_api/generated/p2p_advert_info_send.dart'; import 'package:flutter_deriv_api/basic_api/generated/p2p_advert_list_send.dart'; -import 'package:flutter_deriv_api/services/connection/api_manager/mock_api.dart'; -import 'package:deriv_dependency_injector/dependency_injector.dart'; import 'package:flutter_deriv_api/helpers/helpers.dart'; +import 'package:flutter_deriv_api/services/connection/api_manager/mock_api.dart'; +import 'package:flutter_test/flutter_test.dart'; void main() { setUp(() => APIInitializer().initialize(api: MockAPI())); @@ -81,6 +80,8 @@ void main() { 'advertiser CR90000018', ); + expect(adverts.first.blockTrade, true); + expect(adverts.first.orderExpiryPeriod, 3600); expect(adverts.first.counterpartyType, advert_list.CounterpartyTypeEnum.sell); expect(adverts.first.country, 'za'); diff --git a/test/helpers/boolean_helper_test.dart b/test/helpers/boolean_helper_test.dart new file mode 100644 index 0000000000..095708e887 --- /dev/null +++ b/test/helpers/boolean_helper_test.dart @@ -0,0 +1,49 @@ +import 'package:test/test.dart'; + +import 'package:flutter_deriv_api/helpers/boolean_helper.dart'; + +void main() { + group('getBool tests =>', () { + test('should return true for 1.', () { + final bool? result = getBool(1); + expect(result, true); + }); + + test('should return true for true.', () { + final bool? result = getBool(true); + expect(result, true); + }); + + test('should return false for 0.', () { + final bool? result = getBool(0); + expect(result, false); + }); + + test('should return false for false.', () { + final bool? result = getBool(false); + expect(result, false); + }); + + test('should return null for null.', () { + final bool? result = getBool(null); + expect(result, null); + }); + }); + + group('getInt tests =>', () { + test('should return 1 for true.', () { + final int? result = getInt(value: true); + expect(result, 1); + }); + + test('should return 0 for false.', () { + final int? result = getInt(value: false); + expect(result, 0); + }); + + test('should return null for null.', () { + final int? result = getInt(); + expect(result, null); + }); + }); +} diff --git a/test/helpers/date_time_helper_test.dart b/test/helpers/date_time_helper_test.dart new file mode 100644 index 0000000000..17b70ec9e5 --- /dev/null +++ b/test/helpers/date_time_helper_test.dart @@ -0,0 +1,120 @@ +// ignore_for_file: avoid_redundant_argument_values + +import 'package:test/test.dart'; + +import 'package:flutter_deriv_api/helpers/date_time_helper.dart'; + +void main() { + group('getCurrentLocalEpoch tests =>', () { + test('should return current epoch time in seconds.', () { + final int result = getCurrentLocalEpoch(); + + expect(result, isA()); + }); + }); + + group('getCurrentServerTime tests =>', () { + test('should return current server time.', () { + const int timeDifference = 3600; + final DateTime result = getCurrentServerTime(timeDifference); + + expect(result, isA()); + }); + }); + + group('getDateTime tests =>', () { + test('should return DateTime from time in seconds.', () { + const int timeInSeconds = 1633459200; + final DateTime? result = getDateTime(timeInSeconds); + + expect(result, isA()); + expect(result?.year, 2021); + expect(result?.month, 10); + expect(result?.day, 5); + expect(result?.hour, 18); + expect(result?.minute, 40); + expect(result?.second, 0); + }); + + test('should return null for null time in seconds.', () { + final DateTime? result = getDateTime(null); + + expect(result, null); + }); + }); + + group('getDateTimeFromString tests =>', () { + test('should return DateTime from string in seconds.', () { + const String timeInSeconds = '1633459200'; + final DateTime? result = getDateTimeFromString(timeInSeconds); + + expect(result, isA()); + expect(result?.year, 2021); + expect(result?.month, 10); + expect(result?.day, 5); + expect(result?.hour, 18); + expect(result?.minute, 40); + expect(result?.second, 0); + }); + + test('should return null for null string.', () { + final DateTime? result = getDateTimeFromString(null); + + expect(result, null); + }); + + test('should return null for invalid string.', () { + final DateTime? result = getDateTimeFromString('invalid'); + + expect(result, null); + }); + }); + + group('getSecondsSinceEpoch tests =>', () { + test('should return seconds since epoch from milliseconds since epoch.', + () { + const int millisecondsSinceEpoch = 1633459200000; + final int result = getSecondsSinceEpoch(millisecondsSinceEpoch); + + expect(result, 1633459200); + }); + }); + + group('getSecondsSinceEpochDateTime tests =>', () { + test('should return seconds since epoch from DateTime object.', () { + final DateTime dateTime = DateTime.utc(2021, 10, 6, 0, 0, 0); + final int? result = getSecondsSinceEpochDateTime(dateTime); + + expect(result, 1633478400); + }); + + test('should return null for null DateTime.', () { + final int? result = getSecondsSinceEpochDateTime(null); + + expect(result, null); + }); + }); + + group('getStringFromDateTime tests =>', () { + test('should return formatted string from DateTime object.', () { + final DateTime dateTime = DateTime.utc(2021, 10, 6); + final String? result = getStringFromDateTime(dateTime); + + expect(result, '2021-10-06'); + }); + + test('should return null for null DateTime.', () { + final String? result = getStringFromDateTime(null); + + expect(result, null); + }); + + test('should return formatted string with custom pattern.', () { + final DateTime dateTime = DateTime.utc(2021, 10, 6); + final String? result = + getStringFromDateTime(dateTime, pattern: 'MM/dd/yyyy'); + + expect(result, '10/06/2021'); + }); + }); +} diff --git a/test/helpers/enum_helper_test.dart b/test/helpers/enum_helper_test.dart new file mode 100644 index 0000000000..9951f1497b --- /dev/null +++ b/test/helpers/enum_helper_test.dart @@ -0,0 +1,208 @@ +import 'package:test/test.dart'; + +import 'package:flutter_deriv_api/api/models/enums.dart'; +import 'package:flutter_deriv_api/helpers/enum_helper.dart'; + +void main() { + group('getEnumName tests =>', () { + test('should return formatted enum name.', () { + final String result = getEnumName('enum_name'); + + expect(result, 'enumName'); + }); + + test('should handle special characters in enum name.', () { + final String result = getEnumName('enum_name_123_&'); + + expect(result, 'enumName123'); + }); + }); + + group('getStringFromEnum tests =>', () { + test('should return string from enum in snake case.', () { + final String result = getStringFromEnum(EnumCase.snakeCase); + + expect(result, 'snake_case'); + }); + + test('should return string from enum in param case.', () { + final String result = + getStringFromEnum(EnumCase.paramCase, enumCase: EnumCase.paramCase); + + expect(result, 'param-case'); + }); + + test('should return string from enum in upper case.', () { + final String result = + getStringFromEnum(EnumCase.upperCase, enumCase: EnumCase.upperCase); + + expect(result, 'UPPERCASE'); + }); + + test('should return empty string for null enum.', () { + final String result = getStringFromEnum(null); + + expect(result, ''); + }); + }); + + group('getEnumFromString tests =>', () { + test('should return enum from string in snake case.', () { + final EnumCase? result = getEnumFromString( + values: EnumCase.values, + name: 'snake_case', + ); + + expect(result, EnumCase.snakeCase); + }); + + test('should return enum from string in param case.', () { + final EnumCase? result = getEnumFromString( + values: EnumCase.values, + name: 'param-case', + enumCase: EnumCase.paramCase, + ); + + expect(result, EnumCase.paramCase); + }); + + test('should return enum from string in upper case.', () { + final EnumCase? result = getEnumFromString( + values: EnumCase.values, + name: 'UPPERCASE', + enumCase: EnumCase.upperCase, + ); + + expect(result, EnumCase.upperCase); + }); + + test('should return null for unknown string.', () { + final EnumCase? result = getEnumFromString( + values: EnumCase.values, + name: 'unknown_case', + ); + expect(result, null); + }); + + test('should return null for null string.', () { + final EnumCase? result = getEnumFromString( + values: EnumCase.values, + name: null, + ); + + expect(result, null); + }); + }); + + group('getStringListFromEnums tests =>', () { + test('should return list of strings from list of enums in snake case.', () { + final List result = getStringListFromEnums( + EnumCase.values, + ); + + expect(result, ['snake_case', 'param_case', 'upper_case']); + }); + + test('should return list of strings from list of enums in param case.', () { + final List result = getStringListFromEnums( + EnumCase.values, + enumCase: EnumCase.paramCase, + ); + + expect(result, ['snake-case', 'param-case', 'upper-case']); + }); + + test('should return list of strings from list of enums in upper case.', () { + final List result = getStringListFromEnums( + EnumCase.values, + enumCase: EnumCase.upperCase, + ); + + expect(result, ['SNAKECASE', 'PARAMCASE', 'UPPERCASE']); + }); + }); + + group('getEnumListFromStrings tests =>', () { + test('should return list of enums from list of strings in snake case.', () { + final List? result = getEnumListFromStrings( + values: EnumCase.values, + names: ['snake_case', 'param-case', 'UPPERCASE'], + ); + + expect(result, [EnumCase.snakeCase, null, null]); + }); + + test('should return list of enums from list of strings in param case.', () { + final List? result = getEnumListFromStrings( + values: EnumCase.values, + names: ['snake-case', 'param-case', 'UPPERCASE'], + enumCase: EnumCase.paramCase, + ); + + expect(result, [EnumCase.snakeCase, EnumCase.paramCase, null]); + }); + + test('should return list of enums from list of strings in upper case.', () { + final List? result = getEnumListFromStrings( + values: EnumCase.values, + names: ['snake_case', 'param_case', 'UPPERCASE'], + enumCase: EnumCase.upperCase, + ); + + expect(result, [null, null, EnumCase.upperCase]); + }); + + test('should return null for unknown strings.', () { + final List? result = getEnumListFromStrings( + values: EnumCase.values, + names: ['unknown_case'], + ); + + expect(result, [null]); + }); + + test('should return null for null strings.', () { + final List? result = getEnumListFromStrings( + values: EnumCase.values, + names: null, + ); + + expect(result, null); + }); + }); + + group('getEnumValueString tests =>', () { + test('should return the enum value string.', () { + final String result = getEnumValueString(EnumCase.snakeCase.toString()); + + expect(result, 'snakeCase'); + }); + }); + + group('EnumConverter tests =>', () { + test('should convert string to AccountRiskClassification enum.', () { + final AccountRiskClassification? result = + 'low'.toAccountRiskClassificationEnum; + + expect(result, AccountRiskClassification.low); + }); + + test('should convert string to VerificationType enum.', () { + final VerificationType? result = 'document'.toVerificationTypeEnum; + + expect(result, VerificationType.document); + }); + + test('should convert string to AccountStatusType enum.', () { + final AccountStatusType? result = 'disabled'.toAccountStatusTypeEnum; + + expect(result, AccountStatusType.disabled); + }); + + test('should convert string to ContractType enum.', () { + final ContractType? result = 'CALLSPREAD'.toContractTypeEnum; + + expect(result, ContractType.callSpread); + }); + }); +} diff --git a/test/helpers/map_helper_test.dart b/test/helpers/map_helper_test.dart new file mode 100644 index 0000000000..df45944991 --- /dev/null +++ b/test/helpers/map_helper_test.dart @@ -0,0 +1,104 @@ +import 'package:flutter_deriv_api/helpers/map_helper.dart'; +import 'package:test/test.dart'; + +void main() { + group('getListFromMap tests =>', () { + test('should return null for null map list.', () { + final List? result = getListFromMap(null); + + expect(result, null); + }); + + test('should return null for empty map list.', () { + final List? result = getListFromMap([]); + + expect(result, null); + }); + + test('should return list of models from map list.', () { + final List> mapList = >[ + {'id': 1, 'name': 'John'}, + {'id': 2, 'name': 'Jane'}, + ]; + + final List? result = getListFromMap( + mapList, + itemToTypeCallback: (dynamic item) => UserModel.fromMap(item), + ); + + expect(result, isNotNull); + expect(result!.length, 2); + expect(result[0], isA()); + expect(result[1], isA()); + expect(result[0]?.id, 1); + expect(result[0]?.name, 'John'); + expect(result[1]?.id, 2); + expect(result[1]?.name, 'Jane'); + }); + + test('should return list of models without callback function.', () { + final List> mapList = >[ + {'id': 1, 'name': 'John'}, + {'id': 2, 'name': 'Jane'}, + ]; + + final List? result = getListFromMap(mapList); + + expect(result, isNotNull); + expect(result!.length, 2); + expect(result[0], {'id': 1, 'name': 'John'}); + expect(result[1], {'id': 2, 'name': 'Jane'}); + }); + }); + + group('getItemFromMap tests =>', () { + test('should return null for null map.', () { + final dynamic result = getItemFromMap(null); + + expect(result, null); + }); + + test('should return model from map.', () { + final Map map = { + 'id': 1, + 'name': 'John' + }; + + final UserModel? result = getItemFromMap( + map, + itemToTypeCallback: (dynamic item) => UserModel.fromMap(item), + ); + + expect(result, isA()); + expect(result?.id, 1); + expect(result?.name, 'John'); + }); + + test('should return map without callback function.', () { + final Map map = { + 'id': 1, + 'name': 'John' + }; + + final Map? result = + getItemFromMap(map, itemToTypeCallback: (dynamic item) => item); + + expect(result, {'id': 1, 'name': 'John'}); + }); + }); +} + +class UserModel { + UserModel({ + required this.id, + required this.name, + }); + + factory UserModel.fromMap(Map map) => UserModel( + id: map['id'], + name: map['name'], + ); + + final int id; + final String name; +} diff --git a/test/helpers/number_helper_test.dart b/test/helpers/number_helper_test.dart new file mode 100644 index 0000000000..a634f6a596 --- /dev/null +++ b/test/helpers/number_helper_test.dart @@ -0,0 +1,212 @@ +import 'package:test/test.dart'; + +import 'package:flutter_deriv_api/helpers/number_helper.dart'; + +void main() { + group('getDecimalDigits tests =>', () { + test('should return 2 for a whole number string.', () { + expect(getDecimalDigits('123'), equals(2)); + }); + + test('should return 2 for a decimal number string.', () { + expect(getDecimalDigits('123.45'), equals(2)); + }); + + test( + 'should return 4 for a decimal number string with more than 2 decimal places.', + () { + expect(getDecimalDigits('123.4567'), equals(4)); + }); + + test('should return 2 for an empty string.', () { + expect(getDecimalDigits(''), equals(2)); + }); + }); + + group('NumberValidator tests =>', () { + test('isANumber should return true for a valid number string.', () { + expect(NumberValidator.isANumber('123'), isTrue); + }); + + test('isANumber should return true for a valid decimal number string.', () { + expect(NumberValidator.isANumber('123.45'), isTrue); + }); + + test('isANumber should return false for an invalid number string.', () { + expect(NumberValidator.isANumber('abc'), isFalse); + }); + + test( + 'isBetweenLimits should return true when the value is within the limits.', + () { + expect( + NumberValidator.isBetweenLimits( + stringValue: '5', + lowerLimit: 1, + upperLimit: 10, + ), + isTrue, + ); + }); + + test( + 'isBetweenLimits should return false when the value is below the lower limit.', + () { + expect( + NumberValidator.isBetweenLimits( + stringValue: '5', + lowerLimit: 10, + upperLimit: 20, + ), + isFalse, + ); + }); + + test( + 'isBetweenLimits should return false when the value is above the upper limit.', + () { + expect( + NumberValidator.isBetweenLimits( + stringValue: '25', + lowerLimit: 10, + upperLimit: 20, + ), + isFalse, + ); + }); + + test( + 'isLessThanLimit should return true when the value is less than the upper limit.', + () { + expect( + NumberValidator.isLessThanLimit(stringValue: '5', upperLimit: 10), + isTrue, + ); + }); + + test( + 'isLessThanLimit should return true when the value is equal to the upper limit.', + () { + expect( + NumberValidator.isLessThanLimit(stringValue: '10', upperLimit: 10), + isTrue, + ); + }); + + test( + 'isLessThanLimit should return false when the value is greater than the upper limit.', + () { + expect( + NumberValidator.isLessThanLimit(stringValue: '15', upperLimit: 10), + isFalse, + ); + }); + + test( + 'isMoreThanLimit should return true when the value is greater than the lower limit.', + () { + expect( + NumberValidator.isMoreThanLimit(stringValue: '5', lowerLimit: 1), + isTrue, + ); + }); + + test( + 'isMoreThanLimit should return true when the value is equal to the lower limit.', + () { + expect( + NumberValidator.isMoreThanLimit(stringValue: '1', lowerLimit: 1), + isTrue, + ); + }); + + test( + 'isMoreThanLimit should return false when the value is less than the lower limit.', + () { + expect( + NumberValidator.isMoreThanLimit(stringValue: '0', lowerLimit: 1), + isFalse, + ); + }); + + test('isAPositiveNumber should return true for a positive number string.', + () { + expect(NumberValidator.isAPositiveNumber('5'), isTrue); + }); + + test('isAPositiveNumber should return false for a negative number string.', + () { + expect(NumberValidator.isAPositiveNumber('-5'), isFalse); + }); + + test('isAPositiveNumber should return false for zero.', () { + expect(NumberValidator.isAPositiveNumber('0'), isFalse); + }); + + test( + 'hasValidPrecision should return true when the decimal number has valid precision.', + () { + expect( + NumberValidator.hasValidPrecision( + stringValue: '1.23', + validDecimalNumber: 2, + ), + isTrue, + ); + }); + + test( + 'hasValidPrecision should return true when the whole number is provided.', + () { + expect( + NumberValidator.hasValidPrecision( + stringValue: '5', + validDecimalNumber: 2, + ), + isTrue, + ); + }); + + test( + 'hasValidPrecision should return false when the decimal number has more decimal places than the valid precision.', + () { + expect( + NumberValidator.hasValidPrecision( + stringValue: '1.2345', + validDecimalNumber: 2, + ), + isFalse, + ); + }); + }); + + group('generateRandomInt tests =>', () { + test('should generate a random int between min and max (inclusive).', () { + final int randomInt = generateRandomInt(min: 1); + + expect(randomInt, greaterThanOrEqualTo(1)); + expect(randomInt, lessThanOrEqualTo(10)); + }); + + test('should generate a random int with default min and max values.', () { + final int randomInt = generateRandomInt(); + + expect(randomInt, greaterThanOrEqualTo(0)); + expect(randomInt, lessThanOrEqualTo(10)); + }); + }); + + group('getDouble tests =>', () { + test('should parse double value from a string.', () { + expect(getDouble('123.45'), equals(123.45)); + }); + + test('should parse double value from a number.', () { + expect(getDouble(123.45), equals(123.45)); + }); + + test('should return null for an invalid value.', () { + expect(getDouble('abc'), isNull); + }); + }); +} diff --git a/test/services/connection/api_manager/exceptions/api_manager_exception_test.dart b/test/services/connection/api_manager/exceptions/api_manager_exception_test.dart new file mode 100644 index 0000000000..21f9671b16 --- /dev/null +++ b/test/services/connection/api_manager/exceptions/api_manager_exception_test.dart @@ -0,0 +1,26 @@ +import 'package:test/test.dart'; + +import 'package:flutter_deriv_api/services/connection/api_manager/exceptions/api_manager_exception.dart'; + +void main() { + group('APIManagerException tests =>', () { + test( + 'should create an APIManagerException instance with the provided message.', + () { + final APIManagerException exception = + APIManagerException(message: 'Test Exception'); + + expect(exception, isA()); + expect(exception.message, 'Test Exception'); + }); + + test( + 'toString should return a string representation of the APIManagerException.', + () { + final APIManagerException exception = + APIManagerException(message: 'Test Exception'); + + expect(exception.toString(), 'APIManagerException: Test Exception'); + }); + }); +} diff --git a/test/state/connection/connection_bloc_test.dart b/test/state/connection/connection_bloc_test.dart index 651094dd51..d4147817a8 100644 --- a/test/state/connection/connection_bloc_test.dart +++ b/test/state/connection/connection_bloc_test.dart @@ -10,7 +10,7 @@ void main() { setUpAll( () { connectionCubit = ConnectionCubit( - ConnectionInformation(appId: '', brand: '', endpoint: ''), + ConnectionInformation(appId: '', brand: '', endpoint: '',authEndpoint: ''), api: MockAPI(), ); },