Skip to content

Commit

Permalink
upd
Browse files Browse the repository at this point in the history
  • Loading branch information
danylo-safonov-solid committed Sep 20, 2023
1 parent ac91006 commit f5c5768
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
17 changes: 2 additions & 15 deletions lib/src/client_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,7 @@ class ClientOptions {
return jsify(
{
if (applicationName != null) 'applicationName': applicationName,
if (connection != null)
'connection': jsify({
if (connection.attempts != null) 'attempts': connection.attempts,
if (connection.nextInterval != null)
'interval': connection.nextInterval
else if (connection.interval != null)
'interval': connection.interval,
}),
if (connection != null) 'connection': jsify(connection.asMap()),
if (database != null) 'database': database,
if (hostname != null) 'hostname': hostname,
if (hostType != null) 'host_type': hostType.name,
Expand All @@ -64,13 +57,7 @@ class ClientOptions {
'port': portString
else if (port != null)
'port': port,
if (tls != null)
'tls': jsify({
if (tls.isEnabled != null) 'enabled': tls.isEnabled,
if (tls.isEnforced != null) 'enforce': tls.isEnforced,
if (tls.caCertificates != null)
'caCertificates': tls.caCertificates,
}),
if (tls != null) 'tls': jsify(tls.asMap()),
if (user != null) 'user': user,
},
) as ClientOptions;
Expand Down
11 changes: 11 additions & 0 deletions lib/src/partial/partial_connection_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,15 @@ class PartialConnectionOptions {
required this.nextInterval,
required this.interval,
}) : assert(interval == null || nextInterval == null);

/// used for jsify.
Map<String, dynamic> asMap() {
return {
if (attempts != null) 'attempts': attempts,
if (nextInterval != null)
'interval': nextInterval
else if (interval != null)
'interval': interval,
};
}
}
9 changes: 9 additions & 0 deletions lib/src/partial/partial_tls_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,13 @@ class PartialTLSOptions {
required this.isEnforced,
required this.caCertificates,
});

/// used for jsify.
Map<String, dynamic> asMap() {
return {
if (isEnabled != null) 'enabled': isEnabled,
if (isEnforced != null) 'enforce': isEnforced,
if (caCertificates != null) 'caCertificates': caCertificates,
};
}
}

0 comments on commit f5c5768

Please sign in to comment.