Skip to content

Commit

Permalink
fix params default values
Browse files Browse the repository at this point in the history
  • Loading branch information
TorstenDittmann committed Jun 3, 2021
1 parent ca567ef commit a864ed8
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 36 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.6.2

- Removed default values, nothing should change in usage as default values are already allocated in server

## 0.6.1

- Fix for image preview param types
Expand Down
6 changes: 6 additions & 0 deletions lib/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ class Client {
};
}

params.keys.forEach((key) {
if (params[key] == null) {
params.remove(key);
}
});

// Origin is hardcoded for testing
Options options = Options(
headers: {...this.headers!, ...headers},
Expand Down
2 changes: 1 addition & 1 deletion lib/services/account.dart
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class Account extends Service {
/// to pass in the new password, and the old password. For users created with
/// OAuth and Team Invites, oldPassword is optional.
///
Future<Response> updatePassword({required String password, String oldPassword = ''}) {
Future<Response> updatePassword({required String password, String? oldPassword}) {
final String path = '/account/password';

final Map<String, dynamic> params = {
Expand Down
12 changes: 6 additions & 6 deletions lib/services/avatars.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Avatars extends Service {
/// /account/sessions endpoint. Use width, height and quality arguments to
/// change the output settings.
///
Future<Response> getBrowser({required String code, int width = 100, int height = 100, int quality = 100}) {
Future<Response> getBrowser({required String code, int? width, int? height, int? quality}) {
final String path = '/avatars/browsers/{code}'.replaceAll(RegExp('{code}'), code);

final Map<String, dynamic> params = {
Expand All @@ -35,7 +35,7 @@ class Avatars extends Service {
/// provider you need. Use width, height and quality arguments to change the
/// output settings.
///
Future<Response> getCreditCard({required String code, int width = 100, int height = 100, int quality = 100}) {
Future<Response> getCreditCard({required String code, int? width, int? height, int? quality}) {
final String path = '/avatars/credit-cards/{code}'.replaceAll(RegExp('{code}'), code);

final Map<String, dynamic> params = {
Expand Down Expand Up @@ -81,7 +81,7 @@ class Avatars extends Service {
/// users. The code argument receives the 2 letter country code. Use width,
/// height and quality arguments to change the output settings.
///
Future<Response> getFlag({required String code, int width = 100, int height = 100, int quality = 100}) {
Future<Response> getFlag({required String code, int? width, int? height, int? quality}) {
final String path = '/avatars/flags/{code}'.replaceAll(RegExp('{code}'), code);

final Map<String, dynamic> params = {
Expand All @@ -106,7 +106,7 @@ class Avatars extends Service {
/// remote images in your app or in case you want to make sure a 3rd party
/// image is properly served using a TLS protocol.
///
Future<Response> getImage({required String url, int width = 400, int height = 400}) {
Future<Response> getImage({required String url, int? width, int? height}) {
final String path = '/avatars/image';

final Map<String, dynamic> params = {
Expand Down Expand Up @@ -137,7 +137,7 @@ class Avatars extends Service {
/// the user's initials when reloading the same theme will always return for
/// the same initials.
///
Future<Response> getInitials({String name = '', int width = 500, int height = 500, String color = '', String background = ''}) {
Future<Response> getInitials({String? name, int? width, int? height, String? color, String? background}) {
final String path = '/avatars/initials';

final Map<String, dynamic> params = {
Expand All @@ -162,7 +162,7 @@ class Avatars extends Service {
/// Converts a given plain text to a QR code image. You can use the query
/// parameters to change the size and style of the resulting image.
///
Future<Response> getQR({required String text, int size = 400, int margin = 1, bool download = false}) {
Future<Response> getQR({required String text, int? size, int? margin, bool? download}) {
final String path = '/avatars/qr';

final Map<String, dynamic> params = {
Expand Down
14 changes: 7 additions & 7 deletions lib/services/database.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ class Database extends Service {
/// of the project's collections. [Learn more about different API
/// modes](/docs/admin).
///
Future<Response> listCollections({String search = '', int limit = 25, int offset = 0, OrderType orderType = OrderType.asc}) {
Future<Response> listCollections({String? search, int? limit, int? offset, OrderType? orderType}) {
final String path = '/database/collections';

final Map<String, dynamic> params = {
'search': search,
'limit': limit,
'offset': offset,
'orderType': orderType.name(),
'orderType': orderType?.name(),
};

final Map<String, String> headers = {
Expand Down Expand Up @@ -71,7 +71,7 @@ class Database extends Service {
///
/// Update a collection by its unique ID.
///
Future<Response> updateCollection({required String collectionId, required String name, List read = const [], List write = const [], List rules = const []}) {
Future<Response> updateCollection({required String collectionId, required String name, List? read, List? write, List? rules}) {
final String path = '/database/collections/{collectionId}'.replaceAll(RegExp('{collectionId}'), collectionId);

final Map<String, dynamic> params = {
Expand Down Expand Up @@ -113,15 +113,15 @@ class Database extends Service {
/// of the project's documents. [Learn more about different API
/// modes](/docs/admin).
///
Future<Response> listDocuments({required String collectionId, List filters = const [], int limit = 25, int offset = 0, String orderField = '', OrderType orderType = OrderType.asc, String orderCast = 'string', String search = ''}) {
Future<Response> listDocuments({required String collectionId, List? filters, int? limit, int? offset, String? orderField, OrderType? orderType, String? orderCast, String? search}) {
final String path = '/database/collections/{collectionId}/documents'.replaceAll(RegExp('{collectionId}'), collectionId);

final Map<String, dynamic> params = {
'filters': filters,
'limit': limit,
'offset': offset,
'orderField': orderField,
'orderType': orderType.name(),
'orderType': orderType?.name(),
'orderCast': orderCast,
'search': search,
};
Expand All @@ -140,7 +140,7 @@ class Database extends Service {
/// integration](/docs/server/database#databaseCreateCollection) API or
/// directly from your database console.
///
Future<Response> createDocument({required String collectionId, required Map data, List read = const [], List write = const [], String parentDocument = '', String parentProperty = '', String parentPropertyType = 'assign'}) {
Future<Response> createDocument({required String collectionId, required Map data, List? read, List? write, String? parentDocument, String? parentProperty, String? parentPropertyType}) {
final String path = '/database/collections/{collectionId}/documents'.replaceAll(RegExp('{collectionId}'), collectionId);

final Map<String, dynamic> params = {
Expand Down Expand Up @@ -182,7 +182,7 @@ class Database extends Service {
/// Update a document by its unique ID. Using the patch method you can pass
/// only specific fields that will get updated.
///
Future<Response> updateDocument({required String collectionId, required String documentId, required Map data, List read = const [], List write = const []}) {
Future<Response> updateDocument({required String collectionId, required String documentId, required Map data, List? read, List? write}) {
final String path = '/database/collections/{collectionId}/documents/{documentId}'.replaceAll(RegExp('{collectionId}'), collectionId).replaceAll(RegExp('{documentId}'), documentId);

final Map<String, dynamic> params = {
Expand Down
18 changes: 9 additions & 9 deletions lib/services/functions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ class Functions extends Service {
/// Get a list of all the project's functions. You can use the query params to
/// filter your results.
///
Future<Response> list({String search = '', int limit = 25, int offset = 0, OrderType orderType = OrderType.asc}) {
Future<Response> list({String? search, int? limit, int? offset, OrderType? orderType}) {
final String path = '/functions';

final Map<String, dynamic> params = {
'search': search,
'limit': limit,
'offset': offset,
'orderType': orderType.name(),
'orderType': orderType?.name(),
};

final Map<String, String> headers = {
Expand All @@ -32,7 +32,7 @@ class Functions extends Service {
/// [permissions](/docs/permissions) to allow different project users or team
/// with access to execute the function using the client API.
///
Future<Response> create({required String name, required List execute, required String env, Map vars = const {}, List events = const [], String schedule = '', int timeout = 15}) {
Future<Response> create({required String name, required List execute, required String env, Map? vars, List? events, String? schedule, int? timeout}) {
final String path = '/functions';

final Map<String, dynamic> params = {
Expand Down Expand Up @@ -73,7 +73,7 @@ class Functions extends Service {
///
/// Update function by its unique ID.
///
Future<Response> update({required String functionId, required String name, required List execute, Map vars = const {}, List events = const [], String schedule = '', int timeout = 15}) {
Future<Response> update({required String functionId, required String name, required List execute, Map? vars, List? events, String? schedule, int? timeout}) {
final String path = '/functions/{functionId}'.replaceAll(RegExp('{functionId}'), functionId);

final Map<String, dynamic> params = {
Expand Down Expand Up @@ -116,14 +116,14 @@ class Functions extends Service {
/// return a list of all of the project's executions. [Learn more about
/// different API modes](/docs/admin).
///
Future<Response> listExecutions({required String functionId, String search = '', int limit = 25, int offset = 0, OrderType orderType = OrderType.asc}) {
Future<Response> listExecutions({required String functionId, String? search, int? limit, int? offset, OrderType? orderType}) {
final String path = '/functions/{functionId}/executions'.replaceAll(RegExp('{functionId}'), functionId);

final Map<String, dynamic> params = {
'search': search,
'limit': limit,
'offset': offset,
'orderType': orderType.name(),
'orderType': orderType?.name(),
};

final Map<String, String> headers = {
Expand All @@ -140,7 +140,7 @@ class Functions extends Service {
/// updates on the current execution status. Once this endpoint is called, your
/// function execution process will start asynchronously.
///
Future<Response> createExecution({required String functionId, String data = ''}) {
Future<Response> createExecution({required String functionId, String? data}) {
final String path = '/functions/{functionId}/executions'.replaceAll(RegExp('{functionId}'), functionId);

final Map<String, dynamic> params = {
Expand Down Expand Up @@ -196,14 +196,14 @@ class Functions extends Service {
/// Get a list of all the project's code tags. You can use the query params to
/// filter your results.
///
Future<Response> listTags({required String functionId, String search = '', int limit = 25, int offset = 0, OrderType orderType = OrderType.asc}) {
Future<Response> listTags({required String functionId, String? search, int? limit, int? offset, OrderType? orderType}) {
final String path = '/functions/{functionId}/tags'.replaceAll(RegExp('{functionId}'), functionId);

final Map<String, dynamic> params = {
'search': search,
'limit': limit,
'offset': offset,
'orderType': orderType.name(),
'orderType': orderType?.name(),
};

final Map<String, String> headers = {
Expand Down
8 changes: 4 additions & 4 deletions lib/services/storage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ class Storage extends Service {
/// your results. On admin mode, this endpoint will return a list of all of the
/// project's files. [Learn more about different API modes](/docs/admin).
///
Future<Response> listFiles({String search = '', int limit = 25, int offset = 0, OrderType orderType = OrderType.asc}) {
Future<Response> listFiles({String? search, int? limit, int? offset, OrderType? orderType}) {
final String path = '/storage/files';

final Map<String, dynamic> params = {
'search': search,
'limit': limit,
'offset': offset,
'orderType': orderType.name(),
'orderType': orderType?.name(),
};

final Map<String, String> headers = {
Expand All @@ -33,7 +33,7 @@ class Storage extends Service {
/// assigned to read and write access unless he has passed custom values for
/// read and write arguments.
///
Future<Response> createFile({required MultipartFile file, List read = const [], List write = const []}) {
Future<Response> createFile({required MultipartFile file, List? read, List? write}) {
final String path = '/storage/files';

final Map<String, dynamic> params = {
Expand Down Expand Up @@ -133,7 +133,7 @@ class Storage extends Service {
/// and spreadsheets, will return the file icon image. You can also pass query
/// string arguments for cutting and resizing your preview image.
///
Future<Response> getFilePreview({required String fileId, int width = 0, int height = 0, int quality = 100, int borderWidth = 0, String borderColor = '', int borderRadius = 0, double opacity = 1, int rotation = 0, String background = '', String output = ''}) {
Future<Response> getFilePreview({required String fileId, int? width, int? height, int? quality, int? borderWidth, String? borderColor, int? borderRadius, double? opacity, int? rotation, String? background, String? output}) {
final String path = '/storage/files/{fileId}/preview'.replaceAll(RegExp('{fileId}'), fileId);

final Map<String, dynamic> params = {
Expand Down
12 changes: 6 additions & 6 deletions lib/services/teams.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ class Teams extends Service {
/// of the project's teams. [Learn more about different API
/// modes](/docs/admin).
///
Future<Response> list({String search = '', int limit = 25, int offset = 0, OrderType orderType = OrderType.asc}) {
Future<Response> list({String? search, int? limit, int? offset, OrderType? orderType}) {
final String path = '/teams';

final Map<String, dynamic> params = {
'search': search,
'limit': limit,
'offset': offset,
'orderType': orderType.name(),
'orderType': orderType?.name(),
};

final Map<String, String> headers = {
Expand All @@ -35,7 +35,7 @@ class Teams extends Service {
/// who will be able add new owners and update or delete the team from your
/// project.
///
Future<Response> create({required String name, List roles = const ["owner"]}) {
Future<Response> create({required String name, List? roles}) {
final String path = '/teams';

final Map<String, dynamic> params = {
Expand Down Expand Up @@ -110,14 +110,14 @@ class Teams extends Service {
/// Get a team members by the team unique ID. All team members have read access
/// for this list of resources.
///
Future<Response> getMemberships({required String teamId, String search = '', int limit = 25, int offset = 0, OrderType orderType = OrderType.asc}) {
Future<Response> getMemberships({required String teamId, String? search, int? limit, int? offset, OrderType? orderType}) {
final String path = '/teams/{teamId}/memberships'.replaceAll(RegExp('{teamId}'), teamId);

final Map<String, dynamic> params = {
'search': search,
'limit': limit,
'offset': offset,
'orderType': orderType.name(),
'orderType': orderType?.name(),
};

final Map<String, String> headers = {
Expand All @@ -143,7 +143,7 @@ class Teams extends Service {
/// the only valid redirect URL's are the once from domains you have set when
/// added your platforms in the console interface.
///
Future<Response> createMembership({required String teamId, required String email, required List roles, required String url, String name = ''}) {
Future<Response> createMembership({required String teamId, required String email, required List roles, required String url, String? name}) {
final String path = '/teams/{teamId}/memberships'.replaceAll(RegExp('{teamId}'), teamId);

final Map<String, dynamic> params = {
Expand Down
6 changes: 3 additions & 3 deletions lib/services/users.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ class Users extends Service {
/// Get a list of all the project's users. You can use the query params to
/// filter your results.
///
Future<Response> list({String search = '', int limit = 25, int offset = 0, OrderType orderType = OrderType.asc}) {
Future<Response> list({String? search, int? limit, int? offset, OrderType? orderType}) {
final String path = '/users';

final Map<String, dynamic> params = {
'search': search,
'limit': limit,
'offset': offset,
'orderType': orderType.name(),
'orderType': orderType?.name(),
};

final Map<String, String> headers = {
Expand All @@ -30,7 +30,7 @@ class Users extends Service {
///
/// Create a new user.
///
Future<Response> create({required String email, required String password, String name = ''}) {
Future<Response> create({required String email, required String password, String? name}) {
final String path = '/users';

final Map<String, dynamic> params = {
Expand Down

0 comments on commit a864ed8

Please sign in to comment.