forked from svix/svix-webhooks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheventtype.go
64 lines (56 loc) · 1.71 KB
/
eventtype.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package svix
import (
"context"
"github.com/svix/svix-libs/go/internal/openapi"
)
type EventType struct {
api *openapi.APIClient
}
type (
ListResponseEventTypeOut openapi.ListResponseEventTypeOut
EventTypeIn openapi.EventTypeIn
EventTypeOut openapi.EventTypeOut
EventTypeUpdate openapi.EventTypeUpdate
)
func (e *EventType) List(options *FetchOptions) (*ListResponseEventTypeOut, error) {
req := e.api.EventTypeApi.ListEventTypesApiV1EventTypeGet(context.Background())
if options != nil {
if options.Iterator != nil {
req = req.Iterator(*options.Iterator)
}
if options.Limit != nil {
req = req.Limit(*options.Limit)
}
}
out, _, err := req.Execute()
if err != nil {
return nil, err
}
ret := ListResponseEventTypeOut(out)
return &ret, nil
}
func (e *EventType) Create(eventTypeIn *EventTypeIn) (*EventTypeOut, error) {
req := e.api.EventTypeApi.CreateEventTypeApiV1EventTypePost(context.Background())
req = req.EventTypeIn(openapi.EventTypeIn(*eventTypeIn))
out, _, err := req.Execute()
if err != nil {
return nil, err
}
ret := EventTypeOut(out)
return &ret, nil
}
func (e *EventType) Update(eventTypeName string, eventTypeUpdate *EventTypeUpdate) (*EventTypeOut, error) {
req := e.api.EventTypeApi.UpdateEventTypeApiV1EventTypeEventTypeNamePut(context.Background(), eventTypeName)
req = req.EventTypeUpdate(openapi.EventTypeUpdate(*eventTypeUpdate))
out, _, err := req.Execute()
if err != nil {
return nil, err
}
ret := EventTypeOut(out)
return &ret, nil
}
func (e *EventType) Delete(eventTypeName string) error {
req := e.api.EventTypeApi.DeleteEventTypeApiV1EventTypeEventTypeNameDelete(context.Background(), eventTypeName)
_, err := req.Execute()
return err
}