Skip to content

Commit

Permalink
add updateUserLastLogin
Browse files Browse the repository at this point in the history
  • Loading branch information
hobbitronics committed Sep 20, 2024
1 parent 0caa626 commit 60b7e3a
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 0 deletions.
8 changes: 8 additions & 0 deletions features/request/RequestContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,14 @@ public function iCallUpdateuser()
$this->getIdBrokerClient()->updateUser($this->requestData);
}

/**
* @When I call updateUserLastLogin
*/
public function iCallUpdateuserlastlogin()
{
$this->getIdBrokerClient()->updateUserLastLogin($this->requestData['employee_id']);
}

/**
* @When I call listUsers and ask for these fields:
*/
Expand Down
9 changes: 9 additions & 0 deletions features/request/request.feature
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,15 @@ Feature: Formatting requests for sending to the ID Broker API
}
"""

Scenario: Updating a users last_login_utc
Given I am using a baseUri of "https://api.example.com/"
And I have indicated not to validate the id broker ip
And I provide an "employee_id" of "12345"
When I call updateUserLastLogin
Then the method should be "PUT"
And the url should be "https://api.example.com/user/12345/update-last-login"
And an authorization header should be present

Scenario: Deactivating a user
Given I am using a baseUri of "https://api.example.com/"
And I have indicated not to validate the id broker ip
Expand Down
20 changes: 20 additions & 0 deletions src/IdBrokerClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,26 @@ public function updateUser(array $config = [ ]): array
$this->reportUnexpectedResponse($result, 1490808841);
}

/**
* Update the User last_login_utc by calling the internal method
* @param string $employeeId
* @return array An array of information about the updated user only including last_login_utc and employee_id
* @throws ServiceException
*/
public function updateUserLastLogin(string $employeeId): array
{
$result = $this->updateUserLastLoginInternal([
'employee_id' => $employeeId,
]);
$statusCode = (int)$result[ 'statusCode' ];

if ($statusCode === 200) {
return $this->getResultAsArrayWithoutStatusCode($result);
}

$this->reportUnexpectedResponse($result, 1490808841);
}

/**
* Determine whether any of the Id-broker's IPs are not in the
* trusted ranges
Expand Down
12 changes: 12 additions & 0 deletions src/descriptions/id-broker-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,18 @@
],
],
],
'updateUserLastLoginInternal' => [
'httpMethod' => 'PUT',
'uri' => '/user/{employee_id}/update-last-login',
'responseModel' => 'Result',
'parameters' => [
'employee_id' => [
'required' => true,
'type' => 'string',
'location' => 'uri',
],
],
],
'createMethodInternal' => [
'httpMethod' => 'POST',
'uri' => '/method',
Expand Down

0 comments on commit 60b7e3a

Please sign in to comment.