Skip to content

Commit 66b5f48

Browse files
committed
Upgraded to support Appwrite 0.6
1 parent b37c7ab commit 66b5f48

File tree

6 files changed

+60
-60
lines changed

6 files changed

+60
-60
lines changed

docs/examples/avatars/get-credit-card.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,8 @@ client
88
.setProject('5df5acd0d48c2') // Your project ID
99
;
1010

11-
Future result = avatars.getCreditCard(
11+
String result = avatars.getCreditCard(
1212
code: 'amex',
1313
);
1414

15-
result
16-
.then((response) {
17-
print(response);
18-
}).catchError((error) {
19-
print(error);
20-
});
15+
print(result); // Resource URL string

docs/examples/avatars/get-favicon.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,8 @@ client
88
.setProject('5df5acd0d48c2') // Your project ID
99
;
1010

11-
Future result = avatars.getFavicon(
11+
String result = avatars.getFavicon(
1212
url: 'https://example.com',
1313
);
1414

15-
result
16-
.then((response) {
17-
print(response);
18-
}).catchError((error) {
19-
print(error);
20-
});
15+
print(result); // Resource URL string

docs/examples/avatars/get-flag.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,8 @@ client
88
.setProject('5df5acd0d48c2') // Your project ID
99
;
1010

11-
Future result = avatars.getFlag(
11+
String result = avatars.getFlag(
1212
code: 'af',
1313
);
1414

15-
result
16-
.then((response) {
17-
print(response);
18-
}).catchError((error) {
19-
print(error);
20-
});
15+
print(result); // Resource URL string

docs/examples/avatars/get-image.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,8 @@ client
88
.setProject('5df5acd0d48c2') // Your project ID
99
;
1010

11-
Future result = avatars.getImage(
11+
String result = avatars.getImage(
1212
url: 'https://example.com',
1313
);
1414

15-
result
16-
.then((response) {
17-
print(response);
18-
}).catchError((error) {
19-
print(error);
20-
});
15+
print(result); // Resource URL string

docs/examples/avatars/get-q-r.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,8 @@ client
88
.setProject('5df5acd0d48c2') // Your project ID
99
;
1010

11-
Future result = avatars.getQR(
11+
String result = avatars.getQR(
1212
text: '[TEXT]',
1313
);
1414

15-
result
16-
.then((response) {
17-
print(response);
18-
}).catchError((error) {
19-
print(error);
20-
});
15+
print(result); // Resource URL string

lib/services/avatars.dart

Lines changed: 50 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -40,39 +40,49 @@ class Avatars extends Service {
4040
/// card provider you need. Use width, height and quality arguments to change
4141
/// the output settings.
4242
///
43-
Future<Response> getCreditCard({@required String code, int width = 100, int height = 100, int quality = 100}) {
43+
String getCreditCard({@required String code, int width = 100, int height = 100, int quality = 100}) {
4444
final String path = '/avatars/credit-cards/{code}'.replaceAll(RegExp('{code}'), code);
4545

4646
final Map<String, dynamic> params = {
4747
'width': width,
4848
'height': height,
4949
'quality': quality,
50+
'project': client.config['project'],
5051
};
5152

52-
final Map<String, String> headers = {
53-
'content-type': 'application/json',
54-
};
53+
Uri endpoint = Uri.parse(client.endPoint);
54+
Uri url = new Uri(scheme: endpoint.scheme,
55+
host: endpoint.host,
56+
port: endpoint.port,
57+
path: endpoint.path + path,
58+
queryParameters:params,
59+
);
5560

56-
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
61+
return url.toString();
5762
}
5863

5964
/// Get Favicon
6065
///
6166
/// Use this endpoint to fetch the favorite icon (AKA favicon) of a any remote
6267
/// website URL.
6368
///
64-
Future<Response> getFavicon({@required String url}) {
69+
String getFavicon({@required String url}) {
6570
final String path = '/avatars/favicon';
6671

6772
final Map<String, dynamic> params = {
6873
'url': url,
74+
'project': client.config['project'],
6975
};
7076

71-
final Map<String, String> headers = {
72-
'content-type': 'application/json',
73-
};
77+
Uri endpoint = Uri.parse(client.endPoint);
78+
Uri url = new Uri(scheme: endpoint.scheme,
79+
host: endpoint.host,
80+
port: endpoint.port,
81+
path: endpoint.path + path,
82+
queryParameters:params,
83+
);
7484

75-
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
85+
return url.toString();
7686
}
7787

7888
/// Get Country Flag
@@ -81,20 +91,25 @@ class Avatars extends Service {
8191
/// users. The code argument receives the 2 letter country code. Use width,
8292
/// height and quality arguments to change the output settings.
8393
///
84-
Future<Response> getFlag({@required String code, int width = 100, int height = 100, int quality = 100}) {
94+
String getFlag({@required String code, int width = 100, int height = 100, int quality = 100}) {
8595
final String path = '/avatars/flags/{code}'.replaceAll(RegExp('{code}'), code);
8696

8797
final Map<String, dynamic> params = {
8898
'width': width,
8999
'height': height,
90100
'quality': quality,
101+
'project': client.config['project'],
91102
};
92103

93-
final Map<String, String> headers = {
94-
'content-type': 'application/json',
95-
};
104+
Uri endpoint = Uri.parse(client.endPoint);
105+
Uri url = new Uri(scheme: endpoint.scheme,
106+
host: endpoint.host,
107+
port: endpoint.port,
108+
path: endpoint.path + path,
109+
queryParameters:params,
110+
);
96111

97-
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
112+
return url.toString();
98113
}
99114

100115
/// Get Image from URL
@@ -104,41 +119,51 @@ class Avatars extends Service {
104119
/// remote images in your app or in case you want to make sure a 3rd party
105120
/// image is properly served using a TLS protocol.
106121
///
107-
Future<Response> getImage({@required String url, int width = 400, int height = 400}) {
122+
String getImage({@required String url, int width = 400, int height = 400}) {
108123
final String path = '/avatars/image';
109124

110125
final Map<String, dynamic> params = {
111126
'url': url,
112127
'width': width,
113128
'height': height,
129+
'project': client.config['project'],
114130
};
115131

116-
final Map<String, String> headers = {
117-
'content-type': 'application/json',
118-
};
132+
Uri endpoint = Uri.parse(client.endPoint);
133+
Uri url = new Uri(scheme: endpoint.scheme,
134+
host: endpoint.host,
135+
port: endpoint.port,
136+
path: endpoint.path + path,
137+
queryParameters:params,
138+
);
119139

120-
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
140+
return url.toString();
121141
}
122142

123143
/// Get QR Code
124144
///
125145
/// Converts a given plain text to a QR code image. You can use the query
126146
/// parameters to change the size and style of the resulting image.
127147
///
128-
Future<Response> getQR({@required String text, int size = 400, int margin = 1, int download = 0}) {
148+
String getQR({@required String text, int size = 400, int margin = 1, int download = 0}) {
129149
final String path = '/avatars/qr';
130150

131151
final Map<String, dynamic> params = {
132152
'text': text,
133153
'size': size,
134154
'margin': margin,
135155
'download': download,
156+
'project': client.config['project'],
136157
};
137158

138-
final Map<String, String> headers = {
139-
'content-type': 'application/json',
140-
};
159+
Uri endpoint = Uri.parse(client.endPoint);
160+
Uri url = new Uri(scheme: endpoint.scheme,
161+
host: endpoint.host,
162+
port: endpoint.port,
163+
path: endpoint.path + path,
164+
queryParameters:params,
165+
);
141166

142-
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
167+
return url.toString();
143168
}
144169
}

0 commit comments

Comments
 (0)