Giter Site home page Giter Site logo

api-frete's Introduction

Banco de Dados

Criação do banco de dados [MYSQL]

CREATE DATABASE `teste_kabum` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci */;

Criação das tabelas

CREATE TABLE `transportadora` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `ALTURA_MAX` int(11) NOT NULL,
  `ALTURA_MIN` int(11) NOT NULL,
  `LARGURA_MAX` int(11) NOT NULL,
  `LARGURA_MIN` int(11) NOT NULL,
  `PRAZO_ENTREGA` int(11) NOT NULL,
  `NOME` varchar(200) NOT NULL,
  `CONSTANTE_FRETE` float NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

Massa de dados inicial

SET NAMES utf8 ;
DROP TABLE IF EXISTS `transportadora`;
SET character_set_client = utf8mb4 ;
CREATE TABLE `transportadora` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `ALTURA_MAX` int(11) NOT NULL,
  `ALTURA_MIN` int(11) NOT NULL,
  `LARGURA_MAX` int(11) NOT NULL,
  `LARGURA_MIN` int(11) NOT NULL,
  `PRAZO_ENTREGA` int(11) NOT NULL,
  `NOME` varchar(200) NOT NULL,
  `CONSTANTE_FRETE` float NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
LOCK TABLES `transportadora` WRITE;
INSERT INTO `transportadora` VALUES (1,200,10,140,6,6,'Entrega Ninja',0.3),(2,140,5,125,13,4,'Entrega KaBuM',0.2);
UNLOCK TABLES;

Configuração do ambiente

A configuração da url da base fica no arquivo .env

SQLALCHEMY_DATABASE_URI="mysql://usuario:senha@host:porta/base"

Instalação de dependencias (ambiente virtual)

pipenv install
pipenv shell

Execução do projeto

python main.py

Rotas e exemplos de chamadas

Cadastro de transportadoras [POST]

http://localhost:8080/v1/transportadora
{
    "altura_max": 140,
    "altura_min": 5,
    "largura_max": 125,
    "largura_min": 13,
    "prazo_entrega": 4,
    "nome": "Entrega KaBuM",
    "constante_frete": 0.2
}

Opções de frete [POST]

http://localhost:8080/v1/transportadora/opcoes_frete
{
    "dimensao": {"altura":102, "largura":40},
    "peso":400
}

Listagem de transportadoras [GET]

http://localhost:8080/v1/transportadora

Get por id de transportadoras [GET]

http://localhost:8080/v1/transportadora/1

Deleção de transportadora [DELETE]

http://localhost:8080/v1/transportadora/1

Update de transportadora [PUT]

http://localhost:8080/v1/transportadora/1
{
    "altura_max": 140,
    "altura_min": 5,
    "largura_max": 125,
    "largura_min": 13,
    "prazo_entrega": 4,
    "nome": "Entrega KaBuM",
    "constante_frete": 0.2
}

api-frete's People

Contributors

lomadara avatar

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.