{
  "openapi": "3.0.1",
  "info": {
    "title": "Auto financing API for B2B partners",
    "description": "This API allows you to create a lead that could receive a credit",
    "contact": {
      "email": "mx-auto-devs@creditas.com"
    },
    "version": "v1"
  },
  "servers": [
    {
      "url": "https://mx-auto-orchestrator.dev.creditas.io",
      "description": "Generated server url"
    }
  ],
  "tags": [
    {
      "name": "AutoFin",
      "description": "Operations for AutoFin"
    }
  ],
  "paths": {
    "/mx/b2b/autofin/api/catalogs/years/{yearId}/brands/{makeId}/models/{modelId}/versions": {
      "get": {
        "tags": [
          "auto-catalog-controller"
        ],
        "summary": "Get versions by auto year, brand and model",
        "operationId": "getVersions",
        "parameters": [
          {
            "name": "yearId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "makeId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "modelId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "*/*": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Catalogue"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/mx/b2b/autofin/api/catalogs/years/{yearId}/brands": {
      "get": {
        "tags": [
          "auto-catalog-controller"
        ],
        "summary": "Get brands by auto year",
        "operationId": "getBrands",
        "parameters": [
          {
            "name": "yearId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "*/*": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Catalogue"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/mx/b2b/autofin/api/catalogs/years/{yearId}/brands/{makeId}/models": {
      "get": {
        "tags": [
          "auto-catalog-controller"
        ],
        "summary": "Get models by auto year and brand",
        "operationId": "getModels",
        "parameters": [
          {
            "name": "yearId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "makeId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "*/*": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Catalogue"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/mx/b2b/autofin/api/catalogs/zip-code/{zipCode}": {
      "get": {
        "tags": [
          "zip-code-controller"
        ],
        "operationId": "findInformationCP",
        "parameters": [
          {
            "name": "zipCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "default response",
            "content": {
              "*/*": {
                "schema": {
                  "$ref": "#/components/schemas/ZipCodeInformation"
                }
              }
            }
          }
        }
      }
    },
    "/mx/b2b/autofin/api/leads/{leadId}/loan-info": {
      "put": {
        "tags": [
          "AutoFin"
        ],
        "summary": "Update lead with loan info",
        "operationId": "updateLoanInfo",
        "parameters": [
          {
            "name": "leadId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LoanInfoPayload"
              }
            }
          }
        },
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "timestamp": "2020-09-02T11:45:40.434041",
                  "message": "Bad Request",
                  "code": 40015
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "timestamp": "2020-09-02T11:45:40.434041",
                  "message": "Lead not found",
                  "code": 4040
                }
              }
            }
          }
        }
      }
    },
    "/mx/b2b/autofin/api/leads/{leadId}/contact-info": {
      "put": {
        "tags": [
          "AutoFin"
        ],
        "summary": "Save email and phone of a lead, and created the card",
        "operationId": "saveContactInfo",
        "parameters": [
          {
            "name": "leadId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PublicContactInfoPayload"
              }
            }
          }
        },
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "timestamp": "2020-09-02T11:45:40.434041",
                  "message": "Bad Request",
                  "code": 40015
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "timestamp": "2020-09-02T11:45:40.434041",
                  "message": "Lead not found",
                  "code": 4040
                }
              }
            }
          }
        }
      }
    },
    "/mx/b2b/autofin/api/leads/{leadId}/address": {
      "put": {
        "tags": [
          "address-controller"
        ],
        "operationId": "update",
        "parameters": [
          {
            "name": "leadId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AddressPayload"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "default response"
          }
        }
      }
    },
    "/mx/b2b/autofin/api/leads": {
      "post": {
        "tags": [
          "auto-fin-lead-controller"
        ],
        "summary": "Post empty lead",
        "operationId": "create",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "affiliate": {
                    "$ref": "#/components/schemas/SecurityTokenInfoDTO"
                  },
                  "autoFinB2BLeadCreatePayload": {
                    "$ref": "#/components/schemas/AutoFinB2BLeadCreatePayload"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created"
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "timestamp": "2020-09-02T11:45:40.434041",
                  "message": "Company not found",
                  "code": 4046
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "timestamp": "2020-09-02T11:45:40.434041",
                  "message": "Bad Request",
                  "code": 40015
                }
              }
            }
          }
        }
      }
    },
    "/mx/b2b/autofin/api/leads/{leadId}/auto": {
      "put": {
        "tags": [
          "auto-lead-controller"
        ],
        "summary": "Save the auto and the estimated price",
        "operationId": "save",
        "parameters": [
          {
            "name": "leadId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AutoLeadPayload"
              }
            }
          }
        },
        "responses": {
          "204": {
            "description": "default response"
          }
        }
      }
    },
    "/mx/b2b/autofin/api/leads/{leadId}/contact": {
      "put": {
        "tags": [
          "contact-controller"
        ],
        "summary": "Update phone and email",
        "operationId": "update_1",
        "parameters": [
          {
            "name": "leadId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ContactPayload"
              }
            }
          }
        },
        "responses": {
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": "{\"timestamp\":\"2022-12-08T11:53:38.720278\", \"message\":\"Bad Request\", \"code\":400, \"requestId\":\"404e6977-6def-4bd5-a36d-f92b3ff43c85\", \"additionalData\": [ + { \"field\":\"phone\", \"errorDetail\":\"Wrong phone format\" }, { \"field\": \"email\", \"errorDetail\":\"must be a well-formed email address\" }]}"
              }
            }
          },
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": "{ \"timestamp\": \"2020-09-02T11:45:40.434041\", \"message\": \"Lead not found\", \"code\": 4040}, \"requestId\":\"efc9f76c-609e-40c7-baf8-5d2f5120fe86\",\"additionalData\":null}"
              }
            }
          }
        }
      }
    },
    "/mx/b2b/autofin/api/leads/{leadId}/financial": {
      "put": {
        "tags": [
          "financial-controller"
        ],
        "operationId": "update_2",
        "parameters": [
          {
            "name": "leadId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FinancialPayload"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "default response"
          }
        }
      }
    },
    "/mx/b2b/autofin/api/leads/{leadId}/person": {
      "post": {
        "tags": [
          "person-controller"
        ],
        "operationId": "create_1",
        "parameters": [
          {
            "name": "leadId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PersonPayload"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "default response"
          }
        }
      }
    },
    "/mx/b2b/autofin/api/leads/{leadId}/pin": {
      "post": {
        "tags": [
          "AutoFin"
        ],
        "summary": "Send or resend PIN to the person related to a lead",
        "operationId": "sendOrResendPin",
        "parameters": [
          {
            "name": "leadId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NipSendRequest"
              }
            }
          }
        },
        "responses": {
          "412": {
            "description": "Precondition Failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": "{ \"timestamp\": \"2020-09-02T11:45:40.434041\", \"message\": \"Third-party message error\", \"code\": 6XXYYY}"
              }
            }
          },
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "timestamp": "2020-09-02T11:45:40.434041",
                  "message": "Bad Request",
                  "code": 4003
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "timestamp": "2020-09-02T11:45:40.434041",
                  "message": "Lead not found",
                  "code": 4040
                }
              }
            }
          }
        }
      }
    },
    "/mx/b2b/autofin/api/leads/{leadId}/pin/confirmation": {
      "post": {
        "tags": [
          "AutoFin"
        ],
        "summary": "Confirm PIN. Generate CDC Report. Apply PreQualification Rules",
        "operationId": "confirmPin",
        "parameters": [
          {
            "name": "leadId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PinConfirmationPayload"
              }
            }
          }
        },
        "responses": {
          "412": {
            "description": "Precondition Failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": "{ \"timestamp\": \"2020-09-02T11:45:40.434041\", \"message\": \"Third-party message error\", \"code\": 6XXYYY}"
              }
            }
          },
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "timestamp": "2020-09-02T11:45:40.434041",
                  "message": "Bad Request",
                  "code": 4003
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "timestamp": "2020-09-02T11:45:40.434041",
                  "message": "Lead not found",
                  "code": 4040
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Catalogue": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "xml": {
              "name": "Clave"
            }
          },
          "name": {
            "type": "string",
            "xml": {
              "name": "Nombre"
            }
          }
        }
      },
      "StateCatalog": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          }
        }
      },
      "ZipCodeInformation": {
        "type": "object",
        "properties": {
          "zipCode": {
            "type": "string"
          },
          "neighborhoods": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "municipality": {
            "type": "string"
          },
          "city": {
            "type": "string"
          },
          "state": {
            "$ref": "#/components/schemas/StateCatalog"
          }
        }
      },
      "LoanInfoPayload": {
        "type": "object",
        "properties": {
          "downPayment": {
            "type": "number",
            "format": "double"
          },
          "term": {
            "type": "integer",
            "format": "int32"
          },
          "phone": {
            "pattern": "^([0-9]{10})$",
            "type": "string"
          },
          "purchaseIntention": {
            "type": "string",
            "enum": [
              "LESS_THAN_TWO_WEEKS",
              "WITHIN_A_MONTH",
              "JUST_SIMULATE"
            ]
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "timestamp": {
            "type": "string",
            "format": "date-time"
          },
          "message": {
            "type": "string"
          },
          "code": {
            "type": "integer",
            "format": "int32"
          },
          "requestId": {
            "type": "string"
          },
          "additionalData": {
            "type": "object"
          }
        }
      },
      "PublicContactInfoPayload": {
        "required": [
          "email",
          "phone"
        ],
        "type": "object",
        "properties": {
          "phone": {
            "pattern": "^([0-9]{10})$",
            "type": "string"
          },
          "email": {
            "type": "string"
          }
        }
      },
      "AddressPayload": {
        "required": [
          "neighborhood",
          "number",
          "street",
          "zipCode"
        ],
        "type": "object",
        "properties": {
          "street": {
            "pattern": "^[a-zA-ZñÑáéíóúÁÉÍÓÚ0-9 ().#\\-]*$",
            "type": "string"
          },
          "number": {
            "pattern": "^[a-zA-ZñÑáéíóúÁÉÍÓÚ0-9 ().#\\-]*$",
            "type": "string"
          },
          "interior": {
            "pattern": "^[a-zA-ZñÑáéíóúÁÉÍÓÚ0-9 ().#\\-]*$",
            "type": "string"
          },
          "zipCode": {
            "pattern": "^\\d{5}$",
            "type": "string"
          },
          "neighborhood": {
            "maxLength": 65,
            "minLength": 0,
            "pattern": "^[a-zA-ZñÑáéíóúÁÉÍÓÚ0-9 ().#\\-]*$",
            "type": "string"
          }
        }
      },
      "SecurityTokenInfoDTO": {
        "type": "object",
        "properties": {
          "user_id": {
            "type": "string",
            "format": "uuid"
          },
          "user_type": {
            "type": "string"
          }
        }
      },
      "AutoFinB2BLeadCreatePayload": {
        "type": "object",
        "properties": {
          "externalAutoId": {
            "type": "string"
          },
          "phone": {
            "pattern": "^([0-9]{10})$",
            "type": "string"
          },
          "email": {
            "type": "string"
          },
          "downPayment": {
            "type": "number",
            "format": "double"
          },
          "term": {
            "type": "integer",
            "format": "int32"
          },
          "purchaseIntention": {
            "type": "string",
            "enum": [
              "LESS_THAN_TWO_WEEKS",
              "WITHIN_A_MONTH",
              "JUST_SIMULATE"
            ]
          }
        }
      },
      "AutoLeadPayload": {
        "required": [
          "id"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "price": {
            "type": "number",
            "format": "double"
          }
        }
      },
      "ContactPayload": {
        "type": "object",
        "properties": {
          "phone": {
            "pattern": "^([0-9]{10})$",
            "type": "string"
          },
          "email": {
            "type": "string"
          }
        }
      },
      "FinancialPayload": {
        "type": "object",
        "properties": {
          "employmentType": {
            "type": "string",
            "enum": [
              "Jubilado",
              "Empleado",
              "Independiente"
            ]
          },
          "startEmploymentDate": {
            "type": "string",
            "format": "date"
          },
          "startDate": {
            "$ref": "#/components/schemas/StartDate"
          },
          "jobPosition": {
            "type": "string"
          },
          "jobTitle": {
            "type": "string",
            "enum": [
              "Abogado",
              "Administrativo",
              "Analista",
              "Arquitecto",
              "Asesor",
              "Comerciante",
              "Comercio industrial",
              "Contabilidad",
              "Derecho",
              "Director",
              "Médico",
              "Educación",
              "Empleado",
              "Empresario",
              "Enfermería",
              "Estudiante",
              "Gerente",
              "Hogar",
              "Ventas",
              "Ingeniería",
              "Jubilado",
              "No especificado",
              "Operador",
              "Transportista",
              "Persona pensionada",
              "Político",
              "Profesor",
              "Psicología",
              "Relaciones públicas",
              "Supervisor",
              "Otro"
            ]
          },
          "businessLine": {
            "type": "string",
            "enum": [
              "Agricultura",
              "Alimentos preparados",
              "Alquiler",
              "Ama de casa",
              "Armas de fuego",
              "Asociaciones",
              "Comercio",
              "Comunicaciones",
              "Construcción",
              "Desempleado",
              "Editorial",
              "Educación",
              "Empleado",
              "Energía electrica",
              "Estudiante",
              "Fabricación de alimentos",
              "Forestal",
              "Ganadería",
              "Gobierno",
              "Immobiliario",
              "Jubilado",
              "Madera",
              "Manufactura",
              "Maquinaria",
              "Medicina",
              "Minerales no métalicos",
              "Minería",
              "Metalúrgica",
              "Papel",
              "Pensionado",
              "Pesca",
              "Petroquímicos",
              "Petróleo",
              "Química",
              "Religión",
              "Rifas y sorteos",
              "Ropa",
              "Servicios de alimentos",
              "Servicios de transporte",
              "Servicios financieros",
              "Servicios personales",
              "Servicios profesionales",
              "Servicios recreativos",
              "Sin actividad",
              "Textil",
              "Tiendas",
              "Transporte aéreo",
              "Transporte terrestre",
              "Turismo",
              "Vehículos",
              "Otra"
            ]
          },
          "employmentCompany": {
            "type": "string"
          },
          "income": {
            "type": "number",
            "format": "double"
          }
        }
      },
      "StartDate": {
        "type": "object",
        "properties": {
          "year": {
            "type": "integer",
            "format": "int32"
          },
          "month": {
            "type": "integer",
            "format": "int32"
          }
        }
      },
      "PersonPayload": {
        "required": [
          "birthDate",
          "firstName",
          "lastName",
          "rfc",
          "secondLastName",
          "secondName"
        ],
        "type": "object",
        "properties": {
          "firstName": {
            "type": "string"
          },
          "secondName": {
            "type": "string"
          },
          "lastName": {
            "type": "string"
          },
          "secondLastName": {
            "type": "string"
          },
          "rfc": {
            "type": "string"
          },
          "birthDate": {
            "type": "string"
          }
        }
      },
      "NipSendRequest": {
        "type": "object",
        "properties": {
          "channel": {
            "type": "string",
            "enum": [
              "SMS",
              "EMAIL"
            ]
          }
        }
      },
      "PinConfirmationPayload": {
        "required": [
          "pin"
        ],
        "type": "object",
        "properties": {
          "pin": {
            "type": "string",
            "example": "123456"
          },
          "pinConfirmation": {
            "type": "string",
            "example": "123455"
          }
        }
      }
    }
  }
}