Execute a Function

You can execute a Catalyst function in any one of the ways given below, based on the HTTP request you pass with the function. You can pass the parameters to the function to be executed as the argument to a function execution method. This method differs for each HTTP request type.

Note: You can create six types of functions in Catalyst: Basic I/O, Advanced I/O, Cron, Integration, Event, and BrowserLogic functions. However, you can only execute Basic I/O functions in Catalyst iOS SDK.

The <FUNCTION_INSTANCE> used in all the code sections below is the instance defined in the Function Instance page.

Execute a GET function

You can execute a function of the HTTP GET type by passing the parameters to the executeGet() method:

    
copy
<FUNCTION_INSTANCE>.executeGet( parameters params : [ String : Any ]? = nil, completion : @escaping( Result< String, ZCatalystError > ) -> Void )

Parameters:

  • params: The parameters to be passed to the function as a Hash map

A sample code snippet is shown below:

    
copy
ZCatalystApp.shared.getFunctionInstance(id: 2823000000097020).executeGet() //Replace this with your function ID { result in switch result { case .success(let output) : print("GET function executed successfully - \( output )") case .error(let error) : print("GET function failed to execute - \( error )") } }

Execute a PUT function

You can execute a function of the HTTP PUT type, by passing the parameters to the executePut() method as a Hash map. You can pass the payload in the PUT request to this method as a Hash map argument as well:

    
copy
<FUNCTION_INSTANCE>.executePut( parameters params : [ String : Any ]? = nil, body : [ String : Any ]? = nil, completion : @escaping( Result< String, ZCatalystError > ) -> Void )

Parameters:

  • params: The parameters to be passed to the function as a Hash map
  • body: The data payload to be passed as a Hash map

A sample code snippet is shown below:

    
copy
var params : [ String : Any ] = [:] params[ "ROWID" ] = "2823000000098012" params[ "Category" ] = "Important" ZCatalystApp.shared.getFunctionInstance(id: 2823000000097020).executePut(parameters: params) //Replace this with your function ID { result in switch result { case .success(let output) : print("PUT function executed successfully - \( output )") case .error(let error) : print("PUT function failed to execute - \( error )") } }

Execute a POST function

You can execute a function of the HTTP POST type, by passing the parameters to the executePOST() method as a Hash map. You can pass the payload in the POST request to this method as a Hash map argument as well:

    
copy
<FUNCTION_INSTANCE>.executePost( parameters params : [ String : Any ]? = nil, body : [ String : Any ]? = nil, completion : @escaping( Result< String, ZCatalystError > ) -> Void )

Parameters:

  • params: The parameters to be passed to the function as a Hash map

  • body: The data payload to be passed as a Hash map

A sample code snippet is shown below:

    
copy
var params : [ String : Any ] = [:] params[ "Title" ] = "Data Migration Tasks" params[ "Category" ] = "Official" ZCatalystApp.shared.getFunctionInstance(id: 2823000000097020).executePost(parameters: ) //Replace this with your function ID { result in switch result { case .success(let output) : print("POST function executed successfully - \( output )") case .error(let error) : print("POST function failed to execute - \( error )") } }

Last Updated 2023-09-15 13:46:34 +0530 +0530