Code Monkey home page Code Monkey logo

opener's Introduction

Opener

Opener is opener for remote unlock doors, base on HTTP protocol.

Installation

Clone Opener

git clone https://github.com/SbWereWolf/opener.git

Setup SQLite database

cd path/to/opener
md configuration

Setup SQLite database into configuration/ catalog with filename 'latch.sqlite'

Setup dependencies

cd path/to/opener
composer install

Setup web public access for opener

Setup web server with virtual host for Opener

Set Directory root to path/to/opener/api

Setup .htaccess

Configure necessary .htaccess into path/to/opener/api

Setup Opener service

For create database tables and fill it with data use :

POST "web/public/path/to/opener/storage/install/"

For drop data use :

DELETE "web/public/path/to/opener/storage/dismount/"

Enjoy!

Using with Swagger

Swagger Php

Clone Swagger Php

git clone https://github.com/zircote/swagger-php.git

Generate documentation (specification) in swagger format

php path/to/swagger-php/bin/swagger -o path/to/opener/api path/to/opener/src

Swagger UI

Clone Swagger UI

git clone https://github.com/swagger-api/swagger-ui.git

Copy Swagger UI to opener web public catalog

cd path/to/swagger-ui
xcopy /y dist/ path/to/opener/api

Option step:

Change specification source

notepad|nano  path/to/opener/api/dist/index.html

looking for text:

    window.onload = function() {
      // Begin Swagger UI call region
      const ui = SwaggerUIBundle({
        url: "https://petstore.swagger.io/v2/swagger.json",

Change url parameter to web/public/path/to/opener/api/swagger.json

Run Swagger

Open with browser the address 'web/public/path/to/opener/api/dist'

If necessary, then input into text field web/public/path/to/opener/swagger.json , press 'Explore'

Enjoy!

Example of use

View free room for lease

Request :
GET "http://local.opener/lease/actual/"

Response :
Body :
[
  {
    "finish": 0,
    "shutter-id": 1,
    "start": 0
  },
  {
    "finish": 0,
    "shutter-id": 2,
    "start": 0
  }
]

Register at Opener service

Request :
POST "http://local.opener/user/"
body:
{
  "email": "[email protected]",
  "password": "123456"
}
Response :
Code: 201

Login into Opener service

Request :
POST "http://local.opener/user/login/"
Body:
{
  "email": "[email protected]",
  "password": "123456"
}

Response :
Code : 201
Body :
Response body
Download
[
  {
    "finish": 0,
    "token": "laraseb28j489f2jrhslodmtu8"
  }
]

Take a lease

Request :
POST "http://local.opener/lease/"
Body :
{
  "token": "laraseb28j489f2jrhslodmtu8",
  "user-id": 0,
  "shutter-id": 1,
  "start": 0,
  "finish": 0,
  "occupancy-type-id": 0
}

Response :
Code : 201
Body :
[]

View available lease

Request :
GET "http://local.opener/lease/current/laraseb28j489f2jrhslodmtu8/"

Response :
Code : 200
Body :
[
  {
    "shutter-id": 0,
    "lease-id": 6,
    "start": 1549120412,
    "finish": 1549122212
  }
]

Unlock a door

Request :
POST "http://local.opener/unlock/"
Body :
{
  "token": "laraseb28j489f2jrhslodmtu8",
  "lease-id": 6
}

Response :
Code : 201

Request unlock of the latch-device

Request :
GET "http://local.opener/unlock/tam-tam-gde-gde/"

Response :
Code : 200

Report successful opening of the latch

Request :
DELETE "http://local.opener/unlock/tam-tam-gde-gde/"

Response :
Code : 204

Logout of Opener service

Request :
DELETE "http://local.opener/session/laraseb28j489f2jrhslodmtu8/"

Response :
Code : 204

Option to update lease at will

Request :
PUT "http://local.opener/lease/"
Body :
{
  "id": 1,
  "user-id": 1,
  "shutter-id": 2,
  "start": 1546889999,
  "finish": 1647600000,
  "occupancy-type-id": 2
}

Response :
Code : 200

opener's People

Contributors

sbwerewolf avatar

Watchers

 avatar  avatar  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.