/
attendence_register.dart
99 lines (86 loc) · 3.01 KB
/
attendence_register.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// ignore_for_file: avoid_dynamic_calls
import 'dart:async';
import 'dart:convert';
import 'package:dio/dio.dart';
import 'package:works_shg_app/models/attendance/attendance_registry_model.dart';
import 'package:works_shg_app/models/attendance/attendee_model.dart';
import '../../../utils/global_variables.dart';
class AttendanceRegisterRepository {
final Dio _client;
AttendanceRegisterRepository(this._client);
Future<AttendanceRegistersModel> createAttendanceRegisters(
{dynamic body, required String url, required Options options}) async {
try {
final response = await _client.post(url, data: body, options: options);
return AttendanceRegistersModel.fromJson(
json.decode(response.toString()),
);
} on DioError catch (ex) {
// Assuming there will be an errorMessage property in the JSON object
rethrow;
}
}
Future<AttendeeModel> createAttendee(
{dynamic body, required String url, required Options options}) async {
try {
// var formData = FormData.fromMap(body);
final response = await _client.post(url, data: body, options: options);
return AttendeeModel.fromJson(
json.decode(response.toString()),
);
} on DioError catch (ex) {
// Assuming there will be an errorMessage property in the JSON object
rethrow;
}
}
Future<AttendeeModel> deEnrollAttendee(
{dynamic body, required String url, required Options options}) async {
try {
// var formData = FormData.fromMap(body);
final response = await _client.post(url, data: body, options: options);
return AttendeeModel.fromJson(
json.decode(response.toString()),
);
} on DioError catch (ex) {
// Assuming there will be an errorMessage property in the JSON object
rethrow;
}
}
Future<AttendanceRegistersModel> searchAttendanceProjects({
dynamic body,
Map<String, String>? queryParameters,
required String url,
}) async {
try {
// var formData = FormData.fromMap(body);
final response = await _client.post(url,
data: body ?? {},
queryParameters: queryParameters,
options: Options(extra: {
"accessToken": GlobalVariables.authToken,
"apiId": "mukta-services",
}));
return AttendanceRegistersModel.fromJson(
json.decode(response.toString()),
);
} on DioError catch (ex) {
print(ex);
// Assuming there will be an errorMessage property in the JSON object
rethrow;
}
}
Future<AttendanceRegistersModel> createAttendanceLog(
{dynamic body, required String url, required Options options}) async {
try {
// var formData = FormData.fromMap(body);
final response = await _client.post(url, data: body, options: options);
return AttendanceRegistersModel.fromJson(
json.decode(response.toString()),
);
} on DioError catch (ex) {
print(ex);
// Assuming there will be an errorMessage property in the JSON object
rethrow;
}
}
}