-
Notifications
You must be signed in to change notification settings - Fork 1
/
update_input.go
executable file
·50 lines (40 loc) · 1.39 KB
/
update_input.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
package services
import "github.com/aws/aws-lambda-go/events"
type UpdateInput struct {
ID string `dynamodbav:"id"`
DueAt int64 `dynamodbav:"dueAt"`
URL string `dynamodbav:"url"`
Method string `dynamodbav:"method"`
Headers map[string]string `dynamodbav:"headers,omitempty"`
Body *string `dynamodbav:"body,omitempty"`
StartedAt *int64 `dynamodbav:"startedAt"`
CompletedAt *int64 `dynamodbav:"completedAt"`
Status string `dynamodbav:"status"`
Result *string `dynamodbav:"result"`
CreatedAt int64 `dynamodbav:"createdAt"`
}
func CreateUpdateInput(
attributes map[string]events.DynamoDBAttributeValue) *UpdateInput {
var body string
if attr, found := attributes["body"]; found && !attr.IsNull() {
body = attr.String()
}
headers := make(map[string]string)
if attr, found := attributes["headers"]; found && !attr.IsNull() {
for k, v := range attr.Map() {
headers[k] = v.String()
}
}
dueAt, _ := attributes["dueAt"].Integer()
createdAt, _ := attributes["createdAt"].Integer()
input := UpdateInput{
ID: attributes["id"].String(),
DueAt: dueAt,
URL: attributes["url"].String(),
Method: attributes["method"].String(),
Headers: headers,
Body: &body,
CreatedAt: createdAt,
}
return &input
}