Skip to content

Switcher Slash Webhook is a simple API wrapper written in Ruby using Sinatra

License

Notifications You must be signed in to change notification settings

switcherapi/switcher-slash-webhook

Repository files navigation


Switcher Slash Webhook
A Slash Add-on App for Slack

Master CI Coverage Status License: MIT Slack: Switcher-HQ


Switcher API: Cloud-based Feature Flag API

Requirements

  • Ruby (Sinatra) 1.3 (Release 2.2.x)
  • Slash add-on for Slack
  • Coffee =D

About

Switcher Slash Webhook is a API wrapper used to check both Switcher Load Balance and Switcher API from the Slack app using Slash Command add-on.

Installing/Running

Setup the environment

Changes on config/development.yaml file.

slack_hook_endpoint: [SLACK_HOOK_URL]
slack_hook_token: [SLACK_API_KEY]
switcher_load_balance: https://switcher-load-balance.herokuapp.com
switcher_api_key: [SWITCHER_COMPONENT_KEY]
switcher_api_domain: [SWITCHER_DOMAIN_NAME]

Running

bundle install rackup -p 4567

Testing

rspec


Usage

Request - status (GET)

{{url}}/cmd?token=SLASH_CMD_TOKEN&text=status

Response

{
    "blocks": [
        {
            "type": "section",
            "text": {
                "type": "mrkdwn",
                "text": "Switcher Load Balance\n\n*Message:* All good\n*Code:* 200\n"
            },
            "accessory": {
                "type": "image",
                "image_url": "https://raw.githubusercontent.com/s/switcherapi-assets/master/logo/switcher_mark_grey.png",
                "alt_text": "Switcher API"
            }
        },
        {
            "type": "divider"
        },
        {
            "type": "section",
            "text": {
                "type": "mrkdwn",
                "text": "*Node:* SNODE1 :sunny:\n*Endpoint:* https://switcher-api.herokuapp.com\n*Status:* online"
            }
        }
    ]
}

Sample: status cmd

Request - check API (GET)

{{url}}/cmd?token=SLASH_CMD_TOKEN&text=check-prd+FEATURE01+-v+Roger

Response

{
    "blocks": [
        {
            "type": "section",
            "text": {
                "type": "mrkdwn",
                "text": "Switcher API\n\n*Result:* Passed\n*Reason:* Success\n"
            },
            "accessory": {
                "type": "image",
                "image_url": "https://raw.githubusercontent.com/switcherapi/switcherapi-assets/master/logo/switcher_mark_grey.png",
                "alt_text": "Switcher API"
            }
        },
        {
            "type": "divider"
        },
        {
            "type": "section",
            "text": {
                "type": "mrkdwn",
                "text": "*Command:* /cmd check-prd FEATURE01 -v Roger"
            }
        }
    ]
}

Sample: check API cmd

Contributing

Please do open an issue or PR if you feel you have something cool to add.

About

Switcher Slash Webhook is a simple API wrapper written in Ruby using Sinatra

Resources

License

Code of conduct

Stars

Watchers

Forks

Languages