com.google.api.services.consumersurveys.Consumersurveys

Here are the examples of the java api class com.google.api.services.consumersurveys.Consumersurveys taken from open source projects.

1. App#main()

Project: consumer-surveys
File: App.java
public static void main(String[] args) throws Exception {
    ArgumentParser parser = ArgumentParsers.newArgumentParser("App").defaultHelp(true).description("Create and modify surveys.");
    parser.addArgument("-o", "--option").choices(OPTIONS).help("The operation to perform.");
    parser.addArgument("-oe", "--owner_email").nargs("*").help("Specify owners' email to use to create surveys.");
    parser.addArgument("-s", "--survey_id").help("survey id to start the survey");
    parser.addArgument("-rf", "--result_file").setDefault("results.xls").help("filename to store excel results");
    parser.addArgument("-se", "--service_account_email").type(String.class).help("Specify a bot email to use for auth.");
    Namespace ns = null;
    try {
        ns = parser.parseArgs(args);
    } catch (ArgumentParserException e) {
        parser.handleError(e);
        System.exit(1);
    }
    String option = ns.getString("option");
    String serviceAccountEmail = ns.getString("service_account_email");
    List<String> owners = ns.<String>getList("owner_email");
    String resultFile = ns.getString("result_file");
    String surveyId = ns.getString("survey_id");
    if (serviceAccountEmail == null) {
        System.out.println("\n\nMissing serviceAccountEmail. " + "serviceAccountEmail is necssary for authenication");
        System.exit(1);
    }
    if (option == null) {
        System.out.println("\n\nMissing option. " + "You must use one of these options: " + OPTIONS);
        System.exit(1);
    }
    Consumersurveys cs = getConsumerSurverysService(serviceAccountEmail);
    try {
        if (option.equals(CREATE)) {
            if (owners == null) {
                System.out.println("\n\nMissing owners. " + "You must specify owners to create a survey.");
                System.exit(1);
            }
            Survey survey = createSurvey(cs, owners);
        }
        if (option.equals(START)) {
            if (surveyId == null) {
                System.out.println("\n\nMissing surveyId. " + "You must specify surveyId to start a survey.");
                System.exit(1);
            }
            startSurvey(cs, surveyId);
        }
        if (option.equals(SET_RESPONSE_COUNT)) {
            if (surveyId == null) {
                System.out.println("\n\nMissing surveyId. " + "You must specify surveyId to set a response count.");
                System.exit(1);
            }
            updateSurveyResponseCount(cs, surveyId, 120);
        }
        if (option.equals(FETCH)) {
            if (surveyId == null) {
                System.out.println("\n\nMissing surveyId. " + "You must specify surveyId to get the results.");
                System.exit(1);
            }
            getSurveyResults(cs, surveyId, resultFile);
        }
        if (option.equals(LIST)) {
            listSurveys(cs);
        }
    } catch (GoogleJsonResponseException e) {
        System.err.println(e.getDetails());
    }
}