Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@internxt/sdk",
"author": "Internxt <[email protected]>",
"version": "1.10.8",
"version": "1.10.9",
"description": "An sdk for interacting with Internxt's services",
"repository": {
"type": "git",
Expand Down
11 changes: 10 additions & 1 deletion src/drive/users/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class Users {
}

private constructor(apiUrl: ApiUrl, appDetails: AppDetails, apiSecurity: ApiSecurity) {
this.client = HttpClient.create(apiUrl, apiSecurity.unauthorizedCallback);
this.client = HttpClient.create(apiUrl, apiSecurity?.unauthorizedCallback);
this.appDetails = appDetails;
this.apiSecurity = apiSecurity;
}
Expand Down Expand Up @@ -79,6 +79,15 @@ export class Users {
return this.client.get('/user/refresh', this.headers());
}

/**
* Returns fresh avatar URL of the user
*/
public refreshAvatarUser(): Promise<{
avatar: UserSettings['avatar'];
}> {
return this.client.get('/user/avatar/refresh', this.headers());
}

/**
* Retrieves the user data for a specific user identified by the uuid.
*
Expand Down
20 changes: 20 additions & 0 deletions test/drive/users/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,26 @@ describe('# users service tests', () => {
});
});

describe('refresh user avatar', () => {
it('should call with right params & return response', async () => {
// Arrange
const { client, headers } = clientAndHeaders();
const mockedAvatarUrl = 'https://example.avatar.com/avatar.jpg';
const callStub = sinon.stub(httpClient, 'get').resolves({
avatar: mockedAvatarUrl,
});

// Act
const body = await client.refreshAvatarUser();

// Assert
expect(callStub.firstCall.args).toStrictEqual(['/user/avatar/refresh', headers]);
expect(body).toStrictEqual({
avatar: mockedAvatarUrl,
});
});
});

describe('pre register user', () => {
it('should pre create user', async () => {
// Arrange
Expand Down
Loading