You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
784 B
Dart
27 lines
784 B
Dart
import 'dart:convert';
|
|
|
|
import 'package:http/http.dart';
|
|
import 'package:test_sa/api/api_client.dart';
|
|
import 'package:test_sa/controllers/api_routes/urls.dart';
|
|
|
|
import '../models/department.dart';
|
|
|
|
class DepartmentsApiClient{
|
|
|
|
static final DepartmentsApiClient _instance = DepartmentsApiClient._internal();
|
|
|
|
DepartmentsApiClient._internal();
|
|
|
|
factory DepartmentsApiClient() => _instance;
|
|
|
|
Future getDepartment() async {
|
|
Response response;
|
|
response = await ApiClient().postJsonForResponse(
|
|
URLs.host1 + URLs.getDepartments,
|
|
{},
|
|
isFormData: false
|
|
);
|
|
Map listJson = json.decode(utf8.decode(response.bodyBytes).replaceAll("\\", ""));
|
|
return listJson['data'].map<Department>((department) => Department.fromJson(department)).toList();
|
|
}
|
|
} |