feat: import users from plex (#428)

* feat: import users from plex

fix #281

* fix(frontend): re-enable delete user confirmation button after finished
This commit is contained in:
johnpyp
2020-12-21 09:41:19 -05:00
committed by GitHub
parent 08c22b03e0
commit 7e8f361af7
5 changed files with 145 additions and 5 deletions

View File

@@ -56,6 +56,21 @@ interface FriendResponse {
};
}
interface UsersResponse {
MediaContainer: {
User: {
$: {
id: string;
title: string;
username: string;
email: string;
thumb: string;
};
Server: ServerResponse[];
}[];
};
}
class PlexTvAPI {
private authToken: string;
private axios: AxiosInstance;
@@ -129,6 +144,18 @@ class PlexTvAPI {
return false;
}
}
public async getUsers(): Promise<UsersResponse> {
const response = await this.axios.get('/api/users', {
transformResponse: [],
responseType: 'text',
});
const parsedXml = (await xml2js.parseStringPromise(
response.data
)) as UsersResponse;
return parsedXml;
}
}
export default PlexTvAPI;