# Operations (sample payloads)

## Main operations

### Add item to list

Adds an item to the end of a list. If this list doesn't already exist, then a new list will be returned with just the new item.
**Sample Input**

```json
\{
    "list": [
        "apple",
        "banana",
        "cherry"
    ],
    "item": "date",
    "unique": true
\}
```

**Sample Output**

```json
\{
    "result": [
        "apple",
        "banana",
        "cherry",
        "date"
    ]
\}
```

### Add multiple items to list

Adds multiple items to the end of a list. If this list doesn't already exist, then a new list will be returned with just the new items.
**Sample Input**

```json
\{
    "list": [
        "apple",
        "banana",
        "cherry"
    ],
    "items": [
        "date",
        "elderberry",
        "fig"
    ],
    "unique": true
\}
```

**Sample Output**

### Chunk

Split a list of items into lists of a fixed size. If the list can’t be split evenly, the final chunk will be the remaining elements.
**Sample Input**

```json
\{
    "list": [
        "apple",
        "banana",
        "cherry",
        "date",
        "elderberry",
        "fig",
        "grape"
    ],
    "size": 3
\}
```

**Sample Output**

```json
\{
    "size": 3,
    "result": [
        [
            "apple",
            "banana",
            "cherry"
        ],
        [
            "date",
            "elderberry",
            "fig"
        ],
        [
            "grape"
        ]
    ]
\}
```

### Concatenate

Concatenate two lists together, adding all of the items from the second list after the items in the first list.
**Sample Input**

```json
\{
    "list": [
        "apple",
        "banana",
        "cherry"
    ],
    "list_two": [
        "date",
        "elderberry",
        "fig"
    ]
\}
```

**Sample Output**

```json
\{
    "result": [
        "apple",
        "banana",
        "cherry",
        "date",
        "elderberry",
        "fig"
    ]
\}
```

### Contains

Returns true if the match item in contained in the list, false otherwise.
**Sample Input**
**Sample Output**

### Count items

Counts up the number of items (or length) in the list.
**Sample Input**
**Sample Output**

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

### Delete items from list

Delete all items from a list that match a condition.
**Sample Input**

```json
{
    "list": [
        "apple",
        "banana",
        "cherry",
        "date",
        "elderberry"
    ],
    "conditions": [
        {
            "string_type": \{
                "comparison_type": "contains",
                "value": "a"
            \}
        },
        {
            "string_type": \{
                "comparison_type": "!==",
                "value": "cherry"
            \}
        }
    ],
    "strictness": "all"
}
```

**Sample Output**

```json
\{
    "removed": true,
    "result": [
        "apple",
        "banana",
        "date"
    ]
\}
```

### Difference

For a given list, filter it down to only return the items that do NOT exist in the second list.
**Sample Input**

```json
\{
    "list": [
        "apple",
        "banana",
        "cherry",
        "date",
        "elderberry"
    ],
    "list_two": [
        "banana",
        "date",
        "fig"
    ]
\}
```

**Sample Output**

```json
\{
    "result": [
        "apple",
        "cherry",
        "elderberry"
    ]
\}
```

### Filter

Use filter conditions to filter a list of objects.
**Sample Input**

```json
{
    "list": [
        \{
            "name": "John",
            "age": 30,
            "city": "New York"
        \},
        \{
            "name": "Alice",
            "age": 25,
            "city": "Los Angeles"
        \},
        \{
            "name": "Bob",
            "age": 35,
            "city": "Chicago"
        \},
        \{
            "name": "Emma",
            "age": 28,
            "city": "New York"
        \}
    ],
    "filter_type": "inclusive",
    "conjunction": "OR",
    "filters": [
        {
            "age": 30
        },
        {
            "city": "New York"
        }
    ]
}
```

**Sample Output**

```json
{
    "result": [
        \{
            "name": "John",
            "age": 30,
            "city": "New York"
        \},
        \{
            "name": "Emma",
            "age": 28,
            "city": "New York"
        \}
    ]
}
```

### Find object in list

From a list of objects, pick the first object that matches the fields in the match object.
**Sample Input**
**Sample Output**

```json
{
    "result": \{
        "id": 2,
        "name": "Jane Smith",
        "age": 25,
        "city": "Los Angeles"
    \}
}
```

### First

Given a list of items, get the first one.
**Sample Input**

```json
\{
    "list": [
        42,
        17,
        99,
        3,
        7
    ],
    "error_on_empty": false
\}
```

**Sample Output**

```json
{
    "result": 42
}
```

### Get item by index

Given a list of items, retrieve the one at a specified index.
**Sample Input**

```json
\{
    "list": [
        "apple",
        "banana",
        "cherry",
        "date",
        "elderberry"
    ],
    "index": 2,
    "default_value": "Not found",
    "index_error": false,
    "error_on_empty": false
\}
```

**Sample Output**

```json
{
    "result": "cherry"
}
```

### Get list of page numbers

Get a list of "page numbers", given a total count, along with the number of items you would like to have in each page. For example, if you had 300 records and 100 per page, the list "\[1,2,3]" would be returned.
**Sample Input**
**Sample Output**

```json
\{
    "result": [
        1,
        2,
        3,
        4,
        5,
        6
    ]
\}
```

### Get numbers between

Given a minimum and maximum value, get a list of all of the numbers in between the two. Includes both the minimum and maximum numbers too.
**Sample Input**

```json
\{
    "min": 5,
    "max": 10
\}
```

**Sample Output**

```json
\{
    "result": [
        5,
        6,
        7,
        8,
        9,
        10
    ]
\}
```

### Get unique items by key

Given a list of objects, retrieve a unique list of objects, excluding duplicate values for a specific key.
**Sample Input**

```json
{
    "list": [
        \{
            "id": 1,
            "name": "John Doe",
            "department": "Sales"
        \},
        \{
            "id": 2,
            "name": "Jane Smith",
            "department": "Marketing"
        \},
        \{
            "id": 3,
            "name": "Bob Johnson",
            "department": "Sales"
        \},
        \{
            "id": 4,
            "name": "Alice Brown",
            "department": "Marketing"
        \}
    ],
    "key": "department"
}
```

**Sample Output**

```json
{
    "result": [
        \{
            "id": 1,
            "name": "John Doe",
            "department": "Sales"
        \},
        \{
            "id": 2,
            "name": "Jane Smith",
            "department": "Marketing"
        \}
    ]
}
```

### Intersection

For two given lists, return only the items that exist in both lists.
**Sample Input**

```json
\{
    "list": [
        1,
        2,
        3,
        4,
        5,
        6
    ],
    "list_two": [
        4,
        5,
        6,
        7,
        8,
        9
    ]
\}
```

**Sample Output**

```json
\{
    "result": [
        4,
        5,
        6
    ]
\}
```

### Iterative transform

Given a list, iterates through the enumerable components, and transforms the associated values accordingly.
**Sample Input**

```json
\{
    "list": [
        "hello world",
        "SAMPLE TEXT",
        "camelCase_example",
        "  trim me  ",
        "snake_case_string"
    ],
    "transform_value": "upperCase"
\}
```

**Sample Output**

### Join

Join all items in a list together as a string, separated by a separator.
**Sample Input**

```json
\{
    "list": [
        "apple",
        "banana",
        "cherry",
        42,
        true,
        [
            "grape",
            "orange"
        ]
    ],
    "separator": " - "
\}
```

**Sample Output**

```json
\{
    "result": "apple - banana - cherry - 42 - true - grape,orange"
\}
```

### Last

Given a list of items, get the last one.
**Sample Input**

```json
\{
    "list": [
        "apple",
        "banana",
        "cherry",
        "date",
        "elderberry"
    ],
    "error_on_empty": false
\}
```

**Sample Output**

```json
{
    "result": "elderberry"
}
```

### Pluck

Given a list of objects, extracts the value of a specific key from each one, returning a flat list of the values for all objects.
**Sample Input**
**Sample Output**

```json
\{
    "result": [
        "john@example.com",
        "jane@example.com",
        "bob@example.com"
    ]
\}
```

### Remove duplicates

Ensures that every item in a list exists once, and only once. Removes any duplicate values.
**Sample Input**
**Sample Output**

### Rename keys

Renames all keys in a list of objects.
**Sample Input**

```json
{
    "list_of_objects": [
        \{
            "first_name": "John",
            "last_name": "Doe",
            "age": 30
        \},
        \{
            "first_name": "Jane",
            "last_name": "Smith",
            "age": 25
        \}
    ],
    "list_of_keys": [
        \{
            "original_key": "first_name",
            "new_key": "given_name"
        \},
        \{
            "original_key": "last_name",
            "new_key": "family_name"
        \}
    ]
}
```

**Sample Output**

```json
{
    "result": [
        \{
            "given_name": "John",
            "family_name": "Doe",
            "age": 30
        \},
        \{
            "given_name": "Jane",
            "family_name": "Smith",
            "age": 25
        \}
    ]
}
```

### Reverse

Reverse the order of a list.
**Sample Input**

```json
\{
    "list": [
        "apple",
        "banana",
        "cherry",
        "date",
        "elderberry"
    ]
\}
```

**Sample Output**

```json
\{
    "result": [
        "elderberry",
        "date",
        "cherry",
        "banana",
        "apple"
    ]
\}
```

### Rotate first item

Takes the first item of the list and puts it at the back.
**Sample Input**

```json
\{
    "list": [
        "apple",
        "banana",
        "cherry",
        "date",
        "elderberry"
    ]
\}
```

**Sample Output**

```json
\{
    "result": [
        "banana",
        "cherry",
        "date",
        "elderberry",
        "apple"
    ]
\}
```

### Simple sort

Sorts a list of strings and / or numbers in ascending or descending order.
**Sample Input**
**Sample Output**

```json
\{
    "result": [
        "elderberry",
        "date",
        "cherry",
        "banana",
        "apple"
    ]
\}
```

### Slice

Creates a slice of the list from start up to, but not including, end.
**Sample Input**

```json
\{
    "list": [
        "apple",
        "banana",
        "cherry",
        "date",
        "elderberry"
    ],
    "start": 1,
    "end": 4
\}
```

**Sample Output**

```json
\{
    "result": [
        "banana",
        "cherry",
        "date"
    ]
\}
```

### Sort objects

Given the inputs list, key and order ("ascending", "descending"), sort the object by the specified key in the desired order.
**Sample Input**
**Sample Output**

```json
{
    "result": [
        \{
            "name": "Alice",
            "age": 25,
            "city": "Los Angeles"
        \},
        \{
            "name": "John",
            "age": 30,
            "city": "New York"
        \},
        \{
            "name": "Bob",
            "age": 35,
            "city": "Chicago"
        \}
    ]
}
```

### Zip

Takes a list of keys and a second list of values and returns a single object with corresponding key value pairs.
**Sample Input**
**Sample Output**

```json
{
    "result": \{
        "name": "John Doe",
        "age": 30,
        "city": "New York"
    \}
}
```
