Added Verbose mode
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *Client) executeRequest(ctx context.Context, request FiscalRequest, response interface{}) error {
|
func (c *Client) executeRequest(ctx context.Context, request FiscalRequest, response interface{}) error {
|
||||||
@@ -15,12 +16,16 @@ func (c *Client) executeRequest(ctx context.Context, request FiscalRequest, resp
|
|||||||
return fmt.Errorf("failed to marshal request: %w", err)
|
return fmt.Errorf("failed to marshal request: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
url := c.apiBaseURL + c.fiscalEndpoint
|
||||||
|
log.Printf("[VCHASNO] POST %s", url)
|
||||||
|
log.Printf("[VCHASNO] Request: %s", string(reqJson))
|
||||||
|
|
||||||
resp, err := c.resty.R().
|
resp, err := c.resty.R().
|
||||||
SetContext(ctx).
|
SetContext(ctx).
|
||||||
SetHeader("Authorization", c.token).
|
SetHeader("Authorization", c.token).
|
||||||
SetHeader("Content-Type", "application/json").
|
SetHeader("Content-Type", "application/json").
|
||||||
SetBody(reqJson).
|
SetBody(reqJson).
|
||||||
Post(c.apiBaseURL + c.fiscalEndpoint)
|
Post(url)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("request failed: %w", err)
|
return fmt.Errorf("request failed: %w", err)
|
||||||
@@ -31,6 +36,8 @@ func (c *Client) executeRequest(ctx context.Context, request FiscalRequest, resp
|
|||||||
return fmt.Errorf("failed to read response: %w", err)
|
return fmt.Errorf("failed to read response: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Printf("[VCHASNO] Response (status %d): %s", resp.StatusCode(), string(body))
|
||||||
|
|
||||||
if resp.StatusCode() != 200 {
|
if resp.StatusCode() != 200 {
|
||||||
return fmt.Errorf("api error (status %d): %s", resp.StatusCode(), string(body))
|
return fmt.Errorf("api error (status %d): %s", resp.StatusCode(), string(body))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user