Skip to content

Commit 04b9092

Browse files
authored
Merge pull request particle-iot#51 from AntonPuko/cleanup
rename getCore to getDevice
2 parents 933c6a2 + 6cc333b commit 04b9092

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

src/repository/DeviceRepository.js

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,11 @@ class DeviceRepository {
8888
throw new HttpError('No device found', 404);
8989
}
9090

91-
const core = this._deviceServer.getCore(attributes.deviceID);
91+
const device = this._deviceServer.getDevice(attributes.deviceID);
9292
// TODO: Not sure if this should actually be the core ID that gets sent
9393
// but that's what the old source code does :/
94-
const response = core
95-
? await core.onApiMessage(
94+
const response = device
95+
? await device.onApiMessage(
9696
attributes.deviceID,
9797
{ cmd: 'Ping' },
9898
)
@@ -110,14 +110,14 @@ class DeviceRepository {
110110
};
111111

112112
getDetailsByID = async (deviceID: string, userID: string): Promise<Device> => {
113-
const core = this._deviceServer.getCore(deviceID);
114-
if (!core) {
113+
const device = this._deviceServer.getDevice(deviceID);
114+
if (!device) {
115115
throw new HttpError('No device found', 404);
116116
}
117117

118118
const [attributes, description] = await Promise.all([
119119
this._deviceAttributeRepository.getById(deviceID, userID),
120-
core.onApiMessage(
120+
device.onApiMessage(
121121
deviceID,
122122
{ cmd: 'Describe' },
123123
),
@@ -141,11 +141,11 @@ class DeviceRepository {
141141
const devicesAttributes =
142142
await this._deviceAttributeRepository.getAll(userID);
143143
const devicePromises = devicesAttributes.map(async attributes => {
144-
const core = this._deviceServer.getCore(attributes.deviceID);
144+
const device = this._deviceServer.getDevice(attributes.deviceID);
145145
// TODO: Not sure if this should actually be the core ID that gets sent
146146
// but that's what the old source code does :/
147-
const response = core
148-
? await core.onApiMessage(
147+
const response = device
148+
? await device.onApiMessage(
149149
attributes.deviceID,
150150
{ cmd: 'Ping' },
151151
)
@@ -175,11 +175,11 @@ class DeviceRepository {
175175
throw new HttpError('No device found', 404);
176176
}
177177

178-
const core = this._deviceServer.getCore(deviceID);
179-
if (!core) {
178+
const device = this._deviceServer.getDevice(deviceID);
179+
if (!device) {
180180
throw new HttpError('Could not get device for ID', 404);
181181
}
182-
const result = await core.onApiMessage(
182+
const result = await device.onApiMessage(
183183
deviceID,
184184
{ cmd: 'CallFn', name: functionName, args: functionArguments },
185185
);
@@ -200,11 +200,11 @@ class DeviceRepository {
200200
throw new HttpError('No device found', 404);
201201
}
202202

203-
const core = this._deviceServer.getCore(deviceID);
204-
if (!core) {
203+
const device = this._deviceServer.getDevice(deviceID);
204+
if (!device) {
205205
throw new HttpError('Could not get device for ID', 404);
206206
}
207-
const result = await core.onApiMessage(
207+
const result = await device.onApiMessage(
208208
deviceID,
209209
{ cmd: 'GetVar', name: varName },
210210
);
@@ -220,12 +220,12 @@ class DeviceRepository {
220220
deviceID: string,
221221
file: File,
222222
) => {
223-
const core = this._deviceServer.getCore(deviceID);
224-
if (!core) {
223+
const device = this._deviceServer.getDevice(deviceID);
224+
if (!device) {
225225
throw new HttpError('Could not get device for ID', 404);
226226
}
227227

228-
const result = await core.onApiMessage(
228+
const result = await device.onApiMessage(
229229
deviceID,
230230
{ cmd: 'UFlash', args: { data: file.buffer } },
231231
);
@@ -252,12 +252,12 @@ class DeviceRepository {
252252
throw new HttpError(`No firmware ${appName} found`);
253253
}
254254

255-
const core = this._deviceServer.getCore(deviceID);
256-
if (!core) {
255+
const device = this._deviceServer.getDevice(deviceID);
256+
if (!device) {
257257
throw new HttpError('Could not get device for ID', 404);
258258
}
259259

260-
const result = await core.onApiMessage(
260+
const result = await device.onApiMessage(
261261
deviceID,
262262
{ cmd: 'UFlash', args: { data: knownFirmware } },
263263
);

test/setup/DeviceServerMock.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import SparkCoreMock from './SparkCoreMock';
44

55
class DeviceServerMock {
6-
getCore(): SparkCoreMock {
6+
getDevice(): SparkCoreMock {
77
return new SparkCoreMock();
88
}
99
}

0 commit comments

Comments
 (0)