passo_mobile_app/lib/sevices/passo/signatories_service.dart

41 lines
1.2 KiB
Dart
Raw Normal View History

2023-07-28 02:35:36 +00:00
import 'dart:convert';
import 'package:http/http.dart' as http;
import 'package:unit2/model/passo/signatories.dart';
2023-09-01 03:22:48 +00:00
import 'package:unit2/utils/request.dart';
import 'package:unit2/utils/urls.dart';
2023-07-28 02:35:36 +00:00
class SignatoriesServices {
static final SignatoriesServices _instance = SignatoriesServices();
static SignatoriesServices get instance => _instance;
2023-09-01 03:22:48 +00:00
String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z";
String xClientKeySecret = "unitcYqAN7GGalyz";
2023-07-28 02:35:36 +00:00
2023-09-01 03:22:48 +00:00
Future<List<Signatories>> fetch() async {
String path = Url.instance.getSignatories();
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
'X-Client-Key': xClientKey,
'X-Client-Secret': xClientKeySecret
};
try {
http.Response response = await Request.instance
.getRequest(param: {}, path: path, headers: headers);
print('Signatories');
print(response.statusCode);
if (response.statusCode == 200) {
final List result = jsonDecode(response.body)['data'];
return result.map(((e) => Signatories.fromJson(e))).toList();
} else {
print(response.reasonPhrase);
throw Exception(response.reasonPhrase);
}
} catch (e) {
throw e.toString();
2023-07-28 02:35:36 +00:00
}
}
}