Skip to content

Commit 09d95b0

Browse files
SombreroElGringoxingoxu
authored andcommitted
LINE Things automatic communication (#150)
* Add LINEThingsScenarioExecutionEvent Add LINEThingsScenarioExecutionEvent in WebhookEvent * Update types.ts
1 parent f610ed7 commit 09d95b0

File tree

1 file changed

+81
-1
lines changed

1 file changed

+81
-1
lines changed

lib/types.ts

Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ export type WebhookEvent =
5252
| BeaconEvent
5353
| AccountLinkEvent
5454
| DeviceLinkEvent
55-
| DeviceUnlinkEvent;
55+
| DeviceUnlinkEvent
56+
| LINEThingsScenarioExecutionEvent;
5657

5758
export type EventBase = {
5859
/**
@@ -243,6 +244,85 @@ export type DeviceUnlinkEvent = ReplyableEvent & {
243244
};
244245
};
245246

247+
export type LINEThingsScenarioExecutionEvent = {
248+
events: Array<LINEThingsEvent>;
249+
destination: string;
250+
};
251+
252+
export type LINEThingsEvent = ReplyableEvent & {
253+
type: "things";
254+
things: {
255+
type: "scenarioResult";
256+
/**
257+
* Device ID of the device that executed the scenario
258+
*/
259+
deviceId: string;
260+
result: {
261+
/**
262+
* Scenario ID executed
263+
*/
264+
scenarioId: string;
265+
/**
266+
* Revision number of the scenario set containing the executed scenario
267+
*/
268+
revision: number;
269+
/**
270+
* Timestamp for when execution of scenario action started (milliseconds, LINE app time)
271+
*/
272+
startTime: number;
273+
/**
274+
* Timestamp for when execution of scenario was completed (milliseconds, LINE app time)
275+
*/
276+
endtime: number;
277+
/**
278+
* Scenario execution completion status
279+
* See also [things.resultCode definitions](https://developers.line.biz/en/reference/messaging-api/#things-resultcode).
280+
*/
281+
resultCode: "success" | "gatt_error" | "runtime_error";
282+
/**
283+
* Execution result of individual operations specified in action
284+
* Note that an array of actions specified in a scenario has the following characteristics
285+
* - The actions defined in a scenario are performed sequentially, from top to bottom.
286+
* - Each action produces some result when executed.
287+
* Even actions that do not generate data, such as `SLEEP`, return an execution result of type `void`.
288+
* The number of items in an action array may be 0.
289+
*
290+
* Therefore, things.actionResults has the following properties:
291+
* - The number of items in the array matches the number of actions defined in the scenario.
292+
* - The order of execution results matches the order in which actions are performed.
293+
* That is, in a scenario set with multiple `GATT_READ` actions,
294+
* the results are returned in the order in which each individual `GATT_READ` action was performed.
295+
* - If 0 actions are defined in the scenario, the number of items in things.actionResults will be 0.
296+
*/
297+
actionResults: Array<LINEThingsActionResult>;
298+
/**
299+
* Data contained in notification
300+
* The value is Base64-encoded binary data.
301+
* Only included for scenarios where `trigger.type = BLE_NOTIFICATION`.
302+
*/
303+
bleNotificationPayload?: string;
304+
/**
305+
* Error reason
306+
*/
307+
errorReason?: string;
308+
};
309+
};
310+
};
311+
312+
export type LINEThingsActionResult = {
313+
/**
314+
* `void`, `binary`
315+
* Depends on `type` of the executed action.
316+
* This property is always included if `things.actionResults` is not empty.
317+
*/
318+
type: "void" | "binary";
319+
/**
320+
* Base64-encoded binary data
321+
* This property is always included when `things.actionResults[].type` is `binary`.
322+
*/
323+
data?: string;
324+
};
325+
246326
export type EventMessage =
247327
| TextEventMessage
248328
| ImageEventMessage

0 commit comments

Comments
 (0)