Gaëtan Renaudeau
7 years ago
committed by
GitHub
9 changed files with 135 additions and 44 deletions
@ -0,0 +1,15 @@ |
|||||
|
// @flow
|
||||
|
|
||||
|
import { createCommand, Command } from 'helpers/ipc' |
||||
|
import { fromPromise } from 'rxjs/observable/fromPromise' |
||||
|
import type { DeviceInfo } from 'helpers/devices/getDeviceInfo' |
||||
|
|
||||
|
import listAppVersions from 'helpers/apps/listAppVersions' |
||||
|
|
||||
|
type Result = * |
||||
|
|
||||
|
const cmd: Command<DeviceInfo, Result> = createCommand('listAppVersions', deviceInfo => |
||||
|
fromPromise(listAppVersions(deviceInfo)), |
||||
|
) |
||||
|
|
||||
|
export default cmd |
@ -0,0 +1,16 @@ |
|||||
|
// @flow
|
||||
|
|
||||
|
import { createCommand, Command } from 'helpers/ipc' |
||||
|
import { fromPromise } from 'rxjs/observable/fromPromise' |
||||
|
|
||||
|
import listCategories from 'helpers/apps/listCategories' |
||||
|
|
||||
|
type Input = {} |
||||
|
|
||||
|
type Result = * |
||||
|
|
||||
|
const cmd: Command<Input, Result> = createCommand('listCategories', () => |
||||
|
fromPromise(listCategories()), |
||||
|
) |
||||
|
|
||||
|
export default cmd |
@ -0,0 +1,31 @@ |
|||||
|
// @flow
|
||||
|
import network from 'api/network' |
||||
|
import type { DeviceInfo } from 'helpers/devices/getDeviceInfo' |
||||
|
|
||||
|
import { APPLICATIONS_BY_DEVICE } from 'helpers/urls' |
||||
|
import getDeviceVersion from 'helpers/devices/getDeviceVersion' |
||||
|
import getCurrentFirmware from 'helpers/devices/getCurrentFirmware' |
||||
|
|
||||
|
export default async (deviceInfo: DeviceInfo) => { |
||||
|
try { |
||||
|
const deviceData = await getDeviceVersion(deviceInfo.targetId, deviceInfo.providerId) |
||||
|
const firmwareData = await getCurrentFirmware({ |
||||
|
deviceId: deviceData.id, |
||||
|
fullVersion: deviceInfo.fullVersion, |
||||
|
provider: deviceInfo.providerId, |
||||
|
}) |
||||
|
const params = { |
||||
|
provider: deviceInfo.providerId, |
||||
|
current_se_firmware_final_version: firmwareData.id, |
||||
|
device_version: deviceData.id, |
||||
|
} |
||||
|
const { |
||||
|
data: { application_versions }, |
||||
|
} = await network({ method: 'POST', url: APPLICATIONS_BY_DEVICE, data: params }) |
||||
|
return application_versions.length > 0 ? application_versions : [] |
||||
|
} catch (err) { |
||||
|
const error = Error(err.message) |
||||
|
error.stack = err.stack |
||||
|
throw err |
||||
|
} |
||||
|
} |
@ -0,0 +1,15 @@ |
|||||
|
// @flow
|
||||
|
import network from 'api/network' |
||||
|
|
||||
|
import { GET_CATEGORIES } from 'helpers/urls' |
||||
|
|
||||
|
export default async () => { |
||||
|
try { |
||||
|
const { data } = await network({ method: 'GET', url: GET_CATEGORIES }) |
||||
|
return data.length > 0 ? data : [] |
||||
|
} catch (err) { |
||||
|
const error = Error(err.message) |
||||
|
error.stack = err.stack |
||||
|
throw err |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue