@@ -36,7 +36,7 @@ class Habr {
3636 String ordString = orderToText[order];
3737 final url =
3838 "$api_url_v2 /articles/?query=$query &order=$ordString &fl=ru&hl=ru&page=$page " ;
39- final response = await safe (http.get (url));
39+ final response = await safe (http.get (Uri . parse ( url) ));
4040 return response
4141 .then (checkHttpStatus)
4242 .map (parseJson)
@@ -49,49 +49,49 @@ class Habr {
4949 final url =
5050 "$api_url_v2 /articles/?period=daily&sort=date&fl=ru&hl=ru&page=$page " ;
5151 logInfo ("Get articles by $url " );
52- final response = await safe (http.get (url));
52+ final response = await safe (http.get (Uri . parse ( url) ));
5353 return response
5454 .then (checkHttpStatus)
55- .asyncMap (asyncParseJson)
56- .then ((val) => val. map (( data) => parsePostPreviewsFromJson (data) ));
55+ .mapAsync (asyncParseJson)
56+ .mapRight (( data) => parsePostPreviewsFromJson (data));
5757 }
5858
5959 Future <Either <AppError , PostPreviews >> userPosts (String user,
6060 {int page = 1 }) async {
6161 final url =
6262 "$api_url_v2 /articles/?user=$user &sort=date&fl=ru&hl=ru&page=$page " ;
6363 logInfo ("Get articles by $url " );
64- final response = await safe (http.get (url));
64+ final response = await safe (http.get (Uri . parse ( url) ));
6565 return response
6666 .then (checkHttpStatus)
67- .asyncMap (asyncParseJson)
68- .then ((val) => val. map (( data) => parsePostPreviewsFromJson (data) ));
67+ .mapAsync (asyncParseJson)
68+ .mapRight (( data) => parsePostPreviewsFromJson (data));
6969 }
7070
7171 Future <Either <AppError , AuthorInfo >> userInfo (String user) async {
7272 final url = "$api_url_v2 /users/$user /card?fl=ru&hl=ru" ;
7373 logInfo ("Get user info by $url " );
74- final response = await safe (http.get (url));
74+ final response = await safe (http.get (Uri . parse ( url) ));
7575 return response
7676 .then (checkHttpStatus)
77- .asyncMap (asyncParseJson)
78- .then ((val) => val. map (( data) => parseAuthorInfoFromJson (data) ));
77+ .mapAsync (asyncParseJson)
78+ .mapRight (( data) => parseAuthorInfoFromJson (data));
7979 }
8080
8181 Future <Either <AppError , Post >> article (String id) async {
8282 final url = "$api_url_v2 /articles/$id " ;
8383 logInfo ("Get article by $url " );
84- final response = await safe (http.get (url));
84+ final response = await safe (http.get (Uri . parse ( url) ));
8585 return response
8686 .then (checkHttpStatus)
87- .asyncMap (asyncParseJson)
88- .then ((val) => val. map (( data) => parsePostFromJson (data) ));
87+ .mapAsync (asyncParseJson)
88+ .mapRight (( data) => parsePostFromJson (data));
8989 }
9090
9191 Future <Either <AppError , Comments >> comments (String articleId) async {
9292 final url = "$api_url_v2 /articles/$articleId /comments" ;
9393 logInfo ("Get comments by $url " );
94- final response = await safe (http.get (url));
94+ final response = await safe (http.get (Uri . parse ( url) ));
9595 return response
9696 .then (checkHttpStatus)
9797 .map (parseJson)
0 commit comments