| 35 | } |
| 36 | |
| 37 | func testConnection(ctx context.Context, connection models.SlackConn) (*SlackTestConnResponse, errors.Error) { |
| 38 | // validate |
| 39 | if vld != nil { |
| 40 | if err := vld.Struct(connection); err != nil { |
| 41 | return nil, errors.Default.Wrap(err, "error validating target") |
| 42 | } |
| 43 | } |
| 44 | // test connection |
| 45 | _, err := api.NewApiClientFromConnection(context.TODO(), basicRes, &connection) |
| 46 | if err != nil { |
| 47 | return nil, err |
| 48 | } |
| 49 | connection = connection.Sanitize() |
| 50 | body := SlackTestConnResponse{} |
| 51 | body.Success = true |
| 52 | body.Message = "success" |
| 53 | body.Connection = &connection |
| 54 | return &body, nil |
| 55 | } |
| 56 | |
| 57 | // TestConnection test slack connection |
| 58 | // @Summary test slack connection |