| 35 | } |
| 36 | |
| 37 | func testConnection(ctx context.Context, connection models.FeishuConn) (*FeishuTestConnResponse, 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 | _, err := api.NewApiClientFromConnection(ctx, basicRes, &connection) |
| 45 | if err != nil { |
| 46 | return nil, err |
| 47 | } |
| 48 | connection = connection.Sanitize() |
| 49 | body := FeishuTestConnResponse{} |
| 50 | body.Success = true |
| 51 | body.Message = "success" |
| 52 | body.Connection = &connection |
| 53 | |
| 54 | return &body, nil |
| 55 | } |
| 56 | |
| 57 | // TestConnection test feishu connection |
| 58 | // @Summary test feishu connection |