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

Sorted parameters for named constructors #363

Merged
merged 8 commits into from
Apr 8, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:ably_flutter/ably_flutter.dart' as ably;
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:rxdart/rxdart.dart';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import 'package:ably_flutter_example/ui/bool_stream_button.dart';
import 'package:device_info_plus/device_info_plus.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:fluttertoast/fluttertoast.dart';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'package:ably_flutter/ably_flutter.dart' as ably;
import 'package:ably_flutter_example/push_notifications/push_notification_service.dart';
import 'package:ably_flutter_example/ui/text_row.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class PushNotificationsDeviceInformation extends StatelessWidget {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import 'package:ably_flutter/ably_flutter.dart' as ably;
import 'package:ably_flutter_example/push_notifications/push_notification_service.dart';
import 'package:ably_flutter_example/ui/bool_stream_button.dart';
import 'package:ably_flutter_example/ui/text_row.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';

Expand Down
1 change: 0 additions & 1 deletion example/lib/ui/rest_sliver.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import 'package:ably_flutter_example/constants.dart';
import 'package:ably_flutter_example/ui/paginated_result_viewer.dart';
import 'package:ably_flutter_example/ui/text_row.dart';
import 'package:ably_flutter_example/ui/utilities.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';

Expand Down
1 change: 0 additions & 1 deletion example/lib/ui/system_details_sliver.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'package:ably_flutter/ably_flutter.dart' as ably;
import 'package:ably_flutter_example/constants.dart';
import 'package:ably_flutter_example/ui/api_key_service.dart';
import 'package:ably_flutter_example/ui/text_row.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
Expand Down
6 changes: 3 additions & 3 deletions lib/src/authentication/src/auth.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,25 @@ abstract class Auth {
///
/// https://docs.ably.com/client-lib-development-guide/features/#RSA10
Future<TokenDetails> authorize({
TokenParams? tokenParams,
AuthOptions? authOptions,
TokenParams? tokenParams,
});

/// Returns a signed TokenRequest object that can be used to obtain
/// a token from Ably.
///
/// https://docs.ably.com/client-lib-development-guide/features/#RSA9
Future<TokenRequest> createTokenRequest({
TokenParams? tokenParams,
AuthOptions? authOptions,
TokenParams? tokenParams,
});

/// Implicitly creates a TokenRequest if required and requests a token
/// from Ably if required. Returns a [TokenDetails] object.
///
/// https://docs.ably.com/client-lib-development-guide/features/#RSA8
Future<TokenDetails> requestToken({
TokenParams? tokenParams,
AuthOptions? authOptions,
TokenParams? tokenParams,
});
}
8 changes: 4 additions & 4 deletions lib/src/authentication/src/auth_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ abstract class AuthOptions {
/// Initializes an instance without any defaults
AuthOptions({
this.authCallback,
this.authUrl,
this.authMethod,
this.key,
this.tokenDetails,
this.authHeaders,
this.authMethod,
this.authParams,
this.authUrl,
this.key,
this.queryTime,
this.tokenDetails,
this.useTokenAuth,
}) {
if (key != null && !key!.contains(':')) {
Expand Down
72 changes: 36 additions & 36 deletions lib/src/authentication/src/client_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -190,41 +190,41 @@ class ClientOptions extends AuthOptions {
/// Initializes an instance with defaults
ClientOptions({
AuthCallback? authCallback,
String? authUrl,
String? authMethod,
String? key,
TokenDetails? tokenDetails,
Map<String, String>? authHeaders,
String? authMethod,
Map<String, String>? authParams,
bool? queryTime,
bool? useTokenAuth,
this.clientId,
this.logHandler,
LogLevel? logLevel,
this.restHost,
this.realtimeHost,
this.port,
bool? tls,
this.tlsPort,
String? authUrl,
bool? autoConnect,
bool? useBinaryProtocol,
bool? queueMessages,
int? channelRetryTimeout,
this.clientId,
this.defaultTokenParams,
int? disconnectedRetryTimeout,
bool? echoMessages,
this.recover,
this.environment,
this.fallbackHosts,
int? fallbackRetryTimeout,
this.fallbackHostsUseDefault,
this.defaultTokenParams,
int? disconnectedRetryTimeout,
int? suspendedRetryTimeout,
this.idempotentRestPublishing,
this.transportParams,
int? httpMaxRetryCount,
int? httpOpenTimeout,
int? httpRequestTimeout,
int? httpMaxRetryCount,
this.idempotentRestPublishing,
String? key,
this.logHandler,
LogLevel? logLevel,
this.port,
bool? queryTime,
bool? queueMessages,
this.realtimeHost,
this.realtimeRequestTimeout,
int? fallbackRetryTimeout,
int? channelRetryTimeout,
this.recover,
this.restHost,
int? suspendedRetryTimeout,
bool? tls,
this.tlsPort,
this.transportParams,
TokenDetails? tokenDetails,
bool? useBinaryProtocol,
bool? useTokenAuth,
}) : super(
authCallback: authCallback,
authUrl: authUrl,
Expand All @@ -239,22 +239,22 @@ class ClientOptions extends AuthOptions {
/// These default value assignments are only required until
/// [ClientOptions.fromKey] is removed, because then defaults can be set
/// directly in the constructor invocation
this.logLevel = logLevel ?? this.logLevel;
this.tls = tls ?? this.tls;
this.autoConnect = autoConnect ?? this.autoConnect;
this.useBinaryProtocol = useBinaryProtocol ?? this.useBinaryProtocol;
this.queueMessages = queueMessages ?? this.queueMessages;
this.echoMessages = echoMessages ?? this.echoMessages;
this.channelRetryTimeout = channelRetryTimeout ?? this.channelRetryTimeout;
this.disconnectedRetryTimeout =
disconnectedRetryTimeout ?? this.disconnectedRetryTimeout;
this.suspendedRetryTimeout =
suspendedRetryTimeout ?? this.suspendedRetryTimeout;
this.httpOpenTimeout = httpOpenTimeout ?? this.httpOpenTimeout;
this.httpRequestTimeout = httpRequestTimeout ?? this.httpRequestTimeout;
this.httpMaxRetryCount = httpMaxRetryCount ?? this.httpMaxRetryCount;
this.echoMessages = echoMessages ?? this.echoMessages;
this.fallbackRetryTimeout =
fallbackRetryTimeout ?? this.fallbackRetryTimeout;
this.channelRetryTimeout = channelRetryTimeout ?? this.channelRetryTimeout;
this.httpMaxRetryCount = httpMaxRetryCount ?? this.httpMaxRetryCount;
this.httpOpenTimeout = httpOpenTimeout ?? this.httpOpenTimeout;
this.httpRequestTimeout = httpRequestTimeout ?? this.httpRequestTimeout;
this.logLevel = logLevel ?? this.logLevel;
this.queueMessages = queueMessages ?? this.queueMessages;
this.suspendedRetryTimeout =
suspendedRetryTimeout ?? this.suspendedRetryTimeout;
this.tls = tls ?? this.tls;
this.useBinaryProtocol = useBinaryProtocol ?? this.useBinaryProtocol;
}

/// initializes [ClientOptions] with a key and log level set to info
Expand Down
12 changes: 6 additions & 6 deletions lib/src/authentication/src/token_details.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:flutter/material.dart';
import 'package:meta/meta.dart';

/// Response to a `requestToken` request
///
Expand Down Expand Up @@ -37,19 +37,19 @@ class TokenDetails {
/// instantiates a [TokenDetails] with provided values
const TokenDetails(
this.token, {
this.expires,
this.issued,
this.capability,
this.clientId,
this.expires,
this.issued,
});

/// Creates an instance from the map
///
/// https://docs.ably.com/client-lib-development-guide/features/#TD7
TokenDetails.fromMap(Map<String, dynamic> map)
: token = map['token'] as String?,
: capability = map['capability'] as String?,
clientId = map['clientId'] as String?,
expires = map['expires'] as int?,
issued = map['issued'] as int?,
capability = map['capability'] as String?,
clientId = map['clientId'] as String?;
token = map['token'] as String?;
}
2 changes: 1 addition & 1 deletion lib/src/authentication/src/token_params.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:ably_flutter/ably_flutter.dart';
import 'package:flutter/cupertino.dart';
import 'package:meta/meta.dart';

/// A class providing parameters of a token request.
///
Expand Down
16 changes: 8 additions & 8 deletions lib/src/authentication/src/token_request.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,23 @@ class TokenRequest {

/// instantiates a [TokenRequest] with provided values
const TokenRequest({
this.keyName,
this.nonce,
this.capability,
this.clientId,
this.keyName,
this.mac,
this.capability,
this.nonce,
this.timestamp,
this.ttl,
});

/// spec: https://docs.ably.com/client-lib-development-guide/features/#TE7
TokenRequest.fromMap(Map<String, dynamic> map)
: keyName = map['keyName'] as String?,
nonce = map['nonce'] as String?,
mac = map['mac'] as String?,
capability = map['capability'] as String?,
: capability = map['capability'] as String?,
clientId = map['clientId'] as String?,
mac = map['mac'] as String?,
nonce = map['nonce'] as String?,
timestamp =
DateTime.fromMillisecondsSinceEpoch(map['timestamp'] as int),
ttl = map['ttl'] as int?;
ttl = map['ttl'] as int?,
keyName = map['keyName'] as String?;
}
6 changes: 3 additions & 3 deletions lib/src/error/src/ably_exception.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ class AblyException implements Exception {
/// initializes with no defaults
AblyException({
this.code,
this.message,
this.errorInfo,
this.message,
});

/// create AblyException from [PlatformException]
AblyException.fromPlatformException(PlatformException exception)
: code = exception.code,
message = exception.message,
errorInfo = exception.details as ErrorInfo?;
errorInfo = exception.details as ErrorInfo?,
message = exception.message;

@override
String toString() {
Expand Down
4 changes: 2 additions & 2 deletions lib/src/error/src/error_info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ class ErrorInfo {

/// instantiates a [ErrorInfo] with provided values
ErrorInfo({
this.cause,
this.code,
this.href,
this.message,
this.cause,
this.statusCode,
this.requestId,
this.statusCode,
});

@override
Expand Down
4 changes: 2 additions & 2 deletions lib/src/message/src/delta_extras.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class DeltaExtras {
/// create instance from a map
@protected
DeltaExtras.fromMap(Map value)
: from = value[TxDeltaExtras.from] as String?,
format = value[TxDeltaExtras.format] as String?;
: format = value[TxDeltaExtras.format] as String?,
from = value[TxDeltaExtras.from] as String?;

@override
bool operator ==(Object other) =>
Expand Down
26 changes: 13 additions & 13 deletions lib/src/message/src/message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,27 +49,27 @@ class Message {

/// Creates a message instance with [name], [data] and [clientId]
Message({
this.id,
this.name,
Object? data,
this.clientId,
this.connectionId,
this.timestamp,
Object? data,
this.encoding,
this.extras,
this.id,
this.name,
this.timestamp,
}) : _data = MessageData.fromValue(data);

@override
bool operator ==(Object other) =>
other is Message &&
other.id == id &&
other.name == name &&
other.clientId == clientId &&
other.connectionId == connectionId &&
other.data == data &&
other.extras == extras &&
other.encoding == encoding &&
other.clientId == clientId &&
other.timestamp == timestamp &&
other.connectionId == connectionId;
other.extras == extras &&
other.id == id &&
other.name == name &&
other.timestamp == timestamp;

@override
int get hashCode => '$id:'
Expand All @@ -89,9 +89,7 @@ class Message {
Message.fromEncoded(
Map<String, dynamic> jsonObject, [
RestChannelOptions? channelOptions,
]) : id = jsonObject['id'] as String?,
name = jsonObject['name'] as String?,
clientId = jsonObject['clientId'] as String?,
]) : clientId = jsonObject['clientId'] as String?,
connectionId = jsonObject['connectionId'] as String?,
_data = MessageData.fromValue(jsonObject['data']),
encoding = jsonObject['encoding'] as String?,
Expand All @@ -100,6 +98,8 @@ class Message {
jsonObject['extras'] as Map,
),
),
id = jsonObject['id'] as String?,
name = jsonObject['name'] as String?,
timestamp = jsonObject['timestamp'] != null
? DateTime.fromMillisecondsSinceEpoch(
jsonObject['timestamp'] as int,
Expand Down
4 changes: 2 additions & 2 deletions lib/src/message/src/presence_message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,26 +49,26 @@ class PresenceMessage {

/// instantiates presence message with
PresenceMessage({
this.id,
this.action,
this.clientId,
this.connectionId,
Object? data,
this.encoding,
this.extras,
this.id,
this.timestamp,
}) : _data = MessageData.fromValue(data);

@override
bool operator ==(Object other) =>
other is PresenceMessage &&
other.id == id &&
other.action == action &&
other.clientId == clientId &&
other.connectionId == connectionId &&
other.data == data &&
other.encoding == encoding &&
other.extras == extras &&
other.id == id &&
other.timestamp == timestamp;

@override
Expand Down