From 6cc333bf1660ac0bbeb93cf579294588f141fa44 Mon Sep 17 00:00:00 2001 From: Anton Puko Date: Fri, 30 Dec 2016 16:16:15 +0200 Subject: [PATCH] rename getCore to getDevice --- src/repository/DeviceRepository.js | 42 +++++++++++++++--------------- test/setup/DeviceServerMock.js | 2 +- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/repository/DeviceRepository.js b/src/repository/DeviceRepository.js index a3585346..f34f3e00 100644 --- a/src/repository/DeviceRepository.js +++ b/src/repository/DeviceRepository.js @@ -88,11 +88,11 @@ class DeviceRepository { throw new HttpError('No device found', 404); } - const core = this._deviceServer.getCore(attributes.deviceID); + const device = this._deviceServer.getDevice(attributes.deviceID); // TODO: Not sure if this should actually be the core ID that gets sent // but that's what the old source code does :/ - const response = core - ? await core.onApiMessage( + const response = device + ? await device.onApiMessage( attributes.deviceID, { cmd: 'Ping' }, ) @@ -110,14 +110,14 @@ class DeviceRepository { }; getDetailsByID = async (deviceID: string, userID: string): Promise => { - const core = this._deviceServer.getCore(deviceID); - if (!core) { + const device = this._deviceServer.getDevice(deviceID); + if (!device) { throw new HttpError('No device found', 404); } const [attributes, description] = await Promise.all([ this._deviceAttributeRepository.getById(deviceID, userID), - core.onApiMessage( + device.onApiMessage( deviceID, { cmd: 'Describe' }, ), @@ -141,11 +141,11 @@ class DeviceRepository { const devicesAttributes = await this._deviceAttributeRepository.getAll(userID); const devicePromises = devicesAttributes.map(async attributes => { - const core = this._deviceServer.getCore(attributes.deviceID); + const device = this._deviceServer.getDevice(attributes.deviceID); // TODO: Not sure if this should actually be the core ID that gets sent // but that's what the old source code does :/ - const response = core - ? await core.onApiMessage( + const response = device + ? await device.onApiMessage( attributes.deviceID, { cmd: 'Ping' }, ) @@ -175,11 +175,11 @@ class DeviceRepository { throw new HttpError('No device found', 404); } - const core = this._deviceServer.getCore(deviceID); - if (!core) { + const device = this._deviceServer.getDevice(deviceID); + if (!device) { throw new HttpError('Could not get device for ID', 404); } - const result = await core.onApiMessage( + const result = await device.onApiMessage( deviceID, { cmd: 'CallFn', name: functionName, args: functionArguments }, ); @@ -200,11 +200,11 @@ class DeviceRepository { throw new HttpError('No device found', 404); } - const core = this._deviceServer.getCore(deviceID); - if (!core) { + const device = this._deviceServer.getDevice(deviceID); + if (!device) { throw new HttpError('Could not get device for ID', 404); } - const result = await core.onApiMessage( + const result = await device.onApiMessage( deviceID, { cmd: 'GetVar', name: varName }, ); @@ -220,12 +220,12 @@ class DeviceRepository { deviceID: string, file: File, ) => { - const core = this._deviceServer.getCore(deviceID); - if (!core) { + const device = this._deviceServer.getDevice(deviceID); + if (!device) { throw new HttpError('Could not get device for ID', 404); } - const result = await core.onApiMessage( + const result = await device.onApiMessage( deviceID, { cmd: 'UFlash', args: { data: file.buffer } }, ); @@ -252,12 +252,12 @@ class DeviceRepository { throw new HttpError(`No firmware ${appName} found`); } - const core = this._deviceServer.getCore(deviceID); - if (!core) { + const device = this._deviceServer.getDevice(deviceID); + if (!device) { throw new HttpError('Could not get device for ID', 404); } - const result = await core.onApiMessage( + const result = await device.onApiMessage( deviceID, { cmd: 'UFlash', args: { data: knownFirmware } }, ); diff --git a/test/setup/DeviceServerMock.js b/test/setup/DeviceServerMock.js index 7a915f5f..c8ef8cae 100644 --- a/test/setup/DeviceServerMock.js +++ b/test/setup/DeviceServerMock.js @@ -3,7 +3,7 @@ import SparkCoreMock from './SparkCoreMock'; class DeviceServerMock { - getCore(): SparkCoreMock { + getDevice(): SparkCoreMock { return new SparkCoreMock(); } }