Skip to content

Commit

Permalink
Fix errors in GetMessagesListPagination
Browse files Browse the repository at this point in the history
- Fix missing page param required for the API call
- Fix trying to parse response as XML instead of JSON
  • Loading branch information
printesoi committed Mar 18, 2024
1 parent 18e1a10 commit 1d1a3e9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
5 changes: 3 additions & 2 deletions invoice.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,9 @@ func (iv Invoice) XML() ([]byte, error) {
return iv.XMLIndent("", "")
}

// XMLIndent returns the XML encoding of the Invoice with the given prefix and
// indent.
// XMLIndent works like XML, but each XML element begins on a new
// indented line that starts with prefix and is followed by one or more
// copies of indent according to the nesting depth.
func (iv Invoice) XMLIndent(prefix, indent string) ([]byte, error) {
var b bytes.Buffer
if _, err := b.WriteString(xml.Header); err != nil {
Expand Down
10 changes: 6 additions & 4 deletions rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"regexp"
"strconv"
"strings"
"time"

"github.com/printesoi/xml-go"
)
Expand Down Expand Up @@ -568,12 +569,13 @@ func (c *Client) GetMessagesList(
// and a filter. For fetching all messages use MessageFilterAll as the value
// for msgType.
func (c *Client) GetMessagesListPagination(
ctx context.Context, cif string, startTs, endTs int64, msgType MessageFilterType,
ctx context.Context, cif string, startTs, endTs time.Time, page int64, msgType MessageFilterType,
) (response *MessagesListPaginationResponse, err error) {
query := url.Values{
"cif": {cif},
"startTime": {strconv.FormatInt(startTs, 10)},
"endTime": {strconv.FormatInt(endTs, 10)},
"startTime": {strconv.FormatInt(startTs.UnixMilli(), 10)},
"endTime": {strconv.FormatInt(endTs.UnixMilli(), 10)},
"pagina": {strconv.FormatInt(page, 10)},
}
if msgType != MessageFilterAll {
query.Set("filter", msgType.String())
Expand All @@ -584,7 +586,7 @@ func (c *Client) GetMessagesListPagination(
return
}

err = c.doApiUnmarshalXML(req, &response)
err = c.doApiUnmarshalJSON(req, &response)
return
}

Expand Down

0 comments on commit 1d1a3e9

Please sign in to comment.