-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.go
35 lines (30 loc) · 788 Bytes
/
main.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
package main
import (
"context"
"fmt"
"os"
"github.com/aws/aws-lambda-go/lambda"
"github.com/pkg/errors"
"github.com/potsbo/jobcan/account"
"github.com/potsbo/jobcan/config"
)
func jobcanTouch(ctx context.Context, c config.Config) (string, error) {
if !c.Valid() {
return "", errors.Errorf("Not enough credential given")
}
mode := os.Getenv("JOBCAN_ADIT")
if len(mode) == 0 {
return "", errors.Errorf("env var JOBCAN_ADIT is empty")
}
a := account.New(c)
if err := a.Login(); err != nil {
return "", errors.Wrap(err, "failed to login")
}
if err := a.ExecAttendance(mode); err != nil {
return "", errors.Wrap(err, "failed to record")
}
return fmt.Sprintf("Your \"%s\" has successfully been recorded.", mode), nil
}
func main() {
lambda.Start(jobcanTouch)
}