Skip to content

Commit

Permalink
Add support for config Admin API
Browse files Browse the repository at this point in the history
  • Loading branch information
const-cloudinary committed Oct 16, 2024
1 parent 85c5bc0 commit 557b80c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/Api/Admin/ApiEndPoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
class ApiEndPoint
{
const PING = 'ping';
const CONFIG = 'config';
const USAGE = 'usage';
const ASSETS = 'resources';
const DERIVED_ASSETS = 'derived_resources';
Expand Down
18 changes: 18 additions & 0 deletions src/Api/Admin/MiscTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,24 @@ public function pingAsync()
return $this->apiClient->getAsync(ApiEndPoint::PING);
}

/**
* Gets account config details.
*
* Fetches the account's configuration details with optional settings.
*
* @param array $options The optional parameters for the API request.
*
* @return ApiResponse
*
* @see https://cloudinary.com/documentation/admin_api#config
*/
public function config($options = [])
{
$params = ArrayUtils::whitelist($options, ['settings']);

return $this->apiClient->get(ApiEndPoint::CONFIG, $params);
}

/**
* Gets cloud usage details.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@

namespace Cloudinary\Test\Integration\Admin;

use Cloudinary\Configuration\Configuration;
use Cloudinary\Test\Integration\IntegrationTestCase;

/**
* Class PingTest
*/
final class PingTest extends IntegrationTestCase
final class MiscTest extends IntegrationTestCase
{
public function testPing()
{
Expand All @@ -30,4 +31,16 @@ public function testPingAsync()

self::assertEquals('ok', $result['status']);
}

public function testConfig()
{
$result = self::$adminApi->config();

self::assertEquals(Configuration::instance()->cloud->cloudName, $result['cloud_name']);
self::assertArrayNotHasKey('settings', $result);

$resultWithSettings = self::$adminApi->config(['settings' => 'true']);

self::assertArrayHasKey('settings', $resultWithSettings);
}
}

0 comments on commit 557b80c

Please sign in to comment.