001/** 002 * Copyright (c) 2010-2019 Mark Allen, Norbert Bartels. 003 * 004 * Permission is hereby granted, free of charge, to any person obtaining a copy 005 * of this software and associated documentation files (the "Software"), to deal 006 * in the Software without restriction, including without limitation the rights 007 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 008 * copies of the Software, and to permit persons to whom the Software is 009 * furnished to do so, subject to the following conditions: 010 * 011 * The above copyright notice and this permission notice shall be included in 012 * all copies or substantial portions of the Software. 013 * 014 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 015 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 016 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 017 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 018 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 019 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 020 * THE SOFTWARE. 021 */ 022package com.restfb.types; 023 024import static java.util.Collections.unmodifiableList; 025 026import java.util.ArrayList; 027import java.util.List; 028 029import com.restfb.Facebook; 030import com.restfb.annotation.GraphAPI; 031 032/** 033 * Represents the <a href="http://developers.facebook.com/docs/api#impersonation">Account Graph API type</a>. 034 * 035 * @author <a href="http://restfb.com">Mark Allen</a> 036 */ 037public class Account extends Page { 038 039 private static final long serialVersionUID = 1L; 040 041 @Deprecated 042 @Facebook("perms") 043 private List<String> perms = new ArrayList<>(); 044 045 @Facebook("tasks") 046 private List<String> tasks = new ArrayList<>(); 047 048 /** 049 * A list of permissions the user has for this page. 050 * <a href="https://developers.facebook.com/docs/facebook-login/access-tokens/#pagetokens">See roles list here</a> 051 * 052 * @return A list of permissions the user has for this page. 053 * @deprecated since graph api v3.1, use getTasks() instead 054 */ 055 @Deprecated 056 @GraphAPI(until = "3.0") 057 public List<String> getPerms() { 058 return unmodifiableList(perms); 059 } 060 061 /** 062 * add a permission to the permission list. 063 * 064 * @param permission 065 * the permission that should be added 066 * @return {@code true} if the permission could be added 067 * @deprecated since graph api v3.1, use {@link Account#addTask} instead 068 */ 069 @Deprecated 070 @GraphAPI(until = "3.0") 071 public boolean addPerm(String permission) { 072 return perms.add(permission); 073 } 074 075 /** 076 * remove the permission from the permission list. 077 * 078 * @param permission 079 * the permission that should be removed 080 * @return {@code true} if the permission could be removed 081 * @deprecated since graph api v3.1, use {@link Account#removeTask} instead 082 */ 083 @Deprecated 084 @GraphAPI(until = "3.0") 085 public boolean removePerm(String permission) { 086 return perms.remove(permission); 087 } 088 089 /** 090 * A list of tasks allowed to perform for this page. 091 * <a href="https://developers.facebook.com/docs/pages/access-tokens#page-tasks">See tasks list here</a> 092 * 093 * @return A list of allowed tasks 094 */ 095 public List<String> getTasks() { 096 return unmodifiableList(tasks); 097 } 098 099 /** 100 * Add a task to the task list. 101 * 102 * @param task 103 */ 104 public boolean addTask(String task) { 105 return tasks.add(task); 106 } 107 108 /** 109 * Remove the task from the task list. 110 * 111 * @param task 112 * @return 113 */ 114 public boolean removeTask(String task) { 115 return tasks.remove(task); 116 } 117 118}