| @@ 46-71 (lines=26) @@ | ||
| 43 | * |
|
| 44 | * @return DataResponse |
|
| 45 | */ |
|
| 46 | public function addMember($uniqueId, $ident, $type) { |
|
| 47 | ||
| 48 | try { |
|
| 49 | $data = $this->membersService->addMember($uniqueId, $ident, (int)$type); |
|
| 50 | } catch (\Exception $e) { |
|
| 51 | return $this->fail( |
|
| 52 | [ |
|
| 53 | 'circle_id' => $uniqueId, |
|
| 54 | 'user_id' => $ident, |
|
| 55 | 'user_type' => (int)$type, |
|
| 56 | 'display' => MiscService::getDisplay($ident, (int)$type), |
|
| 57 | 'error' => $e->getMessage() |
|
| 58 | ] |
|
| 59 | ); |
|
| 60 | } |
|
| 61 | ||
| 62 | return $this->success( |
|
| 63 | [ |
|
| 64 | 'circle_id' => $uniqueId, |
|
| 65 | 'user_id' => $ident, |
|
| 66 | 'user_type' => (int)$type, |
|
| 67 | 'display' => MiscService::getDisplay($ident, (int)$type), |
|
| 68 | 'members' => $data |
|
| 69 | ] |
|
| 70 | ); |
|
| 71 | } |
|
| 72 | ||
| 73 | ||
| 74 | /** |
|
| @@ 126-152 (lines=27) @@ | ||
| 123 | * |
|
| 124 | * @return DataResponse |
|
| 125 | */ |
|
| 126 | public function removeMember($uniqueId, $member, $type) { |
|
| 127 | ||
| 128 | try { |
|
| 129 | $data = $this->membersService->removeMember($uniqueId, $member, (int)$type); |
|
| 130 | } catch (\Exception $e) { |
|
| 131 | return |
|
| 132 | $this->fail( |
|
| 133 | [ |
|
| 134 | 'circle_id' => $uniqueId, |
|
| 135 | 'user_id' => $member, |
|
| 136 | 'user_type' => (int)$type, |
|
| 137 | 'display' => MiscService::getDisplay($member, (int)$type), |
|
| 138 | 'error' => $e->getMessage() |
|
| 139 | ] |
|
| 140 | ); |
|
| 141 | } |
|
| 142 | ||
| 143 | return $this->success( |
|
| 144 | [ |
|
| 145 | 'circle_id' => $uniqueId, |
|
| 146 | 'user_id' => $member, |
|
| 147 | 'user_type' => (int)$type, |
|
| 148 | 'display' => MiscService::getDisplay($member, (int)$type), |
|
| 149 | 'members' => $data, |
|
| 150 | ] |
|
| 151 | ); |
|
| 152 | } |
|
| 153 | ||
| 154 | ||
| 155 | /** |
|