public function testAddMember() { $email = Utils::randomEmail(); $user = new User(); $user->setEmail($email); $newUser = Utils::getBuddy()->getApiMembers()->addWorkspaceMember($user, Utils::getWorkspaceDomain()); $this->assertInstanceOf('Buddy\\Objects\\User', $newUser); $this->assertEquals($email, $newUser->getEmail()); }
public function testUpdateUser() { $user = new User(); $user->setTitle(Utils::randomString()); $user->setName(Utils::randomString()); $resp = Utils::getBuddy()->getApiProfile()->editAuthenticatedUser($user); $this->assertInstanceOf('Buddy\\Objects\\User', $resp); $this->assertEquals($user->getName(), $resp->getName()); $this->assertEquals($user->getTitle(), $resp->getTitle()); }
public function editMember() { try { $buddy = new Buddy(['accessToken' => 'yourAccessToken']); $user = new User(); $user->setAdmin(true); $resp = $buddy->getApiMembers()->editWorkspaceMember($user, 'domain', 1); var_dump($resp); exit; } catch (BuddyResponseException $e) { echo $e->getMessage(); exit; } catch (BuddySDKException $e) { echo $e->getMessage(); exit; } }
public function editAuthenticatedUser() { try { $buddy = new Buddy(['accessToken' => 'yourAccessToken']); $user = new User(); $user->setName('My new name'); $resp = $buddy->getApiProfile()->editAuthenticatedUser($user); var_dump($resp); exit; } catch (BuddyResponseException $e) { echo $e->getMessage(); exit; } catch (BuddySDKException $e) { echo $e->getMessage(); exit; } }
/** * @param Project $project * @param User $user * @return User * @throws BuddySDKException */ public static function addUser2Project(Project $project, User $user) { $user->setPermissionSet(self::addPermission()); return Utils::getBuddy()->getApiProjects()->addProjectMember($user, Utils::getWorkspaceDomain(), $project->getName()); }
/** * @param User $user * @param string $domain * @param int $groupId * @param null|string $accessToken * @return User */ public function addGroupMember(User $user, $domain, $groupId, $accessToken = null) { return $this->postJson($accessToken, ['id' => $user->getId()], '/workspaces/:domain/groups/:group_id/members', ['domain' => $domain, 'group_id' => $groupId])->getAsUser(); }
public function testAddProjectMember() { $project = Utils::addProject(); $user = Utils::addUser(); $perm = Utils::addPermission(); $perm2 = new PermissionSet(); $perm2->setId($perm->getId()); $member = new User(); $member->setId($user->getId()); $member->setPermissionSet($perm2); $resp = Utils::getBuddy()->getApiProjects()->addProjectMember($member, Utils::getWorkspaceDomain(), $project->getName()); $this->assertInstanceOf('Buddy\\Objects\\User', $resp); $this->assertEquals($member->getId(), $resp->getId()); }
/** * @param User $user * @param string $domain * @param int $memberId * @param null|string $accessToken * @return User */ public function editWorkspaceMember(User $user, $domain, $memberId, $accessToken = null) { return $this->patchJson($accessToken, ['admin' => $user->getAdmin()], '/workspaces/:domain/members/:member_id', ['domain' => $domain, 'member_id' => $memberId])->getAsUser(); }
/** * @param User $user * @param null|string $accessToken * @return User */ public function editAuthenticatedUser(User $user, $accessToken = null) { return $this->patchJson($accessToken, ['name' => $user->getName(), 'title' => $user->getTitle()], '/user')->getAsUser(); }
/** * @param User $user * @param string $domain * @param string $projectName * @param int $memberId * @param null|string $accessToken * @return User * @throws BuddySDKException */ public function editProjectMember(User $user, $domain, $projectName, $memberId, $accessToken = null) { if (!$user->getPermissionSet() instanceof PermissionSet) { throw new BuddySDKException('PermissionSet must be set'); } return $this->patchJson($accessToken, ['permission_set' => ['id' => $user->getPermissionSet()->getId()]], '/workspaces/:domain/projects/:project_name/members/:member_id', ['domain' => $domain, 'project_name' => $projectName, 'member_id' => $memberId])->getAsUser(); }
public function addGroupMember() { try { $buddy = new Buddy(['accessToken' => 'yourAccessToken']); $user = new User(); $user->setId(2); $resp = $buddy->getApiGroups()->addGroupMember($user, 'domain', 1); var_dump($resp); exit; } catch (BuddyResponseException $e) { echo $e->getMessage(); exit; } catch (BuddySDKException $e) { echo $e->getMessage(); exit; } }
public function editProjectMember() { try { $buddy = new Buddy(['accessToken' => 'yourAccessToken']); $permission = new PermissionSet(); $permission->setId(2); $user = new User(); $user->setPermissionSet($permission); $resp = $buddy->getApiProjects()->editProjectMember($user, 'domain', 'projectName', 1); var_dump($resp); exit; } catch (BuddyResponseException $e) { echo $e->getMessage(); exit; } catch (BuddySDKException $e) { echo $e->getMessage(); exit; } }