openapi: 3.0.0
info:
  description: Rejestr Podatników VAT
  version: "1.6.0"
  title: API Rejestr WL
  contact:
    email: WykazPodatnikow@mf.gov.pl
  license:
    name: Apache 2.0
    url: 'http://www.apache.org/licenses/LICENSE-2.0.html'

#====================================================================================
paths:
  /api/search/nip/{nip}:
    get:
      operationId: nip?date
      parameters:
        - in: path
          name: nip
          required: true
          schema:
            type: string
            minLength: 10
            maxLength: 10
          description: "Nip"
        - in: query
          name: date
          required: true
          schema:
            type: string
            format: date
            example: '2019-05-17'
      responses:
        '200':
          description: Pojedynczy podmiot, który spełnił warunki wyszukiwania
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EntityResponse'
        '400':
          description: niepoprawny parametr na wejściu
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Exception'
      description: Wyszukiwanie pojedynczego podmiotu po nip

  /api/search/nips/{nips}:
    get:
      operationId: nips?date
      parameters:
        - in: path
          name: nips
          required: true
          schema:
            type: string
            minLength: 10
            example: '1111111111,2222222222,3333333333'
          description: "Lista maksymalnie 30 numerow NIP rozdzielonych przecinkami"
        - in: query
          name: date
          required: true
          schema:
            type: string
            format: date
            example: '2019-05-17'
      responses:
        '200':
          description: Rezultat wyszukiwania w postaci listy wpisów
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EntryListResponse'
        '400':
          description: niepoprawny parametr na wejściu
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Exception'
      description: Wyszukiwanie podmiotow po numerach nip

  /api/search/regon/{regon}:
    get:
      operationId: regon?date
      parameters:
        - in: path
          name: regon
          required: true
          schema:
            type: string
            pattern: '^\d{9}$|^\d{14}$'
            description: |
              Numer identyfikacyjny REGON
          example: '364760520'
          description: Regon
        - in: query
          name: date
          required: true
          schema:
            type: string
            format: date
            example: '2019-05-17'
      responses:
        '200':
          description: Pojedynczy podmiot, który spełnił warunki wyszukiwania
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EntityResponse'
        '400':
          description: niepoprawny parametr na wejściu
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Exception'
      description: Wyszukiwanie pojedynczego podmiotu po regon

  /api/search/regons/{regons}:
    get:
      operationId: regons?date
      parameters:
        - in: path
          name: regons
          required: true
          schema:
            type: string
            example: '111111111,22222222222222,333333333'
            description: |
              Lista maksymalnie 30 numerow REGON rozdzielonych przecinkami
          description: Regon
        - in: query
          name: date
          required: true
          schema:
            type: string
            format: date
            example: '2019-05-17'
      responses:
        '200':
          description: Rezultat wyszukiwania w postaci listy wpisów
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EntryListResponse'
        '400':
          description: niepoprawny parametr na wejściu
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Exception'
      description: Wyszukiwanie podmiotow po numerach regon

  /api/search/bank-account/{bank-account}:
    get:
      operationId: bank-account?date
      parameters:
        - in: path
          name: bank-account
          required: true
          schema:
            type: string
            minLength: 26
            maxLength: 26
          description: Numer rachunku bankowego
        - in: query
          name: date
          required: true
          schema:
            type: string
            format: date
            example: '2019-05-17'
      responses:
        '200':
          description: Lista podmiotow, które spełnily warunki wyszukiwania
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EntityListResponse'
        '400':
          description: niepoprawny parametr na wejściu
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Exception'
      description: Wyszukiwanie podmiotow po numerze konta

  /api/search/bank-accounts/{bank-accounts}:
    get:
      operationId: bank-accounts?date
      parameters:
        - in: path
          name: bank-accounts
          required: true
          schema:
            type: string
            minLength: 26
            example: '12345678901234567890123456, 09876543210987654321098765'
          description: |
            Lista maksymalnie 30 numerow rachunkow bankowych rozdzielonych przecinkami
        - in: query
          name: date
          required: true
          schema:
            type: string
            format: date
            example: '2019-05-17'
      responses:
        '200':
          description: Rezultat wyszukiwania w postaci listy wpisów
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EntryListResponse'
        '400':
          description: niepoprawny parametr na wejściu
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Exception'
      description: Wyszukiwanie podmiotow po numerach kont

  /api/check/nip/{nip}/bank-account/{bank-account}:
    get:
      operationId: checkNip

      parameters:
        - in: path
          name: nip
          required: true
          schema:
            type: string
            minLength: 10
            maxLength: 10
          description: "Nip"
        - in: path
          name: bank-account
          required: true
          schema:
            type: string
            minLength: 26
            maxLength: 26
          description: Numer rachunku bankowego
        - in: query
          name: date
          required: true
          schema:
            type: string
            format: date
            example: '2019-05-17'

      responses:
        '200':
          description: Informacja, że dany rachunek jest przypisany do podmiotu
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EntityCheckResponse'
        '400':
          description: niepoprawny parametr na wejściu
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Exception'
      description: Sprawdzenie pojedynczego podmiotu po nip i numerze konta

  /api/check/regon/{regon}/bank-account/{bank-account}:
    get:
      operationId: checkRegon

      parameters:
        - in: path
          name: regon
          required: true
          schema:
            type: string
            pattern: '^\d{9}$|^\d{14}$'
            description: |
              Numer identyfikacyjny REGON
          description: Regon
        - in: path
          name: bank-account
          required: true
          schema:
            type: string
            minLength: 26
            maxLength: 26
          description: Numer rachunku bankowego
        - in: query
          name: date
          required: true
          schema:
            type: string
            format: date
            example: '2019-05-17'

      responses:
        '200':
          description: Informacja, że dany rachunek jest przypisany do podmiotu
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EntityCheckResponse'
        '400':
          description: niepoprawny parametr na wejściu
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Exception'
      description: Sprawdzenie pojedynczego podmiotu po regon i numerze konta

components:
  schemas:
    Exception:
      properties:
        message:
          type: string
          maxLength: 256
          example: 'error message'
        code:
          type: string
          example: 'WL-101'
      required:
        - message
        - code
    #====================================================================================
    Pesel:
      type: string
      description: |
        numer PESEL jeżeli został nadany
      minLength: 11
      maxLength: 11
      example: '22222222222'
    #====================================================================================
    EntityPerson:
      properties:
        companyName:
          type: string
          example: 'Nazwa firmy'
        firstName:
          type: string
          maxLength: 60
          example: Jan
        lastName:
          type: string
          maxLength: 160
          example: Nowak
        pesel:
          $ref: '#/components/schemas/Pesel'
        nip:
          type: string
          minLength: 10
          maxLength: 10
          example: '1111111111'
    #====================================================================================
    EntityCheck:
      properties:
        accountAssigned:
          type: string
          example: TAK
          description: |
            Czy rachunek przypisany do podmiotu czynnego
        requestDateTime:
          type: string
          maxLength: 19
          example: '19-11-2019 14:58:49'
        requestId:
          type: string
          maxLength: 18
          example: 'd2n10-84df1a1'
    #====================================================================================
    Entity:
      properties:
        name:
          type: string
          example: 'ABC Jan Nowak'
          description: |
            Firma (nazwa) lub imię i nazwisko
        nip:
          type: string
          minLength: 10
          maxLength: 10
          example: '1111111111'
        statusVat:
          type: string
          enum:
            - Czynny
            - Zwolniony
            - Niezarejestrowany
          example: Zwolniony
          description: |
            Status podatnika VAT.
        regon:
          type: string
          pattern: '^\d{9}$|^\d{14}$'
          description: |
            Numer identyfikacyjny REGON
        pesel:
          $ref: '#/components/schemas/Pesel'
        krs:
          type: string
          example: '0000636771'
          maxLength: 10
          minLength: 10
          description: |
            numer KRS jeżeli został nadany
        residenceAddress:
          type: string
          maxLength: 200
          example: 'ul/ Chmielna 85/87 00-805 Warszawa'
          description: |
            Adres siedziby działalności gospodarczej (Adres siedziby OSOBY FIZYCZNEJ prowadzącej działalność gospodarczą)
        workingAddress:
          type: string
          maxLength: 200
          example: 'ul/ Prosta 49 00-838 Warszawa'
          description: |
            Adres rejestracyjny (Adres zamieszkania OSOBY FIZYCZNEJ lub adres siedziby ORGANIZACJI.).
        representatives:
          type: array
          items:
            $ref: '#/components/schemas/EntityPerson'
          description: |
            Imiona i nazwiska osób wchodzących w skład organu uprawnionego do reprezentowania podmiotu oraz ich numery NIP i/lub PESEL
        authorizedClerks:
          type: array
          items:
            $ref: '#/components/schemas/EntityPerson'
          description: |
            Imiona i nazwiska prokurentów oraz ich numery NIP i/lub PESEL
        partners:
          type: array
          items:
            $ref: '#/components/schemas/EntityPerson'
          description: |
            Imiona i nazwiska lub firmę (nazwa) wspólnika oraz jego numeryNIP i/lub PESEL
        registrationLegalDate:
          type: string
          format: date
          example: '2018-02-21'
          description: |
            Data rejestracji jako podatnika VAT
        registrationDenialDate:
          type: string
          format: date
          example: '2019-02-21'
          description: |
            Data odmowy rejestracji jako podatnika VAT
        registrationDenialBasis:
          type: string
          maxLength: 200
          example: 'Ustawa o podatku od towarów i usług art. 96'
          description: |
            Podstawa prawna odmowy rejestracji
        restorationDate:
          type: string
          format: date
          example: '2019-02-21'
          description: |
            Data przywrócenia jako podatnika VAT
        restorationBasis:
          type: string
          maxLength: 200
          example: 'Ustawa o podatku od towarów i usług art. 96'
          description: |
            Podstawa prawna przywrócenia jako podatnika VAT
        removalDate:
          type: string
          format: date
          example: '2019-02-21'
          description: |
            Data wykreślenia odmowy rejestracji jako podatnika VAT
        exemptionSmeDate:
          type: string
          format: date
          example: '2019-02-21'
          description: |
            Data zwolnienia SME
        removalBasis:
          type: string
          maxLength: 200
          example: 'Ustawa o podatku od towarów i usług Art. 97'
          description: |
            Podstawa prawna wykreślenia odmowy rejestracji jako podatnika VAT
        accountNumbers:
          type: array
          items:
            type: string
            minLength: 26
            maxLength: 26
            example: '90249000050247256316596736'
            description: |
              Numer konta bankowego w formacie NRB
        hasVirtualAccounts:
          type: boolean
          example: true
          description: |
            Podmiot posiada maski kont wirtualnych

      required:
        - name
    #====================================================================================
    EntityItem:
      properties:
        subject:
          $ref: '#/components/schemas/Entity'
        requestDateTime:
          type: string
          maxLength: 19
          example: '19-11-2019 14:58:49'
        requestId:
          type: string
          maxLength: 18
          example: 'd2n10-84df1a1'
    #====================================================================================
    EntityList:
      properties:
        subjects:
          type: array
          items:
            $ref: '#/components/schemas/Entity'
          description: |
            Lista podmiotów
        requestDateTime:
          type: string
          maxLength: 19
          example: '19-11-2019 14:58:49'
        requestId:
          type: string
          maxLength: 18
          example: 'd2n10-84df1a1'
    #====================================================================================
    Entry:
      properties:
        identifier:
          type: string
          description: |
            Przekazany identyfikator (Nip, Regon, Numer rachunku bankowego)
        subjects:
          type: array
          items:
            $ref: '#/components/schemas/Entity'
          description:
            Lista podmiotów
      required:
        - identifier
        - subjects
    #====================================================================================
    EntryError:
      properties:
        identifier:
          type: string
          description: |
            Przekazany identyfikator (Nip, Regon, Numer rachunku bankowego)
        error:
          $ref: '#/components/schemas/Exception'
      required:
        - identifier
        - error
    #====================================================================================
    EntryList:
      properties:
        entries:
          type: array
          items:
            oneOf:
              - $ref: '#/components/schemas/Entry'
              - $ref: '#/components/schemas/EntryError'
          description:
            Lista odpowiedzi
        requestDateTime:
          type: string
          maxLength: 19
          example: '19-11-2019 14:58:49'
        requestId:
          type: string
          maxLength: 18
          example: 'd2n10-84df1a1'
      required:
        - entries
    #====================================================================================
    EntityResponse:
      properties:
        result:
          $ref: '#/components/schemas/EntityItem'
    #====================================================================================
    EntityCheckResponse:
      properties:
        result:
          $ref: '#/components/schemas/EntityCheck'
    #====================================================================================
    EntityListResponse:
      properties:
        result:
          $ref: '#/components/schemas/EntityList'
    #====================================================================================
    EntryListResponse:
      properties:
        result:
          $ref: '#/components/schemas/EntryList'
