Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
644 changes: 140 additions & 504 deletions lib/services/account.dart

Large diffs are not rendered by default.

133 changes: 25 additions & 108 deletions lib/services/databases.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,11 @@ class Databases extends Service {
'content-type': 'application/json',
};

final cacheModel =
'/databases/{databaseId}/collections/{collectionId}/documents'
.replaceAll('{databaseId}', databaseId)
.replaceAll('{collectionId}', collectionId);
final cacheKey = '';
final cacheResponseIdKey = '\$id';
final cacheResponseContainerKey = 'documents';

final res = await client.call(withCacheParams(
CallParams(
HttpMethod.get,
path,
params: params,
headers: headers,
),
CacheParams(
model: cacheModel,
key: cacheKey,
responseIdKey: cacheResponseIdKey,
responseContainerKey: cacheResponseContainerKey,
),
final res = await client.call(CallParams(
HttpMethod.get,
path,
params: params,
headers: headers,
));

return models.DocumentList.fromMap(res.data);
Expand Down Expand Up @@ -81,27 +65,11 @@ class Databases extends Service {
'content-type': 'application/json',
};

final cacheModel =
'/databases/{databaseId}/collections/{collectionId}/documents'
.replaceAll('{databaseId}', databaseId)
.replaceAll('{collectionId}', collectionId);
final cacheKey = documentId;
final cacheResponseIdKey = '\$id';
final cacheResponseContainerKey = '';

final res = await client.call(withCacheParams(
CallParams(
HttpMethod.post,
path,
params: params,
headers: headers,
),
CacheParams(
model: cacheModel,
key: cacheKey,
responseIdKey: cacheResponseIdKey,
responseContainerKey: cacheResponseContainerKey,
),
final res = await client.call(CallParams(
HttpMethod.post,
path,
params: params,
headers: headers,
));

return models.Document.fromMap(res.data);
Expand All @@ -128,28 +96,11 @@ class Databases extends Service {
'content-type': 'application/json',
};

final cacheModel =
'/databases/{databaseId}/collections/{collectionId}/documents'
.replaceAll('{databaseId}', databaseId)
.replaceAll('{collectionId}', collectionId)
.replaceAll('{documentId}', documentId);
final cacheKey = documentId;
final cacheResponseIdKey = '\$id';
final cacheResponseContainerKey = '';

final res = await client.call(withCacheParams(
CallParams(
HttpMethod.get,
path,
params: params,
headers: headers,
),
CacheParams(
model: cacheModel,
key: cacheKey,
responseIdKey: cacheResponseIdKey,
responseContainerKey: cacheResponseContainerKey,
),
final res = await client.call(CallParams(
HttpMethod.get,
path,
params: params,
headers: headers,
));

return models.Document.fromMap(res.data);
Expand Down Expand Up @@ -181,28 +132,11 @@ class Databases extends Service {
'content-type': 'application/json',
};

final cacheModel =
'/databases/{databaseId}/collections/{collectionId}/documents'
.replaceAll('{databaseId}', databaseId)
.replaceAll('{collectionId}', collectionId)
.replaceAll('{documentId}', documentId);
final cacheKey = documentId;
final cacheResponseIdKey = '\$id';
final cacheResponseContainerKey = '';

final res = await client.call(withCacheParams(
CallParams(
HttpMethod.patch,
path,
params: params,
headers: headers,
),
CacheParams(
model: cacheModel,
key: cacheKey,
responseIdKey: cacheResponseIdKey,
responseContainerKey: cacheResponseContainerKey,
),
final res = await client.call(CallParams(
HttpMethod.patch,
path,
params: params,
headers: headers,
));

return models.Document.fromMap(res.data);
Expand All @@ -228,28 +162,11 @@ class Databases extends Service {
'content-type': 'application/json',
};

final cacheModel =
'/databases/{databaseId}/collections/{collectionId}/documents'
.replaceAll('{databaseId}', databaseId)
.replaceAll('{collectionId}', collectionId)
.replaceAll('{documentId}', documentId);
final cacheKey = documentId;
final cacheResponseIdKey = '\$id';
final cacheResponseContainerKey = '';

final res = await client.call(withCacheParams(
CallParams(
HttpMethod.delete,
path,
params: params,
headers: headers,
),
CacheParams(
model: cacheModel,
key: cacheKey,
responseIdKey: cacheResponseIdKey,
responseContainerKey: cacheResponseContainerKey,
),
final res = await client.call(CallParams(
HttpMethod.delete,
path,
params: params,
headers: headers,
));

return res.data;
Expand Down
69 changes: 15 additions & 54 deletions lib/services/functions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,11 @@ class Functions extends Service {
'content-type': 'application/json',
};

final cacheModel = '';
final cacheKey = '';
final cacheResponseIdKey = '\$id';
final cacheResponseContainerKey = 'executions';

final res = await client.call(withCacheParams(
CallParams(
HttpMethod.get,
path,
params: params,
headers: headers,
),
CacheParams(
model: cacheModel,
key: cacheKey,
responseIdKey: cacheResponseIdKey,
responseContainerKey: cacheResponseContainerKey,
),
final res = await client.call(CallParams(
HttpMethod.get,
path,
params: params,
headers: headers,
));

return models.ExecutionList.fromMap(res.data);
Expand All @@ -70,24 +57,11 @@ class Functions extends Service {
'content-type': 'application/json',
};

final cacheModel = '';
final cacheKey = '';
final cacheResponseIdKey = '\$id';
final cacheResponseContainerKey = '';

final res = await client.call(withCacheParams(
CallParams(
HttpMethod.post,
path,
params: params,
headers: headers,
),
CacheParams(
model: cacheModel,
key: cacheKey,
responseIdKey: cacheResponseIdKey,
responseContainerKey: cacheResponseContainerKey,
),
final res = await client.call(CallParams(
HttpMethod.post,
path,
params: params,
headers: headers,
));

return models.Execution.fromMap(res.data);
Expand All @@ -109,24 +83,11 @@ class Functions extends Service {
'content-type': 'application/json',
};

final cacheModel = '';
final cacheKey = '';
final cacheResponseIdKey = '\$id';
final cacheResponseContainerKey = '';

final res = await client.call(withCacheParams(
CallParams(
HttpMethod.get,
path,
params: params,
headers: headers,
),
CacheParams(
model: cacheModel,
key: cacheKey,
responseIdKey: cacheResponseIdKey,
responseContainerKey: cacheResponseContainerKey,
),
final res = await client.call(CallParams(
HttpMethod.get,
path,
params: params,
headers: headers,
));

return models.Execution.fromMap(res.data);
Expand Down
46 changes: 10 additions & 36 deletions lib/services/graphql.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,11 @@ class Graphql extends Service {
'content-type': 'application/json',
};

final cacheModel = '';
final cacheKey = '';
final cacheResponseIdKey = '\$id';
final cacheResponseContainerKey = '';

final res = await client.call(withCacheParams(
CallParams(
HttpMethod.post,
path,
params: params,
headers: headers,
),
CacheParams(
model: cacheModel,
key: cacheKey,
responseIdKey: cacheResponseIdKey,
responseContainerKey: cacheResponseContainerKey,
),
final res = await client.call(CallParams(
HttpMethod.post,
path,
params: params,
headers: headers,
));

return res.data;
Expand All @@ -60,24 +47,11 @@ class Graphql extends Service {
'content-type': 'application/json',
};

final cacheModel = '';
final cacheKey = '';
final cacheResponseIdKey = '\$id';
final cacheResponseContainerKey = '';

final res = await client.call(withCacheParams(
CallParams(
HttpMethod.post,
path,
params: params,
headers: headers,
),
CacheParams(
model: cacheModel,
key: cacheKey,
responseIdKey: cacheResponseIdKey,
responseContainerKey: cacheResponseContainerKey,
),
final res = await client.call(CallParams(
HttpMethod.post,
path,
params: params,
headers: headers,
));

return res.data;
Expand Down
Loading