Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for config Admin API #407

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}