Skip to content

Commit a864ed8

Browse files
fix params default values
1 parent ca567ef commit a864ed8

9 files changed

+46
-36
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.6.2
2+
3+
- Removed default values, nothing should change in usage as default values are already allocated in server
4+
15
## 0.6.1
26

37
- Fix for image preview param types

lib/client.dart

+6
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ class Client {
8282
};
8383
}
8484

85+
params.keys.forEach((key) {
86+
if (params[key] == null) {
87+
params.remove(key);
88+
}
89+
});
90+
8591
// Origin is hardcoded for testing
8692
Options options = Options(
8793
headers: {...this.headers!, ...headers},

lib/services/account.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ class Account extends Service {
108108
/// to pass in the new password, and the old password. For users created with
109109
/// OAuth and Team Invites, oldPassword is optional.
110110
///
111-
Future<Response> updatePassword({required String password, String oldPassword = ''}) {
111+
Future<Response> updatePassword({required String password, String? oldPassword}) {
112112
final String path = '/account/password';
113113

114114
final Map<String, dynamic> params = {

lib/services/avatars.dart

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class Avatars extends Service {
1111
/// /account/sessions endpoint. Use width, height and quality arguments to
1212
/// change the output settings.
1313
///
14-
Future<Response> getBrowser({required String code, int width = 100, int height = 100, int quality = 100}) {
14+
Future<Response> getBrowser({required String code, int? width, int? height, int? quality}) {
1515
final String path = '/avatars/browsers/{code}'.replaceAll(RegExp('{code}'), code);
1616

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

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

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

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

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

168168
final Map<String, dynamic> params = {

lib/services/database.dart

+7-7
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ class Database extends Service {
1111
/// of the project's collections. [Learn more about different API
1212
/// modes](/docs/admin).
1313
///
14-
Future<Response> listCollections({String search = '', int limit = 25, int offset = 0, OrderType orderType = OrderType.asc}) {
14+
Future<Response> listCollections({String? search, int? limit, int? offset, OrderType? orderType}) {
1515
final String path = '/database/collections';
1616

1717
final Map<String, dynamic> params = {
1818
'search': search,
1919
'limit': limit,
2020
'offset': offset,
21-
'orderType': orderType.name(),
21+
'orderType': orderType?.name(),
2222
};
2323

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

7777
final Map<String, dynamic> params = {
@@ -113,15 +113,15 @@ class Database extends Service {
113113
/// of the project's documents. [Learn more about different API
114114
/// modes](/docs/admin).
115115
///
116-
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 = ''}) {
116+
Future<Response> listDocuments({required String collectionId, List? filters, int? limit, int? offset, String? orderField, OrderType? orderType, String? orderCast, String? search}) {
117117
final String path = '/database/collections/{collectionId}/documents'.replaceAll(RegExp('{collectionId}'), collectionId);
118118

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

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

188188
final Map<String, dynamic> params = {

lib/services/functions.dart

+9-9
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ class Functions extends Service {
99
/// Get a list of all the project's functions. You can use the query params to
1010
/// filter your results.
1111
///
12-
Future<Response> list({String search = '', int limit = 25, int offset = 0, OrderType orderType = OrderType.asc}) {
12+
Future<Response> list({String? search, int? limit, int? offset, OrderType? orderType}) {
1313
final String path = '/functions';
1414

1515
final Map<String, dynamic> params = {
1616
'search': search,
1717
'limit': limit,
1818
'offset': offset,
19-
'orderType': orderType.name(),
19+
'orderType': orderType?.name(),
2020
};
2121

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

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

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

122122
final Map<String, dynamic> params = {
123123
'search': search,
124124
'limit': limit,
125125
'offset': offset,
126-
'orderType': orderType.name(),
126+
'orderType': orderType?.name(),
127127
};
128128

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

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

202202
final Map<String, dynamic> params = {
203203
'search': search,
204204
'limit': limit,
205205
'offset': offset,
206-
'orderType': orderType.name(),
206+
'orderType': orderType?.name(),
207207
};
208208

209209
final Map<String, String> headers = {

lib/services/storage.dart

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ class Storage extends Service {
1010
/// your results. On admin mode, this endpoint will return a list of all of the
1111
/// project's files. [Learn more about different API modes](/docs/admin).
1212
///
13-
Future<Response> listFiles({String search = '', int limit = 25, int offset = 0, OrderType orderType = OrderType.asc}) {
13+
Future<Response> listFiles({String? search, int? limit, int? offset, OrderType? orderType}) {
1414
final String path = '/storage/files';
1515

1616
final Map<String, dynamic> params = {
1717
'search': search,
1818
'limit': limit,
1919
'offset': offset,
20-
'orderType': orderType.name(),
20+
'orderType': orderType?.name(),
2121
};
2222

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

3939
final Map<String, dynamic> params = {
@@ -133,7 +133,7 @@ class Storage extends Service {
133133
/// and spreadsheets, will return the file icon image. You can also pass query
134134
/// string arguments for cutting and resizing your preview image.
135135
///
136-
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 = ''}) {
136+
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}) {
137137
final String path = '/storage/files/{fileId}/preview'.replaceAll(RegExp('{fileId}'), fileId);
138138

139139
final Map<String, dynamic> params = {

lib/services/teams.dart

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ class Teams extends Service {
1111
/// of the project's teams. [Learn more about different API
1212
/// modes](/docs/admin).
1313
///
14-
Future<Response> list({String search = '', int limit = 25, int offset = 0, OrderType orderType = OrderType.asc}) {
14+
Future<Response> list({String? search, int? limit, int? offset, OrderType? orderType}) {
1515
final String path = '/teams';
1616

1717
final Map<String, dynamic> params = {
1818
'search': search,
1919
'limit': limit,
2020
'offset': offset,
21-
'orderType': orderType.name(),
21+
'orderType': orderType?.name(),
2222
};
2323

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

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

116116
final Map<String, dynamic> params = {
117117
'search': search,
118118
'limit': limit,
119119
'offset': offset,
120-
'orderType': orderType.name(),
120+
'orderType': orderType?.name(),
121121
};
122122

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

149149
final Map<String, dynamic> params = {

lib/services/users.dart

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ class Users extends Service {
99
/// Get a list of all the project's users. You can use the query params to
1010
/// filter your results.
1111
///
12-
Future<Response> list({String search = '', int limit = 25, int offset = 0, OrderType orderType = OrderType.asc}) {
12+
Future<Response> list({String? search, int? limit, int? offset, OrderType? orderType}) {
1313
final String path = '/users';
1414

1515
final Map<String, dynamic> params = {
1616
'search': search,
1717
'limit': limit,
1818
'offset': offset,
19-
'orderType': orderType.name(),
19+
'orderType': orderType?.name(),
2020
};
2121

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

3636
final Map<String, dynamic> params = {

0 commit comments

Comments
 (0)