deleteBlogPost method
Delete a blog post (authenticated)
Implementation
Future<void> deleteBlogPost({
required String authToken,
required int blogPostId,
}) async {
try {
final response = await _dio.delete(
'$baseUrl/blog-posts/$blogPostId',
options: Options(headers: {'Authorization': 'Bearer $authToken'}),
);
if (response.statusCode == 200) {
return;
} else if (response.statusCode == 403) {
throw Exception('Unauthorized - you do not own this app');
} else if (response.statusCode == 404) {
throw Exception('Blog post not found');
} else {
throw Exception('Failed to delete blog post');
}
} on DioException catch (e) {
throw Exception('Error deleting blog post: ${e.message}');
} catch (e) {
throw Exception('Error: $e');
}
}