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.

pengajuanST_post.dart 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import 'dart:convert';
  2. import 'dart:core';
  3. import 'package:http/http.dart' as http;
  4. import 'package:hris_selfservice_mobile/constants.dart';
  5. import 'dart:developer' as developer;
  6. import 'package:shared_preferences/shared_preferences.dart';
  7. class PengajuanST_Post {
  8. late String session;
  9. late String tanggal_st;
  10. late String uang_muka;
  11. late String keperluan;
  12. late String tanggal_berangkat;
  13. late String tanggal_kembali;
  14. late String tujuan;
  15. late String ticket_type;
  16. late String ticket_from;
  17. late String ticket_to;
  18. late String date;
  19. late String harga;
  20. PengajuanST_Post({required this.session});
  21. static Future<String> connectToAPI(String tanggal_st, String uang_muka, String keperluan,
  22. String tanggal_berangkat, String tanggal_kembali, String tujuan, String ticket_type,
  23. String ticket_from, String ticket_to, String date, String harga) async {
  24. String URL = baseURL + "/api/v1/pengajuan_st";
  25. final SharedPreferences prefs = await SharedPreferences.getInstance();
  26. final session = prefs.getString('session');
  27. var sendData = await http.post(Uri.parse(URL), body: jsonEncode({
  28. "data": [
  29. {
  30. "tanggal_st" : tanggal_st,
  31. "uang_muka" : uang_muka,
  32. "keperluan" : keperluan,
  33. "tanggal_berangkat" : tanggal_berangkat,
  34. "tanggal_kembali" : tanggal_kembali,
  35. "tujuan" : tujuan,
  36. "tiketnya" : [
  37. {
  38. "ticket_type" : ticket_type,
  39. "ticket_from" : ticket_from,
  40. "ticket_to" : ticket_to,
  41. "date" : date,
  42. "harga" : harga
  43. }
  44. ],
  45. "session" : "fsfssdfsdfsdf"
  46. }
  47. ]
  48. }), headers: {
  49. "Content-Type": "application/json",
  50. "Api-key": apiKey
  51. });
  52. //developer.log(sendData.body, name: "Get Jenis Cuti Result");
  53. return sendData.body;
  54. }
  55. }