Constants and Variables
Ductape provides interfaces for managing the constants and variables used in your service.
Constants
Constants are values that do not change and can be reused across multiple actions within your application.
Creating Constants
- TypeScript
- Java
- Go
- .NET
import { DataTypes } from "@ductape/sdk/types";
const details = {
key: "USER_TYPE",
value: "user",
type: DataTypes.STRING,
description: "The User Type field, to be used during user registration"
};
const constants = await ductape.app.constant.create(details);
Map<String, Object> details = Map.of(
"key", "USER_TYPE",
"value", "user",
type: DataTypes.STRING,
"description", "The User Type field, to be used during user registration"
);
Map<String, Object> constants = ductape.app.constant.create(details);
details := map[string]any{
"key": "USER_TYPE",
"value": "user",
type: DataTypes.STRING,
"description": "The User Type field, to be used during user registration"
};
constants := client.app.constant.create(details);
var details = new Dictionary<string, object?>
{
["key"] = "USER_TYPE",
["value"] = "user",
type: DataTypes.STRING,
["description"] = "The User Type field, to be used during user registration"
};
var constants = await ductape.app.constant.create(details);
Fields
- key: The unique identifier field
- value: The value to be stored
- type: The data type (see table below)
- description: A description of the field and what it entails (optional)
DataTypes Enum
| Key | Value |
|---|---|
| STRING | string |
| NUMBER_STRING | numberstring |
| INTEGER | number |
| FLOAT | float |
| DOUBLE | double |
| UUID | uuid |
| ARRAY | array |
| OBJECT | object |
| BOOLEAN | boolean |
Updating Constants
- TypeScript
- Java
- Go
- .NET
import { DataTypes } from "@ductape/sdk/types";
const details = {
value: "user",
type: DataTypes.STRING,
description: "The User Type field, to be used during user registration"
};
const constant = await ductape.app.constant.update(details);
Map<String, Object> details = Map.of(
"value", "user",
type: DataTypes.STRING,
"description", "The User Type field, to be used during user registration"
);
Map<String, Object> constant = ductape.app.constant.update(details);
details := map[string]any{
"value": "user",
type: DataTypes.STRING,
"description": "The User Type field, to be used during user registration"
};
constant := client.app.constant.update(details);
var details = new Dictionary<string, object?>
{
["value"] = "user",
type: DataTypes.STRING,
["description"] = "The User Type field, to be used during user registration"
};
var constant = await ductape.app.constant.update(details);
Fetching Constants
- TypeScript
- Java
- Go
- .NET
const constants = await ductape.app.constant.fetchAll();
Map<String, Object> constants = ductape.app.constant.fetchAll();
constants := client.app.constant.fetchAll();
var constants = await ductape.app.constant.fetchAll();
- TypeScript
- Java
- Go
- .NET
const key = "USER_TYPE";
const constant = await ductape.app.constant.fetch(key);
Map<String, Object> key = "USER_TYPE";
Map<String, Object> constant = ductape.app.constant.fetch(key);
key := "USER_TYPE";
constant := client.app.constant.fetch(key);
var key = "USER_TYPE";
var constant = await ductape.app.constant.fetch(key);
Variables
Variables are values that are meant to be supplied by third parties and can be reused across multiple actions within your application. Defining variables is similar to defining constants, but the values are not set by you, but instead by your customers.
Creating Variables
- TypeScript
- Java
- Go
- .NET
import { DataTypes } from "@ductape/sdk/types";
const details = {
key: "PUBLIC_KEY",
type: DataTypes.UUID,
description: "The User's Public Key"
};
const variable = await ductape.app.variable.create(details);
Map<String, Object> details = Map.of(
"key", "PUBLIC_KEY",
type: DataTypes.UUID,
"description", "The User's Public Key"
);
Map<String, Object> variable = ductape.app.variable.create(details);
details := map[string]any{
"key": "PUBLIC_KEY",
type: DataTypes.UUID,
"description": "The User's Public Key"
};
variable := client.app.variable.create(details);
var details = new Dictionary<string, object?>
{
["key"] = "PUBLIC_KEY",
type: DataTypes.UUID,
["description"] = "The User's Public Key"
};
var variable = await ductape.app.variable.create(details);
Updating Variables
- TypeScript
- Java
- Go
- .NET
import { DataTypes } from "@ductape/sdk/types";
const key = "PUBLIC_KEY";
const update = {
type: DataTypes.STRING,
description: "The User's Public Key"
};
const variable = await ductape.app.variable.update(key, update);
Map<String, Object> key = "PUBLIC_KEY";
Map<String, Object> update = Map.of(
type: DataTypes.STRING,
"description", "The User's Public Key"
);
Map<String, Object> variable = ductape.app.variable.update(key, update);
key := "PUBLIC_KEY";
update := map[string]any{
type: DataTypes.STRING,
"description": "The User's Public Key"
};
variable := client.app.variable.update(key, update);
var key = "PUBLIC_KEY";
var update = new Dictionary<string, object?>
{
type: DataTypes.STRING,
["description"] = "The User's Public Key"
};
var variable = await ductape.app.variable.update(key, update);
Fetching Variables
- TypeScript
- Java
- Go
- .NET
const variables = await ductape.app.variable.fetchAll();
Map<String, Object> variables = ductape.app.variable.fetchAll();
variables := client.app.variable.fetchAll();
var variables = await ductape.app.variable.fetchAll();
- TypeScript
- Java
- Go
- .NET
const key = "USER_TYPE";
const variable = await ductape.app.variable.fetch(key);
Map<String, Object> key = "USER_TYPE";
Map<String, Object> variable = ductape.app.variable.fetch(key);
key := "USER_TYPE";
variable := client.app.variable.fetch(key);
var key = "USER_TYPE";
var variable = await ductape.app.variable.fetch(key);