1- use crate :: cnb:: ing:: { IngReq , ING_API_BASE_URL } ;
1+ use crate :: cnb:: ing:: IngReq ;
2+ use crate :: http:: unit_or_err;
23use crate :: infra:: http:: { setup_auth, APPLICATION_JSON } ;
3- use crate :: infra:: result:: IntoResult ;
4- use crate :: panic_hook;
4+ use crate :: infra:: result:: ResultExt ;
5+ use crate :: { openapi , panic_hook} ;
56use alloc:: format;
6- use alloc:: string:: { String , ToString } ;
7- use anyhow:: { anyhow, Result } ;
8- use core:: ops:: Not ;
7+ use alloc:: string:: String ;
8+ use anyhow:: Result ;
99use reqwest:: header:: CONTENT_TYPE ;
1010use serde:: { Deserialize , Serialize } ;
1111use wasm_bindgen:: prelude:: * ;
@@ -32,7 +32,7 @@ impl IngReq {
3232 parent_comment_id : Option < usize > ,
3333 ) -> Result < ( ) , String > {
3434 panic_hook ! ( ) ;
35- let url = format ! ( "{ING_API_BASE_URL}/{ing_id }/comments" ) ;
35+ let url = openapi ! ( "/statuses/{ }/comments" , ing_id ) ;
3636
3737 let client = reqwest:: Client :: new ( ) . post ( url) ;
3838
@@ -47,16 +47,10 @@ impl IngReq {
4747 let result: Result < ( ) > = try {
4848 let body = serde_json:: to_string_pretty ( & body) ?;
4949 let req = req. body ( body) ;
50-
5150 let resp = req. send ( ) . await ?;
52- let code = resp. status ( ) ;
53-
54- if code. is_success ( ) . not ( ) {
55- let text = resp. text ( ) . await ?;
56- anyhow ! ( "{}: {}" , code, text) . into_err ( ) ?
57- }
51+ unit_or_err ( resp) . await ?
5852 } ;
5953
60- result. map_err ( |e| e . to_string ( ) )
54+ result. err_to_string ( )
6155 }
6256}
0 commit comments