1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
// 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/UserModel/service/remote/entity/UserResultBean.dart';
import 'package:gmalpha_flutter/UserModel/service/remote/entity/CommentBean.dart';
import 'package:gmalpha_flutter/UserModel/service/remote/entity/CountryBean.dart';
import 'package:gmalpha_flutter/UserModel/service/remote/entity/UploadTokenBean.dart';
import 'package:gmalpha_flutter/UserModel/service/remote/entity/SetUserBean.dart';
import 'package:gmalpha_flutter/commonModel/net/Responce/SimpleResponce.dart';
import 'package:gmalpha_flutter/UserModel/service/remote/entity/PrestigeEntity.dart';
import 'package:gmalpha_flutter/commonModel/net/DioUtil.dart';
class UserApiImpl {
factory UserApiImpl() => _sharedInstance();
static UserApiImpl _instance;
UserApiImpl._() {}
static UserApiImpl _sharedInstance() {
if (_instance == null) {
_instance = UserApiImpl._();
}
return _instance;
}
Observable<UserResultBean> getUserInfo(String userID) {
return Observable.fromFuture(DioUtil().get('api/account/user_profile',
data: {'user_id': userID})).flatMap((value) {
if (value != null && value.statusCode == 200) {
return Observable.fromFuture(
compute(paseUserResultBean, value.toString()));
} else {
return Observable.fromFuture(null);
}
});
}
Observable<CommentBean> comment(String content, String phone) {
return Observable.fromFuture(DioUtil().post('api/v1/suggestion',
data: {'content': content, 'phone': phone})).flatMap((value) {
if (value != null && value.statusCode == 200) {
return Observable.fromFuture(
compute(paseCommentBean, value.toString()));
} else {
return Observable.fromFuture(null);
}
});
}
Observable<CountryBean> getCountrys() {
return Observable.fromFuture(DioUtil().get('api/v1/countries'))
.flatMap((value) {
if (value != null && value.statusCode == 200) {
return Observable.fromFuture(
compute(paseCountryBean, value.toString()));
} else {
return Observable.fromFuture(null);
}
});
}
Observable<UploadTokenBean> getUploadToken(int token_type) {
return Observable.fromFuture(DioUtil().post('api/v1/app/upload_token',
data: {'token_type': token_type})).flatMap((value) {
if (value != null && value.statusCode == 200) {
return Observable.fromFuture(
compute(paseUploadTokenBean, value.toString()));
} else {
return Observable.fromFuture(null);
}
});
}
Observable<SetUserBean> settingUserInfo(String country_id, String nick_name,
String profile_pic, String user_id, String age) {
return Observable.fromFuture(
DioUtil().post('api/account/user_settle', data: {
'country_id': country_id,
'nick_name': nick_name,
'profile_pic': profile_pic,
'user_id': user_id,
'age': age
})).flatMap((value) {
if (value != null && value.statusCode == 200) {
return Observable.fromFuture(
compute(paseSetUserBean, value.toString()));
} else {
return Observable.fromFuture(null);
}
});
}
Observable<SimpleResponce> logout(String user_id) {
return Observable.fromFuture(
DioUtil().post('api/account/logout/', data: {'user_id': user_id}))
.flatMap((value) {
if (value != null && value.statusCode == 200) {
return Observable.fromFuture(
compute(paseSimpleResponce, value.toString()));
} else {
return Observable.fromFuture(null);
}
});
}
Observable<PrestigeEntity> getReputations(int userId) {
return Observable.fromFuture(
DioUtil().get('api/v1/reputations', data: {'user_id': userId}))
.flatMap((value) {
if (value != null && value.statusCode == 200) {
return Observable.fromFuture(
compute(pasePrestigeEntity, value.toString()));
} else {
return Observable.fromFuture(null);
}
});
}
}
UserResultBean paseUserResultBean(String value) {
return UserResultBean.fromJson(json.decode(value));
}
CommentBean paseCommentBean(String value) {
return CommentBean.fromJson(json.decode(value));
}
CountryBean paseCountryBean(String value) {
return CountryBean.fromJson(json.decode(value));
}
UploadTokenBean paseUploadTokenBean(String value) {
return UploadTokenBean.fromJson(json.decode(value));
}
SetUserBean paseSetUserBean(String value) {
return SetUserBean.fromJson(json.decode(value));
}
SimpleResponce paseSimpleResponce(String value) {
return SimpleResponce.fromJson(json.decode(value));
}
PrestigeEntity pasePrestigeEntity(String value) {
return PrestigeEntity.fromJson(json.decode(value));
}