Skip to main content

Conditional Operation

There are two ways to go about creating a conditional operation.
  1. Using the if, then and else methods of the ConditionalOperation class.
  2. Creating Condition objects and passing them to the constructor of the ConditionalOperation class.

1. Using the if, then and else methods

Using the Condition class

The Condition class can be used to construct a conditional operation without using the if, then and else methods. Condition objects can be reused and combined to create more complex conditional operations. A condition looks is implemented as follows:
The value_a and value_b fields are the operands of the condition. The operator field determines the type of condition. The action field is the work step or operation that will be executed if the condition is met. The value_a and value_b fields can accept any of the following:
  1. A work step or operation output
  2. Another condition
  3. A static value
You can create the same conditional operation as the previous example using the Condition class as follows:

Combining conditions

You can combine conditions to create more complex conditions as shown below:

Referencing web2 payloads in conditions

Web2 requests return various shapes of payload when executed, including plain text or JSON. Let’s illustrate how you can reference these payloads using a GET request to read the current BTC price.
The value we can use in a condition is nested inside the bitcoin object under the usd key. We can reference the value as shown below:
When dealing with web2 endpoints that return a single value, eg. a string or number, or when you want to reference the whole payload, you can do the following: