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

hamed/add_raw_methods_for_p2p #232

Merged
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
19 changes: 16 additions & 3 deletions lib/api/response/authorize_response_result.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ 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
static Future<AuthorizeResponse> authorizeMethod(
AuthorizeRequest request) async {
/// Throws an [AuthorizeException] if API response contains an error.
static Future<AuthorizeReceive> authorizeMethodRaw(
AuthorizeRequest request,
) async {
final AuthorizeReceive response = await _api.call(
request: request,
);
Expand All @@ -68,6 +69,18 @@ class AuthorizeResponse extends AuthorizeResponseModel {
AuthorizeException(baseExceptionModel: baseExceptionModel),
);

return response;
}

/// 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.
static Future<AuthorizeResponse> authorizeMethod(
AuthorizeRequest request,
) async {
final AuthorizeReceive response = await authorizeMethodRaw(request);

return AuthorizeResponse.fromJson(response.authorize);
}

Expand Down
22 changes: 18 additions & 4 deletions lib/api/response/exchange_rates_response_result.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ 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
static Future<ExchangeRates?> fetchExchangeRates(
/// Throws an [ExchangeException] if API response contains an error.
static Future<ExchangeRatesReceive?> fetchExchangeRatesRaw(
ExchangeRatesRequest request,
) async {
final ExchangeRatesReceive response = await _api.call(request: request);
Expand All @@ -81,9 +81,21 @@ class ExchangeRatesResponse extends ExchangeRatesResponseModel {
ExchangeException(baseExceptionModel: baseExceptionModel),
);

return response.exchangeRates == null
return response;
}

/// 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.
static Future<ExchangeRates?> fetchExchangeRates(
ExchangeRatesRequest request,
) async {
final ExchangeRatesReceive? response = await fetchExchangeRatesRaw(request);

return response?.exchangeRates == null
? null
: ExchangeRates.fromJson(response.exchangeRates!);
: ExchangeRates.fromJson(response!.exchangeRates!);
}

/// Creates a copy of instance with given parameters.
Expand All @@ -96,6 +108,7 @@ class ExchangeRatesResponse extends ExchangeRatesResponseModel {
subscription: subscription ?? this.subscription,
);
}

/// Exchange rates model class.
abstract class ExchangeRatesModel {
/// Initializes Exchange rates model class .
Expand Down Expand Up @@ -165,6 +178,7 @@ class ExchangeRates extends ExchangeRatesModel {
rates: rates ?? this.rates,
);
}

/// Subscription model class.
abstract class SubscriptionModel {
/// Initializes Subscription model class .
Expand Down
31 changes: 29 additions & 2 deletions lib/api/response/get_account_status_response_result.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,11 @@ class GetAccountStatusResponse extends GetAccountStatusResponseModel {

static final BaseAPI _api = Injector.getInjector().get<BaseAPI>()!;

/// Gets the account's status
static Future<GetAccountStatusResponse> fetchAccountStatus() async {
/// Gets the account's status.
///
/// For parameters information refer to [GetAccountStatusRequest].
/// Throws an [AccountStatusException] if API response contains an error.
static Future<GetAccountStatusReceive> fetchAccountStatusRaw() async {
final GetAccountStatusReceive response = await _api.call(
request: const GetAccountStatusRequest(),
);
Expand All @@ -65,6 +68,16 @@ class GetAccountStatusResponse extends GetAccountStatusResponseModel {
AccountStatusException(baseExceptionModel: baseExceptionModel),
);

return response;
}

/// Gets the account's status.
///
/// For parameters information refer to [GetAccountStatusRequest].
/// Throws an [AccountStatusException] if API response contains an error.
static Future<GetAccountStatusResponse> fetchAccountStatus() async {
final GetAccountStatusReceive response = await fetchAccountStatusRaw();

return GetAccountStatusResponse.fromJson(response.getAccountStatus);
}

Expand Down Expand Up @@ -226,6 +239,7 @@ enum SocialIdentityProviderEnum {
/// apple.
apple,
}

/// Get account status model class.
abstract class GetAccountStatusModel {
/// Initializes Get account status model class .
Expand Down Expand Up @@ -431,6 +445,7 @@ class GetAccountStatus extends GetAccountStatusModel {
socialIdentityProvider ?? this.socialIdentityProvider,
);
}

/// Currency config property model class.
abstract class CurrencyConfigPropertyModel {
/// Initializes Currency config property model class .
Expand Down Expand Up @@ -485,6 +500,7 @@ class CurrencyConfigProperty extends CurrencyConfigPropertyModel {
isWithdrawalSuspended ?? this.isWithdrawalSuspended,
);
}

/// Authentication model class.
abstract class AuthenticationModel {
/// Initializes Authentication model class .
Expand Down Expand Up @@ -604,6 +620,7 @@ class Authentication extends AuthenticationModel {
ownership: ownership ?? this.ownership,
);
}

/// Attempts model class.
abstract class AttemptsModel {
/// Initializes Attempts model class .
Expand Down Expand Up @@ -678,6 +695,7 @@ class Attempts extends AttemptsModel {
latest: latest ?? this.latest,
);
}

/// History item model class.
abstract class HistoryItemModel {
/// Initializes History item model class .
Expand Down Expand Up @@ -764,6 +782,7 @@ class HistoryItem extends HistoryItemModel {
timestamp: timestamp ?? this.timestamp,
);
}

/// Document model class.
abstract class DocumentModel {
/// Initializes Document model class .
Expand Down Expand Up @@ -821,6 +840,7 @@ class Document extends DocumentModel {
status: status ?? this.status,
);
}

/// Identity model class.
abstract class IdentityModel {
/// Initializes Identity model class .
Expand Down Expand Up @@ -892,6 +912,7 @@ class Identity extends IdentityModel {
status: status ?? this.status,
);
}

/// Services model class.
abstract class ServicesModel {
/// Initializes Services model class .
Expand Down Expand Up @@ -960,6 +981,7 @@ class Services extends ServicesModel {
onfido: onfido ?? this.onfido,
);
}

/// Idv model class.
abstract class IdvModel {
/// Initializes Idv model class .
Expand Down Expand Up @@ -1058,6 +1080,7 @@ class Idv extends IdvModel {
submissionsLeft: submissionsLeft ?? this.submissionsLeft,
);
}

/// Manual model class.
abstract class ManualModel {
/// Initializes Manual model class .
Expand Down Expand Up @@ -1105,6 +1128,7 @@ class Manual extends ManualModel {
status: status ?? this.status,
);
}

/// Onfido model class.
abstract class OnfidoModel {
/// Initializes Onfido model class .
Expand Down Expand Up @@ -1258,6 +1282,7 @@ class Onfido extends OnfidoModel {
submissionsLeft: submissionsLeft ?? this.submissionsLeft,
);
}

/// Income model class.
abstract class IncomeModel {
/// Initializes Income model class .
Expand Down Expand Up @@ -1315,6 +1340,7 @@ class Income extends IncomeModel {
status: status ?? this.status,
);
}

/// Ownership model class.
abstract class OwnershipModel {
/// Initializes Ownership model class .
Expand Down Expand Up @@ -1384,6 +1410,7 @@ class Ownership extends OwnershipModel {
status: status ?? this.status,
);
}

/// Requests item model class.
abstract class RequestsItemModel {
/// Initializes Requests item model class .
Expand Down
40 changes: 33 additions & 7 deletions lib/api/response/get_settings_response_result.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,11 @@ class GetSettingsResponse extends GetSettingsResponseModel {

static final BaseAPI _api = Injector.getInjector().get<BaseAPI>()!;

/// Gets user's settings (email, date of birth, address etc)
/// Gets user's settings (email, date of birth, address etc).
///
/// Throws an [AccountSettingsException] if API response contains an error
static Future<GetSettingsResponse> fetchAccountSetting([
/// For parameters information refer to [GetSettingsRequest].
/// Throws an [AccountSettingsException] if API response contains an error.
static Future<GetSettingsReceive> fetchAccountSettingRaw([
GetSettingsRequest? request,
]) async {
final GetSettingsReceive response = await _api.call(
Expand All @@ -72,13 +73,14 @@ class GetSettingsResponse extends GetSettingsResponseModel {
AccountSettingsException(baseExceptionModel: baseExceptionModel),
);

return GetSettingsResponse.fromJson(response.getSettings);
return response;
}

/// Changes the user's settings with parameters specified as [SetSettingsRequest]
/// Gets user's settings (email, date of birth, address etc).
///
/// Throws an [AccountSettingsException] if API response contains an error
static Future<SetSettingsResponse> changeAccountSetting(
/// For parameters information refer to [GetSettingsRequest].
/// Throws an [AccountSettingsException] if API response contains an error.
static Future<SetSettingsReceive> changeAccountSettingRaw(
SetSettingsRequest request,
) async {
final SetSettingsReceive response = await _api.call(request: request);
Expand All @@ -89,6 +91,28 @@ class GetSettingsResponse extends GetSettingsResponseModel {
AccountSettingsException(baseExceptionModel: baseExceptionModel),
);

return response;
}

/// Gets user's settings (email, date of birth, address etc).
///
/// Throws an [AccountSettingsException] if API response contains an error.
static Future<GetSettingsResponse> fetchAccountSetting([
GetSettingsRequest? request,
]) async {
final GetSettingsReceive response = await fetchAccountSettingRaw(request);

return GetSettingsResponse.fromJson(response.getSettings);
}

/// Changes the user's settings with parameters specified as [SetSettingsRequest].
///
/// Throws an [AccountSettingsException] if API response contains an error.
static Future<SetSettingsResponse> changeAccountSetting(
SetSettingsRequest request,
) async {
final SetSettingsReceive response = await changeAccountSettingRaw(request);

return SetSettingsResponse(setSettings: response.setSettings ?? 0);
}

Expand Down Expand Up @@ -132,6 +156,7 @@ class GetSettingsResponse extends GetSettingsResponseModel {
getSettings: getSettings ?? this.getSettings,
);
}

/// Get settings model class.
abstract class GetSettingsModel {
/// Initializes Get settings model class .
Expand Down Expand Up @@ -494,6 +519,7 @@ class GetSettings extends GetSettingsModel {
userHash: userHash ?? this.userHash,
);
}

/// Feature flag model class.
abstract class FeatureFlagModel {
/// Initializes Feature flag model class .
Expand Down
21 changes: 14 additions & 7 deletions lib/api/response/logout_response_result.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,27 @@ 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
static Future<LogoutResponse> logoutMethod([
LogoutRequest? request,
]) async {
final LogoutReceive response = await _api.call(
request: request ?? const LogoutRequest(),
);
/// Throws an [AuthorizeException] if API response contains an error.
static Future<LogoutReceive> logoutMethodRaw([LogoutRequest? request]) async {
final LogoutReceive response =
await _api.call(request: request ?? const LogoutRequest());

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

return response;
}

/// Logs out from the web-socket's session.
///
/// For parameters information refer to [LogoutRequest].
/// Throws an [AuthorizeException] if API response contains an error.
static Future<LogoutResponse> logoutMethod([LogoutRequest? request]) async {
final LogoutReceive response = await logoutMethodRaw(request);

return LogoutResponse.fromJson(response.logout);
}

Expand Down
Loading