Bonusly
The Bonusly integration is used to interact with the Bonusly platform through the API. Bonusly is an employee recognition platform which enterprises use to for employee recognition.
Utilities · Bonusly
Details
| ID | Bonusly |
|---|---|
| Provider | Bonusly |
| Category | Utilities |
| From Version | 5.0.0 |
| Docker Image | demisto/python3:3.12.13.10116658 |
| Supported Modules | Agentix XSIAM |
README
Overview
Bonus.ly is an employee recognition platform which enterprises use to for employee recognition. We’re building tools to help people feel a sense of purpose and progress at work. The platform which also has an API enables employees to recognize each other by providing a point based bonus system. Bonus.ly helps your employees feel connected, engaged, and aligned is mission critical right now. Bonusly makes employee recognition easy and fun, fostering community and creating company-wide alignment. It also provides employees with positive feedback in the work that they are doing.
Use Cases
-Automate a bonus.ly when an employee completes an incident within the SLA time period.
-Allow for command line bonus.ly recognitions
-Commands for bonuses like create, retrieve, update, delete
Configure Bonusly in Cortex
| Parameter | Description | Required |
|---|---|---|
| url | Server URL (e.g. https://bonus.ly/api/v1/ ) |
True |
| api_key | API Key | True |
| incidentType | Incident type | False |
| insecure | Trust any certificate (not secure) | False |
| proxy | Use system proxy settings | False |
| application_name | Enter the name of the specific bonusly application if required. | False |
| limit | Limit the number of bonuses to fetch (Default 20) | False |
| user_email | Filter to receive only bonuses that match either a giver or receiver with this email. (person@somewhere.com) | False |
| hashtag | Filter based on a hashtag like %23teamwork | False |
| fetch_time | Start fetching from X days ago (defaults to 1 day) | False |
| isFetch | Fetch incidents | False |
Commands
You can execute these commands from the CLI, as part of an automation, or in a playbook.
After you successfully execute a command, a DBot message appears in the War Room with the command details.
bonusly-list-bonuses
Get a list of bonuses based on a filter
Base Command
bonusly-list-bonuses
Input
| Argument Name | Description | Required |
|---|---|---|
| limit | Number of bonuses to retrieve (min: 1, max: 100) Default: 20. | Optional |
| start-time | Example: 2015-10-28T21:26:50Z | Optional |
| end-time | Example: 2015-10-28T21:26:50Z | Optional |
| giver-email | Filter by email address of the person giving the bonusly | Optional |
| receiver-email | Filter by email address of the person receiving the bonusly | Optional |
| user-email | Filter to retrieve bonuses that have either giver or reciever with this email | Optional |
| hashtag | Filter to get a list of bonusers by a hashtag Example: %23teamwork | Optional |
| include-children | Includes any children responses to the bonusly | Optional |
| show-private-bonuses | If Admin API key you can list private bonuses | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| Bonusly.Bonus.id | String | ID of the bonusly bonus and can be used to gather further information on the bonus |
| Bonusly.Bonus.created_at | Date | Date created IE: 2015-10-28T21:26:50Z |
| Bonusly.Bonus.reason | String | Description of bonus given like For signing up for the world’s favorite employee recognition solution! #problem-solving |
| Bonusly.Bonus.reason_html | String | HTML representation of the bonus |
| Bonusly.Bonus.amount | Number | Number amount of the bonus |
| Bonusly.Bonus.amount_with_currency | String | Amount with the points of the bonus |
| Bonusly.Bonus.value | String | A hash tag like #problem-solving |
| Bonusly.Bonus.giver.id | String | ID of the person giving the bonus |
| Bonusly.Bonus.giver.short_name | String | Persons short name who gave the bonus |
| Bonusly.Bonus.giver.display_name | String | Display name for who gave the bonus |
| Bonusly.Bonus.giver.username | String | Username for who gave the bonus |
| Bonusly.Bonus.giver.email | String | Email of the person who gave the bonus |
| Bonusly.Bonus.giver.path | String | URL path for who gave the bonus |
| Bonusly.Bonus.giver.full_pic_url | String | Full picture URL for who gave the bonus |
| Bonusly.Bonus.giver.profile_pic_url | String | Profile Picture of the person who gave the bonus |
| Bonusly.Bonus.giver.first_name | String | First name for the giver of the bonus |
| Bonusly.Bonus.giver.last_name | String | Last name for the giver of the bonus |
| Bonusly.Bonus.giver.last_active_at | Unknown | Last time giver was active when available |
| Bonusly.Bonus.giver.external_unique_id | String | Unique ID for the giver externally |
| Bonusly.Bonus.giver.budget_boost | Number | Whether there is a boost given for the bonus |
| Bonusly.Bonus.giver.user_mode | String | Mode of the giver user |
| Bonusly.Bonus.giver.country | String | Country of where the giver resides |
| Bonusly.Bonus.giver.time_zone | String | Timezone for the giver America/Los_Angeles |
| Bonusly.Bonus.giver.custom_property_name | String | Any custom properties given |
| Bonusly.Bonus.giver.can_give | Number | Whether the giver can give |
| Bonusly.Bonus.giver.earning_balance | Number | Balance earning available |
| Bonusly.Bonus.giver.earning_balance_with_currency | String | Earning balance with currency |
| Bonusly.Bonus.giver.lifetime_earnings | Number | Lifetime earnings of giver overall |
| Bonusly.Bonus.giver.lifetime_earnings_with_currency | String | Lifetime earnings of giver with currency |
| Bonusly.Bonus.giver.can_receive | Number | Wether giver can receive or not |
| Bonusly.Bonus.giver.giving_balance | Number | Number of balance available to give |
| Bonusly.Bonus.giver.giving_balance_with_currency | String | Currency or points of giver balance |
| Bonusly.Bonus.giver.status | String | Status like archived |
| Bonusly.Bonus.receiver | Unknown | Unknown |
| Bonusly.Bonus.child_count | Number | Cound of the child add on bonuses |
| Bonusly.Bonus.via | String | Where the bonus came from like web etc |
| Bonusly.Bonus.family_amount | Number | Amount family has |
Command Example
!bonusly-list-bonuses limit="20"
Context Example
{
"Bonusly": {
"Bonus": [
{
"id": "24abcdef1234567890abcdef",
"created_at": "2015-10-28T21:26:50Z",
"reason": "For signing up for the world's favorite employee recognition solution! #problem-solving",
"reason_html": "For signing up for the world's favorite employee-recognition solution! <a class=\"hashtag\" href=\"http://bonus.ly/company/hashtags/problem-solving\">#problem-solving</a>",
"amount": 50,
"amount_with_currency": "50 points",
"value": "#problem-solving",
"giver": {
"id": "24abcdef1234567890abcdef",
"short_name": "Bill",
"display_name": "Bill",
"username": "blumbergh",
"email": "blumbergh@initech56313d8f1ba2397878000004.com",
"path": "/company/users/56313d971ba23978780000c6",
"full_pic_url": "http://bonus.ly/avatar/blumbergh.png",
"profile_pic_url": "http://bonus.ly/avatar/blumbergh.png",
"first_name": "Bill",
"last_name": "Lumbergh",
"last_active_at": null,
"external_unique_id": "foo",
"budget_boost": 0,
"user_mode": "normal",
"country": "US",
"time_zone": "America/Los_Angeles",
"*custom_property_name*": "*custom_property_value*",
"can_give": true,
"earning_balance": 80,
"earning_balance_with_currency": "80 points",
"lifetime_earnings": 80,
"lifetime_earnings_with_currency": "80 points",
"can_receive": true,
"giving_balance": 42,
"giving_balance_with_currency": "42 points",
"status": "archived"
},
"receiver": null,
"child_count": 42,
"child_bonuses": [
{}
],
"via": "web",
"family_amount": 42
}
]
}
}
Human Readable Output
Latest Updates From Bonus.ly
|amount|amount_with_currency|child_bonuses|created_at|editable_until|family_amount|giver|hashtag|id|parent_bonus_id|reason|reason_decoded|reason_html|receiver|receivers|value|via|
|—|—|—|—|—|—|—|—|—|—|—|—|—|—|—|—|—|
bonusly-create-bonus
Creates a bonusly bonus
Base Command
bonusly-create-bonus
Input
| Argument Name | Description | Required |
|---|---|---|
| giver-email | The email address of the person giving the bonus like myemail@email.com | Required |
| reason | +10 @george and @john for #execution with that customer #collaboration with the team, and #integrity on the known vulnerabilities to the application. +10 @francesco because he is fast and detailed |
Required |
| parent-bonus-id | Allows you to associate to a parent bonus based on what you have created before. Example: 24abcdef1234567890abcdef | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| Bonusly.Bonus.id | String | ID of the bonusly bonus and can be used to gather further information on the bonus |
| Bonusly.Bonus.created_at | Date | Date created IE: 2015-10-28T21:26:50Z |
| Bonusly.Bonus.reason | String | Description of bonus given like For signing up for the world’s favorite employee recognition solution! #problem-solving |
| Bonusly.Bonus.reason_html | String | HTML representation of the bonus |
| Bonusly.Bonus.amount | Number | Number amount of the bonus |
| Bonusly.Bonus.amount_with_currency | String | Amount with the points of the bonus |
| Bonusly.Bonus.value | String | A hash tag like #problem-solving |
| Bonusly.Bonus.giver.id | String | ID of the person giving the bonus |
| Bonusly.Bonus.giver.short_name | String | Persons short name who gave the bonus |
| Bonusly.Bonus.giver.display_name | String | Display name for who gave the bonus |
| Bonusly.Bonus.giver.username | String | Username for who gave the bonus |
| Bonusly.Bonus.giver.email | String | Email of the person who gave the bonus |
| Bonusly.Bonus.giver.path | String | URL path for who gave the bonus |
| Bonusly.Bonus.giver.full_pic_url | String | Full picture URL for who gave the bonus |
| Bonusly.Bonus.giver.profile_pic_url | String | Profile Picture of the person who gave the bonus |
| Bonusly.Bonus.giver.first_name | String | First name for the giver of the bonus |
| Bonusly.Bonus.giver.last_name | String | Last name for the giver of the bonus |
| Bonusly.Bonus.giver.last_active_at | Unknown | Last time giver was active when available |
| Bonusly.Bonus.giver.external_unique_id | String | Unique ID for the giver externally |
| Bonusly.Bonus.giver.budget_boost | Number | Whether there is a boost given for the bonus |
| Bonusly.Bonus.giver.user_mode | String | Mode of the giver user |
| Bonusly.Bonus.giver.country | String | Country of where the giver resides |
| Bonusly.Bonus.giver.time_zone | String | Timezone for the giver America/Los_Angeles |
| Bonusly.Bonus.giver.custom_property_name | String | Any custom properties given |
| Bonusly.Bonus.giver.can_give | Number | Whether the giver can give |
| Bonusly.Bonus.giver.earning_balance | Number | Balance earning available |
| Bonusly.Bonus.giver.earning_balance_with_currency | String | Earning balance with currency |
| Bonusly.Bonus.giver.lifetime_earnings | Number | Lifetime earnings of giver overall |
| Bonusly.Bonus.giver.lifetime_earnings_with_currency | String | Lifetime earnings of giver with currency |
| Bonusly.Bonus.giver.can_receive | Number | Wether giver can receive or not |
| Bonusly.Bonus.giver.giving_balance | Number | Number of balance available to give |
| Bonusly.Bonus.giver.giving_balance_with_currency | String | Currency or points of giver balance |
| Bonusly.Bonus.giver.status | String | Status like archived |
| Bonusly.Bonus.receiver | Unknown | Unknown |
| Bonusly.Bonus.child_count | Number | Cound of the child add on bonuses |
| Bonusly.Bonus.via | String | Where the bonus came from like web etc |
| Bonusly.Bonus.family_amount | Number | Amount family has |
Command Example
bonusly-get-bonus id="5ec263bb0e519c009a1ec0db"
Human Readable Output
bonusly-get-bonus
Get a bonusly based on an ID
Base Command
bonusly-get-bonus
Input
| Argument Name | Description | Required |
|---|---|---|
| id | Id of bonus that you want to fetch | Required |
Context Output
| Path | Type | Description |
|---|---|---|
| Bonusly.Bonus.id | String | ID of the bonusly bonus and can be used to gather further information on the bonus |
| Bonusly.Bonus.created_at | Date | Date created IE: 2015-10-28T21:26:50Z |
| Bonusly.Bonus.reason | String | Description of bonus given like For signing up for the world’s favorite employee recognition solution! #problem-solving |
| Bonusly.Bonus.reason_html | String | HTML representation of the bonus |
| Bonusly.Bonus.amount | Number | Number amount of the bonus |
| Bonusly.Bonus.amount_with_currency | String | Amount with the points of the bonus |
| Bonusly.Bonus.value | String | A hash tag like #problem-solving |
| Bonusly.Bonus.giver.id | String | ID of the person giving the bonus |
| Bonusly.Bonus.giver.short_name | String | Persons short name who gave the bonus |
| Bonusly.Bonus.giver.display_name | String | Display name for who gave the bonus |
| Bonusly.Bonus.giver.username | String | Username for who gave the bonus |
| Bonusly.Bonus.giver.email | String | Email of the person who gave the bonus |
| Bonusly.Bonus.giver.path | String | URL path for who gave the bonus |
| Bonusly.Bonus.giver.full_pic_url | String | Full picture URL for who gave the bonus |
| Bonusly.Bonus.giver.profile_pic_url | String | Profile Picture of the person who gave the bonus |
| Bonusly.Bonus.giver.first_name | String | First name for the giver of the bonus |
| Bonusly.Bonus.giver.last_name | String | Last name for the giver of the bonus |
| Bonusly.Bonus.giver.last_active_at | Unknown | Last time giver was active when available |
| Bonusly.Bonus.giver.external_unique_id | String | Unique ID for the giver externally |
| Bonusly.Bonus.giver.budget_boost | Number | Whether there is a boost given for the bonus |
| Bonusly.Bonus.giver.user_mode | String | Mode of the giver user |
| Bonusly.Bonus.giver.country | String | Country of where the giver resides |
| Bonusly.Bonus.giver.time_zone | String | Timezone for the giver America/Los_Angeles |
| Bonusly.Bonus.giver.custom_property_name | String | Any custom properties given |
| Bonusly.Bonus.giver.can_give | Number | Whether the giver can give |
| Bonusly.Bonus.giver.earning_balance | Number | Balance earning available |
| Bonusly.Bonus.giver.earning_balance_with_currency | String | Earning balance with currency |
| Bonusly.Bonus.giver.lifetime_earnings | Number | Lifetime earnings of giver overall |
| Bonusly.Bonus.giver.lifetime_earnings_with_currency | String | Lifetime earnings of giver with currency |
| Bonusly.Bonus.giver.can_receive | Number | Wether giver can receive or not |
| Bonusly.Bonus.giver.giving_balance | Number | Number of balance available to give |
| Bonusly.Bonus.giver.giving_balance_with_currency | String | Currency or points of giver balance |
| Bonusly.Bonus.giver.status | String | Status like archived |
| Bonusly.Bonus.receiver | Unknown | Unknown |
| Bonusly.Bonus.child_count | Number | Cound of the child add on bonuses |
| Bonusly.Bonus.via | String | Where the bonus came from like web etc |
| Bonusly.Bonus.family_amount | Number | Amount family has |
Command Example
!bonusly-get-bonus id="24abcdef1234567890abcdef"
Context Example
{
"Bonusly": {
"Bonus": {
"id": "24abcdef1234567890abcdef",
"created_at": "2015-10-28T21:26:50Z",
"reason": "For signing up for the world's favorite employee recognition solution! #problem-solving",
"reason_html": "For signing up for the world's favorite employee recognition solution! <a class=\"hashtag\" href=\"http://bonus.ly/company/hashtags/problem-solving\">#problem-solving</a>",
"amount": 50,
"amount_with_currency": "50 points",
"value": "#problem-solving",
"giver": {
"id": "24abcdef1234567890abcdef",
"short_name": "Bill",
"display_name": "Bill",
"username": "blumbergh",
"email": "blumbergh@initech56313d8f1ba2397878000004.com",
"path": "/company/users/56313d971ba23978780000c6",
"full_pic_url": "http://bonus.ly/avatar/blumbergh.png",
"profile_pic_url": "http://bonus.ly/avatar/blumbergh.png",
"first_name": "Bill",
"last_name": "Lumbergh",
"last_active_at": null,
"external_unique_id": "foo",
"budget_boost": 0,
"user_mode": "normal",
"country": "US",
"time_zone": "America/Los_Angeles",
"*custom_property_name*": "*custom_property_value*",
"can_give": true,
"earning_balance": 80,
"earning_balance_with_currency": "80 points",
"lifetime_earnings": 80,
"lifetime_earnings_with_currency": "80 points",
"can_receive": true,
"giving_balance": 42,
"giving_balance_with_currency": "42 points",
"status": "archived"
},
"receiver": null,
"child_count": 42,
"child_bonuses": [
{}
],
"via": "web",
"family_amount": 42
}
}
}
Human Readable Output
Latest Updates From Bonus.ly
|amount|amount_with_currency|child_count|created_at|editable_until|family_amount|giver|hashtag|id|parent_bonus_id|reason|reason_decoded|reason_html|receiver|receivers|value|via|
|—|—|—|—|—|—|—|—|—|—|—|—|—|—|—|—|—|
|—|—|—|—|—|—|—|—|—|—|—|—|—|—|—|—|—|
bonusly-update-bonus
Update a bonus to bonusly
Base Command
bonusly-update-bonus
Input
| Argument Name | Description | Required |
|---|---|---|
| id | Id to update | Required |
| reason | Example +10 @francesco @bumblebee for #integrity #collaboration #execution | Required |
Context Output
| Path | Type | Description |
|---|---|---|
| Bonusly.Bonus.id | String | ID of the bonusly bonus and can be used to gather further information on the bonus |
| Bonusly.Bonus.created_at | Date | Date created IE: 2015-10-28T21:26:50Z |
| Bonusly.Bonus.reason | String | Description of bonus given like For signing up for the world’s favorite employee recognition solution! #problem-solving |
| Bonusly.Bonus.reason_html | String | HTML representation of the bonus |
| Bonusly.Bonus.amount | Number | Number amount of the bonus |
| Bonusly.Bonus.amount_with_currency | String | Amount with the points of the bonus |
| Bonusly.Bonus.value | String | A hash tag like #problem-solving |
| Bonusly.Bonus.giver.id | String | ID of the person giving the bonus |
| Bonusly.Bonus.giver.short_name | String | Persons short name who gave the bonus |
| Bonusly.Bonus.giver.display_name | String | Display name for who gave the bonus |
| Bonusly.Bonus.giver.username | String | Username for who gave the bonus |
| Bonusly.Bonus.giver.email | String | Email of the person who gave the bonus |
| Bonusly.Bonus.giver.path | String | URL path for who gave the bonus |
| Bonusly.Bonus.giver.full_pic_url | String | Full picture URL for who gave the bonus |
| Bonusly.Bonus.giver.profile_pic_url | String | Profile Picture of the person who gave the bonus |
| Bonusly.Bonus.giver.first_name | String | First name for the giver of the bonus |
| Bonusly.Bonus.giver.last_name | String | Last name for the giver of the bonus |
| Bonusly.Bonus.giver.last_active_at | Unknown | Last time giver was active when available |
| Bonusly.Bonus.giver.external_unique_id | String | Unique ID for the giver externally |
| Bonusly.Bonus.giver.budget_boost | Number | Whether there is a boost given for the bonus |
| Bonusly.Bonus.giver.user_mode | String | Mode of the giver user |
| Bonusly.Bonus.giver.country | String | Country of where the giver resides |
| Bonusly.Bonus.giver.time_zone | String | Timezone for the giver America/Los_Angeles |
| Bonusly.Bonus.giver.custom_property_name | String | Any custom properties given |
| Bonusly.Bonus.giver.can_give | Number | Whether the giver can give |
| Bonusly.Bonus.giver.earning_balance | Number | Balance earning available |
| Bonusly.Bonus.giver.earning_balance_with_currency | String | Earning balance with currency |
| Bonusly.Bonus.giver.lifetime_earnings | Number | Lifetime earnings of giver overall |
| Bonusly.Bonus.giver.lifetime_earnings_with_currency | String | Lifetime earnings of giver with currency |
| Bonusly.Bonus.giver.can_receive | Number | Wether giver can receive or not |
| Bonusly.Bonus.giver.giving_balance | Number | Number of balance available to give |
| Bonusly.Bonus.giver.giving_balance_with_currency | String | Currency or points of giver balance |
| Bonusly.Bonus.giver.status | String | Status like archived |
| Bonusly.Bonus.receiver | Unknown | Unknown |
| Bonusly.Bonus.child_count | Number | Cound of the child add on bonuses |
| Bonusly.Bonus.via | String | Where the bonus came from like web etc |
| Bonusly.Bonus.family_amount | Number | Amount family has |
Command Example
!bonusly-update-bonus id="5ec279591160850099b1ae3c" reason="Removing old archive"
Human Readable Output
|amount|amount_with_currency|child_count|created_at|editable_until|family_amount|giver|hashtag|id|parent_bonus_id|reason|reason_decoded|reason_html|receiver|receivers|value|via|
|—|—|—|—|—|—|—|—|—|—|—|—|—|—|—|—|—|
|—|—|—|—|—|—|—|—|—|—|—|—|—|—|—|—|—|
Context Example
{
"Bonusly": {
"Bonus": {
"id": "24abcdef1234567890abcdef",
"created_at": "2015-10-28T21:26:50Z",
"reason": "For signing up for the world's favorite employee recognition solution! #problem-solving",
"reason_html": "For signing up for the world's favorite employee recognition solution! <a class=\"hashtag\" href=\"http://bonus.ly/company/hashtags/problem-solving\">#problem-solving</a>",
"amount": 50,
"amount_with_currency": "50 points",
"value": "#problem-solving",
"giver": {
"id": "24abcdef1234567890abcdef",
"short_name": "Bill",
"display_name": "Bill",
"username": "blumbergh",
"email": "blumbergh@initech56313d8f1ba2397878000004.com",
"path": "/company/users/56313d971ba23978780000c6",
"full_pic_url": "http://bonus.ly/avatar/blumbergh.png",
"profile_pic_url": "http://bonus.ly/avatar/blumbergh.png",
"first_name": "Bill",
"last_name": "Lumbergh",
"last_active_at": null,
"external_unique_id": "foo",
"budget_boost": 0,
"user_mode": "normal",
"country": "US",
"time_zone": "America/Los_Angeles",
"*custom_property_name*": "*custom_property_value*",
"can_give": true,
"earning_balance": 80,
"earning_balance_with_currency": "80 points",
"lifetime_earnings": 80,
"lifetime_earnings_with_currency": "80 points",
"can_receive": true,
"giving_balance": 42,
"giving_balance_with_currency": "42 points",
"status": "archived"
},
"receiver": null,
"child_count": 42,
"child_bonuses": [
{}
],
"via": "web",
"family_amount": 42
}
}
}
bonusly-delete-bonus
Delete a bonus based on an ID like 24abcdef1234567890abcdef
Base Command
bonusly-delete-bonus
Input
| Argument Name | Description | Required |
|---|---|---|
| id | Delete a bonus based on an ID like 24abcdef1234567890abcdef | Required |
Context Output
| Path | Type | Description |
|---|---|---|
| Bonusly.Bonus.message | Unknown | Message of result if deleted successfully |
Command Example
!bonusly-delete-bonus id="5ec279591160850099b1ae3c"
Human Readable Output
Latest Updates From Bonus.ly
No entries.
Context Example
{
"Bonusly": {
"Bonus": {
"message": "No entries"
}
}
}
=======
Bonusly
Bonus.ly is an employee recognition platform which enterprises use to for employee recognition. We’re building tools to help people feel a sense of purpose and progress at work. The platform which also has an API enables employees to recognize each other by providing a point based bonus system. Bonus.ly helps your employees feel connected, engaged, and aligned is mission critical right now. Bonusly makes employee recognition easy and fun, fostering community and creating company-wide alignment. It also provides employees with positive feedback in the work that they are doing.
Configuration parameters
url— Server URL (e.g. https://bonus.ly/api/v1/) (required)api_key— API Key (required)incidentType— Incident typeincidentFetchInterval— Incidents Fetch Intervalinsecure— Trust any certificate (not secure)proxy— Use system proxy settingsapplication_name— Name of the specific Bonusly application (if required)limit— Max. number of bonuses to fetch (Default is 20)user_email— Filter by user email address (given and received)hashtag— Filter by hashtag (e.g., %23teamwork)fetch_time— Start fetching from X days ago (Defaults is 1 day)isFetch— Fetch incidents
Commands (5)
-
bonusly-create-bonusCreates a Bonusly bonus.
-
bonusly-delete-bonusDeletes a bonus by bonus ID.
-
bonusly-get-bonusGets a bonus by bonus ID.
-
bonusly-list-bonusesGets a list of bonuses based on the supplied filters.
-
bonusly-update-bonusUpdates a bonus.
import demistomock as demisto # noqa: F401 from CommonServerPython import * # noqa: F401 """Bonusly Integration for Cortex XSOAR (aka DBot) This integration only has a few commands and more maybe added depending on feedback. """ import json import dateparser import urllib3 from CommonServerUserPython import * # noqa: E402 lgtm [py/polluting-import] # IMPORTS # Disable insecure warnings urllib3.disable_warnings() # CONSTANTS DATE_FORMAT = "%Y-%m-%dT%H:%M:%SZ" # Client Class class Client(BaseClient): """ This is the base client used for Bonusly http requests """ def bonusly_test(self): suffix = "bonuses" return self._http_request("GET", suffix) def bonusly_list_bonuses_http_request(self, url_params) -> dict: """ Gets a list of bonusly bonuses Args: limit=20 - defaults to 20 skip=0 - skip start_time=%Y-%m-%dT%H:%M:%SZ - end_time=%Y-%m-%dT%H:%M:%SZ giver_email=person@company.com - giver email address receiver_email=otherperson@company.com - receiver email address user_email=someperson@company.com - user email address hashtag=%23#collaboration - hashtag to filter on include_children=false - include children responses custom_property_name='somename' - filter on some customer property show_private_bonuses=false - show private bonuses if admin API key """ suffix = "bonuses" params = url_params params["limit"] = url_params.get("limit", 20) params["skip"] = 0 an_hour_ago_date = dateparser.parse("1 hour ago") assert an_hour_ago_date is not None start_time = an_hour_ago_date.strftime(DATE_FORMAT) now_date = datetime.utcnow() assert now_date is not None end_time = now_date.strftime(DATE_FORMAT) if url_params.get("start_time") is not None: start_time_date = dateparser.parse(url_params["start_time"]) assert start_time_date is not None, f'failed parsing {url_params["start_time"]}' start_time = start_time_date.strftime(DATE_FORMAT) if url_params.get("end_time") is not None: end_time_date = dateparser.parse(url_params["end_time"]) assert end_time_date is not None end_time = end_time_date.strftime(DATE_FORMAT) params["start_time"] = start_time params["end_time"] = end_time params["giver_email"] = url_params.get("giver_email", "") params["receiver_email"] = url_params.get("receiver_email", "") params["user_email"] = url_params.get("user_email", "") params["include_children"] = url_params.get("include_children", "false") params["show_private_bonuses"] = url_params.get("show_private_bonuses", "false") resp = self._http_request("GET", suffix, params=params) return resp def bonusly_get_bonus_http_request(self, url_params) -> dict: """ Get a bonusly based on an ID Args: id - id of bonusly bonus to fetch """ id = url_params["id"] result = self._http_request(method="GET", url_suffix="/bonuses/" + id) return result def bonusly_create_bonus_http_request(self, url_params) -> dict: """ Creates a bonusly using a giver_email and a reason Args: giver_email - person@company.com reason - they did a great job with #integrity """ values = {"giver_email": url_params.get("giver_email"), "reason": url_params.get("reason")} valstring = json.dumps(values) return self._http_request(method="POST", url_suffix="bonuses", data=valstring) def bonusly_update_bonus_http_request(self, url_params) -> dict: """ Updates a bonusly using Args: id - id of bonusly to update reason - reason for bonusly """ values = {"reason": url_params["reason"]} valstring = json.dumps(values) id = url_params.get("id") result = self._http_request(method="PUT", url_suffix="/bonuses/" + id, data=valstring) return result def bonusly_delete_bonus_http_request(self, url_params) -> dict: """ Deletes a bonusly Args: id - of bonusly bonus """ id = url_params["id"] result = self._http_request(method="DELETE", url_suffix="/bonuses/" + id) return result def list_incidents(self, last_fetch_date, fetch_params): """ returns an array of JSON bonuses """ url_params = {} url_params["application_name"] = fetch_params.get("application_name", None) url_params["limit"] = fetch_params.get("limit") url_params["user_email"] = fetch_params.get("user_email") url_params["hashtag"] = fetch_params.get("hashtag") url_params["start_date"] = last_fetch_date demisto.debug("URL Params being called is " + str(url_params)) resp = self.bonusly_list_bonuses_http_request(url_params) return resp.get("result", []) def test_module(client): """ Returns: 'ok' if test passed, anything else will fail the test. """ result = client.bonusly_test() if result.get("success"): return "ok" else: return "Test failed Message:" + json.dumps(result) def bonusly_list_bonuses_command(client, args): """ Returns: list of bonuses based on the bonusly_list_bonuses_http_request """ resp = client.bonusly_list_bonuses_http_request(args) result = resp.get("result") readable_output = tableToMarkdown("Latest Updates From Bonus.ly", result) outputs = {"Bonusly.Bonus": result} return ( readable_output, outputs, resp, # raw response - the original response ) def bonusly_get_bonus_command(client, args): resp = client.bonusly_get_bonus_http_request(args) result = resp.get("result") readable_output = tableToMarkdown("Latest Updates From Bonus.ly", result) outputs = {"Bonusly.Bonus": result} return ( readable_output, outputs, resp, # raw response - the original response ) def bonusly_create_bonus_command(client, args): resp = client.bonusly_create_bonus_http_request(args) result = resp.get("result") readable_output = tableToMarkdown("Latest Updates From Bonus.ly", result) outputs = {"Bonusly.Bonus": result} return ( readable_output, outputs, resp, # raw response - the original response ) def bonusly_update_bonus_command(client, args): resp = client.bonusly_update_bonus_http_request(args) result = resp.get("result") readable_output = tableToMarkdown("Message Deleted From Bonus.ly", result) outputs = {"Bonusly.Bonus": result} return ( readable_output, outputs, resp, # raw response - the original response ) def bonusly_delete_bonus_command(client, args): resp = client.bonusly_delete_bonus_http_request(args) result_text = resp.get("message") res_message = [] res_message_table = {"Message": result_text} res_message.append(res_message_table) readable_output = tableToMarkdown("Latest Updates From Bonus.ly", res_message_table) outputs = {"Bonusly.Bonus.message": result_text} return ( readable_output, outputs, resp, # raw response - the original response ) def fetch_incidents(client, last_run, first_fetch_time, fetch_params): """ This function will execute each interval (default is 1 minute). Args: client (Client): client last_run (dateparser.time): The greatest incident created_time we fetched from last fetch first_fetch_time (dateparser.time): If last_run is None then fetch all incidents since first_fetch_time Returns: next_run: This will be last_run in the next fetch-incidents incidents: Incidents that will be created in Demisto :param fetch_params params from integration settings """ # Get the last fetch time, if exists last_fetch = last_run.get("last_fetch") # Handle first time fetch if last_fetch is None: last_fetch = dateparser.parse(first_fetch_time) else: last_fetch = dateparser.parse(last_fetch) latest_created_time = last_fetch incidents = [] last_fetch_date = last_fetch.strftime("%Y-%m-%dT%H:%M:%SZ") items = client.list_incidents(last_fetch_date=last_fetch_date, fetch_params=fetch_params) for item in items: incident_created_time = dateparser.parse(item["created_at"]) assert incident_created_time is not None, f'failed parsing {item["created_at"]}' incident = { "name": "New Bonusly - " + item["reason"], "occurred": incident_created_time.strftime(DATE_FORMAT), "type": fetch_params.get("incidentType"), "rawJSON": json.dumps(item), } # If created time is greater than latest created time then set latest created time # to incident created time if incident_created_time.timestamp() > latest_created_time.timestamp(): latest_created_time = incident_created_time # if the last time fetched is before the current incident time then add it to the list of incidents if last_fetch.timestamp() < incident_created_time.timestamp(): incidents.append(incident) next_run = {"last_fetch": latest_created_time.strftime(DATE_FORMAT)} return next_run, incidents def main(): """ PARSE AND VALIDATE INTEGRATION PARAMS """ # set default params params = demisto.params() base_url = params.get("url") api_key = params.get("api_key") # is_fetch = params.get('isFetch') # inc_type = params.get('incidentType') verify_certificate = not params.get("insecure", False) # Fetch Params proxy = params.get("proxy", False) # get the service API url # base_url = urljoin(demisto.params()['url'], '/api/v1/suffix') # How much time before the first fetch to retrieve incidents first_fetch_time = demisto.params().get("fetch_time", "1 day").strip() LOG(f"Command being called is {demisto.command()}") try: bearer_token = "Bearer " + api_key client = Client( base_url=base_url, verify=verify_certificate, headers={"Authorization": bearer_token, "Content-Type": "application/json"}, proxy=proxy, ) if demisto.command() == "test-module": # This is the call made when pressing the integration Test button. result = test_module(client) demisto.results(result) elif demisto.command() == "fetch-incidents": # Set and define the fetch incidents command to run after activated via integration settings. next_run, incidents = fetch_incidents( client=client, last_run=demisto.getLastRun(), first_fetch_time=first_fetch_time, fetch_params=params ) demisto.setLastRun(next_run) demisto.incidents(incidents) elif demisto.command() == "bonusly-list-bonuses": return_outputs(*bonusly_list_bonuses_command(client, demisto.args())) elif demisto.command() == "bonusly-get-bonus": return_outputs(*bonusly_get_bonus_command(client, demisto.args())) elif demisto.command() == "bonusly-create-bonus": return_outputs(*bonusly_create_bonus_command(client, demisto.args())) elif demisto.command() == "bonusly-update-bonus": return_outputs(*bonusly_update_bonus_command(client, demisto.args())) elif demisto.command() == "bonusly-delete-bonus": return_outputs(*bonusly_delete_bonus_command(client, demisto.args())) # Log exceptions except Exception as e: if "Error in API call [404]" in str(e): return_error(f"Failed to execute {demisto.command()} command. Error: 404 Error URL Not Found Or Invalid") return_error(f"Failed to execute {demisto.command()} command. Error: {e!s}") if __name__ in ("__main__", "__builtin__", "builtins"): main()