2024-07-27 13:13:42 +00:00
|
|
|
import 'dart:typed_data';
|
|
|
|
|
|
|
|
|
|
import 'package:dio/dio.dart';
|
|
|
|
|
import 'package:mnemo_cards_common/mnemo_cards_common.dart';
|
|
|
|
|
|
|
|
|
|
import '../../managers/repository/api.dart';
|
|
|
|
|
|
|
|
|
|
class SubscriptionApi with Api {
|
|
|
|
|
final Dio _dio;
|
|
|
|
|
|
|
|
|
|
SubscriptionApi(this._dio);
|
|
|
|
|
|
2024-08-03 22:37:10 +00:00
|
|
|
Future<SubscriptionDto?> getBuySubscription() async {
|
2024-07-27 13:13:42 +00:00
|
|
|
final r = await _dio.get<String>(
|
2024-08-03 22:37:10 +00:00
|
|
|
'$path/subscription/page',
|
2024-07-27 13:13:42 +00:00
|
|
|
options: Options(
|
|
|
|
|
sendTimeout: Duration(seconds: 5),
|
|
|
|
|
receiveTimeout: Duration(seconds: 5),
|
|
|
|
|
),
|
|
|
|
|
);
|
2024-08-03 22:37:10 +00:00
|
|
|
return (r.data as String).decode(SubscriptionDto.fromJson);
|
2024-07-27 13:13:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// cards zip archive for available pack
|
|
|
|
|
/// unavailable packs transfer images by base64
|
|
|
|
|
Future<Uint8List> packImagesArchive(String packId) async {
|
|
|
|
|
final response = await _dio.get<Uint8List>(
|
|
|
|
|
'$path/pack/cards/$packId',
|
|
|
|
|
options: Options(
|
|
|
|
|
responseType: ResponseType.bytes,
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
final data = response.data;
|
|
|
|
|
if (data == null) {
|
|
|
|
|
return Uint8List.fromList([]);
|
|
|
|
|
}
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
}
|