77 "github.com/DanielFillol/DataJUD_API_CALLER/models"
88 "io"
99 "io/ioutil"
10- "log"
1110 "net/http"
1211 "strconv"
1312 "time"
@@ -29,7 +28,6 @@ func APIRequest(url, method string, auth string, request models.ReadCsv) (models
2928 // Serialize the BodyRequest struct to JSON.
3029 jsonReq , err := json .Marshal (req )
3130 if err != nil {
32- log .Println (err )
3331 return models.ResponseBody {}, err
3432 }
3533
@@ -39,22 +37,19 @@ func APIRequest(url, method string, auth string, request models.ReadCsv) (models
3937 // Make the API call and get the response.
4038 res , err := call (url , method , auth , reqBody )
4139 if err != nil {
42- log .Println (err )
4340 return models.ResponseBody {}, errors .New (err .Error () + " " + req .Query .Match .CNJNumber )
4441 }
4542
4643 // Read the response body.
4744 body , err := ioutil .ReadAll (res .Body )
4845 if err != nil {
49- log .Println (err )
5046 return models.ResponseBody {}, err
5147 }
5248
5349 // Unmarshal the response body into a ResponseBody struct.
5450 var response models.ResponseBody
5551 err = json .Unmarshal (body , & response )
5652 if err != nil {
57- log .Println (err )
5853 return models.ResponseBody {}, err
5954 }
6055
@@ -75,7 +70,6 @@ func call(url, method string, AUTH string, body io.Reader) (*http.Response, erro
7570 // Create a new HTTP request with the specified method, URL, and request body.
7671 req , err := http .NewRequest (method , url , body )
7772 if err != nil {
78- log .Println (err )
7973 return nil , err
8074 }
8175
@@ -86,14 +80,11 @@ func call(url, method string, AUTH string, body io.Reader) (*http.Response, erro
8680 // Send the request and get the response.
8781 response , err := client .Do (req )
8882 if err != nil {
89- log .Println (err )
9083 return nil , err
9184 }
9285
9386 // If the response status code is not OK, return an error with the status code.
9487 if response .StatusCode != http .StatusOK {
95- log .Println (req .URL )
96- log .Println (strconv .Itoa (response .StatusCode ))
9788 return nil , errors .New (strconv .Itoa (response .StatusCode ))
9889 }
9990
0 commit comments