Skip to content

Commit

Permalink
Merge pull request particle-iot#51 from AntonPuko/cleanup
Browse files Browse the repository at this point in the history
rename getCore to getDevice
  • Loading branch information
jlkalberer authored Dec 30, 2016
2 parents 933c6a2 + 6cc333b commit 04b9092
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
42 changes: 21 additions & 21 deletions src/repository/DeviceRepository.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
)
Expand All @@ -110,14 +110,14 @@ class DeviceRepository {
};

getDetailsByID = async (deviceID: string, userID: string): Promise<Device> => {
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' },
),
Expand All @@ -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' },
)
Expand Down Expand Up @@ -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 },
);
Expand All @@ -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 },
);
Expand All @@ -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 } },
);
Expand All @@ -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 } },
);
Expand Down
2 changes: 1 addition & 1 deletion test/setup/DeviceServerMock.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import SparkCoreMock from './SparkCoreMock';

class DeviceServerMock {
getCore(): SparkCoreMock {
getDevice(): SparkCoreMock {
return new SparkCoreMock();
}
}
Expand Down

0 comments on commit 04b9092

Please sign in to comment.