# Operations (sample payloads)

## Main operations

### Add

Add two numbers together.
**Sample Input**

```json
\{
    "first_value": 5,
    "second_value": "3.7"
\}
```

**Sample Output**

```json
{
    "result": 8.7
}
```

### Average

Get the average of a list of numbers.
**Sample Input**

```json
\{
    "values": [
        10,
        20,
        30,
        40,
        50
    ]
\}
```

**Sample Output**

```json
{
    "result": 30
}
```

### Divide

Divide one number by another number.
**Sample Input**

```json
\{
    "first_value": 10,
    "second_value": 2
\}
```

**Sample Output**

```json
{
    "result": 5
}
```

### Multiply

Multiply two numbers.
**Sample Input**

```json
\{
    "first_value": 5.5,
    "second_value": "3"
\}
```

**Sample Output**

```json
{
    "result": 16.5
}
```

### Page offset

When looping through pages, you'll often want to get the "offset" - the number of items to skip. If the page is zero based, the offset is page number x per page.
**Sample Input**

```json
\{
    "page": 3,
    "per_page": 20,
    "is_page_zero_based": false
\}
```

**Sample Output**

```json
{
    "result": 40
}
```

### Parse number

Parse a number from a string. Will parse "$20" as 20 by removing the currency symbol.
**Sample Input**

```json
\{
    "string": "$1,234.56"
\}
```

**Sample Output**

```json
{
    "result": 1234.56
}
```

### Remainder

Given two numbers, return the remainder/modulus by dividing the first by the second.
**Sample Input**

```json
\{
    "value": 17,
    "divider": 5
\}
```

**Sample Output**

```json
{
    "result": 2
}
```

### Round

Round a number to the specified number of decimals. Note that floating point numbers cannot represent all decimals precisely in binary.
**Sample Input**

```json
\{
    "number": 3.14159265359,
    "decimal_precision": 2
\}
```

**Sample Output**

```json
{
    "result": 3.14
}
```

### Run expression

Run an arithmetic expression such as "1 + 2 \* (2 + 4)" and get the result.
**Sample Input**

```json
{
    "expression": "5 * (3 + 2) - 10 / 2"
}
```

**Sample Output**

```json
{
    "result": 20
}
```

### Subtract

Subtract one number from another number.
**Sample Input**

```json
\{
    "first_value": 10,
    "second_value": 3
\}
```

**Sample Output**

```json
{
    "result": 7
}
```

### Sum

Get the sum of a list of numbers.
**Sample Input**

```json
\{
    "values": [
        10,
        20,
        30,
        "40",
        50.5
    ]
\}
```

**Sample Output**

```json
{
    "result": 150.5
}
```
