Skip to content

Commit 77ea07b

Browse files
author
Nate Mara
committed
Simplify deserialization logic
1 parent bd60d4e commit 77ea07b

File tree

1 file changed

+3
-21
lines changed

1 file changed

+3
-21
lines changed

component.go

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
package jira
22

3-
import (
4-
"encoding/json"
5-
"fmt"
6-
"io/ioutil"
7-
)
8-
93
// ComponentService handles components for the JIRA instance / API.
104
//
115
// JIRA API docs: https://docs.atlassian.com/software/jira/docs/api/REST/7.10.1/#api/2/component
@@ -32,21 +26,9 @@ func (s *ComponentService) Create(options *CreateComponentOptions) (*ProjectComp
3226
if err != nil {
3327
return nil, nil, err
3428
}
35-
resp, err := s.client.Do(req, nil)
36-
if err != nil {
37-
// incase of error return the resp for further inspection
38-
return nil, resp, err
39-
}
4029

4130
component := new(ProjectComponent)
42-
defer resp.Body.Close()
43-
data, err := ioutil.ReadAll(resp.Body)
44-
if err != nil {
45-
return nil, resp, fmt.Errorf("Could not read the returned data")
46-
}
47-
err = json.Unmarshal(data, component)
48-
if err != nil {
49-
return nil, resp, fmt.Errorf("Could not unmarshall the data into struct")
50-
}
51-
return component, resp, nil
31+
resp, err := s.client.Do(req, component)
32+
33+
return component, resp, err
5234
}

0 commit comments

Comments
 (0)