Fix model property capitalization

This commit is contained in:
Bill Thornton 2021-09-16 16:02:03 -04:00
parent fc9fc0bc35
commit 8c6f3c8a54
5 changed files with 18 additions and 18 deletions

View File

@ -22,9 +22,9 @@ export class Jellyfin {
deviceInfo;
constructor(
clientInfo: ClientInfo = { Name: 'jellyfin-sdk-typescript', Version: 'v0.1.0' },
clientInfo: ClientInfo = { name: 'jellyfin-sdk-typescript', version: 'v0.1.0' },
// FIXME: The device info should always be required.
deviceInfo: DeviceInfo = { Name: 'device-name', Id: 'device-id' }
deviceInfo: DeviceInfo = { name: 'device-name', id: 'device-id' }
) {
this.clientInfo = clientInfo;
this.deviceInfo = deviceInfo;

View File

@ -8,6 +8,6 @@
* An interface representing a client application.
*/
export interface ClientInfo {
Name: string,
Version: string
name: string,
version: string
}

View File

@ -8,6 +8,6 @@
* An interface representing a client device.
*/
export interface DeviceInfo {
Id: string,
Name: string
id: string,
name: string
}

View File

@ -8,22 +8,22 @@ import { getAuthorizationHeader } from '..';
describe('Authentication', () => {
it('should return the correct header value without token', () => {
const header = getAuthorizationHeader({
Name: 'SDK Test',
Version: '0.0.0'
name: 'SDK Test',
version: '0.0.0'
}, {
Name: 'Test Device',
Id: 'TESTID'
name: 'Test Device',
id: 'TESTID'
});
expect(header).toEqual('MediaBrowser Client="SDK Test", Device="Test Device", DeviceId="TESTID", Version="0.0.0", Token=""');
});
it('should return the correct header value with token', () => {
const header = getAuthorizationHeader({
Name: 'SDK Test',
Version: '0.0.0'
name: 'SDK Test',
version: '0.0.0'
}, {
Name: 'Test Device',
Id: 'TESTID'
name: 'Test Device',
id: 'TESTID'
}, 'TESTTOKEN');
expect(header).toEqual('MediaBrowser Client="SDK Test", Device="Test Device", DeviceId="TESTID", Version="0.0.0", Token="TESTTOKEN"');
});

View File

@ -11,10 +11,10 @@ import { ClientInfo, DeviceInfo } from '../models';
export function getAuthorizationHeader(clientInfo: ClientInfo, deviceInfo: DeviceInfo, accessToken = ''): string {
// TODO: We should ensure values are properly escaped
return [
`MediaBrowser Client="${clientInfo.Name}"`,
`Device="${deviceInfo.Name}"`,
`DeviceId="${deviceInfo.Id}"`,
`Version="${clientInfo.Version}"`,
`MediaBrowser Client="${clientInfo.name}"`,
`Device="${deviceInfo.name}"`,
`DeviceId="${deviceInfo.id}"`,
`Version="${clientInfo.version}"`,
`Token="${accessToken}"`
].join(', ');
}