| @@ 103-116 (lines=14) @@ | ||
| 100 | * @param int $client_id |
|
| 101 | * @return \Illuminate\Http\JsonResponse |
|
| 102 | */ |
|
| 103 | public function activateClient(int $client_id): JsonResponse |
|
| 104 | { |
|
| 105 | $client = Client::find($client_id); |
|
| 106 | ||
| 107 | if (! $client) { |
|
| 108 | return $this->error("No client found with id $client_id"); |
|
| 109 | } |
|
| 110 | ||
| 111 | $client->update([ |
|
| 112 | 'status' => ApiCredential::STATUSES['ACTIVE'], |
|
| 113 | ]); |
|
| 114 | ||
| 115 | return $this->success('Client successfully activated'); |
|
| 116 | } |
|
| 117 | ||
| 118 | /** |
|
| 119 | * Suspend Client's Api Credential. |
|
| @@ 124-137 (lines=14) @@ | ||
| 121 | * @param int $client_id |
|
| 122 | * @return \Illuminate\Http\JsonResponse |
|
| 123 | */ |
|
| 124 | public function suspendApiCredential(int $client_id): JsonResponse |
|
| 125 | { |
|
| 126 | $key = ApiCredential::where('key_client_id', $client_id)->first(); |
|
| 127 | ||
| 128 | if (! $key) { |
|
| 129 | return $this->error('Client information not found'); |
|
| 130 | } |
|
| 131 | ||
| 132 | $key->update([ |
|
| 133 | 'status' => ApiCredential::STATUSES['SUSPENDED'], |
|
| 134 | ]); |
|
| 135 | ||
| 136 | return $this->success('ApiCredential successfully suspended'); |
|
| 137 | } |
|
| 138 | ||
| 139 | /** |
|
| 140 | * Activate Client's Api Credential. |
|
| @@ 145-158 (lines=14) @@ | ||
| 142 | * @param int $client_id |
|
| 143 | * @return \Illuminate\Http\JsonResponse |
|
| 144 | */ |
|
| 145 | public function activateApiCredential(int $client_id): JsonResponse |
|
| 146 | { |
|
| 147 | $key = ApiCredential::where('key_client_id', $client_id)->first(); |
|
| 148 | ||
| 149 | if (! $key) { |
|
| 150 | return $this->error('Client information not found'); |
|
| 151 | } |
|
| 152 | ||
| 153 | $key->update([ |
|
| 154 | 'status' => ApiCredential::STATUSES['ACTIVE'], |
|
| 155 | ]); |
|
| 156 | ||
| 157 | return $this->success('ApiCredential successfully activated'); |
|
| 158 | } |
|
| 159 | ||
| 160 | } |
|
| 161 | ||