// GENERATED CODE - DO NOT MODIFY BY HAND

// **************************************************************************
// ServiceGenerator
// **************************************************************************

import 'dart:convert';

import 'dart:io';

import 'package:rxdart/rxdart.dart';

import 'package:dio/dio.dart';

import 'package:flutter/foundation.dart';

import 'package:gmalpha_flutter/ActivityReportModel/service/remote/entity/ActivityReportEntity.dart';

import 'package:gmalpha_flutter/commonModel/net/DioUtil.dart';

class ActivityReportApiImpl {
  factory ActivityReportApiImpl() => _sharedInstance();

  static ActivityReportApiImpl _instance;

  ActivityReportApiImpl._() {}

  static ActivityReportApiImpl _sharedInstance() {
    if (_instance == null) {
      _instance = ActivityReportApiImpl._();
    }
    return _instance;
  }

  Observable<ActivityReportEntity> getActivityReport(int id, int type) {
    return Observable.fromFuture(DioUtil().get('api/v1/survey_question/report',
        data: {'survey_record_id': id, 'template_id': type})).flatMap((value) {
      if (value != null && value.statusCode == 200) {
        return Observable.fromFuture(
            compute(paseActivityReportEntity, value.toString()));
      } else {
        return Observable.fromFuture(null);
      }
    });
  }
}

ActivityReportEntity paseActivityReportEntity(String value) {
  return ActivityReportEntity.fromJson(json.decode(value));
}
