Code

CodeMash Code service allows you to add your own custom functions or CodeMash provided functions which can later be used in various triggers, scheduled tasks, or called through API.

To start using Code API you first need to enable code service in your CodeMash dashboard.

Features included in code service:

  1. Providers - the ability to add your own functions from external providers.

  2. Functions - executing your own custom pieces of code.

  3. CodeMash functions - using CodeMash implemented functions.

Using SDK

If you decide to use one of our provided SDK, the following code shows how to initialize code service.

.NET
Node
.NET
var projectId = Guid.Parse("{YOUR_PROJECT_ID}");
var apiKey = "{YOUR_SECRET_KEY}";
var client = new CodeMashClient(apiKey, projectId);
var codeService = new CodeMashCodeService(client);
Node

Example

The following are examples of code SDK using different languages and frameworks.

.NET
Node
.NET
using System;
using CodeMash.Client;
using CodeMash.Code.Services;
using Isidos.CodeMash.ServiceContracts;
namespace ConsoleApplication
{
class Program
{
static void Main(string[] args)
{
// 1. Get your Project ID and Secret Key
var projectId = Guid.Parse("{YOUR_PROJECT_ID}");
var apiKey = "{YOUR_SECRET_KEY}";
// 2. Create a general client for API calls
var client = new CodeMashClient(apiKey, projectId);
// 3. Create a service object
var codeService = new CodeMashCodeService(client);
// 4. Call an API method
codeService.ExecuteFunction(new ExecuteFunctionRequest
{
Id = Guid.Parse("{YOUR_FUNCTION_ID}")
});
}
}
}
Node

Working with Code Service

The following links explore the usage of code service: