diff --git a/src/CrowdinApiClient/Api/Enterprise/SecurityLogApi.php b/src/CrowdinApiClient/Api/Enterprise/SecurityLogApi.php
new file mode 100644
index 00000000..34b493c0
--- /dev/null
+++ b/src/CrowdinApiClient/Api/Enterprise/SecurityLogApi.php
@@ -0,0 +1,47 @@
+
+ * string $params[createdAfter]
+ * string $params[createdBefore]
+ * string $params[ipAddress]
+ * integer $params[userId]
+ * integer $params[limit]
+ * integer $params[offset]
+ * @return ModelCollection
+ */
+ public function listOrganizationSecurityLogs(array $params = []): ModelCollection
+ {
+ return $this->_list('security-logs', SecurityLog::class, $params);
+ }
+
+ /**
+ * Get Organization Security Log
+ * @link https://support.crowdin.com/developer/enterprise/api/v2/#tag/Security-Logs/operation/api.security-logs.get API Documentation
+ *
+ * @param int $securityLogId
+ * @return SecurityLog|null
+ */
+ public function getOrganizationSecurityLog(int $securityLogId): ?SecurityLog
+ {
+ $path = sprintf('security-logs/%d', $securityLogId);
+ return $this->_get($path, SecurityLog::class);
+ }
+}
diff --git a/src/CrowdinApiClient/Api/SecurityLogApi.php b/src/CrowdinApiClient/Api/SecurityLogApi.php
new file mode 100644
index 00000000..6dafad83
--- /dev/null
+++ b/src/CrowdinApiClient/Api/SecurityLogApi.php
@@ -0,0 +1,50 @@
+
+ * string $params[createdAfter]
+ * string $params[createdBefore]
+ * string $params[ipAddress]
+ * integer $params[limit]
+ * integer $params[offset]
+ * @return ModelCollection
+ */
+ public function listUserSecurityLogs(int $userId, array $params = []): ModelCollection
+ {
+ $path = sprintf('users/%d/security-logs', $userId);
+ return $this->_list($path, SecurityLog::class, $params);
+ }
+
+ /**
+ * Get User Security Log
+ * @link https://support.crowdin.com/developer/api/v2/#tag/Security-Logs/operation/api.users.security-logs.get API Documentation
+ * @link https://support.crowdin.com/developer/enterprise/api/v2/#tag/Security-Logs/operation/api.users.security-logs.get API Documentation Enterprise
+ *
+ * @param int $userId
+ * @param int $securityLogId
+ * @return SecurityLog|null
+ */
+ public function getUserSecurityLog(int $userId, int $securityLogId): ?SecurityLog
+ {
+ $path = sprintf('users/%d/security-logs/%d', $userId, $securityLogId);
+ return $this->_get($path, SecurityLog::class);
+ }
+}
diff --git a/src/CrowdinApiClient/Crowdin.php b/src/CrowdinApiClient/Crowdin.php
index 95c17a9c..6eb5ae06 100644
--- a/src/CrowdinApiClient/Crowdin.php
+++ b/src/CrowdinApiClient/Crowdin.php
@@ -46,6 +46,7 @@
* @property \CrowdinApiClient\Api\OrganizationWebhookApi $organizationWebhook
* @property \CrowdinApiClient\Api\ReportArchiveApi|\CrowdinApiClient\Api\Enterprise\ReportArchiveApi $reportArchive
* @property \CrowdinApiClient\Api\GraphqlApi $graphql
+ * @property \CrowdinApiClient\Api\SecurityLogApi|\CrowdinApiClient\Api\Enterprise\SecurityLogApi $securityLog
*/
class Crowdin
{
@@ -116,6 +117,7 @@ class Crowdin
'organizationWebhook',
'reportArchive',
'graphql',
+ 'securityLog',
];
protected $servicesEnterprise = [
@@ -154,6 +156,7 @@ class Crowdin
'organizationWebhook',
'reportArchive',
'graphql',
+ 'securityLog',
];
public function __construct(array $config)
diff --git a/src/CrowdinApiClient/Model/SecurityLog.php b/src/CrowdinApiClient/Model/SecurityLog.php
new file mode 100644
index 00000000..43bf326c
--- /dev/null
+++ b/src/CrowdinApiClient/Model/SecurityLog.php
@@ -0,0 +1,127 @@
+id = (int)$this->getDataProperty('id');
+ $this->event = (string)$this->getDataProperty('event');
+ $this->info = (string)$this->getDataProperty('info');
+ $this->userId = (int)$this->getDataProperty('userId');
+ $this->location = (string)$this->getDataProperty('location');
+ $this->ipAddress = (string)$this->getDataProperty('ipAddress');
+ $this->deviceName = (string)$this->getDataProperty('deviceName');
+ $this->createdAt = (string)$this->getDataProperty('createdAt');
+ }
+
+ /**
+ * @return int
+ */
+ public function getId(): int
+ {
+ return $this->id;
+ }
+
+ /**
+ * @return string
+ */
+ public function getEvent(): string
+ {
+ return $this->event;
+ }
+
+ /**
+ * @return string
+ */
+ public function getInfo(): string
+ {
+ return $this->info;
+ }
+
+ /**
+ * @return int
+ */
+ public function getUserId(): int
+ {
+ return $this->userId;
+ }
+
+ /**
+ * @return string
+ */
+ public function getLocation(): string
+ {
+ return $this->location;
+ }
+
+ /**
+ * @return string
+ */
+ public function getIpAddress(): string
+ {
+ return $this->ipAddress;
+ }
+
+ /**
+ * @return string
+ */
+ public function getDeviceName(): string
+ {
+ return $this->deviceName;
+ }
+
+ /**
+ * @return string
+ */
+ public function getCreatedAt(): string
+ {
+ return $this->createdAt;
+ }
+}
diff --git a/tests/CrowdinApiClient/Api/Enterprise/SecurityLogApiTest.php b/tests/CrowdinApiClient/Api/Enterprise/SecurityLogApiTest.php
new file mode 100644
index 00000000..f50ce2d6
--- /dev/null
+++ b/tests/CrowdinApiClient/Api/Enterprise/SecurityLogApiTest.php
@@ -0,0 +1,76 @@
+mockRequestGet('/security-logs', '{
+ "data": [
+ {
+ "data": {
+ "id": 2,
+ "event": "Some event",
+ "info": "Some info",
+ "userId": 4,
+ "location": "USA",
+ "ipAddress": "127.0.0.1",
+ "deviceName": "MacOs on MacBook",
+ "createdAt": "2019-09-19T15:10:43+00:00"
+ }
+ }
+ ],
+ "pagination": {
+ "offset": 0,
+ "limit": 25
+ }
+ }');
+
+ $securityLogs = $this->crowdin->securityLog->listOrganizationSecurityLogs();
+ $this->assertInstanceOf(ModelCollection::class, $securityLogs);
+ $this->assertCount(1, $securityLogs);
+
+ /** @var SecurityLog $securityLog */
+ $securityLog = $securityLogs[0];
+ $this->assertInstanceOf(SecurityLog::class, $securityLog);
+ $this->assertEquals(2, $securityLog->getId());
+ $this->assertEquals('Some event', $securityLog->getEvent());
+ $this->assertEquals('Some info', $securityLog->getInfo());
+ $this->assertEquals(4, $securityLog->getUserId());
+ $this->assertEquals('USA', $securityLog->getLocation());
+ $this->assertEquals('127.0.0.1', $securityLog->getIpAddress());
+ $this->assertEquals('MacOs on MacBook', $securityLog->getDeviceName());
+ $this->assertEquals('2019-09-19T15:10:43+00:00', $securityLog->getCreatedAt());
+ }
+
+ public function testGet()
+ {
+ $this->mockRequestGet('/security-logs/2', '{
+ "data": {
+ "id": 2,
+ "event": "Some event",
+ "info": "Some info",
+ "userId": 4,
+ "location": "USA",
+ "ipAddress": "127.0.0.1",
+ "deviceName": "MacOs on MacBook",
+ "createdAt": "2019-09-19T15:10:43+00:00"
+ }
+ }');
+
+ $securityLog = $this->crowdin->securityLog->getOrganizationSecurityLog(2);
+ $this->assertInstanceOf(SecurityLog::class, $securityLog);
+ $this->assertEquals(2, $securityLog->getId());
+ $this->assertEquals('Some event', $securityLog->getEvent());
+ $this->assertEquals('Some info', $securityLog->getInfo());
+ $this->assertEquals(4, $securityLog->getUserId());
+ $this->assertEquals('USA', $securityLog->getLocation());
+ $this->assertEquals('127.0.0.1', $securityLog->getIpAddress());
+ $this->assertEquals('MacOs on MacBook', $securityLog->getDeviceName());
+ $this->assertEquals('2019-09-19T15:10:43+00:00', $securityLog->getCreatedAt());
+ }
+}
diff --git a/tests/CrowdinApiClient/Api/SecurityLogApiTest.php b/tests/CrowdinApiClient/Api/SecurityLogApiTest.php
new file mode 100644
index 00000000..3aa42f5b
--- /dev/null
+++ b/tests/CrowdinApiClient/Api/SecurityLogApiTest.php
@@ -0,0 +1,76 @@
+mockRequestGet('/users/4/security-logs', '{
+ "data": [
+ {
+ "data": {
+ "id": 2,
+ "event": "Some event",
+ "info": "Some info",
+ "userId": 4,
+ "location": "USA",
+ "ipAddress": "127.0.0.1",
+ "deviceName": "MacOs on MacBook",
+ "createdAt": "2019-09-19T15:10:43+00:00"
+ }
+ }
+ ],
+ "pagination": {
+ "offset": 0,
+ "limit": 25
+ }
+ }');
+
+ $securityLogs = $this->crowdin->securityLog->listUserSecurityLogs(4);
+ $this->assertInstanceOf(ModelCollection::class, $securityLogs);
+ $this->assertCount(1, $securityLogs);
+
+ /** @var SecurityLog $securityLog */
+ $securityLog = $securityLogs[0];
+ $this->assertInstanceOf(SecurityLog::class, $securityLog);
+ $this->assertEquals(2, $securityLog->getId());
+ $this->assertEquals('Some event', $securityLog->getEvent());
+ $this->assertEquals('Some info', $securityLog->getInfo());
+ $this->assertEquals(4, $securityLog->getUserId());
+ $this->assertEquals('USA', $securityLog->getLocation());
+ $this->assertEquals('127.0.0.1', $securityLog->getIpAddress());
+ $this->assertEquals('MacOs on MacBook', $securityLog->getDeviceName());
+ $this->assertEquals('2019-09-19T15:10:43+00:00', $securityLog->getCreatedAt());
+ }
+
+ public function testGet()
+ {
+ $this->mockRequestGet('/users/4/security-logs/2', '{
+ "data": {
+ "id": 2,
+ "event": "Some event",
+ "info": "Some info",
+ "userId": 4,
+ "location": "USA",
+ "ipAddress": "127.0.0.1",
+ "deviceName": "MacOs on MacBook",
+ "createdAt": "2019-09-19T15:10:43+00:00"
+ }
+ }');
+
+ $securityLog = $this->crowdin->securityLog->getUserSecurityLog(4, 2);
+ $this->assertInstanceOf(SecurityLog::class, $securityLog);
+ $this->assertEquals(2, $securityLog->getId());
+ $this->assertEquals('Some event', $securityLog->getEvent());
+ $this->assertEquals('Some info', $securityLog->getInfo());
+ $this->assertEquals(4, $securityLog->getUserId());
+ $this->assertEquals('USA', $securityLog->getLocation());
+ $this->assertEquals('127.0.0.1', $securityLog->getIpAddress());
+ $this->assertEquals('MacOs on MacBook', $securityLog->getDeviceName());
+ $this->assertEquals('2019-09-19T15:10:43+00:00', $securityLog->getCreatedAt());
+ }
+}
diff --git a/tests/CrowdinApiClient/Model/SecurityLogTest.php b/tests/CrowdinApiClient/Model/SecurityLogTest.php
new file mode 100644
index 00000000..c3f50f04
--- /dev/null
+++ b/tests/CrowdinApiClient/Model/SecurityLogTest.php
@@ -0,0 +1,43 @@
+ 2,
+ 'event' => 'Some event',
+ 'info' => 'Some info',
+ 'userId' => 4,
+ 'location' => 'USA',
+ 'ipAddress' => '127.0.0.1',
+ 'deviceName' => 'MacOs on MacBook',
+ 'createdAt' => '2019-09-19T15:10:43+00:00',
+ ];
+
+ public function testLoadData()
+ {
+ $this->securityLog = new SecurityLog($this->data);
+ $this->checkData();
+ }
+
+ public function checkData()
+ {
+ $this->assertEquals($this->data['id'], $this->securityLog->getId());
+ $this->assertEquals($this->data['event'], $this->securityLog->getEvent());
+ $this->assertEquals($this->data['info'], $this->securityLog->getInfo());
+ $this->assertEquals($this->data['userId'], $this->securityLog->getUserId());
+ $this->assertEquals($this->data['location'], $this->securityLog->getLocation());
+ $this->assertEquals($this->data['ipAddress'], $this->securityLog->getIpAddress());
+ $this->assertEquals($this->data['deviceName'], $this->securityLog->getDeviceName());
+ $this->assertEquals($this->data['createdAt'], $this->securityLog->getCreatedAt());
+ }
+}