-
Notifications
You must be signed in to change notification settings - Fork 20
/
event.go
44 lines (35 loc) · 1 KB
/
event.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 lago
import "context"
type EventRequest struct {
client *Client
}
type EventParams struct {
Event *EventInput `json:"event"`
}
type EventInput struct {
TransactionID string `json:"transaction_id,omitempty"`
ExternalCustomerID string `json:"external_customer_id,omitempty"`
ExternalSubscriptionID string `json:"external_subscription_id,omitempty"`
Code string `json:"code,omitempty"`
Timestamp int64 `json:"timestamp,omitempty"`
Properties map[string]string `json:"properties,omitempty"`
}
func (c *Client) Event() *EventRequest {
return &EventRequest{
client: c,
}
}
func (er *EventRequest) Create(ctx context.Context, eventInput *EventInput) *Error {
eventParams := &EventParams{
Event: eventInput,
}
clientRequest := &ClientRequest{
Path: "events",
Body: eventParams,
}
err := er.client.PostWithoutResult(ctx, clientRequest)
if err != nil {
return err
}
return nil
}