| @@ 43-66 (lines=24) @@ | ||
| 40 | * |
|
| 41 | * @return DataResponse |
|
| 42 | */ |
|
| 43 | public function add($uniqueId, $name) { |
|
| 44 | ||
| 45 | try { |
|
| 46 | $data = $this->membersService->addMember($uniqueId, $name); |
|
| 47 | } catch (\Exception $e) { |
|
| 48 | return $this->fail( |
|
| 49 | [ |
|
| 50 | 'circle_id' => $uniqueId, |
|
| 51 | 'user_id' => $name, |
|
| 52 | 'name' => $this->miscService->getDisplayName($name, true), |
|
| 53 | 'error' => $e->getMessage() |
|
| 54 | ] |
|
| 55 | ); |
|
| 56 | } |
|
| 57 | ||
| 58 | return $this->success( |
|
| 59 | [ |
|
| 60 | 'circle_id' => $uniqueId, |
|
| 61 | 'user_id' => $name, |
|
| 62 | 'name' => $this->miscService->getDisplayName($name, true), |
|
| 63 | 'members' => $data |
|
| 64 | ] |
|
| 65 | ); |
|
| 66 | } |
|
| 67 | ||
| 68 | ||
| 69 | /** |
|
| @@ 78-101 (lines=24) @@ | ||
| 75 | * |
|
| 76 | * @return DataResponse |
|
| 77 | */ |
|
| 78 | public function importFromGroup($uniqueId, $name) { |
|
| 79 | ||
| 80 | try { |
|
| 81 | $data = $this->membersService->importMembersFromGroup($uniqueId, $name); |
|
| 82 | } catch (\Exception $e) { |
|
| 83 | return $this->fail( |
|
| 84 | [ |
|
| 85 | 'circle_id' => $uniqueId, |
|
| 86 | 'user_id' => $name, |
|
| 87 | 'name' => $this->miscService->getDisplayName($name, true), |
|
| 88 | 'error' => $e->getMessage() |
|
| 89 | ] |
|
| 90 | ); |
|
| 91 | } |
|
| 92 | ||
| 93 | return $this->success( |
|
| 94 | [ |
|
| 95 | 'circle_id' => $uniqueId, |
|
| 96 | 'user_id' => $name, |
|
| 97 | 'name' => $this->miscService->getDisplayName($name, true), |
|
| 98 | 'members' => $data |
|
| 99 | ] |
|
| 100 | ); |
|
| 101 | } |
|
| 102 | ||
| 103 | ||
| 104 | /** |
|
| @@ 152-176 (lines=25) @@ | ||
| 149 | * |
|
| 150 | * @return DataResponse |
|
| 151 | */ |
|
| 152 | public function remove($uniqueId, $member) { |
|
| 153 | ||
| 154 | try { |
|
| 155 | $data = $this->membersService->removeMember($uniqueId, $member); |
|
| 156 | } catch (\Exception $e) { |
|
| 157 | return |
|
| 158 | $this->fail( |
|
| 159 | [ |
|
| 160 | 'circle_id' => $uniqueId, |
|
| 161 | 'user_id' => $member, |
|
| 162 | 'name' => $this->miscService->getDisplayName($member, true), |
|
| 163 | 'error' => $e->getMessage() |
|
| 164 | ] |
|
| 165 | ); |
|
| 166 | } |
|
| 167 | ||
| 168 | return $this->success( |
|
| 169 | [ |
|
| 170 | 'circle_id' => $uniqueId, |
|
| 171 | 'user_id' => $member, |
|
| 172 | 'name' => $this->miscService->getDisplayName($member, true), |
|
| 173 | 'members' => $data, |
|
| 174 | ] |
|
| 175 | ); |
|
| 176 | } |
|
| 177 | ||
| 178 | ||
| 179 | } |
|