swagger: '2.0'
info:
  title: Plany Postępowań
  description: Moduł ten służy do publikacji planu postępowań o udzielenie zamówień.
  version: '1.0'
host: api.ezamowienia.gov.pl
basePath: /pp
schemes:
  - https
consumes:
  - application/json
produces:
  - application/json
tags:
  - name: Zamówienia
  - name: Plany postępowań
paths:
  '/planypostepowan':
    post:
      summary: Zapis planu postępowan
      description: Dane ustrukturyzowane
      operationId: ZapiszPlanPostepowan
      tags:
        - Plany postępowań
      parameters:
        - in: body
          name: body
          description: Informacje planu postepowań
          required: true
          schema:
            $ref: '#/definitions/UtworzPlanPostepowanRequest'
      responses:
        '201':
          description: Utworzono plan postępowan
          schema:
            $ref: '#/definitions/UtworzPlanPostepowanResponse'
        '400':
          description: Nieprawidłowy plan postępowania
          schema:
            $ref: '#/definitions/Blad'
        '401':
          description: Niezalogowany
          schema:
            $ref: '#/definitions/Blad'
        '403':
          description: Brak uprawnień
          schema:
            $ref: '#/definitions/Blad'
        '409':
          description: Istnieje już taki plan postępowań
          schema:
            $ref: '#/definitions/Blad'
  '/planypostepowan/{idPlanuPostepowan}':
    put:
      summary: Aktualizacja planu postępowań
      description: Aktualizacja obecnego planu postępowań
      operationId: AktualizujPlanPostepowan
      tags:
        - Plany postępowań
      parameters:
        - in: body
          name: body
          description: Informacje planu postępowań
          required: true
          schema:
            $ref: '#/definitions/AktualizujPlanPostepowanRequest'
        - $ref: '#/parameters/IdPlanuPostepowan'
      responses:
        '200':
          description: Zaktualizowany plan postępowań
          schema:
            $ref: '#/definitions/AktualizujPlanPostepowanResponse'
        '400':
          description: Niepoprawne żądanie
          schema:
            $ref: '#/definitions/Blad'
        '401':
          description: Niezalogowany
          schema:
            $ref: '#/definitions/Blad'
        '403':
          description: Brak uprawnień
          schema:
            $ref: '#/definitions/Blad'
        '404':
          description: Brak planu postępowań dla danego identyfikatora
          schema:
            $ref: '#/definitions/Blad'
    get:
      summary: Pobranie planu postępowań
      description: Pobranie w celu publikacji
      operationId: PobierzPlanPostepowan
      tags:
        - Plany postępowań
      parameters:
        - $ref: '#/parameters/IdPlanuPostepowan'
      responses:
        '200':
          description: Pobrany plan postępowań
          schema:
            $ref: '#/definitions/PobierzPlanPostepowanResponse'
        '400':
          description: Niepoprawne żądanie
          schema:
            $ref: '#/definitions/Blad'
        '401':
          description: Niezalogowany
          schema:
            $ref: '#/definitions/Blad'
        '403':
          description: Brak uprawnień
          schema:
            $ref: '#/definitions/Blad'
        '404':
          description: Brak planu postępowań dla danego identyfikatora
          schema:
            $ref: '#/definitions/Blad'
parameters:
  IdPlanuPostepowan:
    name: idPlanuPostepowan
    in: path
    description: Identyfikator planu postępowań
    required: true
    type: string
    format: uuid
  IdZamawiajacego:
    name: idZamawiajacego
    in: path
    description: Identyfikator zamawiającego
    required: true
    type: string
    format: uuid
definitions:
  IdPlanuPostepowan:
    description: Identyfikator planu postępowań
    type: string
    format: uuid
    example: e63bf835-224a-4b3b-a564-160640911f0a
  IdZamawiajacego:
    description: Identyfikator zamawiającego
    type: string
    format: uuid
  PobierzPlanPostepowanResponse:
    type: object
    properties:
      id:
        $ref: '#/definitions/IdPlanuPostepowan'
      idZamawiajacego:
        $ref: '#/definitions/IdZamawiajacego'
      rok:
        type: string
      pozycjePlanu:
        type: array
        minItems: 1
        items:
          $ref: '#/definitions/PozycjaPlanu'
      links:
        $ref: '#/definitions/Links'
    example:
      id: d1950b7a-0dc6-4881-bfd6-dc7b845a9477
      idZamawiajacego: d1950b7a-0dc6-4881-bfd6-dc7b845a9477
      rok: 2018
      pozycjePlanu:
        - czyKlauzuleSpoleczne : true
          kodCPV:
            glowny: 01.01
            dodatkowe:
              - 02.02
              - 03.03
          przedmiotZamowienia: Testowy przedmiot zamowienia
          przewidywanyTerminWszczecia: II 2018
          rodzajZamowienia: dostawy
          ujecieTerminu: kwartalny
          wartoscZamowienia:
            kwota: 1000000.00
            waluta: PLN
            czyNetto: true
      links:
        - rel: AktualizujPlanPostepowan
          action: PUT
          href: /planypostepowan/d1950b7a-0dc6-4881-bfd6-dc7b845a9477
  UtworzPlanPostepowanRequest:
    type: object
    required:
      - czyObowiazekPublikacji
      - rok
      - pozycjePlanu
    properties:
      czyObowiazekPublikacji:
        type: boolean
        example: false
      rok:
        type: string
        example: '2018'
      pozycjePlanu:
        type: array
        minItems: 1
        items:
          $ref: '#/definitions/PozycjaPlanu'
      dataPublikacji:
        type: string
        format: date-time
  UtworzPlanPostepowanResponse:
    type: object
    required:
      - id
      - idZamawiajacego
      - links
    properties:
      id:
        $ref: '#/definitions/IdPlanuPostepowan'
      idZamawiajacego:
        $ref: '#/definitions/IdZamawiajacego'
      dataPublikacjiPlanu:
        type: string
        format: date-time
      links:
        $ref: '#/definitions/Links'
    example:
      id: d1950b7a-0dc6-4881-bfd6-dc7b845a9477
      idZamawiajacego: d1950b7a-0dc6-4881-bfd6-dc7b845a9477
      przedmiot: Usługi projektów graficznych
      dataPublikacjiPlanu: '2018-05-07 10:30:00.000'
      links:
        - rel: PobierzPlanPostepowan
          action: GET
          href: /planypostepowan/d1950b7a-0dc6-4881-bfd6-dc7b845a9477
        - rel: AktualizujPlanPostepowan
          action: PUT
          href: /planypostepowan/d1950b7a-0dc6-4881-bfd6-dc7b845a9477
  AktualizujPlanPostepowanRequest:
    type: object
    required:
      - czyObowiazekPublikacji
      - rok
      - pozycjePlanu
    properties:
      idPlanu:
        $ref: '#/definitions/IdPlanuPostepowan'
      czyObowiazekPublikacji:
        type: boolean
        example: false
      rok:
        type: string
        example: '2018'
      pozycjePlanu:
        type: array
        minItems: 1
        items:
          $ref: '#/definitions/PozycjaPlanu'
      dataPublikacji:
        type: string
        format: date-time
  AktualizujPlanPostepowanResponse:
    type: object
    properties:
      dataModyfikacjiPlanu:
        type: string
        format: date-time
      links:
        $ref: '#/definitions/Links'
    example:
      dataModyfikacjiPlanu: '2018-05-07 10:30:00.000'
      links:
        - rel: PobierzPlanPostepowan
          action: GET
          href: /planypostepowan/d1950b7a-0dc6-4881-bfd6-dc7b845a9477
        - rel: AktualizujPlanPostepowan
          action: PUT
          href: /planypostepowan/d1950b7a-0dc6-4881-bfd6-dc7b845a9477
        
  PozycjaPlanu:
    type: object
    properties:
      czyKlauzuleSpoleczne:
        description: Informacja czy w planie postępowania są klauzule społeczne
        type: boolean
      kodCPV:
        $ref: '#/definitions/KodCPV'
      przedmiotZamowienia:
        description: przedmiot zamowienia
        type: string
        example: Przykładowy przedmiot zamówienia
      przewidywanyTerminWszczecia:
        description: przewidywany termin wszczęcia
        type: string
        example: 'II 2018'
      rodzajZamowienia:
        type: string
        enum:
          - roboty budowlane
          - dostawy
          - usługi
        example: dostawy
      ujecieTerminu:
        type: string
        enum:
          - kwartalny
          - miesięczny
      trybZamowienia:
        type: string
        enum:
          - nieograniczony
          - ograniczony
          - negocjacji z ogłoszeniem
          - dialogu konkurencyjnego
          - negocjacji bez ogłoszenia
          - wolnej ręki
          - zapytania o cenę
        example: nieograniczony
      wartoscZamowienia:
        $ref: '#/definitions/WartoscZamowienia'
  WartoscZamowienia:
    type: object
    properties:
      kwota:
        type: number
        format: double
      waluta:
        type: string
      czyNetto:
        type: boolean
    example:
      kwota: 2000000.00
      waluta: PLN
      czyNetto: false
  KodCPV:
    type: object
    required:
      - glowny
    properties:
      glowny:
        type: string
      dodatkowe:
        type: array
        items:
          type: string
  Blad:
    description: Błąd
    type: object
    required:
      - blad
    properties:
      blad:
        type: object
        required:
          - id
          - podsystem
          - kod
          - opis
          - czas
        properties:
          id:
            description: Unikalny identyfikator błędu
            type: string
            format: uuid
          podsystem:
            description: 'ID modułu Platformy, w ramach którego wystąpił błąd'
            type: string
          kod:
            description: Kod błędu
            type: string
          opis:
            description: Opis błędu
            type: string
          czas:
            description: Znacznik czasu wystąpienia błędu
            type: string
            format: date-time
    example:
      blad:
        id: e63bf835-224a-4b3b-a564-160640911f0a
        podsystem: PP
        kod: 123
        opis: Szczegółowy opis błędu
        czas: '2018-04-05T11:51:20.123'
  Links:
    description: Odnośniki do zasobów
    type: array
    items:
      description: Odnośnik
      type: object
      required:
        - rel
        - action
        - href
      properties:
        rel:
          description: Nazwa odnośnika do zasobu
          type: string
        action:
          description: Metoda HTTP
          type: string
          enum:
            - GET
            - POST
            - PUT
            - DELETE
        href:
          description: Adres zasobu
          type: string
