diff --git a/src/Api/Admin/ApiEndPoint.php b/src/Api/Admin/ApiEndPoint.php index 4a6fd399..6da5cd28 100644 --- a/src/Api/Admin/ApiEndPoint.php +++ b/src/Api/Admin/ApiEndPoint.php @@ -16,6 +16,7 @@ class ApiEndPoint { const PING = 'ping'; + const CONFIG = 'config'; const USAGE = 'usage'; const ASSETS = 'resources'; const DERIVED_ASSETS = 'derived_resources'; diff --git a/src/Api/Admin/MiscTrait.php b/src/Api/Admin/MiscTrait.php index 51bf5542..9288fc4b 100644 --- a/src/Api/Admin/MiscTrait.php +++ b/src/Api/Admin/MiscTrait.php @@ -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. * diff --git a/tests/Integration/Admin/PingTest.php b/tests/Integration/Admin/MiscTest.php similarity index 57% rename from tests/Integration/Admin/PingTest.php rename to tests/Integration/Admin/MiscTest.php index 9922de34..1966b927 100644 --- a/tests/Integration/Admin/PingTest.php +++ b/tests/Integration/Admin/MiscTest.php @@ -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() { @@ -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); + } }