/tractian-api

Assets management API made easy for any company that needs top level maintenance as fast as it can be.

Primary LanguageTypeScript

Project logo

Tractian Management Api

Status GitHub Issues GitHub Pull Requests


Assets management API made easy for any company that needs top level maintanance as fast as it can be.

📝 Table of Contents

🧐 About

Api for assets management, where a user, as a part of a company, can add, update, check and delete assets and it's data.

🏁 Getting Started

This API data is deployed on heroku, and you should be able to access all the endpoints and data on the link below:


Heroku deploy:
https://tractian-api-db.herokuapp.com/

🟢 Endpoints

Companies


POST /companies

Create a new company

  • Body:

    {
      "name": "string",
      "cnpj": "string"
    }
  • Requirements :

    {
      "name": "required",
      "cnpj": "required, 14 numeric characters only"
    }

GET by CNPJ /companies/:cnpj

Get a registered company data by it's CNPJ

  • Params:

    {
      "cnpj": "string"
    }
  • Requirements :

    {
      "cnpj": "required, 14 numeric characters only"
    }

Users


POST /users

Create a new user

  • Body:

    {
      "name": "string",
      "cpf": "string",
      "phoneNumber": "string",
      "role": "string",
      "companyId": "string"
    }
  • Requirements :

    {
      "name": "required",
      "cpf": "required, 11 numeric characters only",
      "phoneNumber": "required, 11 numeric characters only",
      "role": "required",
      "companyId": "required, must be a valid company id"
    }

GET by CPF /users/:cpf

Get a registered user data by it's CPF

  • Params:

    {
      "cpf": "string"
    }
  • Requirements :

    {
      "cpf": "required, 11 numeric characters only"
    }

GET Company by user CPF /users/:cpf/company

Get a registered company data by it's user's CPF

  • Params:

    {
      "cpf": "string"
    }
  • Requirements :

    {
      "cpf": "required, 11 numeric characters only"
    }

PUT Update user data /users/:cpf

Update a registered user data by it's CPF

  • Params:

    {
      "cpf": "string"
    }
  • Requirements :

    {
      "cpf": "required, 11 numeric characters only"
    }
  • Body:

    {
      "name": "string",
      "phoneNumber": "string",
      "role": "string"
    }

DELETE Delete user /users/:cpf

Delete a registered user by it's CPF

  • Params:

    {
      "cpf": "string"
    }
  • Requirements :

    {
      "cpf": "required, 11 numeric characters only"
    }

Units


POST /units

Create a new unit of a registered company

  • Body:

    {
      "name": "string",
      "address": "string",
      "companyId": "string"
    }
  • Requirements :

    {
      "name": "required",
      "address": "required",
      "companyId": "required, must be a valid company id"
    }

GET unit by name /units/:name

Get a registered unit data by it's name

  • Params:

    {
      "name": "string"
    }
  • Requirements :

    {
      "name": "required"
    }

GET units by CompanyId /units/company

Get all registered units data by it's company id

  • Headers:

    {
      "company-id": "string"
    }
  • Requirements :

    {
      "company-id": "required, must be a valid company id"
    }

Assets


POST /assets

Register one or more assets for a registered unit

  • Body:

    [
      {
        "name": "string",
        "alias": "string",
        "model": "string",
        "images": ["string"],
        "description": "string",
        "status": "string",
        "healthLevel": "number",
        "ownerId": "string",
        "unitId": "string"
      }
    ]
  • Requirements :

    {
      "name": "required",
      "alias": "required",
      "model": "required",
      "images": "required, array of strings, must have at least one image",
      "description": "required",
      "status": "required, must be one of the following: 'RUNNING', 'ALERTING', 'STOPPED'",
      "healthLevel": "required, must be a number between 0 and 100",
      "ownerId": "required, must be a valid user id",
      "unitId": "required, must be a valid unit id"
    }

GET asset by alias /assets

Get a registered asset data by it's alias

  • Headers:

    {
      "asset-alias": "string"
    }
  • Requirements :

    {
      "asset-alias": "required"
    }

GET assets by unitId /assets/:unitId

Get all assets from a registered unit

  • Params:

    {
      "unitId": "string"
    }
  • Requirements :

    {
      "unitId": "required, must be a valid unit id"
    }

PUT update asset data /assets

Update a registered asset data by it's alias

  • Headers:

    {
      "asset-alias": "string"
    }
  • Requirements :

    {
      "asset-alias": "required, must an alias of a registered asset"
    }

DELETE delete asset /assets

Delete a registered asset by it's alias

  • Headers:

    {
      "asset-alias": "string"
    }
  • Requirements :

    {
      "asset-alias": "required, must an alias of a registered asset"
    }

⛏️ Built Using