842 lines
18 KiB
YAML
842 lines
18 KiB
YAML
basePath: /
|
|
definitions:
|
|
domain.Company:
|
|
properties:
|
|
cnpj:
|
|
type: string
|
|
corporate_name:
|
|
type: string
|
|
created_at:
|
|
type: string
|
|
id:
|
|
type: string
|
|
is_verified:
|
|
type: boolean
|
|
license_number:
|
|
type: string
|
|
role:
|
|
description: pharmacy, distributor, admin
|
|
type: string
|
|
updated_at:
|
|
type: string
|
|
type: object
|
|
domain.Order:
|
|
properties:
|
|
buyer_id:
|
|
type: string
|
|
created_at:
|
|
type: string
|
|
id:
|
|
type: string
|
|
items:
|
|
items:
|
|
$ref: '#/definitions/domain.OrderItem'
|
|
type: array
|
|
seller_id:
|
|
type: string
|
|
shipping:
|
|
$ref: '#/definitions/domain.ShippingAddress'
|
|
status:
|
|
$ref: '#/definitions/domain.OrderStatus'
|
|
total_cents:
|
|
type: integer
|
|
updated_at:
|
|
type: string
|
|
type: object
|
|
domain.OrderItem:
|
|
properties:
|
|
batch:
|
|
type: string
|
|
expires_at:
|
|
type: string
|
|
id:
|
|
type: string
|
|
order_id:
|
|
type: string
|
|
product_id:
|
|
type: string
|
|
quantity:
|
|
type: integer
|
|
unit_cents:
|
|
type: integer
|
|
type: object
|
|
domain.OrderStatus:
|
|
enum:
|
|
- Pendente
|
|
- Pago
|
|
- Faturado
|
|
- Entregue
|
|
type: string
|
|
x-enum-varnames:
|
|
- OrderStatusPending
|
|
- OrderStatusPaid
|
|
- OrderStatusInvoiced
|
|
- OrderStatusDelivered
|
|
domain.PaymentPreference:
|
|
properties:
|
|
commission_pct:
|
|
type: number
|
|
gateway:
|
|
type: string
|
|
marketplace_fee:
|
|
type: integer
|
|
order_id:
|
|
type: string
|
|
payment_url:
|
|
type: string
|
|
seller_receivable:
|
|
type: integer
|
|
type: object
|
|
domain.PaymentSplitResult:
|
|
properties:
|
|
marketplace_fee:
|
|
type: integer
|
|
order_id:
|
|
type: string
|
|
payment_id:
|
|
type: string
|
|
seller_receivable:
|
|
type: integer
|
|
status:
|
|
type: string
|
|
total_paid_amount:
|
|
type: integer
|
|
type: object
|
|
domain.PaymentWebhookEvent:
|
|
properties:
|
|
marketplace_fee:
|
|
type: integer
|
|
order_id:
|
|
type: string
|
|
payment_id:
|
|
type: string
|
|
seller_amount:
|
|
type: integer
|
|
status:
|
|
type: string
|
|
total_paid_amount:
|
|
type: integer
|
|
type: object
|
|
domain.Product:
|
|
properties:
|
|
batch:
|
|
type: string
|
|
created_at:
|
|
type: string
|
|
description:
|
|
type: string
|
|
expires_at:
|
|
type: string
|
|
id:
|
|
type: string
|
|
name:
|
|
type: string
|
|
price_cents:
|
|
type: integer
|
|
seller_id:
|
|
type: string
|
|
stock:
|
|
type: integer
|
|
updated_at:
|
|
type: string
|
|
type: object
|
|
domain.Shipment:
|
|
properties:
|
|
carrier:
|
|
type: string
|
|
created_at:
|
|
type: string
|
|
external_tracking:
|
|
type: string
|
|
id:
|
|
type: string
|
|
order_id:
|
|
type: string
|
|
status:
|
|
type: string
|
|
tracking_code:
|
|
type: string
|
|
updated_at:
|
|
type: string
|
|
type: object
|
|
domain.ShippingAddress:
|
|
properties:
|
|
city:
|
|
type: string
|
|
complement:
|
|
type: string
|
|
country:
|
|
type: string
|
|
district:
|
|
type: string
|
|
number:
|
|
type: string
|
|
recipient_name:
|
|
type: string
|
|
state:
|
|
type: string
|
|
street:
|
|
type: string
|
|
zip_code:
|
|
type: string
|
|
type: object
|
|
domain.User:
|
|
properties:
|
|
company_id:
|
|
type: string
|
|
created_at:
|
|
type: string
|
|
email:
|
|
type: string
|
|
id:
|
|
type: string
|
|
name:
|
|
type: string
|
|
role:
|
|
type: string
|
|
updated_at:
|
|
type: string
|
|
type: object
|
|
domain.UserPage:
|
|
properties:
|
|
page:
|
|
type: integer
|
|
page_size:
|
|
type: integer
|
|
total:
|
|
type: integer
|
|
users:
|
|
items:
|
|
$ref: '#/definitions/domain.User'
|
|
type: array
|
|
type: object
|
|
handler.authResponse:
|
|
properties:
|
|
expires_at:
|
|
type: string
|
|
token:
|
|
type: string
|
|
type: object
|
|
handler.createOrderRequest:
|
|
properties:
|
|
buyer_id:
|
|
type: string
|
|
items:
|
|
items:
|
|
$ref: '#/definitions/domain.OrderItem'
|
|
type: array
|
|
seller_id:
|
|
type: string
|
|
shipping:
|
|
$ref: '#/definitions/domain.ShippingAddress'
|
|
type: object
|
|
handler.createShipmentRequest:
|
|
properties:
|
|
carrier:
|
|
type: string
|
|
external_tracking:
|
|
type: string
|
|
order_id:
|
|
type: string
|
|
tracking_code:
|
|
type: string
|
|
type: object
|
|
handler.createUserRequest:
|
|
properties:
|
|
company_id:
|
|
type: string
|
|
email:
|
|
type: string
|
|
name:
|
|
type: string
|
|
password:
|
|
type: string
|
|
role:
|
|
type: string
|
|
type: object
|
|
handler.loginRequest:
|
|
properties:
|
|
email:
|
|
type: string
|
|
password:
|
|
type: string
|
|
type: object
|
|
handler.registerAuthRequest:
|
|
properties:
|
|
company:
|
|
$ref: '#/definitions/handler.registerCompanyTarget'
|
|
company_id:
|
|
type: string
|
|
email:
|
|
type: string
|
|
name:
|
|
type: string
|
|
password:
|
|
type: string
|
|
role:
|
|
type: string
|
|
type: object
|
|
handler.registerCompanyRequest:
|
|
properties:
|
|
cnpj:
|
|
type: string
|
|
corporate_name:
|
|
type: string
|
|
license_number:
|
|
type: string
|
|
role:
|
|
type: string
|
|
type: object
|
|
handler.registerCompanyTarget:
|
|
properties:
|
|
cnpj:
|
|
type: string
|
|
corporate_name:
|
|
type: string
|
|
id:
|
|
type: string
|
|
license_number:
|
|
type: string
|
|
role:
|
|
type: string
|
|
type: object
|
|
handler.registerProductRequest:
|
|
properties:
|
|
batch:
|
|
type: string
|
|
description:
|
|
type: string
|
|
expires_at:
|
|
type: string
|
|
name:
|
|
type: string
|
|
price_cents:
|
|
type: integer
|
|
seller_id:
|
|
type: string
|
|
stock:
|
|
type: integer
|
|
type: object
|
|
handler.updateStatusRequest:
|
|
properties:
|
|
status:
|
|
type: string
|
|
type: object
|
|
handler.updateUserRequest:
|
|
properties:
|
|
company_id:
|
|
type: string
|
|
email:
|
|
type: string
|
|
name:
|
|
type: string
|
|
password:
|
|
type: string
|
|
role:
|
|
type: string
|
|
type: object
|
|
info:
|
|
contact:
|
|
email: devops@saveinmed.com
|
|
name: Engenharia SaveInMed
|
|
description: API REST B2B para marketplace farmacêutico com split de pagamento e
|
|
rastreabilidade.
|
|
title: SaveInMed Performance Core API
|
|
version: "1.0"
|
|
paths:
|
|
/api/companies:
|
|
get:
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"200":
|
|
description: OK
|
|
schema:
|
|
items:
|
|
$ref: '#/definitions/domain.Company'
|
|
type: array
|
|
summary: Lista empresas
|
|
tags:
|
|
- Empresas
|
|
post:
|
|
consumes:
|
|
- application/json
|
|
description: Cadastra farmácia, distribuidora ou administrador com CNPJ e licença
|
|
sanitária.
|
|
parameters:
|
|
- description: Dados da empresa
|
|
in: body
|
|
name: company
|
|
required: true
|
|
schema:
|
|
$ref: '#/definitions/handler.registerCompanyRequest'
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"201":
|
|
description: Created
|
|
schema:
|
|
$ref: '#/definitions/domain.Company'
|
|
summary: Registro de empresas
|
|
tags:
|
|
- Empresas
|
|
/api/orders:
|
|
post:
|
|
consumes:
|
|
- application/json
|
|
parameters:
|
|
- description: Pedido
|
|
in: body
|
|
name: order
|
|
required: true
|
|
schema:
|
|
$ref: '#/definitions/handler.createOrderRequest'
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"201":
|
|
description: Created
|
|
schema:
|
|
$ref: '#/definitions/domain.Order'
|
|
summary: Criação de pedido com split
|
|
tags:
|
|
- Pedidos
|
|
/api/orders/{id}:
|
|
get:
|
|
parameters:
|
|
- description: Order ID
|
|
in: path
|
|
name: id
|
|
required: true
|
|
type: string
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"200":
|
|
description: OK
|
|
schema:
|
|
$ref: '#/definitions/domain.Order'
|
|
summary: Consulta pedido
|
|
tags:
|
|
- Pedidos
|
|
/api/orders/{id}/payment:
|
|
post:
|
|
parameters:
|
|
- description: Order ID
|
|
in: path
|
|
name: id
|
|
required: true
|
|
type: string
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"201":
|
|
description: Created
|
|
schema:
|
|
$ref: '#/definitions/domain.PaymentPreference'
|
|
summary: Cria preferência de pagamento Mercado Pago com split nativo
|
|
tags:
|
|
- Pagamentos
|
|
/api/orders/{id}/status:
|
|
patch:
|
|
consumes:
|
|
- application/json
|
|
parameters:
|
|
- description: Order ID
|
|
in: path
|
|
name: id
|
|
required: true
|
|
type: string
|
|
- description: Novo status
|
|
in: body
|
|
name: status
|
|
required: true
|
|
schema:
|
|
$ref: '#/definitions/handler.updateStatusRequest'
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"204":
|
|
description: ""
|
|
summary: Atualiza status do pedido
|
|
tags:
|
|
- Pedidos
|
|
/api/products:
|
|
get:
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"200":
|
|
description: OK
|
|
schema:
|
|
items:
|
|
$ref: '#/definitions/domain.Product'
|
|
type: array
|
|
summary: Lista catálogo com lote e validade
|
|
tags:
|
|
- Produtos
|
|
post:
|
|
consumes:
|
|
- application/json
|
|
parameters:
|
|
- description: Produto
|
|
in: body
|
|
name: product
|
|
required: true
|
|
schema:
|
|
$ref: '#/definitions/handler.registerProductRequest'
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"201":
|
|
description: Created
|
|
schema:
|
|
$ref: '#/definitions/domain.Product'
|
|
summary: Cadastro de produto com rastreabilidade de lote
|
|
tags:
|
|
- Produtos
|
|
/api/v1/auth/login:
|
|
post:
|
|
consumes:
|
|
- application/json
|
|
description: Autentica usuário e retorna token JWT.
|
|
parameters:
|
|
- description: Credenciais
|
|
in: body
|
|
name: payload
|
|
required: true
|
|
schema:
|
|
$ref: '#/definitions/handler.loginRequest'
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"200":
|
|
description: OK
|
|
schema:
|
|
$ref: '#/definitions/handler.authResponse'
|
|
"400":
|
|
description: Bad Request
|
|
schema:
|
|
additionalProperties:
|
|
type: string
|
|
type: object
|
|
"401":
|
|
description: Unauthorized
|
|
schema:
|
|
additionalProperties:
|
|
type: string
|
|
type: object
|
|
summary: Login
|
|
tags:
|
|
- Autenticação
|
|
/api/v1/auth/register:
|
|
post:
|
|
consumes:
|
|
- application/json
|
|
description: Cria um usuário e opcionalmente uma empresa, retornando token JWT.
|
|
parameters:
|
|
- description: Dados do usuário e empresa
|
|
in: body
|
|
name: payload
|
|
required: true
|
|
schema:
|
|
$ref: '#/definitions/handler.registerAuthRequest'
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"201":
|
|
description: Created
|
|
schema:
|
|
$ref: '#/definitions/handler.authResponse'
|
|
"400":
|
|
description: Bad Request
|
|
schema:
|
|
additionalProperties:
|
|
type: string
|
|
type: object
|
|
"500":
|
|
description: Internal Server Error
|
|
schema:
|
|
additionalProperties:
|
|
type: string
|
|
type: object
|
|
summary: Cadastro de usuário
|
|
tags:
|
|
- Autenticação
|
|
/api/v1/payments/webhook:
|
|
post:
|
|
consumes:
|
|
- application/json
|
|
parameters:
|
|
- description: Evento do gateway
|
|
in: body
|
|
name: notification
|
|
required: true
|
|
schema:
|
|
$ref: '#/definitions/domain.PaymentWebhookEvent'
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"200":
|
|
description: OK
|
|
schema:
|
|
$ref: '#/definitions/domain.PaymentSplitResult'
|
|
summary: Recebe notificações do Mercado Pago
|
|
tags:
|
|
- Pagamentos
|
|
/api/v1/shipments:
|
|
post:
|
|
consumes:
|
|
- application/json
|
|
parameters:
|
|
- description: Dados de envio
|
|
in: body
|
|
name: shipment
|
|
required: true
|
|
schema:
|
|
$ref: '#/definitions/handler.createShipmentRequest'
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"201":
|
|
description: Created
|
|
schema:
|
|
$ref: '#/definitions/domain.Shipment'
|
|
summary: Gera guia de postagem/transporte
|
|
tags:
|
|
- Logistica
|
|
/api/v1/shipments/{order_id}:
|
|
get:
|
|
parameters:
|
|
- description: Order ID
|
|
in: path
|
|
name: order_id
|
|
required: true
|
|
type: string
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"200":
|
|
description: OK
|
|
schema:
|
|
$ref: '#/definitions/domain.Shipment'
|
|
summary: Rastreia entrega
|
|
tags:
|
|
- Logistica
|
|
/api/v1/users:
|
|
get:
|
|
parameters:
|
|
- description: Página
|
|
in: query
|
|
name: page
|
|
type: integer
|
|
- description: Tamanho da página
|
|
in: query
|
|
name: page_size
|
|
type: integer
|
|
- description: Filtro por empresa
|
|
in: query
|
|
name: company_id
|
|
type: string
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"200":
|
|
description: OK
|
|
schema:
|
|
$ref: '#/definitions/domain.UserPage'
|
|
"400":
|
|
description: Bad Request
|
|
schema:
|
|
additionalProperties:
|
|
type: string
|
|
type: object
|
|
"500":
|
|
description: Internal Server Error
|
|
schema:
|
|
additionalProperties:
|
|
type: string
|
|
type: object
|
|
security:
|
|
- BearerAuth: []
|
|
summary: Listar usuários
|
|
tags:
|
|
- Usuários
|
|
post:
|
|
consumes:
|
|
- application/json
|
|
parameters:
|
|
- description: Novo usuário
|
|
in: body
|
|
name: payload
|
|
required: true
|
|
schema:
|
|
$ref: '#/definitions/handler.createUserRequest'
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"201":
|
|
description: Created
|
|
schema:
|
|
$ref: '#/definitions/domain.User'
|
|
"400":
|
|
description: Bad Request
|
|
schema:
|
|
additionalProperties:
|
|
type: string
|
|
type: object
|
|
"403":
|
|
description: Forbidden
|
|
schema:
|
|
additionalProperties:
|
|
type: string
|
|
type: object
|
|
"500":
|
|
description: Internal Server Error
|
|
schema:
|
|
additionalProperties:
|
|
type: string
|
|
type: object
|
|
security:
|
|
- BearerAuth: []
|
|
summary: Criar usuário
|
|
tags:
|
|
- Usuários
|
|
/api/v1/users/{id}:
|
|
delete:
|
|
parameters:
|
|
- description: User ID
|
|
in: path
|
|
name: id
|
|
required: true
|
|
type: string
|
|
responses:
|
|
"204":
|
|
description: No Content
|
|
schema:
|
|
type: string
|
|
"400":
|
|
description: Bad Request
|
|
schema:
|
|
additionalProperties:
|
|
type: string
|
|
type: object
|
|
"403":
|
|
description: Forbidden
|
|
schema:
|
|
additionalProperties:
|
|
type: string
|
|
type: object
|
|
"404":
|
|
description: Not Found
|
|
schema:
|
|
additionalProperties:
|
|
type: string
|
|
type: object
|
|
"500":
|
|
description: Internal Server Error
|
|
schema:
|
|
additionalProperties:
|
|
type: string
|
|
type: object
|
|
security:
|
|
- BearerAuth: []
|
|
summary: Excluir usuário
|
|
tags:
|
|
- Usuários
|
|
get:
|
|
parameters:
|
|
- description: User ID
|
|
in: path
|
|
name: id
|
|
required: true
|
|
type: string
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"200":
|
|
description: OK
|
|
schema:
|
|
$ref: '#/definitions/domain.User'
|
|
"400":
|
|
description: Bad Request
|
|
schema:
|
|
additionalProperties:
|
|
type: string
|
|
type: object
|
|
"403":
|
|
description: Forbidden
|
|
schema:
|
|
additionalProperties:
|
|
type: string
|
|
type: object
|
|
"404":
|
|
description: Not Found
|
|
schema:
|
|
additionalProperties:
|
|
type: string
|
|
type: object
|
|
security:
|
|
- BearerAuth: []
|
|
summary: Obter usuário
|
|
tags:
|
|
- Usuários
|
|
put:
|
|
consumes:
|
|
- application/json
|
|
parameters:
|
|
- description: User ID
|
|
in: path
|
|
name: id
|
|
required: true
|
|
type: string
|
|
- description: Campos para atualização
|
|
in: body
|
|
name: payload
|
|
required: true
|
|
schema:
|
|
$ref: '#/definitions/handler.updateUserRequest'
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"200":
|
|
description: OK
|
|
schema:
|
|
$ref: '#/definitions/domain.User'
|
|
"400":
|
|
description: Bad Request
|
|
schema:
|
|
additionalProperties:
|
|
type: string
|
|
type: object
|
|
"403":
|
|
description: Forbidden
|
|
schema:
|
|
additionalProperties:
|
|
type: string
|
|
type: object
|
|
"404":
|
|
description: Not Found
|
|
schema:
|
|
additionalProperties:
|
|
type: string
|
|
type: object
|
|
"500":
|
|
description: Internal Server Error
|
|
schema:
|
|
additionalProperties:
|
|
type: string
|
|
type: object
|
|
security:
|
|
- BearerAuth: []
|
|
summary: Atualizar usuário
|
|
tags:
|
|
- Usuários
|
|
schemes:
|
|
- http
|
|
securityDefinitions:
|
|
BearerAuth:
|
|
in: header
|
|
name: Authorization
|
|
type: apiKey
|
|
swagger: "2.0"
|