@@ -68,17 +68,6 @@ func (c *Client) CreateRequestURL(location string) string {
6868 return fmt .Sprintf ("%s%s" , c .getBaseURL (), location )
6969}
7070
71- // PerformGetRequest performs a GET request to the specified URL and returns the response body and eventual errors
72- func (c * Client ) PerformGetRequest (url string ) ([]byte , error ) {
73- request , err := http .NewRequest (http .MethodGet , url , nil )
74-
75- if err != nil {
76- return nil , err
77- }
78-
79- return c .performRequest (request )
80- }
81-
8271// PerformJSONGetRequest performs a GET request to the specified URL and returns the response body and eventual errors
8372func (c * Client ) PerformJSONGetRequest (url string ) ([]byte , error ) {
8473 request , err := http .NewRequest (http .MethodGet , url , nil )
@@ -90,23 +79,6 @@ func (c *Client) PerformJSONGetRequest(url string) ([]byte, error) {
9079 return c .performJSONRequest (request )
9180}
9281
93- // PerformPostRequest performs a POST request to the specified URL and returns the response body and eventual errors
94- func (c * Client ) PerformPostRequest (url string , requestBody []byte ) ([]byte , error ) {
95- var bodyReader io.Reader
96-
97- if requestBody != nil {
98- bodyReader = bytes .NewBuffer (requestBody )
99- }
100-
101- request , err := http .NewRequest (http .MethodPost , url , bodyReader )
102-
103- if err != nil {
104- return nil , err
105- }
106-
107- return c .performRequest (request )
108- }
109-
11082// PerformJSONPostRequest performs a POST request to the specified URL and returns the response body and eventual errors
11183func (c * Client ) PerformJSONPostRequest (url string , requestBody []byte ) ([]byte , error ) {
11284 var bodyReader io.Reader
@@ -124,33 +96,21 @@ func (c *Client) PerformJSONPostRequest(url string, requestBody []byte) ([]byte,
12496 return c .performJSONRequest (request )
12597}
12698
127- // PerformPutRequest performs a PUT request to the specified URL and returns the response body and eventual errors
128- func (c * Client ) PerformPutRequest (url string , requestBody []byte ) ([]byte , error ) {
99+ // PerformJSONPutRequest performs a PUT request to the specified URL and returns the response body and eventual errors
100+ func (c * Client ) PerformJSONPutRequest (url string , requestBody []byte ) ([]byte , error ) {
129101 var bodyReader io.Reader
130102
131103 if requestBody != nil {
132104 bodyReader = bytes .NewBuffer (requestBody )
133105 }
134106
135- request , err := http .NewRequest ("PUT" , url , bodyReader )
107+ request , err := http .NewRequest (http . MethodPut , url , bodyReader )
136108
137109 if err != nil {
138110 return nil , err
139111 }
140112
141- return c .performRequest (request )
142- }
143-
144- // PerformDeleteRequest performs a DELETE request to the specified URL and returns the response body and eventual errors
145- func (c * Client ) PerformDeleteRequest (url string ) error {
146- request , err := http .NewRequest (http .MethodDelete , url , nil )
147-
148- if err != nil {
149- return err
150- }
151-
152- _ , err = c .performRequest (request )
153- return err
113+ return c .performJSONRequest (request )
154114}
155115
156116// PerformJSONDeleteRequest performs a DELETE request to the specified URL and returns the response body and eventual errors
@@ -165,15 +125,6 @@ func (c *Client) PerformJSONDeleteRequest(url string) error {
165125 return err
166126}
167127
168- // Adds common headers to the specified request
169- func (c * Client ) addRequestHeaders (request * http.Request ) * http.Request {
170- request .SetBasicAuth (c .userName , c .password )
171- request .Header .Add ("Accept" , "application/xml" )
172- request .Header .Add ("Content-Type" , "application/xml" )
173-
174- return request
175- }
176-
177128// Adds common headers to the specified request
178129func (c * Client ) addJSONRequestHeaders (request * http.Request ) * http.Request {
179130 request .SetBasicAuth (c .userName , c .password )
@@ -183,18 +134,6 @@ func (c *Client) addJSONRequestHeaders(request *http.Request) *http.Request {
183134 return request
184135}
185136
186- // Performs the specified HTTP request and returns the response through handleResponse()
187- func (c * Client ) performRequest (request * http.Request ) ([]byte , error ) {
188- c .addRequestHeaders (request )
189- response , err := c .httpClient .Do (request )
190-
191- if err != nil {
192- return nil , err
193- }
194-
195- return handleResponse (response )
196- }
197-
198137// Performs the specified HTTP request and returns the response through handleResponse()
199138func (c * Client ) performJSONRequest (request * http.Request ) ([]byte , error ) {
200139 c .addJSONRequestHeaders (request )
0 commit comments