| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace Metricool\Http\Metricool\Entities; |
| 6 |
|
| 7 |
use Metricool\Http\Metricool\Exceptions\ApiException; |
| 8 |
use Metricool\Http\Metricool\MetricoolClient; |
| 9 |
|
| 10 |
class UserCredentials |
| 11 |
{ |
| 12 |
protected MetricoolClient $client; |
| 13 |
protected string $endpoint; |
| 14 |
|
| 15 |
public function __construct(MetricoolClient $client) |
| 16 |
{ |
| 17 |
$this->client = $client; |
| 18 |
$this->endpoint = 'v2/settings/users/' . $client->getUserId() . '/credentials'; |
| 19 |
} |
| 20 |
|
| 21 |
/** |
| 22 |
* Update the user password |
| 23 |
* |
| 24 |
* @throws ApiException |
| 25 |
*/ |
| 26 |
public function updatePassword(string $oldPassword, string $newPassword): array |
| 27 |
{ |
| 28 |
$this->client->patch($this->endpoint . '?fields=password', [ |
| 29 |
'oldPassword' => $oldPassword, |
| 30 |
'password' => $newPassword, |
| 31 |
]); |
| 32 |
|
| 33 |
return ['success' => true]; |
| 34 |
} |
| 35 |
} |
| 36 |
|