createComment method

  1. @override
Future<CommentActivityResult> createComment({
  1. required String token,
  2. required String targetId,
  3. required String body,
  4. String? category,
  5. List<String>? tags,
  6. String? pushRedirectUrl,
})
override

Implementation

@override
Future<CommentActivityResult> createComment({
  required String token,
  required String targetId,
  required String body,
  String? category,
  List<String>? tags,
  String? pushRedirectUrl,
}) async {
  final response = await dio.post(
    '/microsite/comments',
    options: Options(headers: {'Authorization': 'Bearer $token'}),
    data: {
      'api_key': Environment.apiKey,
      'campaign': Environment.campaign,
      'target_id': targetId,
      'comment': {
        'body': body,
        'category': ?category,
        if (tags != null && tags.isNotEmpty) 'tags': tags,
        'push_redirect_url': ?pushRedirectUrl,
      },
    },
  );
  final responseData = _parseResponse(response.data);
  return CommentMapper.commentActivityResultToEntity(
    CommentActivityResultResponse.fromJson(responseData),
  );
}