| @@ 46-73 (lines=28) @@ | ||
| 43 | * |
|
| 44 | * @return DataResponse |
|
| 45 | */ |
|
| 46 | public function addMember($uniqueId, $ident, $type) { |
|
| 47 | ||
| 48 | try { |
|
| 49 | $this->mustHaveFrontEndEnabled(); |
|
| 50 | ||
| 51 | $data = $this->membersService->addMember($uniqueId, $ident, (int)$type); |
|
| 52 | } catch (\Exception $e) { |
|
| 53 | return $this->fail( |
|
| 54 | [ |
|
| 55 | 'circle_id' => $uniqueId, |
|
| 56 | 'user_id' => $ident, |
|
| 57 | 'user_type' => (int)$type, |
|
| 58 | 'display' => MiscService::getDisplay($ident, (int)$type), |
|
| 59 | 'error' => $e->getMessage() |
|
| 60 | ] |
|
| 61 | ); |
|
| 62 | } |
|
| 63 | ||
| 64 | return $this->success( |
|
| 65 | [ |
|
| 66 | 'circle_id' => $uniqueId, |
|
| 67 | 'user_id' => $ident, |
|
| 68 | 'user_type' => (int)$type, |
|
| 69 | 'display' => MiscService::getDisplay($ident, (int)$type), |
|
| 70 | 'members' => $data |
|
| 71 | ] |
|
| 72 | ); |
|
| 73 | } |
|
| 74 | ||
| 75 | ||
| 76 | /** |
|
| @@ 164-192 (lines=29) @@ | ||
| 161 | * |
|
| 162 | * @return DataResponse |
|
| 163 | */ |
|
| 164 | public function removeMember($uniqueId, $member, $type) { |
|
| 165 | ||
| 166 | try { |
|
| 167 | $this->mustHaveFrontEndEnabled(); |
|
| 168 | ||
| 169 | $data = $this->membersService->removeMember($uniqueId, $member, (int)$type); |
|
| 170 | } catch (\Exception $e) { |
|
| 171 | return |
|
| 172 | $this->fail( |
|
| 173 | [ |
|
| 174 | 'circle_id' => $uniqueId, |
|
| 175 | 'user_id' => $member, |
|
| 176 | 'user_type' => (int)$type, |
|
| 177 | 'display' => MiscService::getDisplay($member, (int)$type), |
|
| 178 | 'error' => $e->getMessage() |
|
| 179 | ] |
|
| 180 | ); |
|
| 181 | } |
|
| 182 | ||
| 183 | return $this->success( |
|
| 184 | [ |
|
| 185 | 'circle_id' => $uniqueId, |
|
| 186 | 'user_id' => $member, |
|
| 187 | 'user_type' => (int)$type, |
|
| 188 | 'display' => MiscService::getDisplay($member, (int)$type), |
|
| 189 | 'members' => $data, |
|
| 190 | ] |
|
| 191 | ); |
|
| 192 | } |
|
| 193 | ||
| 194 | ||
| 195 | /** |
|