Giter Club home page Giter Club logo

myshift2teams's Introduction

myshift2teams

Simple API service for organization of shifts

What?

This is a minimal app sending messages about shifts in a organization to MS Teams. You can send a json to the myshift endpoint with a list of people and it will store the configuration and the initial shift in a Redis database. Then you can update the shift or send a shift reminder to a MS Teams channel.

How to build it?

You will need a D compiler installed (DMD/ldc/...), a C compiler and the DUB package manager. You also will need the sources of phobos library, zlib and openssl lib.

With all these elements, you only need to run dub install in this directory.

Alternatively, there is a Dockerfile that you can use to build a container.

How to run it?

In order to run myshift2teams, you must have installed zlib, openssl library and phobos. And, you'll need a running Redis database where the configuration and shifts will be stored.

Then you can execute the binary:

$ ./myshift2teams 
[main(----) INF] Listening for requests on http://127.0.0.1:9000

By default, the service will listen at 127.0.0.1:9000 but you can override this value exporting MYSHIFT_HOST and MYSHIFT_PORT environment variables. Also you can override the default redis address (127.0.0.1:6379) exporting REDIS_HOST and REDIS_PORT environment variables.

You also can use the Docker image, vg.:

$ docker pull frantsao/myshift2teams:latest
$ docker run -p 9000:9000 -e MYSHIFT_HOST=0.0.0.0 frantsao/myshift2teams:latest

Then you can send a POST to /api/myshift path with a json payload like data.json. With this configuration example, the hook will be sent to a test endpoint in the same myshift service; you must change the notificationUrl with the webhook url you created in your MS Teams channel:

$ http POST 127.0.0.1:9000/api/myshift < data.json 
HTTP/1.1 200 OK
Content-Length: 54
Content-Type: application/json
Date: Tue, 24 May 2022 20:22:12 GMT
Keep-Alive: timeout=10
Server: vibe.d/1.16.0

{
    "OK": "Created/updated configuration"
}

The initial config sets the shift to the first name of the list (that is the number 0). You can set that variable to a different number:

$ http "127.0.0.1:9000/api/setmyshift?shift=4"
HTTP/1.1 200 OK
Content-Length: 16
Content-Type: application/json; charset=UTF-8
Date: Tue, 24 May 2022 20:24:02 GMT
Keep-Alive: timeout=10
Server: vibe.d/1.22.3

"Set shift to 4"

Or you simply need to move along the list:

$ http 127.0.0.1:9000/api/updatemyshift
HTTP/1.1 200 OK
Content-Length: 16
Content-Type: application/json; charset=UTF-8
Date: Tue, 24 May 2022 20:26:36 GMT
Keep-Alive: timeout=10
Server: vibe.d/1.22.3

"Set shift to 5"

Then you will send the shift reminder:

$ http 127.0.0.1:9000/api/sendmyshift
HTTP/1.1 200 OK
Content-Length: 24
Content-Type: application/json; charset=UTF-8
Date: Tue, 24 May 2022 20:29:11 GMT
Keep-Alive: timeout=10
Server: vibe.d/1.22.3

"Sent shift reminder to: Sergio"

You always can check the current state of shifts:

$ http 127.0.0.1:9000/api/myshift
HTTP/1.1 200 OK
Content-Length: 97
Content-Type: application/json; charset=UTF-8
Date: Mon, 30 May 2022 22:54:06 GMT
Keep-Alive: timeout=10
Server: vibe.d/1.22.3

{
    "Current shift for": "Álex",
    "Team": "[Jaime, Fran, Álex, Marcos, Marcelo, Sergio, Santi, Omar]"
}

I sent the example requests using the wonderful HTTPie (but you can use cURL or whatever).

Why?

This is a minimal evolution of my first experiment with Dlang that solves a need we had in my team at idealista.

How?

This has been my documentation:

Status

Functional :-)

Built With

DMD DUB vibe.d tinyredis

About

AGPLv3

This work is under AGPLv3 license (see see the LICENSE file).

myshift2teams's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.