Timer Service API

Set up timers which will fire events once, on an interval, or on a schedule.

Operations

Events

Operations


cancel

This operation will cancel an active timer.

Arguments
parameters - object - Object containing service call parameters.
Name Type Description
timer_id string The ID of the timer to cancel
Responses
Operation successful - object
Name Type Description
result string Okay if successful
Operation error information - object
Name Type Description
type string Error type
error string Error message
status integer Response code
Example
local req = Timer.schedule({timer_id="exampleId",duration=100,schedule={yearly=true,monthly=true}}) print(req) req = Timer.cancel({timer_id="exampleId"}) print(req)

cancelAll

This operation will cancel all active timers in the given solution.

Responses
Operation successful - object
Name Type Description
result string Okay if successful
Operation error information - object
Name Type Description
type string Error type
error string Error message
status integer Response code
Example
local req = Timer.cancelAll() print(req)

schedule

Sets up a timer which will fire on a schedule which is based on the date and time on which the schedule is created.

Arguments
parameters - object - Object containing service call parameters.
Name Type Description
message string, object The message to send when the timer is hit. This message will be fired to Solution -> Service -> Timer, and user can handle this message there.
duration integer The duration of the timer in milliseconds.
Required for send_after and send_interval,
ignored for scheduled tasks.
schedule object The task schedule definition
schedule.daily boolean This task should occur daily
schedule.hourly boolean This task should occur hourly
schedule.weekly boolean This task should occur weekly
schedule.yearly boolean This task should occur yearly
schedule.monthly boolean This task should occur monthly
timer_id string The ID of the timer. If null, it will be generated for you.
Responses
New timer task information - object
Name Type Description
result string A message describing the result of the operation
timer_id string The ID of the timer
Operation error information - object
Name Type Description
type string Error type
error string Error message
status integer Response code
Example
local req = Timer.schedule({timer_id="exampleId", duration=100,schedule={yearly=true, monthly=true}}) print(req) response.message= req response.code = 200

sendAfter

Sets up a timer which will fire once after duration has passed.

Arguments
parameters - object - Object containing service call parameters.
Name Type Description
message string, object The message to send when the timer is hit. This message will be fired to Solution -> Service -> Timer, and user can handle this message there.
duration integer The duration of the timer in milliseconds.
Required for send_after and send_interval,
ignored for scheduled tasks.
schedule object The task schedule definition
schedule.daily boolean This task should occur daily
schedule.hourly boolean This task should occur hourly
schedule.weekly boolean This task should occur weekly
schedule.yearly boolean This task should occur yearly
schedule.monthly boolean This task should occur monthly
timer_id string The ID of the timer. If null, it will be generated for you.
Responses
New timer task information - object
Name Type Description
result string A message describing the result of the operation
timer_id string The ID of the timer
Operation error information - object
Name Type Description
type string Error type
error string Error message
status integer Response code
Example
local req = Timer.sendAfter({timer_id="abc123", duration=100}) print(req) response.message = req response.code = 200

sendInterval

Sets up a timer which will fire once every duration.

Arguments
parameters - object - Object containing service call parameters.
Name Type Description
message string, object The message to send when the timer is hit. This message will be fired to Solution -> Service -> Timer, and user can handle this message there.
duration integer The duration of the timer in milliseconds.
Required for send_after and send_interval,
ignored for scheduled tasks.
schedule object The task schedule definition
schedule.daily boolean This task should occur daily
schedule.hourly boolean This task should occur hourly
schedule.weekly boolean This task should occur weekly
schedule.yearly boolean This task should occur yearly
schedule.monthly boolean This task should occur monthly
timer_id string The ID of the timer. If null, it will be generated for you.
Responses
New timer task information - object
Name Type Description
result string A message describing the result of the operation
timer_id string The ID of the timer
Operation error information - object
Name Type Description
type string Error type
error string Error message
status integer Response code
Example
local req = Timer.sendInterval({timer_id="abc123", duration=100}) print(req) response.message = req response.code = 200

Events


timer

A scheduled timer is occurring. And timer task data is transmitted.

Arguments
request - object - The timer task data
Name Type Description
message object The message to send when the timer is hit. This message will be fired to Solution -> Service -> Timer, and user can handle this message there.
timer_id string The ID of the timer. If null, it will be generated for you.
solution_id string The ID of the solution this timer is associated with.
Example
function handle_timer_timer (request)

 ... 

end