{
  "openapi": "3.0.1",
  "info": {
    "title": "Users API",
    "version": "1.0"
  },
  "servers": [
    {
      "url": "https://api.mercadoe.com"
    }
  ],
  "paths": {
    "/v1/users/{userId}/business-organizations": {
      "get": {
        "tags": [
          "Users"
        ],
        "summary": "Get user related to business organizations",
        "description": "Get a list of all business organizations assigned to a specific user.",
        "parameters": [
          {
            "name": "userId",
            "in": "path",
            "description": "the user id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "pageNumber",
            "in": "query",
            "description": "the page number must be an integer greater than or equal to 1",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 1
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "description": "the page size must be an integer greater than or equal to 1",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 10
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GetBusinessOrganizationsResponse"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/v1/users": {
      "post": {
        "tags": [
          "Users"
        ],
        "summary": "Create a user",
        "description": "Create a new user by providing the name, login, profile, and other details.",
        "parameters": [
          {
            "name": "X-ME-CORRELATION-ID",
            "in": "header",
            "description": "Internal client code to be identified in the webhook. It can be, for example, a product code in your ERP, an order number, etc.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateCommand"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Users"
        ],
        "summary": "Get all users",
        "description": "Get information about users with the given workflowId.",
        "parameters": [
          {
            "name": "pageNumber",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 1
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 10
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GetManyResponse"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/v1/users/{id}": {
      "put": {
        "tags": [
          "Users"
        ],
        "summary": "Update a user by id",
        "description": "Update fields of user by providing the Id",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "User id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "X-ME-CORRELATION-ID",
            "in": "header",
            "description": "Internal client code to be identified in the webhook. It can be, for example, a product code in your ERP, an order number, etc.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateCommand"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Users"
        ],
        "summary": "Get user by Id",
        "description": "Get information about a specific user with the given Id.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GetByIdResponse"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/v1/users/{userId}/cost-centers": {
      "get": {
        "tags": [
          "Users"
        ],
        "summary": "Get user related to cost centers",
        "description": "Get a list of all cost centers assigned to a specific user.",
        "parameters": [
          {
            "name": "userId",
            "in": "path",
            "description": "the user id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "pageNumber",
            "in": "query",
            "description": "the page number must be an integer greater than or equal to 1",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 1
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "description": "the page size must be an integer greater than or equal to 1",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 10
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GetCostCentersResponse"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/v1/users/{userId}/purchasing-groups": {
      "get": {
        "tags": [
          "Users"
        ],
        "summary": "Get user related to purchasing groups",
        "description": "Get a list of all purchasing groups assigned to a specific user.",
        "parameters": [
          {
            "name": "userId",
            "in": "path",
            "description": "the user id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "pageNumber",
            "in": "query",
            "description": "the page number must be an integer greater than or equal to 1",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 1
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "description": "the page size must be an integer greater than or equal to 1",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 10
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GetPurchasingGroupsResponse"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "BusinessOrganization": {
        "required": [
          "code",
          "virtualEntityField"
        ],
        "type": "object",
        "properties": {
          "code": {
            "minLength": 1,
            "type": "string"
          },
          "virtualEntityField": {
            "minLength": 1,
            "type": "string"
          },
          "userId": {
            "type": "integer",
            "format": "int32"
          }
        },
        "additionalProperties": false
      },
      "CostCenter": {
        "required": [
          "clientCostCenterId"
        ],
        "type": "object",
        "properties": {
          "clientCostCenterId": {
            "minLength": 1,
            "type": "string"
          },
          "userId": {
            "type": "integer",
            "format": "int32"
          }
        },
        "additionalProperties": false
      },
      "CreateCommand": {
        "required": [
          "contact",
          "email",
          "integrationTag",
          "languageId",
          "login",
          "name",
          "permission",
          "profile",
          "role"
        ],
        "type": "object",
        "properties": {
          "name": {
            "maxLength": 200,
            "minLength": 1,
            "type": "string",
            "description": "Name"
          },
          "login": {
            "maxLength": 30,
            "minLength": 1,
            "type": "string",
            "description": "Login"
          },
          "contact": {
            "maxLength": 150,
            "minLength": 1,
            "type": "string",
            "description": "Contact"
          },
          "email": {
            "maxLength": 100,
            "minLength": 1,
            "type": "string",
            "description": "Email"
          },
          "phone": {
            "maxLength": 18,
            "type": "string",
            "description": "Phone"
          },
          "profile": {
            "maxLength": 30,
            "minLength": 1,
            "type": "string",
            "description": "Profile"
          },
          "permission": {
            "maxLength": 30,
            "minLength": 1,
            "type": "string",
            "description": "Permission"
          },
          "role": {
            "maxLength": 30,
            "minLength": 1,
            "type": "string",
            "description": "Role/ Position in the company"
          },
          "integrationTag": {
            "maxLength": 30,
            "minLength": 1,
            "type": "string",
            "description": "Identification of the ME user used in the integration."
          },
          "isDeactivated": {
            "type": "boolean",
            "description": "Is this user deactivated?"
          },
          "languageId": {
            "type": "integer",
            "description": "Default language:\r\n0=EN/BR\r\n1=English\r\n3=Spanish",
            "format": "int32"
          },
          "businessOrganizations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BusinessOrganization"
            },
            "description": "Business Organizations is a list consisting of the Company Code and the Delivery Center/Location Code.",
            "nullable": true
          },
          "costCenters": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CostCenter"
            },
            "description": "Cost centers is a list consisting of the Cost center codes.",
            "nullable": true
          },
          "purchasingGroups": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PurchasingGroup"
            },
            "description": "Purchasing groups is a list consisting of the Purchasing group code and the Purchasing group description.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "User Request Command"
      },
      "CreateResponse": {
        "type": "object",
        "properties": {
          "correlationId": {
            "type": "string"
          }
        },
        "additionalProperties": false
      },
      "GetBusinessOrganizationsResponse": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/GetBusinessOrganizationsResponseData"
            }
          },
          "hits": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "next": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "GetBusinessOrganizationsResponseData": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Company code",
            "nullable": true
          },
          "virtualEntityField": {
            "type": "string",
            "description": "Delivery center/location code",
            "nullable": true
          },
          "userId": {
            "type": "integer",
            "description": "User related to the Business Organizations",
            "format": "int32"
          }
        },
        "additionalProperties": false
      },
      "GetByIdResponse": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "description": "Identifier",
            "format": "int32"
          },
          "name": {
            "type": "string",
            "description": "Name"
          },
          "login": {
            "type": "string",
            "description": "Login"
          },
          "contact": {
            "type": "string",
            "description": "Contact"
          },
          "email": {
            "type": "string",
            "description": "Email"
          },
          "phone": {
            "type": "string",
            "description": "Phone"
          },
          "profile": {
            "type": "string",
            "description": "Profile"
          },
          "permission": {
            "type": "string",
            "description": "Permission"
          },
          "role": {
            "type": "string",
            "description": "Role/ Position in the company"
          },
          "integrationTag": {
            "type": "string",
            "description": "Identification of the ME user used in the integration."
          },
          "isDeactivated": {
            "type": "boolean",
            "description": "Is this user deactivated?"
          },
          "languageId": {
            "type": "integer",
            "description": "Default language:\r\n0=EN/BR\r\n1=English\r\n3=Spanish",
            "format": "int32",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "GetCostCentersResponse": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/GetCostCentersResponseData"
            }
          },
          "hits": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "next": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "GetCostCentersResponseData": {
        "type": "object",
        "properties": {
          "clientCostCenterId": {
            "type": "string",
            "description": "Cost center code (if the accountingCategory is equal to \"K\", you must enter the Cost center code).",
            "nullable": true
          },
          "userId": {
            "type": "integer",
            "description": "User related to the Cost center",
            "format": "int32"
          }
        },
        "additionalProperties": false
      },
      "GetManyResponse": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/GetManyResponseData"
            }
          },
          "hits": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "next": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "GetManyResponseData": {
        "type": "object",
        "properties": {
          "userId": {
            "type": "integer",
            "description": "User id",
            "format": "int32"
          },
          "login": {
            "type": "string",
            "description": "Login."
          },
          "integrationTag": {
            "type": "string",
            "description": "Identification of the ME user used in the integration."
          }
        },
        "additionalProperties": false
      },
      "GetPurchasingGroupsResponse": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/GetPurchasingGroupsResponseData"
            }
          },
          "hits": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "next": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "GetPurchasingGroupsResponseData": {
        "type": "object",
        "properties": {
          "clientPurchasingGroupCode": {
            "type": "string",
            "description": "Purchasing group code",
            "nullable": true
          },
          "clientPurchasingGroupDescription": {
            "type": "string",
            "description": "Purchasing group description",
            "nullable": true
          },
          "userId": {
            "type": "integer",
            "description": "User related to the Purchasing Group",
            "format": "int32"
          }
        },
        "additionalProperties": false
      },
      "ProblemDetails": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "nullable": true
          },
          "title": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "detail": {
            "type": "string",
            "nullable": true
          },
          "instance": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": {}
      },
      "PurchasingGroup": {
        "type": "object",
        "properties": {
          "clientPurchasingGroupCode": {
            "type": "string",
            "nullable": true
          },
          "clientPurchasingGroupDescription": {
            "type": "string",
            "nullable": true
          },
          "userId": {
            "type": "integer",
            "format": "int32"
          }
        },
        "additionalProperties": false
      },
      "SupplierGroup": {
        "type": "object",
        "properties": {
          "description": {
            "type": "string",
            "nullable": true
          },
          "enabled": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "UpdateCommand": {
        "required": [
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "maxLength": 200,
            "minLength": 1,
            "type": "string",
            "description": "Name"
          },
          "contact": {
            "type": "string",
            "description": "Contact"
          },
          "email": {
            "type": "string",
            "description": "Email"
          },
          "phone": {
            "type": "string",
            "description": "Phone"
          },
          "profile": {
            "type": "string",
            "description": "Profile"
          },
          "permission": {
            "type": "string",
            "description": "Permission"
          },
          "role": {
            "type": "string",
            "description": "Role/ Position in the company"
          },
          "integrationTag": {
            "type": "string",
            "description": "Identification of the ME user used in the integration."
          },
          "isDeactivated": {
            "type": "boolean",
            "description": "Is this user deactivated?",
            "nullable": true
          },
          "languageId": {
            "type": "integer",
            "description": "Default language selection:\r\n- 0 = Portuguese (BR)\r\n- 1 = English\r\n- 2 = Spanish",
            "format": "int32",
            "nullable": true
          },
          "businessOrganizations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BusinessOrganization"
            },
            "description": "Business Organizations is a list consisting of the Company Code and the Delivery Center/Location Code.",
            "nullable": true
          },
          "costCenters": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CostCenter"
            },
            "description": "Cost centers is a list consisting of the Cost center codes.",
            "nullable": true
          },
          "purchasingGroups": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PurchasingGroup"
            },
            "description": "Purchasing groups is a list consisting of the Purchasing group code and the Purchasing group description.",
            "nullable": true
          },
          "supplierGroups": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SupplierGroup"
            },
            "description": "It is a list of group of suppliers used by the user with the buyer profile",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "UpdateResponse": {
        "type": "object",
        "properties": {
          "correlationId": {
            "type": "string"
          }
        },
        "additionalProperties": false
      }
    },
    "securitySchemes": {
      "Bearer": {
        "type": "apiKey",
        "description": "Please enter the word 'Bearer' followed by a space and then your JWT.",
        "name": "Authorization",
        "in": "header"
      }
    }
  },
  "security": [
    {
      "Bearer": []
    }
  ]
}