forked from Invoiced/invoiced-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchasing.go
44 lines (31 loc) · 919 Bytes
/
chasing.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package invdapi
import (
"github.com/gabrielsoaressantos/invoiced-go/invdendpoint"
)
type ChasingCadence struct {
*Connection
*invdendpoint.ChasingCadence
}
type ChasingCadences []*ChasingCadence
func (c *Connection) NewChasingCadence() *ChasingCadence {
chasing := new(invdendpoint.ChasingCadence)
return &ChasingCadence{c, chasing}
}
func (c *ChasingCadence) ListAll(filter *invdendpoint.Filter, sort *invdendpoint.Sort) (ChasingCadences, error) {
endpoint := addFilterAndSort(invdendpoint.ChasingCadenceEndpoint, filter, sort)
chasing := make(ChasingCadences, 0)
NEXT:
tmpChasing := make(ChasingCadences, 0)
endpointTmp, apiErr := c.retrieveDataFromAPI(endpoint, &tmpChasing)
if apiErr != nil {
return nil, apiErr
}
chasing = append(chasing, tmpChasing...)
if endpointTmp != "" {
goto NEXT
}
for _, chase := range chasing {
chase.Connection = c.Connection
}
return chasing, nil
}