Created method visibility_level_to_api

This commit is contained in:
Pierre HUBERT 2018-08-01 07:19:44 +02:00
parent f0b9058894
commit 78aadd55a1

View File

@ -212,23 +212,7 @@ public class PostsHelper {
} }
//Determine the visibility level of the post //Determine the visibility level of the post
switch (post.getVisibilityLevel()){ req.addString("visibility", visibility_level_to_api(post.getVisibilityLevel()));
case PUBLIC:
req.addString("visibility", "public");
break;
case FRIENDS:
req.addString("visibility", "friends");
break;
case PRIVATE:
req.addString("visibility", "private");
break;
default:
throw new RuntimeException("Unsupported kind of Visibility level!");
}
//Set the kind of target page //Set the kind of target page
switch (post.getPage_type()){ switch (post.getPage_type()){
@ -407,4 +391,27 @@ public class PostsHelper {
return post; return post;
} }
/**
* Turn a POST visibility level into a string ready for the API
*
* @param level The level to convert
* @return Generated API string
*/
private String visibility_level_to_api(PostVisibilityLevels level){
switch (level){
case PUBLIC:
return "public";
case FRIENDS:
return "friends";
case PRIVATE:
return "private";
default:
throw new RuntimeException("Unsupported kind of Visibility level!");
}
}
} }