(methodDecl *wshrpc.WshRpcMethodDecl, tsTypesMap map[reflect.Type]string)
| 481 | } |
| 482 | |
| 483 | func generateWshClientApiMethod_Call(methodDecl *wshrpc.WshRpcMethodDecl, tsTypesMap map[reflect.Type]string) string { |
| 484 | var sb strings.Builder |
| 485 | sb.WriteString(fmt.Sprintf(" // command %q [%s]\n", methodDecl.Command, methodDecl.CommandType)) |
| 486 | rtnType := "Promise<void>" |
| 487 | if methodDecl.DefaultResponseDataType != nil { |
| 488 | rtnTypeName, _ := TypeToTSType(methodDecl.DefaultResponseDataType, tsTypesMap) |
| 489 | rtnType = fmt.Sprintf("Promise<%s>", rtnTypeName) |
| 490 | } |
| 491 | methodSigDataParams, dataName := getTsWshMethodDataParamsAndExpr(methodDecl, tsTypesMap) |
| 492 | if methodSigDataParams == "" { |
| 493 | sb.WriteString(fmt.Sprintf(" %s(client: WshClient, opts?: RpcOpts): %s {\n", methodDecl.MethodName, rtnType)) |
| 494 | } else { |
| 495 | sb.WriteString(fmt.Sprintf(" %s(client: WshClient, %s, opts?: RpcOpts): %s {\n", methodDecl.MethodName, methodSigDataParams, rtnType)) |
| 496 | } |
| 497 | sb.WriteString(fmt.Sprintf(" if (this.mockClient) return this.mockClient.mockWshRpcCall(client, %q, %s, opts);\n", methodDecl.Command, dataName)) |
| 498 | sb.WriteString(fmt.Sprintf(" return client.wshRpcCall(%q, %s, opts);\n", methodDecl.Command, dataName)) |
| 499 | sb.WriteString(" }\n") |
| 500 | return sb.String() |
| 501 | } |
| 502 | |
| 503 | func getTsWshMethodDataParamsAndExpr(methodDecl *wshrpc.WshRpcMethodDecl, tsTypesMap map[reflect.Type]string) (string, string) { |
| 504 | dataTypes := methodDecl.GetCommandDataTypes() |
no test coverage detected