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

updated get settings response and send #352

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion bom-core
142 changes: 142 additions & 0 deletions lib/api/response/get_settings_response_result.dart
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ abstract class GetSettingsModel {
this.email,
this.emailConsent,
this.employmentStatus,
this.fatcaDeclaration,
this.featureFlag,
this.firstName,
this.hasSecretAnswer,
Expand All @@ -213,13 +214,16 @@ abstract class GetSettingsModel {
this.lastName,
this.nonPepDeclaration,
this.phone,
this.phoneNumberVerification,
this.placeOfBirth,
this.preferredLanguage,
this.requestProfessionalStatus,
this.residence,
this.salutation,
this.taxIdentificationNumber,
this.taxResidence,
this.tinSkipped,
this.tncStatus,
this.tradingHub,
this.userHash,
});
Expand Down Expand Up @@ -275,6 +279,9 @@ abstract class GetSettingsModel {
/// Employment Status.
final EmploymentStatusEnum? employmentStatus;

/// Indicates client's self-declaration for FATCA.
final int? fatcaDeclaration;

/// Contains features that are enabled or disabled for this user
final FeatureFlag? featureFlag;

Expand All @@ -299,6 +306,9 @@ abstract class GetSettingsModel {
/// Telephone (note: Only available for users who have at least one real account)
final String? phone;

/// The status of the Phone Number Verification.
final PhoneNumberVerification? phoneNumberVerification;

/// Place of birth, 2-letter country code.
final String? placeOfBirth;

Expand All @@ -320,6 +330,12 @@ abstract class GetSettingsModel {
/// Residence for tax purpose. Comma separated iso country code if multiple jurisdictions. Only applicable for real money account.
final String? taxResidence;

/// [Optional] Whether the client has skipped the TIN form. Only applicable for real money account.
final bool? tinSkipped;

/// Terms and condition status tells us whether all the accounts of this user has accepted the latest T&C version.
final Map<String, dynamic>? tncStatus;

/// Boolean value 1 or 0, indicating if client has enabled the Trading Hub dashboard
final int? tradingHub;

Expand Down Expand Up @@ -348,6 +364,7 @@ class GetSettings extends GetSettingsModel {
super.email,
super.emailConsent,
super.employmentStatus,
super.fatcaDeclaration,
super.featureFlag,
super.firstName,
super.hasSecretAnswer,
Expand All @@ -356,13 +373,16 @@ class GetSettings extends GetSettingsModel {
super.lastName,
super.nonPepDeclaration,
super.phone,
super.phoneNumberVerification,
super.placeOfBirth,
super.preferredLanguage,
super.requestProfessionalStatus,
super.residence,
super.salutation,
super.taxIdentificationNumber,
super.taxResidence,
super.tinSkipped,
super.tncStatus,
super.tradingHub,
super.userHash,
});
Expand All @@ -389,6 +409,7 @@ class GetSettings extends GetSettingsModel {
employmentStatus: json['employment_status'] == null
? null
: employmentStatusEnumMapper[json['employment_status']],
fatcaDeclaration: json['fatca_declaration'],
featureFlag: json['feature_flag'] == null
? null
: FeatureFlag.fromJson(json['feature_flag']),
Expand All @@ -406,13 +427,19 @@ class GetSettings extends GetSettingsModel {
lastName: json['last_name'],
nonPepDeclaration: getBool(json['non_pep_declaration']),
phone: json['phone'],
phoneNumberVerification: json['phone_number_verification'] == null
? null
: PhoneNumberVerification.fromJson(
json['phone_number_verification']),
placeOfBirth: json['place_of_birth'],
preferredLanguage: json['preferred_language'],
requestProfessionalStatus: getBool(json['request_professional_status']),
residence: json['residence'],
salutation: json['salutation'],
taxIdentificationNumber: json['tax_identification_number'],
taxResidence: json['tax_residence'],
tinSkipped: getBool(json['tin_skipped']),
tncStatus: json['tnc_status'],
tradingHub: json['trading_hub'],
userHash: json['user_hash'],
);
Expand Down Expand Up @@ -442,6 +469,7 @@ class GetSettings extends GetSettingsModel {
.firstWhere((MapEntry<String, EmploymentStatusEnum> entry) =>
entry.value == employmentStatus)
.key;
resultMap['fatca_declaration'] = fatcaDeclaration;
if (featureFlag != null) {
resultMap['feature_flag'] = featureFlag!.toJson();
}
Expand All @@ -458,13 +486,19 @@ class GetSettings extends GetSettingsModel {
resultMap['last_name'] = lastName;
resultMap['non_pep_declaration'] = nonPepDeclaration;
resultMap['phone'] = phone;
if (phoneNumberVerification != null) {
resultMap['phone_number_verification'] =
phoneNumberVerification!.toJson();
}
resultMap['place_of_birth'] = placeOfBirth;
resultMap['preferred_language'] = preferredLanguage;
resultMap['request_professional_status'] = requestProfessionalStatus;
resultMap['residence'] = residence;
resultMap['salutation'] = salutation;
resultMap['tax_identification_number'] = taxIdentificationNumber;
resultMap['tax_residence'] = taxResidence;
resultMap['tin_skipped'] = tinSkipped;
resultMap['tnc_status'] = tncStatus;
resultMap['trading_hub'] = tradingHub;
resultMap['user_hash'] = userHash;

Expand All @@ -490,6 +524,7 @@ class GetSettings extends GetSettingsModel {
String? email,
bool? emailConsent,
EmploymentStatusEnum? employmentStatus,
int? fatcaDeclaration,
FeatureFlag? featureFlag,
String? firstName,
bool? hasSecretAnswer,
Expand All @@ -498,13 +533,16 @@ class GetSettings extends GetSettingsModel {
String? lastName,
bool? nonPepDeclaration,
String? phone,
PhoneNumberVerification? phoneNumberVerification,
String? placeOfBirth,
String? preferredLanguage,
bool? requestProfessionalStatus,
String? residence,
String? salutation,
String? taxIdentificationNumber,
String? taxResidence,
bool? tinSkipped,
Map<String, dynamic>? tncStatus,
int? tradingHub,
String? userHash,
}) =>
Expand All @@ -527,6 +565,7 @@ class GetSettings extends GetSettingsModel {
email: email ?? this.email,
emailConsent: emailConsent ?? this.emailConsent,
employmentStatus: employmentStatus ?? this.employmentStatus,
fatcaDeclaration: fatcaDeclaration ?? this.fatcaDeclaration,
featureFlag: featureFlag ?? this.featureFlag,
firstName: firstName ?? this.firstName,
hasSecretAnswer: hasSecretAnswer ?? this.hasSecretAnswer,
Expand All @@ -536,6 +575,8 @@ class GetSettings extends GetSettingsModel {
lastName: lastName ?? this.lastName,
nonPepDeclaration: nonPepDeclaration ?? this.nonPepDeclaration,
phone: phone ?? this.phone,
phoneNumberVerification:
phoneNumberVerification ?? this.phoneNumberVerification,
placeOfBirth: placeOfBirth ?? this.placeOfBirth,
preferredLanguage: preferredLanguage ?? this.preferredLanguage,
requestProfessionalStatus:
Expand All @@ -545,6 +586,8 @@ class GetSettings extends GetSettingsModel {
taxIdentificationNumber:
taxIdentificationNumber ?? this.taxIdentificationNumber,
taxResidence: taxResidence ?? this.taxResidence,
tinSkipped: tinSkipped ?? this.tinSkipped,
tncStatus: tncStatus ?? this.tncStatus,
tradingHub: tradingHub ?? this.tradingHub,
userHash: userHash ?? this.userHash,
);
Expand Down Expand Up @@ -590,3 +633,102 @@ class FeatureFlag extends FeatureFlagModel {
wallet: wallet ?? this.wallet,
);
}

/// Phone number verification model class.
abstract class PhoneNumberVerificationModel {
/// Initializes Phone number verification model class .
const PhoneNumberVerificationModel({
required this.verified,
this.challengeAttemptsRemaining,
this.nextAttempt,
this.nextEmailAttempt,
this.nextVerifyAttempt,
this.sessionTimestamp,
this.verifyAttemptsRemaining,
});

/// Indicates the verification status of the client's phone number.
final bool verified;

/// Indicates the attempts remaining for /phone_number_challenge
final int? challengeAttemptsRemaining;

/// (Optional) Indicates the timestamp for the next verification attempt
final int? nextAttempt;

/// (Optional) Indicates the timestamp for the next email verification attempt
final int? nextEmailAttempt;

/// (Optional) Indicates the timestamp for the next verify attempt
final int? nextVerifyAttempt;

/// (Optional) Indicates the timestamp for the current's session email code expiry
final DateTime? sessionTimestamp;

/// Indicates the attempts remaining for /phone_number_verification
final int? verifyAttemptsRemaining;
}

/// Phone number verification class.
class PhoneNumberVerification extends PhoneNumberVerificationModel {
/// Initializes Phone number verification class.
const PhoneNumberVerification({
required super.verified,
super.challengeAttemptsRemaining,
super.nextAttempt,
super.nextEmailAttempt,
super.nextVerifyAttempt,
super.sessionTimestamp,
super.verifyAttemptsRemaining,
});

/// Creates an instance from JSON.
factory PhoneNumberVerification.fromJson(Map<String, dynamic> json) =>
PhoneNumberVerification(
verified: getBool(json['verified'])!,
challengeAttemptsRemaining: json['challenge_attempts_remaining'],
nextAttempt: json['next_attempt'],
nextEmailAttempt: json['next_email_attempt'],
nextVerifyAttempt: json['next_verify_attempt'],
sessionTimestamp: getDateTime(json['session_timestamp']),
verifyAttemptsRemaining: json['verify_attempts_remaining'],
);

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

resultMap['verified'] = verified;
resultMap['challenge_attempts_remaining'] = challengeAttemptsRemaining;
resultMap['next_attempt'] = nextAttempt;
resultMap['next_email_attempt'] = nextEmailAttempt;
resultMap['next_verify_attempt'] = nextVerifyAttempt;
resultMap['session_timestamp'] =
getSecondsSinceEpochDateTime(sessionTimestamp);
resultMap['verify_attempts_remaining'] = verifyAttemptsRemaining;

return resultMap;
}

/// Creates a copy of instance with given parameters.
PhoneNumberVerification copyWith({
bool? verified,
int? challengeAttemptsRemaining,
int? nextAttempt,
int? nextEmailAttempt,
int? nextVerifyAttempt,
DateTime? sessionTimestamp,
int? verifyAttemptsRemaining,
}) =>
PhoneNumberVerification(
verified: verified ?? this.verified,
challengeAttemptsRemaining:
challengeAttemptsRemaining ?? this.challengeAttemptsRemaining,
nextAttempt: nextAttempt ?? this.nextAttempt,
nextEmailAttempt: nextEmailAttempt ?? this.nextEmailAttempt,
nextVerifyAttempt: nextVerifyAttempt ?? this.nextVerifyAttempt,
sessionTimestamp: sessionTimestamp ?? this.sessionTimestamp,
verifyAttemptsRemaining:
verifyAttemptsRemaining ?? this.verifyAttemptsRemaining,
);
}
2 changes: 1 addition & 1 deletion lib/basic_api/generated/get_settings_send.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class GetSettingsRequest extends Request {
/// Must be `true`
final bool? getSettings;

/// [Optional] The login id of the user. If left unspecified, it defaults to the initial authorized token's login id.
/// [Optional] The login id of the user. Mandatory when multiple tokens were provided during authorize.
final String? loginid;

/// Converts this instance to JSON
Expand Down
19 changes: 16 additions & 3 deletions lib/basic_api/generated/set_settings_send.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class SetSettingsRequest extends Request {
this.setSettings = true,
this.taxIdentificationNumber,
this.taxResidence,
this.tinSkipped,
this.tradingHub,
super.msgType = 'set_settings',
super.passthrough,
Expand Down Expand Up @@ -78,6 +79,8 @@ class SetSettingsRequest extends Request {
json['set_settings'] == null ? null : json['set_settings'] == 1,
taxIdentificationNumber: json['tax_identification_number'] as String?,
taxResidence: json['tax_residence'] as String?,
tinSkipped:
json['tin_skipped'] == null ? null : json['tin_skipped'] == 1,
tradingHub:
json['trading_hub'] == null ? null : json['trading_hub'] == 1,
passthrough: json['passthrough'] as Map<String, dynamic>?,
Expand Down Expand Up @@ -123,13 +126,13 @@ class SetSettingsRequest extends Request {
/// [Optional] Enable or disable one or multiple features.
final Map<String, dynamic>? featureFlag;

/// [Optional] Within 2-50 characters, use only letters, spaces, hyphens, full-stops or apostrophes (can only be changed on unauthenticated svg accounts).
/// [Optional] Within 1-50 characters, use only letters, spaces, hyphens, full-stops or apostrophes (can only be changed on unauthenticated svg accounts).
final String? firstName;

/// [Optional] Within 2-50 characters, use only letters, spaces, hyphens, full-stops or apostrophes (can only be changed on unauthenticated svg accounts).
/// [Optional] Within 1-50 characters, use only letters, spaces, hyphens, full-stops or apostrophes (can only be changed on unauthenticated svg accounts).
final String? lastName;

/// [Optional] The login id of the user. If left unspecified, it defaults to the initial authorized token's login id.
/// [Optional] The login id of the user. Mandatory when multiple tokens were provided during authorize.
final String? loginid;

/// [Optional] Indicates client's self-declaration of not being a PEP/RCA (Politically Exposed Person/Relatives and Close Associates). Effective for real accounts only.
Expand Down Expand Up @@ -168,6 +171,9 @@ class SetSettingsRequest extends Request {
/// [Optional] 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;

/// [Optional] Whether the client has skipped the TIN form. Only applicable for real money account.
final bool? tinSkipped;

/// [Optional] Enable/Disable Trading Hub dashboard
final bool? tradingHub;

Expand Down Expand Up @@ -218,6 +224,11 @@ class SetSettingsRequest extends Request {
: 0,
'tax_identification_number': taxIdentificationNumber,
'tax_residence': taxResidence,
'tin_skipped': tinSkipped == null
? null
: tinSkipped!
? 1
: 0,
'trading_hub': tradingHub == null
? null
: tradingHub!
Expand Down Expand Up @@ -258,6 +269,7 @@ class SetSettingsRequest extends Request {
bool? setSettings,
String? taxIdentificationNumber,
String? taxResidence,
bool? tinSkipped,
bool? tradingHub,
Map<String, dynamic>? passthrough,
int? reqId,
Expand Down Expand Up @@ -293,6 +305,7 @@ class SetSettingsRequest extends Request {
taxIdentificationNumber:
taxIdentificationNumber ?? this.taxIdentificationNumber,
taxResidence: taxResidence ?? this.taxResidence,
tinSkipped: tinSkipped ?? this.tinSkipped,
tradingHub: tradingHub ?? this.tradingHub,
passthrough: passthrough ?? this.passthrough,
reqId: reqId ?? this.reqId,
Expand Down
Loading