ServiceNowDevProgram / Points-Thing

The official application repository for the bot @Points-Thing on the sndevs.com workspace.
https://github.com/ServiceNowDevProgram/Hacktoberfest
4 stars 30 forks source link

Add support for API Points #41

Closed SapphicFire closed 10 months ago

SapphicFire commented 10 months ago

This PR implements support for API points with a Scripted REST API. This API is bound to a specific role ACL, and allows invocation with varying payloads. This resolves #2.

Invocation

The SR API endpoint is /api/x_snc_pointsthing/points_thing/api_point and this accepts a POST with Content-Type application/json. The payload is formatted as follows:

{
    "reason": "Testing",
    "target": "U0K4BD8DC",
    "targetType": "slack_id",
    "points": 2,
    "sender": "Slacker"
}

Payload notes

Sample Call

POST /api/x_snc_pointsthing/points_thing/api_point HTTP/1.1 Content-Type: application/json Host: instance.service-now.com

{ "reason": "Testing", "target": "U0K4BD8DC", "targetType": "slack_id", "points":2 }

Notes

I also added a Points field to the API Points table, tweaked the lists slightly, and extended the PointsThing SI for API-specific methods/behaviour. Because of who I am I also added a semicolon on a line in PointsThing because the linter warning bothered me.