Skip to content

Commit

Permalink
Proper success message
Browse files Browse the repository at this point in the history
  • Loading branch information
tdaron committed Feb 3, 2021
1 parent 8f5b89e commit 05d8ea0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
1 change: 1 addition & 0 deletions jira/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
type Worklog struct {
TimeSpentSeconds int `json:"timeSpentSeconds"`
Date string `json:"created"`
TimeSpent string `json:"timeSpent"`
}

func (w *Worklog) GetDate() string {
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func Handler(ctx context.Context, request events.APIGatewayProxyRequest) (events
return ErrorResponse(jiraRequest, err), nil
}

teamsnotifier.Notify(teamsnotifier.NewSuccess())
teamsnotifier.Notify(teamsnotifier.NewSuccess(jiraRequest))
return events.APIGatewayProxyResponse{
StatusCode: 200,
Body: "OK",
Expand Down
28 changes: 23 additions & 5 deletions teamsnotifier/notifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package teamsnotifier
import (
"bytes"
"encoding/json"
"fmt"
"jira-timesheet/jira"
"net/http"
"os"
Expand Down Expand Up @@ -53,7 +52,7 @@ func NewOdooError(request jira.Request, err error) Notification{
},
{
Name: "Worklog Time",
Value: fmt.Sprintf("%f", lastWorklog.GetHours()),
Value: lastWorklog.TimeSpent,
},
{
Name:"Timesheet Code",
Expand Down Expand Up @@ -86,17 +85,36 @@ func NewJiraError(err error) Notification{
}
}

func NewSuccess() Notification {
func NewSuccess(request jira.Request) Notification {
var lastWorklog = request.GetLastWorklog()
return Notification{
Summary: "success",
Type: "MessageCard",
Context: "http://schema.org/extensions",
Color: "00EE00",
Sections: []NotificationSection{
{
Title: "Request processed",
Subtitle: "Success",
Title: "Process Status",
Subtitle: "Done",
Image: "https://repository-images.githubusercontent.com/202264544/3ce58c00-19ab-11ea-8a01-81d62334b3ed",
Facts: []SectionFact{
{
Name: "Issue Key",
Value: request.Issue.Key,
},
{
Name: "Employee",
Value: request.User.Email,
},
{
Name: "Worklog Time",
Value: lastWorklog.TimeSpent,
},
{
Name:"Timesheet Code",
Value: request.Issue.Fields.TimesheetCode,
},
},
Markdown: true,

},
Expand Down

0 comments on commit 05d8ea0

Please sign in to comment.