// 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/FindModel/service/remote/entity/FindEntity.dart';

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

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

  static FindApiImpl _instance;

  FindApiImpl._() {}

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

  Observable<FindEntity> getFindPage(int page, int count) {
    return Observable.fromFuture(DioUtil().get('api/v1/discover',
        data: {'page': page, 'count': count})).flatMap((value) {
      if (value != null && value.statusCode == 200) {
        return Observable.fromFuture(compute(paseFindEntity, value.toString()));
      } else {
        return Observable.fromFuture(null);
      }
    });
  }
}

FindEntity paseFindEntity(String value) {
  return FindEntity.fromJson(json.decode(value));
}
