-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpayload.go
39 lines (30 loc) · 844 Bytes
/
payload.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
// Copyright 2022 Axel Etcheverry. All rights reserved.
// Use of this source code is governed by a MIT
// license that can be found in the LICENSE file.
package amplitude
import "fmt"
type RequestPayload struct {
APIKey string `json:"api_key"`
Events []*Event `json:"events"`
Options *PayloadOptions `json:"options,omitempty"`
}
type PayloadOptions struct {
MinIDLength int `json:"min_id_length"`
}
type Payload struct {
Body []byte
Attempts int
Size int
}
type ErrorResponse struct {
Code int `json:"code"`
ErrorMessage string `json:"error"`
MissingField string `json:"missing_field"`
}
func (e *ErrorResponse) Error() string {
msg := fmt.Sprintf("%d: %s", e.Code, e.ErrorMessage)
if e.MissingField != "" {
msg = fmt.Sprintf("%s: missing: %s", msg, e.MissingField)
}
return msg
}