我正在用RingCentral编写一个教程,它使用了var。我还在用java 8,有人知道该怎么写吗?
package Call_RingOut;
import java.io.IOException;
import com.ringcentral.*;
import com.ringcentral.definitions.*;
public class Call_RingOut {
static String RECIPIENT_NUMBER = "<ENTER PHONE NUMBER>";
static String RINGCENTRAL_CLIENTID = "<ENTER CLIENT ID>";
static String RINGCENTRAL_CLIENTSECRET = "<ENTER CLIENT SECRET>";
static String RINGCENTRAL_SERVER = "https://platform.devtest.ringcentral.com";
static String RINGCENTRAL_USERNAME = "<YOUR ACCOUNT PHONE NUMBER>";
static String RINGCENTRAL_PASSWORD = "<YOUR ACCOUNT PASSWORD>";
static String RINGCENTRAL_EXTENSION = "<YOUR EXTENSION, PROBABLY '101'>";
static RestClient restClient;
public static void main(String[] args) {
var obj = new Call_RingOut();
try {
restClient = new RestClient(RINGCENTRAL_CLIENTID, RINGCENTRAL_CLIENTSECRET, RINGCENTRAL_SERVER);
restClient.authorize(RINGCENTRAL_USERNAME, RINGCENTRAL_EXTENSION, RINGCENTRAL_PASSWORD);
obj.call_ringout()();
} catch (RestException | IOException e) {
e.printStackTrace();
}
}
public void call_ringout() throws RestException, IOException {
MakeRingOutRequest requestBody = new MakeRingOutRequest();
requestBody.from(new MakeRingOutCallerInfoRequestFrom().phoneNumber(RINGCENTRAL_USERNAME));
requestBody.to(new MakeRingOutCallerInfoRequestTo().phoneNumber(RECIPIENT_NUMBER));
requestBody.playPrompt = false;
var response = restClient.restapi().account().extension().ringout().post(requestBody);
System.out.println("Call Placed. Call status: " + response.status.callStatus);
}
}发布于 2020-02-21 20:31:43
如果您将Lombok添加到您的项目中,则可以使用var in Java 8。实现并不相同,但对于您的目的来说,这是无关紧要的。
发布于 2020-02-21 10:58:49
您可以将var替换为GetRingOutStatusResponse,它是最终消息post()的返回值的类。
GetRingOutStatusResponse response = restClient.restapi().account().extension().ringout().post(requestBody);发布于 2020-02-21 11:04:51
试试下面的内容
Call_RingOut obj = new Call_RingOut();
GetRingOutStatusResponse response = restClient.restapi().account().extension().ringout().post(requestBody);
https://stackoverflow.com/questions/60330389
复制相似问题