diff --git a/README.md b/README.md
index 04034b3..2d19249 100644
--- a/README.md
+++ b/README.md
@@ -474,7 +474,13 @@ $response = $descopeSDK->management->user->searchAll(
['ssoApp123'], // ssoAppIds
[ // sort
['field' => 'displayName', 'desc' => true]
- ]
+ ],
+ null, // tenantRoleIds
+ null, // tenantRoleNames
+ 1700000000000, // fromCreatedTime (Unix epoch milliseconds)
+ 1800000000000, // toCreatedTime (Unix epoch milliseconds)
+ 1700000000000, // fromModifiedTime (Unix epoch milliseconds)
+ 1800000000000 // toModifiedTime (Unix epoch milliseconds)
);
print_r($response);
```
diff --git a/phpunit.xml b/phpunit.xml
index 59b32e5..59b2983 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -11,6 +11,7 @@
src/tests/StaticStateIsolationTest.php
src/tests/EndpointsTest.php
src/tests/Management/ManagementParityTest.php
+ src/tests/Management/UserSearchMockTest.php
src/tests/Auth/AuthParityTest.php
diff --git a/src/SDK/Management/User.php b/src/SDK/Management/User.php
index 20d1fc0..416057f 100644
--- a/src/SDK/Management/User.php
+++ b/src/SDK/Management/User.php
@@ -547,6 +547,10 @@ public function loadByUserId(string $userId): array
* @param string|null $text Optional string, allows free text search among all user's attributes.
* @param array|null $tenantRoleIds Optional map of tenants and list of role IDs to filter by.
* @param array|null $tenantRoleNames Optional map of tenants and list of role names to filter by.
+ * @param int|null $fromCreatedTime Optional, only include users created after this time (Unix epoch milliseconds).
+ * @param int|null $toCreatedTime Optional, only include users created on or before this time (Unix epoch milliseconds).
+ * @param int|null $fromModifiedTime Optional, only include users modified after this time (Unix epoch milliseconds).
+ * @param int|null $toModifiedTime Optional, only include users modified on or before this time (Unix epoch milliseconds).
* @return array Return dict in the format {"users": []}. "users" contains a list of all of the found users and their information.
* @throws AuthException if search operation fails.
*/
@@ -567,7 +571,11 @@ public function searchAll(
$ssoAppIds = null,
$sort = null,
$tenantRoleIds = null,
- $tenantRoleNames = null
+ $tenantRoleNames = null,
+ $fromCreatedTime = null,
+ $toCreatedTime = null,
+ $fromModifiedTime = null,
+ $toModifiedTime = null
) {
// Prepare the request body ensuring PHP 7.x compatibility
$body = [
@@ -593,13 +601,17 @@ public function searchAll(
}, $sort) : [],
'loginIds' => [],
'tenantRoleIds' => $this->mapToValuesObject($tenantRoleIds),
- 'tenantRoleNames' => $this->mapToValuesObject($tenantRoleNames)
+ 'tenantRoleNames' => $this->mapToValuesObject($tenantRoleNames),
+ 'fromCreatedTime' => $fromCreatedTime !== null ? (int)$fromCreatedTime : null,
+ 'toCreatedTime' => $toCreatedTime !== null ? (int)$toCreatedTime : null,
+ 'fromModifiedTime' => $fromModifiedTime !== null ? (int)$fromModifiedTime : null,
+ 'toModifiedTime' => $toModifiedTime !== null ? (int)$toModifiedTime : null
];
-
+
$body = array_filter($body, function ($value) {
return $value !== null && $value !== '';
});
-
+
return $this->api->doPost(
MgmtV1::$USERS_SEARCH_PATH,
$body,
@@ -1425,6 +1437,10 @@ public function loadUsers(array $userIds, bool $includeInvalidUsers = false): ar
* @param string|null $text Optional free text search.
* @param array|null $tenantRoleIds Optional map of tenants and list of role IDs.
* @param array|null $tenantRoleNames Optional map of tenants and list of role names.
+ * @param int|null $fromCreatedTime Optional, only include users created after this time (Unix epoch milliseconds).
+ * @param int|null $toCreatedTime Optional, only include users created on or before this time (Unix epoch milliseconds).
+ * @param int|null $fromModifiedTime Optional, only include users modified after this time (Unix epoch milliseconds).
+ * @param int|null $toModifiedTime Optional, only include users modified on or before this time (Unix epoch milliseconds).
* @return array Return dict in the format {"users": []}.
* @throws AuthException
*/
@@ -1442,7 +1458,11 @@ public function searchAllTestUsers(
$ssoAppIds = null,
$sort = null,
$tenantRoleIds = null,
- $tenantRoleNames = null
+ $tenantRoleNames = null,
+ $fromCreatedTime = null,
+ $toCreatedTime = null,
+ $fromModifiedTime = null,
+ $toModifiedTime = null
): array {
$body = [
'loginId' => $loginId ?? '',
@@ -1466,7 +1486,11 @@ public function searchAllTestUsers(
}, $sort) : [],
'loginIds' => [],
'tenantRoleIds' => $this->mapToValuesObject($tenantRoleIds),
- 'tenantRoleNames' => $this->mapToValuesObject($tenantRoleNames)
+ 'tenantRoleNames' => $this->mapToValuesObject($tenantRoleNames),
+ 'fromCreatedTime' => $fromCreatedTime !== null ? (int)$fromCreatedTime : null,
+ 'toCreatedTime' => $toCreatedTime !== null ? (int)$toCreatedTime : null,
+ 'fromModifiedTime' => $fromModifiedTime !== null ? (int)$fromModifiedTime : null,
+ 'toModifiedTime' => $toModifiedTime !== null ? (int)$toModifiedTime : null
];
$body = array_filter($body, function ($value) {
diff --git a/src/tests/Management/UserSearchMockTest.php b/src/tests/Management/UserSearchMockTest.php
new file mode 100644
index 0000000..bc8a3df
--- /dev/null
+++ b/src/tests/Management/UserSearchMockTest.php
@@ -0,0 +1,115 @@
+ []]))]);
+ $stack = HandlerStack::create($mock);
+ $stack->push(Middleware::history($requests));
+ $injectedClient = new Client(['handler' => $stack]);
+
+ $sdk = new DescopeSDK([
+ 'projectId' => 'test_project_id',
+ 'managementKey' => 'test_management_key',
+ 'httpClient' => $injectedClient,
+ ]);
+
+ $fromCreatedTime = 1700000000000;
+ $toCreatedTime = 1800000000000;
+ $fromModifiedTime = 1700000000000;
+ $toModifiedTime = 1800000000000;
+
+ $sdk->management->user->searchAll(
+ null,
+ null,
+ null,
+ 0,
+ null,
+ 0,
+ false,
+ false,
+ false,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ $fromCreatedTime,
+ $toCreatedTime,
+ $fromModifiedTime,
+ $toModifiedTime
+ );
+
+ $this->assertCount(1, $requests);
+ $body = json_decode((string) $requests[0]['request']->getBody(), true);
+
+ $this->assertSame($fromCreatedTime, $body['fromCreatedTime']);
+ $this->assertSame($toCreatedTime, $body['toCreatedTime']);
+ $this->assertSame($fromModifiedTime, $body['fromModifiedTime']);
+ $this->assertSame($toModifiedTime, $body['toModifiedTime']);
+ }
+
+ public function testSearchAllTestUsersSendsTimeFilterParams()
+ {
+ $requests = [];
+ $mock = new MockHandler([new Response(200, [], json_encode(['users' => []]))]);
+ $stack = HandlerStack::create($mock);
+ $stack->push(Middleware::history($requests));
+ $injectedClient = new Client(['handler' => $stack]);
+
+ $sdk = new DescopeSDK([
+ 'projectId' => 'test_project_id',
+ 'managementKey' => 'test_management_key',
+ 'httpClient' => $injectedClient,
+ ]);
+
+ $fromCreatedTime = 1700000000000;
+ $toCreatedTime = 1800000000000;
+ $fromModifiedTime = 1700000000000;
+ $toModifiedTime = 1800000000000;
+
+ $sdk->management->user->searchAllTestUsers(
+ null,
+ null,
+ null,
+ 0,
+ null,
+ 0,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ $fromCreatedTime,
+ $toCreatedTime,
+ $fromModifiedTime,
+ $toModifiedTime
+ );
+
+ $this->assertCount(1, $requests);
+ $body = json_decode((string) $requests[0]['request']->getBody(), true);
+
+ $this->assertSame($fromCreatedTime, $body['fromCreatedTime']);
+ $this->assertSame($toCreatedTime, $body['toCreatedTime']);
+ $this->assertSame($fromModifiedTime, $body['fromModifiedTime']);
+ $this->assertSame($toModifiedTime, $body['toModifiedTime']);
+ }
+}