40 lines
890 B
Dart
40 lines
890 B
Dart
import 'dart:convert';
|
|
|
|
import 'package:http/http.dart' as http;
|
|
import 'package:http/http.dart';
|
|
|
|
import '../talk_api.dart';
|
|
import 'create_room_params.dart';
|
|
import 'create_room_response.dart';
|
|
|
|
class CreateRoom extends TalkApi<CreateRoomResponse> {
|
|
CreateRoomParams params;
|
|
|
|
CreateRoom(this.params) : super('v4/room', params);
|
|
|
|
@override
|
|
CreateRoomResponse assemble(String raw) {
|
|
final decoded = jsonDecode(raw) as Map<String, dynamic>;
|
|
return CreateRoomResponse.fromJson(decoded['ocs'] as Map<String, dynamic>);
|
|
}
|
|
|
|
@override
|
|
Future<Response>? request(
|
|
Uri uri,
|
|
Object? body,
|
|
Map<String, String>? headers,
|
|
) {
|
|
if (body is CreateRoomParams) {
|
|
return http.post(
|
|
uri,
|
|
headers: headers,
|
|
body: body.toJson().map(
|
|
(key, value) => MapEntry(key, value.toString()),
|
|
),
|
|
);
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|