Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

v1.1.0 #329

Merged
merged 3 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions lib/api/response/cashier_withdrawal_cancel_response_extended.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// ignore_for_file: prefer_single_quotes, unnecessary_import, unused_import

import 'package:deriv_dependency_injector/dependency_injector.dart';
import 'package:equatable/equatable.dart';
import 'package:flutter_deriv_api/api/exceptions/base_api_exception.dart';
import 'package:flutter_deriv_api/api/models/base_exception_model.dart';
import 'package:flutter_deriv_api/api/response/cashier_withdrawal_cancel_response_result.dart';
import 'package:flutter_deriv_api/basic_api/generated/cashier_withdrawal_cancel_receive.dart';
import 'package:flutter_deriv_api/basic_api/generated/cashier_withdrawal_cancel_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 [CashierWithdrawalCancelResponseExtended] class to implement
/// the API call methods.
class CashierWithdrawalCancelResponseExtended
extends CashierWithdrawalCancelResponseModel {
static final BaseAPI _api = Injector()<BaseAPI>();

/// Fetches the cashier payments.
static Future<CashierWithdrawalCancelResponse> cancelCasWithdrawl({
required CashierWithdrawalCancelRequest request,
}) async {
final CashierWithdrawalCancelReceive response =
await _api.call(request: request);

checkException(
response: response,
exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>
BaseAPIException(baseExceptionModel: baseExceptionModel),
);

return CashierWithdrawalCancelResponse.fromJson(
response.cashierWithdrawalCancel);
}
}
155 changes: 155 additions & 0 deletions lib/api/response/get_account_status_response_result.dart
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ abstract class GetAccountStatusModel {
/// - `mt5_additional_kyc_required`: client tax information, place of birth and account opening reason is missing.
/// - `poi_expiring_soon`: the POI documents of the client will get expired soon, allow them to reupload POI documents.
/// - `poa_expiring_soon`: the POA documents of the client will get outdated soon, allow them to reupload POA documents.
/// - `tin_manually_approved`: the client's tax_identification_number has been manually approved as client is not applicable for tax_identification_number
final List<String> status;

/// Client risk classification: `low`, `standard`, `high`.
Expand Down Expand Up @@ -825,6 +826,7 @@ abstract class DocumentModel {
this.authenticatedWithIdv,
this.expiryDate,
this.status,
this.verifiedJurisdiction,
});

/// This represents the current status of idv authentication for each mt5 jurisdiction.
Expand All @@ -835,6 +837,9 @@ abstract class DocumentModel {

/// This represents the current status of the proof of address document submitted for authentication.
final DocumentStatusEnum? status;

/// This represents the current status of authentication for each mt5 jurisdiction.
final VerifiedJurisdiction? verifiedJurisdiction;
}

/// Document class.
Expand All @@ -844,6 +849,7 @@ class Document extends DocumentModel {
super.authenticatedWithIdv,
super.expiryDate,
super.status,
super.verifiedJurisdiction,
});

/// Creates an instance from JSON.
Expand All @@ -855,6 +861,9 @@ class Document extends DocumentModel {
status: json['status'] == null
? null
: documentStatusEnumMapper[json['status']],
verifiedJurisdiction: json['verified_jurisdiction'] == null
? null
: VerifiedJurisdiction.fromJson(json['verified_jurisdiction']),
);

/// Converts an instance to JSON.
Expand All @@ -869,6 +878,9 @@ class Document extends DocumentModel {
.firstWhere((MapEntry<String, DocumentStatusEnum> entry) =>
entry.value == status)
.key;
if (verifiedJurisdiction != null) {
resultMap['verified_jurisdiction'] = verifiedJurisdiction!.toJson();
}

return resultMap;
}
Expand All @@ -878,11 +890,13 @@ class Document extends DocumentModel {
AuthenticatedWithIdv? authenticatedWithIdv,
DateTime? expiryDate,
DocumentStatusEnum? status,
VerifiedJurisdiction? verifiedJurisdiction,
}) =>
Document(
authenticatedWithIdv: authenticatedWithIdv ?? this.authenticatedWithIdv,
expiryDate: expiryDate ?? this.expiryDate,
status: status ?? this.status,
verifiedJurisdiction: verifiedJurisdiction ?? this.verifiedJurisdiction,
);
}

Expand Down Expand Up @@ -1018,6 +1032,138 @@ class AuthenticatedWithIdv extends AuthenticatedWithIdvModel {
);
}

/// Verified jurisdiction model class.
abstract class VerifiedJurisdictionModel {
/// Initializes Verified jurisdiction model class .
const VerifiedJurisdictionModel({
this.bvi,
this.dsl,
this.iom,
this.labuan,
this.malta,
this.maltainvest,
this.samoa,
this.samoaVirtual,
this.svg,
this.vanuatu,
this.virtual,
});

/// This represents whether the client is allowed or not to create an account under this jurisdiction
final bool? bvi;

/// This represents whether the client is allowed or not to create an account under this jurisdiction
final bool? dsl;

/// This represents whether the client is allowed or not to create an account under this jurisdiction
final bool? iom;

/// This represents whether the client is allowed or not to create an account under this jurisdiction
final bool? labuan;

/// This represents whether the client is allowed or not to create an account under this jurisdiction
final bool? malta;

/// This represents whether the client is allowed or not to create an account under this jurisdiction
final bool? maltainvest;

/// This represents whether the client is allowed or not to create an account under this jurisdiction
final bool? samoa;

/// This represents whether the client is allowed or not to create an account under this jurisdiction
final bool? samoaVirtual;

/// This represents whether the client is allowed or not to create an account under this jurisdiction
final bool? svg;

/// This represents whether the client is allowed or not to create an account under this jurisdiction
final bool? vanuatu;

/// This represents whether the client is allowed or not to create an account under this jurisdiction
final bool? virtual;
}

/// Verified jurisdiction class.
class VerifiedJurisdiction extends VerifiedJurisdictionModel {
/// Initializes Verified jurisdiction class.
const VerifiedJurisdiction({
super.bvi,
super.dsl,
super.iom,
super.labuan,
super.malta,
super.maltainvest,
super.samoa,
super.samoaVirtual,
super.svg,
super.vanuatu,
super.virtual,
});

/// Creates an instance from JSON.
factory VerifiedJurisdiction.fromJson(Map<String, dynamic> json) =>
VerifiedJurisdiction(
bvi: getBool(json['bvi']),
dsl: getBool(json['dsl']),
iom: getBool(json['iom']),
labuan: getBool(json['labuan']),
malta: getBool(json['malta']),
maltainvest: getBool(json['maltainvest']),
samoa: getBool(json['samoa']),
samoaVirtual: getBool(json['samoa-virtual']),
svg: getBool(json['svg']),
vanuatu: getBool(json['vanuatu']),
virtual: getBool(json['virtual']),
);

/// Converts an instance to JSON.
Map<String, dynamic> toJson() {
final Map<String, dynamic> resultMap = <String, dynamic>{};

resultMap['bvi'] = bvi;
resultMap['dsl'] = dsl;
resultMap['iom'] = iom;
resultMap['labuan'] = labuan;
resultMap['malta'] = malta;
resultMap['maltainvest'] = maltainvest;
resultMap['samoa'] = samoa;
resultMap['samoa-virtual'] = samoaVirtual;
resultMap['svg'] = svg;
resultMap['vanuatu'] = vanuatu;
resultMap['virtual'] = virtual;

return resultMap;
}

/// Creates a copy of instance with given parameters.
VerifiedJurisdiction copyWith({
bool? bvi,
bool? dsl,
bool? iom,
bool? labuan,
bool? malta,
bool? maltainvest,
bool? samoa,
bool? samoaVirtual,
bool? svg,
bool? vanuatu,
bool? virtual,
}) =>
VerifiedJurisdiction(
bvi: bvi ?? this.bvi,
dsl: dsl ?? this.dsl,
iom: iom ?? this.iom,
labuan: labuan ?? this.labuan,
malta: malta ?? this.malta,
maltainvest: maltainvest ?? this.maltainvest,
samoa: samoa ?? this.samoa,
samoaVirtual: samoaVirtual ?? this.samoaVirtual,
svg: svg ?? this.svg,
vanuatu: vanuatu ?? this.vanuatu,
virtual: virtual ?? this.virtual,
);
}

/// Identity model class.
abstract class IdentityModel {
/// Initializes Identity model class .
Expand Down Expand Up @@ -1157,6 +1303,7 @@ abstract class IdvModel {
const IdvModel({
this.expiryDate,
this.lastRejected,
this.reportAvailable,
this.reportedProperties,
this.status,
this.submissionsLeft,
Expand All @@ -1168,6 +1315,9 @@ abstract class IdvModel {
/// Show the last IDV reported reasons for the rejected cases
final List<String>? lastRejected;

/// Indicate if the verification report was returned by the provider
final bool? reportAvailable;

/// Shows the latest document properties detected and reported by IDVS
final Map<String, dynamic>? reportedProperties;

Expand All @@ -1184,6 +1334,7 @@ class Idv extends IdvModel {
const Idv({
super.expiryDate,
super.lastRejected,
super.reportAvailable,
super.reportedProperties,
super.status,
super.submissionsLeft,
Expand All @@ -1199,6 +1350,7 @@ class Idv extends IdvModel {
(dynamic item) => item,
),
),
reportAvailable: getBool(json['report_available']),
reportedProperties: json['reported_properties'],
status:
json['status'] == null ? null : idvStatusEnumMapper[json['status']],
Expand All @@ -1217,6 +1369,7 @@ class Idv extends IdvModel {
)
.toList();
}
resultMap['report_available'] = reportAvailable;
resultMap['reported_properties'] = reportedProperties;
resultMap['status'] = idvStatusEnumMapper.entries
.firstWhere(
Expand All @@ -1231,13 +1384,15 @@ class Idv extends IdvModel {
Idv copyWith({
DateTime? expiryDate,
List<String>? lastRejected,
bool? reportAvailable,
Map<String, dynamic>? reportedProperties,
IdvStatusEnum? status,
int? submissionsLeft,
}) =>
Idv(
expiryDate: expiryDate ?? this.expiryDate,
lastRejected: lastRejected ?? this.lastRejected,
reportAvailable: reportAvailable ?? this.reportAvailable,
reportedProperties: reportedProperties ?? this.reportedProperties,
status: status ?? this.status,
submissionsLeft: submissionsLeft ?? this.submissionsLeft,
Expand Down
17 changes: 11 additions & 6 deletions lib/api/response/proposal_open_contract_response_result.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// ignore_for_file: prefer_single_quotes, unnecessary_import, unused_import

import 'package:equatable/equatable.dart';

import 'package:flutter_deriv_api/api/exceptions/exceptions.dart';
import 'package:flutter_deriv_api/api/models/base_exception_model.dart';
import 'package:flutter_deriv_api/api/models/enums.dart';
Expand Down Expand Up @@ -163,14 +161,21 @@ class ProposalOpenContractResponse extends ProposalOpenContractResponseModel {
/// Default be 0 for 'sell at market'.
/// Throws a [BaseAPIException] if API response contains an error
static Future<SellResponse> sell(
{required int contractId, double price = 0}) =>
SellResponse.sellContract(SellRequest(sell: contractId, price: price));
{required int contractId, double price = 0, String? loginId}) =>
SellResponse.sellContract(SellRequest(
sell: contractId,
price: price,
loginid: loginId,
));

/// Cancels this contract
///
/// Throws a [BaseAPIException] if API response contains an error
static Future<CancelResponse> cancel(int contractId) =>
CancelResponse.cancelContract(CancelRequest(cancel: contractId));
static Future<CancelResponse> cancel(int contractId, {String? loginId}) =>
CancelResponse.cancelContract(CancelRequest(
cancel: contractId,
loginid: loginId,
));

/// Creates a copy of instance with given parameters.
ProposalOpenContractResponse copyWith({
Expand Down
9 changes: 6 additions & 3 deletions lib/api/response/topup_virtual_response_result.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// ignore_for_file: prefer_single_quotes, unnecessary_import, unused_import

import 'package:build/build.dart';
import 'package:equatable/equatable.dart';

import 'package:flutter_deriv_api/api/exceptions/exceptions.dart';
Expand Down Expand Up @@ -55,11 +56,13 @@ class TopupVirtualResponse extends TopupVirtualResponseModel {
///
/// For parameters information refer to [TopupVirtualRequest].
/// Throws a [BaseAPIException] if API response contains an error
static Future<TopupVirtualResponse> topUp([
static Future<TopupVirtualResponse> topUp({
TopupVirtualRequest? request,
]) async {
String? loginId,
}) async {
final TopupVirtualReceive response = await _api.call(
request: request ?? const TopupVirtualRequest(),
request: request?.copyWith(loginid: loginId) ??
TopupVirtualRequest(loginid: loginId),
);

checkException(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"methods": "static final BaseAPI _api = Injector()<BaseAPI>();\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<TopupVirtualResponse> topUp([\n TopupVirtualRequest? request,\n ]) async {\n final TopupVirtualReceive response = await _api.call(\n request: request ?? const TopupVirtualRequest(),\n );\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return TopupVirtualResponse.fromJson(response.topupVirtual);\n }",
"methods": "static final BaseAPI _api = Injector()<BaseAPI>();\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<TopupVirtualResponse> topUp({\n TopupVirtualRequest? request,\n String? loginId, \n}) async {\n final TopupVirtualReceive response = await _api.call(\n request: request?.copyWith(loginid: loginId) ?? TopupVirtualRequest(loginid: loginId),\n );\n\n checkException(\n response: response,\n exceptionCreator: ({BaseExceptionModel? baseExceptionModel}) =>\n BaseAPIException(baseExceptionModel: baseExceptionModel),\n );\n\n return TopupVirtualResponse.fromJson(response.topupVirtual);\n }",
"imports": "import 'package:flutter_deriv_api/api/exceptions/exceptions.dart';\nimport 'package:flutter_deriv_api/api/models/base_exception_model.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/topup_virtual_receive.dart';\nimport 'package:flutter_deriv_api/basic_api/generated/topup_virtual_send.dart';\nimport 'package:flutter_deriv_api/helpers/helpers.dart';\nimport 'package:flutter_deriv_api/services/connection/api_manager/base_api.dart';\nimport 'package:deriv_dependency_injector/dependency_injector.dart';\n"
}
Loading
Loading