No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

pengajuanCuti_post.dart 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import 'dart:convert';
  2. import 'dart:core';
  3. import 'package:http/http.dart' as http;
  4. import 'package:employee_selfservice_mobile/constants.dart';
  5. import 'dart:developer' as developer;
  6. import 'package:shared_preferences/shared_preferences.dart';
  7. class PengajuanCuti_Post {
  8. late String session;
  9. late String tipe;
  10. late String date_from;
  11. late String date_to;
  12. late String deskripsi;
  13. late List<String> file;
  14. PengajuanCuti_Post({required this.session});
  15. static Future<String> connectToAPI(String tipe, String date_from, String date_to, String deskripsi, List<String> file) async {
  16. String URL = baseURL + "/api/v1/pengajuan_cuti";
  17. final SharedPreferences prefs = await SharedPreferences.getInstance();
  18. final session = prefs.getString('session');
  19. var sendData = await http.post(Uri.parse(URL), body: jsonEncode({
  20. "data": [
  21. {
  22. "session": session,
  23. "tipe" : tipe,
  24. "date_from" : date_from,
  25. "date_to" : date_to,
  26. "deskripsi" : deskripsi,
  27. "file" : file
  28. }
  29. ]
  30. }), headers: {
  31. "Content-Type": "application/json",
  32. "Api-key": apiKey
  33. });
  34. developer.log(sendData.body, name: "Get Jenis Cuti Result");
  35. return sendData.body;
  36. /*var jsonObject = json.decode(sendData.body);
  37. developer.log(jsonObject.toString(), name: 'Log');*/
  38. // return jsonObject;
  39. // return LoginPostResult.createPostResult(jsonObject);
  40. }
  41. }