public static Field getOptions(TeamchatAPI api, String[] name) { Field f = api.objects().select().label("Buckets").name("bucket"); for (int i = 0; i < name.length; i++) { f.addOption(name[i]); } return f; }
@OnAlias("selectedproject") public void select_story(TeamchatAPI api) { String[] Project = api.context().currentReply().getField("project_name").split("-"); pid = Long.valueOf(Project[Project.length - 1]); String URL = "https://www.pivotaltracker.com/services/v5/projects/" + pid + "/stories"; String URL_parameter = ""; SendGet sg = new SendGet(); Field field_story = null; try { String jsonData = sg.sendGet(URL, USER_AGENT, URL_parameter, pb.getAccess_token()); Gson gson = new Gson(); Data[] Story = gson.fromJson(jsonData, Data[].class); field_story = api.objects().select().name("story_name").label("Story"); for (Data story : Story) { field_story.addOption(story.getName() + "-" + story.getId()); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } api.perform( api.context() .currentRoom() .post( new PrimaryChatlet() .setQuestion("Select story to be deleted") .setReplyScreen(api.objects().form().addField(field_story)) .alias("deleteselectedstory"))); }