Skip to content
This repository was archived by the owner on Jun 25, 2025. It is now read-only.

Commit 232e6da

Browse files
authored
Merge pull request #57 from apisearch-io/fix/refactored-click-method
AppUUID and IndexUUID should be plain values
2 parents 54243f4 + d397cee commit 232e6da

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "apisearch",
3-
"version": "0.2.26",
3+
"version": "0.2.27",
44
"description": "Javascript client for Apisearch.",
55
"main": "lib/index.js",
66
"types": "lib/index.d.ts",

src/Repository/HttpRepository.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -345,13 +345,17 @@ export class HttpRepository extends Repository {
345345
/**
346346
* Click
347347
*
348-
* @param {Item} item
348+
* @param {string} app_id
349+
* @param {string} index_id
350+
* @param {string} item_id
349351
* @param {string} user_id
350352
*
351353
* @return {Promise<void>}
352354
*/
353355
public async click(
354-
item: Item,
356+
app_id: string,
357+
index_id: string,
358+
item_id: string,
355359
user_id?: string
356360
): Promise<void> {
357361
var parameters = <any>{};
@@ -361,9 +365,11 @@ export class HttpRepository extends Repository {
361365

362366
try {
363367
await this.httpClient.get(
364-
"/" + item.getAppUUID().composedUUID() + "/indices/" + item.getIndexUUID().composedUUID() + "/items/" + item.getUUID().composedUUID() + '/click',
368+
"/" + app_id + "/indices/" + index_id + "/items/" + item_id + '/click',
365369
"post",
366-
this.getCredentials(),
370+
{
371+
token: this.token
372+
},
367373
parameters,
368374
{}
369375
);

test/Functional/Apisearch/Click.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ describe('Click', () => {
2626
await repository.flush();
2727
const result = await repository.query(Query.createMatchAll());
2828
const items = result.getItems();
29+
const nItem0 = items[0];
30+
const nItem1 = items[1];
2931

30-
await repository.click(items[0], 'user1234');
31-
await repository.click(items[1], 'user5678');
32+
await repository.click(nItem0.getAppUUID().composedUUID(), nItem0.getIndexUUID().composedUUID(), nItem0.getUUID().composedUUID(), 'user1234');
33+
await repository.click(nItem1.getAppUUID().composedUUID(), nItem1.getIndexUUID().composedUUID(), nItem1.getUUID().composedUUID(), 'user5678');
3234
});
3335
});

0 commit comments

Comments
 (0)