@@ -94,6 +94,49 @@ type RequestHeader struct {
9494 Value string
9595}
9696
97+ // DoRequestWithoutAuth performs the HTTP request with the current ServiceClient's HTTPClient.
98+ // Authentication and optional headers will be added automatically.
99+ //
100+ //nolint:bodyclose
101+ func (client * ServiceClient ) DoRequestWithoutAuth (
102+ ctx context.Context , method , path string , body io.Reader , headers ... * RequestHeader ,
103+ ) (* ResponseResult , error ) {
104+ // Prepare an HTTP request with the provided context.
105+ request , err := http .NewRequestWithContext (ctx , method , path , body )
106+ if err != nil {
107+ return nil , err
108+ }
109+
110+ request .Header .Set ("User-Agent" , client .userAgent )
111+ if body != nil {
112+ request .Header .Set ("Content-Type" , "application/json" )
113+ }
114+
115+ for _ , header := range headers {
116+ request .Header .Set (header .Key , header .Value )
117+ }
118+
119+ // Send the HTTP request and populate the ResponseResult.
120+ response , err := client .HTTPClient .Do (request )
121+ if err != nil {
122+ return nil , err
123+ }
124+
125+ responseResult := & ResponseResult {
126+ Response : response ,
127+ }
128+
129+ // Check status code and populate custom error body with extended error message if it's possible.
130+ if response .StatusCode >= http .StatusBadRequest {
131+ err = responseResult .extractErr ()
132+ }
133+ if err != nil {
134+ return nil , err
135+ }
136+
137+ return responseResult , nil
138+ }
139+
97140// DoRequest performs the HTTP request with the current ServiceClient's HTTPClient.
98141// Authentication and optional headers will be added automatically.
99142//
0 commit comments