| @@ 44-67 (lines=24) @@ | ||
| 41 | * |
|
| 42 | * @return DataResponse |
|
| 43 | */ |
|
| 44 | public function addLocalMember($uniqueId, $name) { |
|
| 45 | ||
| 46 | try { |
|
| 47 | $data = $this->membersService->addLocalMember($uniqueId, $name); |
|
| 48 | } catch (\Exception $e) { |
|
| 49 | return $this->fail( |
|
| 50 | [ |
|
| 51 | 'circle_id' => $uniqueId, |
|
| 52 | 'user_id' => $name, |
|
| 53 | 'name' => $this->miscService->getDisplayName($name, true), |
|
| 54 | 'error' => $e->getMessage() |
|
| 55 | ] |
|
| 56 | ); |
|
| 57 | } |
|
| 58 | ||
| 59 | return $this->success( |
|
| 60 | [ |
|
| 61 | 'circle_id' => $uniqueId, |
|
| 62 | 'user_id' => $name, |
|
| 63 | 'name' => $this->miscService->getDisplayName($name, true), |
|
| 64 | 'members' => $data |
|
| 65 | ] |
|
| 66 | ); |
|
| 67 | } |
|
| 68 | ||
| 69 | ||
| 70 | /** |
|
| @@ 79-102 (lines=24) @@ | ||
| 76 | * |
|
| 77 | * @return DataResponse |
|
| 78 | */ |
|
| 79 | public function addEmailAddress($uniqueId, $email) { |
|
| 80 | ||
| 81 | try { |
|
| 82 | $data = $this->membersService->addEmailAddress($uniqueId, $email); |
|
| 83 | } catch (\Exception $e) { |
|
| 84 | return $this->fail( |
|
| 85 | [ |
|
| 86 | 'circle_id' => $uniqueId, |
|
| 87 | 'user_id' => $email, |
|
| 88 | 'name' => $this->miscService->getDisplayName($email, true), |
|
| 89 | 'error' => $e->getMessage() |
|
| 90 | ] |
|
| 91 | ); |
|
| 92 | } |
|
| 93 | ||
| 94 | return $this->success( |
|
| 95 | [ |
|
| 96 | 'circle_id' => $uniqueId, |
|
| 97 | 'user_id' => $email, |
|
| 98 | 'name' => $this->miscService->getDisplayName($email, true), |
|
| 99 | 'members' => $data |
|
| 100 | ] |
|
| 101 | ); |
|
| 102 | } |
|
| 103 | ||
| 104 | ||
| 105 | /** |
|
| @@ 114-137 (lines=24) @@ | ||
| 111 | * |
|
| 112 | * @return DataResponse |
|
| 113 | */ |
|
| 114 | public function importFromGroup($uniqueId, $name) { |
|
| 115 | ||
| 116 | try { |
|
| 117 | $data = $this->membersService->importMembersFromGroup($uniqueId, $name); |
|
| 118 | } catch (\Exception $e) { |
|
| 119 | return $this->fail( |
|
| 120 | [ |
|
| 121 | 'circle_id' => $uniqueId, |
|
| 122 | 'user_id' => $name, |
|
| 123 | 'name' => $this->miscService->getDisplayName($name, true), |
|
| 124 | 'error' => $e->getMessage() |
|
| 125 | ] |
|
| 126 | ); |
|
| 127 | } |
|
| 128 | ||
| 129 | return $this->success( |
|
| 130 | [ |
|
| 131 | 'circle_id' => $uniqueId, |
|
| 132 | 'user_id' => $name, |
|
| 133 | 'name' => $this->miscService->getDisplayName($name, true), |
|
| 134 | 'members' => $data |
|
| 135 | ] |
|
| 136 | ); |
|
| 137 | } |
|
| 138 | ||
| 139 | ||
| 140 | /** |
|
| @@ 188-212 (lines=25) @@ | ||
| 185 | * |
|
| 186 | * @return DataResponse |
|
| 187 | */ |
|
| 188 | public function removeLocalMember($uniqueId, $member) { |
|
| 189 | ||
| 190 | try { |
|
| 191 | $data = $this->membersService->removeMember($uniqueId, $member, Member::TYPE_USER); |
|
| 192 | } catch (\Exception $e) { |
|
| 193 | return |
|
| 194 | $this->fail( |
|
| 195 | [ |
|
| 196 | 'circle_id' => $uniqueId, |
|
| 197 | 'user_id' => $member, |
|
| 198 | 'name' => $this->miscService->getDisplayName($member, true), |
|
| 199 | 'error' => $e->getMessage() |
|
| 200 | ] |
|
| 201 | ); |
|
| 202 | } |
|
| 203 | ||
| 204 | return $this->success( |
|
| 205 | [ |
|
| 206 | 'circle_id' => $uniqueId, |
|
| 207 | 'user_id' => $member, |
|
| 208 | 'name' => $this->miscService->getDisplayName($member, true), |
|
| 209 | 'members' => $data, |
|
| 210 | ] |
|
| 211 | ); |
|
| 212 | } |
|
| 213 | ||
| 214 | ||
| 215 | } |
|