News & Announcements User Community Developer Community

Welcome to the RingCentral Community

Please note the community is currently under maintenance and is read-only.

Search
Make sure to review our Terms of Use and Community Guidelines.
  Please note the community is currently under maintenance and is read-only.
Home » Developers
Java 8 "var"
Tags: getting started
Feb 20, 2020 at 4:06pm   •   2 replies  •  0 likes
Ryan Phelps

As I'm going through the tutorials, some of them use var, a keyword introduced in Java 11. I'm still on Java 8. Anyone know the equivalent?


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);
    }
}


2 Answers
answered on Feb 20, 2020 at 7:13pm  

So you need to make 3 changes to the sample code:

Call_RingOut obj = new Call_RingOut();
obj.call_ringout();   // remove the second pair "()"

GetRingOutStatusResponse response = restClient.restapi().account().extension().ringout().post(requestBody);

Then it will work in Java 8

 0
answered on Feb 20, 2020 at 5:52pm  

You can find out the object name from the Java SDK sample codes.

GetRingOutStatusResponse is the response object returned from the ringout API.


 0



A new Community is coming to RingCentral!

Posts are currently read-only as we transition into our new platform.

We thank you for your patience
during this downtime.

Try Workflow Builder

Did you know you can easily automate tasks like responding to SMS, team messages, and more? Plus it's included with RingCentral Video and RingEX plans!

Try RingCentral Workflow Builder

PRODUCTS
RingEX
Message
Video
Phone
OPEN ECOSYSTEM
Developer Platform
APIs
Integrated Apps
App Gallery
Developer support
Games and rewards

RESOURCES
Resource center
Blog
Product Releases
Accessibility
QUICK LINKS
App Download
RingCentral App login
Admin Portal Login
Contact Sales
© 1999-2024 RingCentral, Inc. All rights reserved. Legal Privacy Notice Site Map Contact Us