Fixes issue #134 - Create list with API
This commit is contained in:
parent
503a643179
commit
13f047ed94
|
@ -1131,6 +1131,33 @@ public class API {
|
|||
return apiResponse;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Posts a list
|
||||
* @param title String, the title of the list
|
||||
* @return APIResponse
|
||||
*/
|
||||
public APIResponse createList(String title){
|
||||
|
||||
HashMap<String, String> params = new HashMap<>();
|
||||
params.put("title",title);
|
||||
List<fr.gouv.etalab.mastodon.client.Entities.List> lists = new ArrayList<>();
|
||||
fr.gouv.etalab.mastodon.client.Entities.List list;
|
||||
try {
|
||||
String response = new HttpsConnection().post(getAbsoluteUrl("/lists"), 60, params, prefKeyOauthTokenT);
|
||||
list = parseList(new JSONObject(response));
|
||||
lists.add(list);
|
||||
} catch (HttpsConnection.HttpsConnectionException e) {
|
||||
setError(e.getStatusCode(), e);
|
||||
}catch (Exception e) {
|
||||
setDefaultError();
|
||||
}
|
||||
apiResponse.setLists(lists);
|
||||
return apiResponse;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Parse json response an unique account
|
||||
* @param resobj JSONObject
|
||||
|
|
|
@ -30,6 +30,7 @@ public class APIResponse {
|
|||
private List<Context> contexts = null;
|
||||
private List<Notification> notifications = null;
|
||||
private List<Relationship> relationships = null;
|
||||
private List<fr.gouv.etalab.mastodon.client.Entities.List> lists = null;
|
||||
private List<Emojis> emojis = null;
|
||||
private fr.gouv.etalab.mastodon.client.Entities.Error error = null;
|
||||
private String since_id, max_id;
|
||||
|
@ -114,4 +115,12 @@ public class APIResponse {
|
|||
public void setEmojis(List<Emojis> emojis) {
|
||||
this.emojis = emojis;
|
||||
}
|
||||
|
||||
public List<fr.gouv.etalab.mastodon.client.Entities.List> getLists() {
|
||||
return lists;
|
||||
}
|
||||
|
||||
public void setLists(List<fr.gouv.etalab.mastodon.client.Entities.List> lists) {
|
||||
this.lists = lists;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue