Implemented structure for push Notifications
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:http/http.dart' as http;
|
||||
import '../apiError.dart';
|
||||
@ -21,6 +22,10 @@ abstract class MhslApi<T> extends ApiRequest {
|
||||
throw ApiError("Request could not be dispatched!");
|
||||
}
|
||||
|
||||
if(data.statusCode > 299) {
|
||||
log("Non 200 Status code from mhsl services: $subpath: ${data.statusCode}");
|
||||
}
|
||||
|
||||
return assemble(utf8.decode(data.bodyBytes));
|
||||
}
|
||||
}
|
26
lib/api/mhsl/notify/register/notifyRegister.dart
Normal file
26
lib/api/mhsl/notify/register/notifyRegister.dart
Normal file
@ -0,0 +1,26 @@
|
||||
|
||||
import 'dart:convert';
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
import '../../mhslApi.dart';
|
||||
import 'notifyRegisterParams.dart';
|
||||
|
||||
class NotifyRegister extends MhslApi<void> {
|
||||
NotifyRegisterParams params;
|
||||
NotifyRegister(this.params) : super("notify/register/");
|
||||
|
||||
|
||||
@override
|
||||
void assemble(String raw) {
|
||||
|
||||
}
|
||||
|
||||
@override
|
||||
Future<http.Response> request(Uri uri) {
|
||||
String requestString = jsonEncode(params.toJson());
|
||||
log(requestString);
|
||||
return http.post(uri, body: requestString);
|
||||
}
|
||||
}
|
19
lib/api/mhsl/notify/register/notifyRegisterParams.dart
Normal file
19
lib/api/mhsl/notify/register/notifyRegisterParams.dart
Normal file
@ -0,0 +1,19 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'notifyRegisterParams.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class NotifyRegisterParams {
|
||||
String username;
|
||||
String password;
|
||||
String fcmToken;
|
||||
|
||||
NotifyRegisterParams({
|
||||
required this.username,
|
||||
required this.password,
|
||||
required this.fcmToken
|
||||
});
|
||||
|
||||
factory NotifyRegisterParams.fromJson(Map<String, dynamic> json) => _$NotifyRegisterParamsFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$NotifyRegisterParamsToJson(this);
|
||||
}
|
23
lib/api/mhsl/notify/register/notifyRegisterParams.g.dart
Normal file
23
lib/api/mhsl/notify/register/notifyRegisterParams.g.dart
Normal file
@ -0,0 +1,23 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'notifyRegisterParams.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
NotifyRegisterParams _$NotifyRegisterParamsFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
NotifyRegisterParams(
|
||||
username: json['username'] as String,
|
||||
password: json['password'] as String,
|
||||
fcmToken: json['fcmToken'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$NotifyRegisterParamsToJson(
|
||||
NotifyRegisterParams instance) =>
|
||||
<String, dynamic>{
|
||||
'username': instance.username,
|
||||
'password': instance.password,
|
||||
'fcmToken': instance.fcmToken,
|
||||
};
|
Reference in New Issue
Block a user