Initial commit: Penyerahan final Source code Tugas Akhir
This commit is contained in:
32
lib/services/detail_invoice_service.dart
Normal file
32
lib/services/detail_invoice_service.dart
Normal file
@ -0,0 +1,32 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:initial_folder/base_service.dart';
|
||||
import 'package:initial_folder/helper/user_info.dart';
|
||||
import 'package:initial_folder/models/detail_invoice_model.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
class DetailInvoiceService {
|
||||
Future<List<DataDetailInvoiceModel>> detailInvoice(String? orderId) async {
|
||||
String? token = await UsersInfo().getToken();
|
||||
|
||||
Uri url = Uri.parse('$baseUrl/payment/invoice-detail/$orderId');
|
||||
|
||||
http.Response response =
|
||||
await http.get(url, headers: headerWithToken(token!));
|
||||
List<DataDetailInvoiceModel> detailOrder = [];
|
||||
if (response.statusCode == 200) {
|
||||
print("BERHASIL COKKKK");
|
||||
var data = jsonDecode(response.body);
|
||||
print("Ini response berhasil get detail transaksi ${response.body}");
|
||||
|
||||
var list = data['data'] as List;
|
||||
detailOrder =
|
||||
list.map((item) => DataDetailInvoiceModel.fromJson(item)).toList();
|
||||
|
||||
return detailOrder;
|
||||
} else {
|
||||
print("GAGAL COKKKK");
|
||||
throw Exception('Data Transaksi Gagal Diambil');
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user