Skip to content

Commit d5f9cba

Browse files
committed
[UC-3] Add create event for user method & add return type to getApiEndpointUrl
1 parent 2649b0c commit d5f9cba

3 files changed

Lines changed: 25 additions & 5 deletions

File tree

src/Api/AbstractClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ protected function getApiEndpointUrl(
7070
UserComApiAwareInterface $resource,
7171
string $endpoint,
7272
string $query = null,
73-
) {
73+
): string {
7474
$url = sprintf(
7575
'%s/%s/%s/',
7676
trim($resource->getUserComUrl(), '/'),

src/Api/UserApi.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,18 @@ public function updateUserByCustomId(UserComApiAwareInterface $resource, string
112112
$this->buildOptions($resource, ['json' => $data]),
113113
);
114114
}
115+
116+
public function createEventForUser(UserComApiAwareInterface $resource, array $data): ?array
117+
{
118+
return $this->request(
119+
$this->getApiEndpointUrl($resource, self::CREATE_EVENT_FOR_USER_BY_CUSTOM_ID_ENDPOINT),
120+
Request::METHOD_POST,
121+
$this->buildOptions($resource, [
122+
'json' => $data,
123+
'headers' => [
124+
'Content-Type' => 'application/json',
125+
],
126+
]),
127+
);
128+
}
115129
}

src/Api/UserApiInterface.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,17 @@ interface UserApiInterface
2121

2222
public const FIND_USER_ENDPOINT = 'users/search';
2323

24-
public const UPDATE_OR_CREATE_USER_ENDPOINT = '/users/update_or_create/';
24+
public const GET_USER_ENDPOINT = '/users/%s';
25+
26+
public const CREATE_USER_ENDPOINT = '/users/';
2527

2628
public const UPDATE_USER_ENDPOINT = '/users/%s';
2729

28-
public const UPDATE_USER_BY_CUSTOM_ID_ENDPOINT = '/users-by-id/%s';
30+
public const UPDATE_OR_CREATE_USER_ENDPOINT = '/users/update_or_create/';
2931

30-
public const GET_USER_ENDPOINT = '/users/%s';
32+
public const UPDATE_USER_BY_CUSTOM_ID_ENDPOINT = '/users-by-id/%s';
3133

32-
public const CREATE_USER_ENDPOINT = '/users/';
34+
public const CREATE_EVENT_FOR_USER_BY_CUSTOM_ID_ENDPOINT = '/users-by-id/%s/events';
3335

3436
public const MERGE_USERS_ENDPOINT = '/users/merge';
3537

@@ -46,4 +48,8 @@ public function updateUser(UserComApiAwareInterface $resource, int $userId, arra
4648
public function createUser(UserComApiAwareInterface $resource, array $data): ?array;
4749

4850
public function mergeUsers(UserComApiAwareInterface $resource, int $parentId, array $usersList): ?array;
51+
52+
public function updateUserByCustomId(UserComApiAwareInterface $resource, string $customId, array $data): ?array;
53+
54+
public function createEventForUser(UserComApiAwareInterface $resource, array $data): ?array;
4955
}

0 commit comments

Comments
 (0)