Skip to content

Commit b25ae00

Browse files
authored
Merge pull request #312 from internxt/bugfix/let-unauthorized-callback-be-null
[_]: bugfix/Hadle Users apiSecurity undefined
2 parents 0f3abae + 0bce818 commit b25ae00

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@internxt/sdk",
33
"author": "Internxt <[email protected]>",
4-
"version": "1.10.8",
4+
"version": "1.10.9",
55
"description": "An sdk for interacting with Internxt's services",
66
"repository": {
77
"type": "git",

src/drive/users/index.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class Users {
2828
}
2929

3030
private constructor(apiUrl: ApiUrl, appDetails: AppDetails, apiSecurity: ApiSecurity) {
31-
this.client = HttpClient.create(apiUrl, apiSecurity.unauthorizedCallback);
31+
this.client = HttpClient.create(apiUrl, apiSecurity?.unauthorizedCallback);
3232
this.appDetails = appDetails;
3333
this.apiSecurity = apiSecurity;
3434
}
@@ -79,6 +79,15 @@ export class Users {
7979
return this.client.get('/user/refresh', this.headers());
8080
}
8181

82+
/**
83+
* Returns fresh avatar URL of the user
84+
*/
85+
public refreshAvatarUser(): Promise<{
86+
avatar: UserSettings['avatar'];
87+
}> {
88+
return this.client.get('/user/avatar/refresh', this.headers());
89+
}
90+
8291
/**
8392
* Retrieves the user data for a specific user identified by the uuid.
8493
*

test/drive/users/index.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,26 @@ describe('# users service tests', () => {
9393
});
9494
});
9595

96+
describe('refresh user avatar', () => {
97+
it('should call with right params & return response', async () => {
98+
// Arrange
99+
const { client, headers } = clientAndHeaders();
100+
const mockedAvatarUrl = 'https://example.avatar.com/avatar.jpg';
101+
const callStub = sinon.stub(httpClient, 'get').resolves({
102+
avatar: mockedAvatarUrl,
103+
});
104+
105+
// Act
106+
const body = await client.refreshAvatarUser();
107+
108+
// Assert
109+
expect(callStub.firstCall.args).toStrictEqual(['/user/avatar/refresh', headers]);
110+
expect(body).toStrictEqual({
111+
avatar: mockedAvatarUrl,
112+
});
113+
});
114+
});
115+
96116
describe('pre register user', () => {
97117
it('should pre create user', async () => {
98118
// Arrange

0 commit comments

Comments
 (0)