-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathAppStore_InfoApp.class.dart
39 lines (34 loc) · 1.08 KB
/
AppStore_InfoApp.class.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Developer by : Azozz ALFiras
import 'dart:convert';
import 'package:http/http.dart' as http;
class AppStoreInfoApp {
Future<Map<String, dynamic>> sentRequest(String bundleId) async {
final response = await http.get(Uri.parse('http://itunes.apple.com/lookup?bundleId=$bundleId'));
final data = json.decode(response.body);
return data['results'][0];
}
Future<Map<String, dynamic>> getInfoApp(String bundleId, String version) async {
final data = await sentRequest(bundleId);
final vAppStore = data['version'];
final appLink = data['trackViewUrl'];
if (vAppStore == version) {
return responseApi('Yes', appLink);
} else {
return responseApi('No', appLink);
}
}
Map<String, dynamic> responseApi(String status, String url) {
if (status == 'Yes') {
return {
'status': 'success',
'status_message': 'There is no application update',
};
} else {
return {
'status': 'failed',
'status_message': 'The version does not match. An update is required',
'app_link': url,
};
}
}
}