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