77
88use std:: collections:: HashMap ;
99
10- use attohttpc:: Response ;
1110use comfy_table:: { Cell , CellAlignment } ;
1211use rayon:: prelude:: * ;
1312use serde_json:: { json, Value } ;
@@ -131,8 +130,10 @@ pub fn create(
131130 payload[ "fields" ] [ "priority" ] = json ! ( { "name" : priority } ) ;
132131 }
133132
134- let resp = post_request ( & url, & payload, global[ "user" ] , global[ "token" ] , true ) . unwrap_right ( ) ;
135- let json: Value = resp. json ( ) . unwrap ( ) ;
133+ let json: Value = post_request ( & url, & payload, global[ "user" ] , global[ "token" ] , true )
134+ . unwrap_right ( )
135+ . json ( )
136+ . unwrap ( ) ;
136137 println ! ( "Issue created: {}" , json[ "key" ] ) ;
137138}
138139
@@ -143,8 +144,10 @@ pub fn create_link_type(global: &HashMap<&str, &str>, name: &str, inward: &str,
143144 "inward" : inward,
144145 "outward" : outward
145146 } ) ;
146- let resp = post_request ( & url, & payload, global[ "user" ] , global[ "token" ] , true ) . unwrap_right ( ) ;
147- let json: Value = resp. json ( ) . unwrap ( ) ;
147+ let json: Value = post_request ( & url, & payload, global[ "user" ] , global[ "token" ] , true )
148+ . unwrap_right ( )
149+ . json ( )
150+ . unwrap ( ) ;
148151 if json[ "errorMessages" ] . is_null ( ) {
149152 println ! (
150153 "New link type {} (id: {} ) created" ,
@@ -183,8 +186,9 @@ pub fn get_link_type(global: &HashMap<&str, &str>, link_type_id: &str) {
183186 "https://{}{}/{}" ,
184187 global[ "domain" ] , URLS [ "issue_link_types" ] , link_type_id
185188 ) ;
186- let resp = get_request ( & url, global[ "user" ] , global[ "token" ] ) ;
187- let json: Value = resp. json ( ) . unwrap ( ) ;
189+ let json: Value = get_request ( & url, global[ "user" ] , global[ "token" ] )
190+ . json ( )
191+ . unwrap ( ) ;
188192 let mut rows: Vec < Vec < Cell > > = Vec :: new ( ) ;
189193 let id: & str = json[ "id" ] . as_str ( ) . unwrap ( ) ;
190194 let name: & str = json[ "name" ] . as_str ( ) . unwrap ( ) ;
@@ -213,8 +217,9 @@ pub fn get_transitions(global: &HashMap<&str, &str>, issue_key: &str) {
213217 "https://{}{}/{}/transitions" ,
214218 global[ "domain" ] , URLS [ "issue" ] , issue_key
215219 ) ;
216- let resp: Response = get_request ( & url, global[ "user" ] , global[ "token" ] ) ;
217- let json: Value = resp. json ( ) . unwrap ( ) ;
220+ let json: Value = get_request ( & url, global[ "user" ] , global[ "token" ] )
221+ . json ( )
222+ . unwrap ( ) ;
218223 let rows: Vec < Vec < Cell > > = json[ "transitions" ]
219224 . as_array ( )
220225 . unwrap ( )
@@ -241,8 +246,9 @@ pub fn get_transitions(global: &HashMap<&str, &str>, issue_key: &str) {
241246//noinspection DuplicatedCode
242247pub fn list_link_types ( global : & HashMap < & str , & str > ) {
243248 let url: String = format ! ( "https://{}{}" , global[ "domain" ] , URLS [ "issue_link_types" ] ) ;
244- let resp: Response = get_request ( & url, global[ "user" ] , global[ "token" ] ) ;
245- let json: Value = resp. json ( ) . unwrap ( ) ;
249+ let json: Value = get_request ( & url, global[ "user" ] , global[ "token" ] )
250+ . json ( )
251+ . unwrap ( ) ;
246252 let rows: Vec < Vec < Cell > > = json[ "issueLinkTypes" ]
247253 . as_array ( )
248254 . unwrap ( )
@@ -270,8 +276,9 @@ pub fn list_link_types(global: &HashMap<&str, &str>) {
270276
271277pub fn list_priorities ( global : & HashMap < & str , & str > ) {
272278 let url: String = format ! ( "https://{}{}" , global[ "domain" ] , URLS [ "priority" ] ) ;
273- let resp: Response = get_request ( & url, global[ "user" ] , global[ "token" ] ) ;
274- let json: Value = resp. json ( ) . unwrap ( ) ;
279+ let json: Value = get_request ( & url, global[ "user" ] , global[ "token" ] )
280+ . json ( )
281+ . unwrap ( ) ;
275282 json. as_array ( ) . unwrap ( ) . par_iter ( ) . for_each ( |x| {
276283 println ! ( "{}" , x[ "name" ] ) ;
277284 } ) ;
@@ -282,8 +289,9 @@ pub fn list_types(global: &HashMap<&str, &str>, project_key: &str) {
282289 "https://{}{}/createmeta?projectKeys={}" ,
283290 global[ "domain" ] , URLS [ "issue" ] , project_key
284291 ) ;
285- let resp: Response = get_request ( & url, global[ "user" ] , global[ "token" ] ) ;
286- let json: Value = resp. json ( ) . unwrap ( ) ;
292+ let json: Value = get_request ( & url, global[ "user" ] , global[ "token" ] )
293+ . json ( )
294+ . unwrap ( ) ;
287295 json[ "projects" ] [ 0 ] [ "issuetypes" ]
288296 . as_array ( )
289297 . unwrap ( )
@@ -299,8 +307,9 @@ pub fn list_votes(global: &HashMap<&str, &str>, issue_key: &str) {
299307 "https://{}{}/{}/votes" ,
300308 global[ "domain" ] , URLS [ "issue" ] , issue_key
301309 ) ;
302- let resp: Response = get_request ( & url, global[ "user" ] , global[ "token" ] ) ;
303- let json: Value = resp. json ( ) . unwrap ( ) ;
310+ let json: Value = get_request ( & url, global[ "user" ] , global[ "token" ] )
311+ . json ( )
312+ . unwrap ( ) ;
304313 if json[ "hasVoted" ] == "true" {
305314 println ! ( "Votes: {}" , json[ "votes" ] ) ;
306315 let rows: Vec < Vec < Cell > > = json[ "voters" ]
@@ -394,8 +403,9 @@ pub fn show_fixversions(global: &HashMap<&str, &str>, issue_key: &str) {
394403 "https://{}{}/{}" ,
395404 global[ "domain" ] , URLS [ "issue" ] , issue_key
396405 ) ;
397- let resp: Response = get_request ( & url, global[ "user" ] , global[ "token" ] ) ;
398- let json: Value = resp. json ( ) . unwrap ( ) ;
406+ let json: Value = get_request ( & url, global[ "user" ] , global[ "token" ] )
407+ . json ( )
408+ . unwrap ( ) ;
399409 json[ "fields" ] [ "fixVersions" ]
400410 . as_array ( )
401411 . unwrap ( )
0 commit comments