-
Notifications
You must be signed in to change notification settings - Fork 0
/
invoices.query.resolvers.go
39 lines (31 loc) · 1.22 KB
/
invoices.query.resolvers.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
package graph
// This file will be automatically regenerated based on the schema, any resolver implementations
// will be copied through when generating and any unknown code will be moved to the end.
// Code generated by github.com/99designs/gqlgen version v0.17.38
import (
"context"
"fmt"
"github.com/fidesy-pay/facade/internal/pkg/middleware/auth"
"github.com/fidesy-pay/facade/internal/pkg/model"
invoicesservice "github.com/fidesy-pay/facade/internal/pkg/services/invoices-service"
)
// Invoices is the resolver for the invoices field.
func (r *queryResolver) Invoices(ctx context.Context, filter *model.InvoicesFilter) (*model.InvoicesPagination, error) {
session := auth.GetSession(ctx)
listInvoicesFilter := invoicesservice.ListInvoicesFilter{}
if filter != nil && len(filter.StatusIn) > 0 {
listInvoicesFilter.StatusIn = filter.StatusIn
}
if filter != nil && len(filter.IDIn) > 0 {
listInvoicesFilter.IDIn = filter.IDIn
} else {
listInvoicesFilter.ClientIDIn = []string{session.ClientID}
}
invoices, err := r.invoicesService.ListInvoices(ctx, listInvoicesFilter)
if err != nil {
return nil, fmt.Errorf("invoicesService.ListInvoices: %w", err)
}
return &model.InvoicesPagination{
Items: invoices,
}, nil
}