MCPcopy Create free account
hub / github.com/SmartThingsCommunity/smartthings-cli / handler

Function handler

src/commands/deviceprofiles/view/update.ts:79–106  ·  view source on GitHub ↗
(argv: ArgumentsCamelCase<CommandArgs>)

Source from the content-addressed store, hash-verified

77 }))
78
79const handler = async (argv: ArgumentsCamelCase<CommandArgs>): Promise<void> => {
80 const command = await apiOrganizationCommand(argv)
81
82 const id = await chooseDeviceProfile(command, argv.id)
83 const executeUpdate: ActionFunction<void, DeviceDefinitionRequest, DeviceDefinition> = async (_, data) => {
84 const profileData = { ...data }
85 delete profileData.view
86
87 const presentationData = data.view
88 ? augmentPresentation(data.view)
89 : await generateDefaultConfig(command.client, id, profileData)
90
91 const presentation = await command.client.presentation.create(presentationData)
92 if (!profileData.metadata) {
93 profileData.metadata = {}
94 }
95 profileData.metadata.vid = presentation.presentationId
96 profileData.metadata.mnmn = presentation.manufacturerName
97 const profile = await command.client.deviceProfiles.update(id, cleanupForUpdate(profileData))
98
99 return { ...profile, presentation: prunePresentation(presentation) }
100 }
101 await inputAndOutputItem(
102 command,
103 { buildTableOutput: data => buildTableOutput(command.tableGenerator, data, { includeViewInfo: true }) },
104 executeUpdate,
105 )
106}
107
108const cmd: CommandModule<object, CommandArgs> = { command, describe, builder, handler }
109export default cmd

Callers

nothing calls this directly

Calls 3

apiOrganizationCommandFunction · 0.85
inputAndOutputItemFunction · 0.85
buildTableOutputFunction · 0.50

Tested by

no test coverage detected