swagger: '2.0'
info:
  version: '1.0'
  title: Otwarty Rejestr Akcjonariuszy API
  license:
    name: "Apache 2.0"
    url: "http://www.apache.org/licenses/LICENSE-2.0.html"
host: 'localhost:8080'
paths:
  /challenge:
    post:
      summary: Wartosc niezbedna do uwierzytelnienia
      consumes:
        - application/json;charset=utf-8
      produces:
        - application/json;charset=utf-8
      parameters:
        - required: true
          schema:
            $ref: '#/definitions/WalletURI'
          in: body
          name: body
      responses:
        '200':
          schema:
            $ref: '#/definitions/Token'
          description: ''
        '400':
          description: Invalid `body`
  /login:
    post:
      summary: Uwierzytelnienie użytkownika
      consumes:
        - application/json;charset=utf-8
      produces:
        - application/json;charset=utf-8
      parameters:
        - name: X-Auth-Token
          in: header
          required: true
          type: string
          description: 'Nagłówek musi zawierac token tymczasowy uzyskany z usługi challenge'
        - required: true
          description: 'Challenge musi zostać podpisany za pomocą klucza prywatnego użytkownika'
          schema:
            $ref: '#/definitions/ChallengeVerification'
          in: body
          name: body
      responses:
        '200':
          schema:
            $ref: '#/definitions/RegularToken'
          description: ''
        '400':
          description: Invalid `body`
  /peers:
    get:
      summary: Lista adresów pozostałych API
      produces:
        - application/json;charset=utf-8
      responses:
        '200':
          schema:
            $ref: '#/definitions/PeersEnvelope'
          description: ''
  /issuers:
    post:
      summary: Lista emitentów
      consumes:
        - application/json;charset=utf-8
      produces:
        - application/json;charset=utf-8
      parameters:
        - name: X-Auth-Token
          in: header
          required: true
          type: string
          description: 'Nagłówek musi zawierac token uzyskany z usługi login'
        - required: true
          schema:
            $ref: '#/definitions/IssuersRequest'
          in: body
          name: body
      responses:
        '200':
          schema:
            $ref: '#/definitions/IssuerEnvelope'
          description: ''
        '400':
          description: Invalid `page`
  /myassets:
    post:
      summary: Lista akcji danej osoby
      consumes:
        - application/json;charset=utf-8
      produces:
        - application/json;charset=utf-8
      parameters:
        - name: X-Auth-Token
          in: header
          required: true
          type: string
          description: 'Nagłówek musi zawierac token uzyskany z usługi login'
        - required: true
          schema:
            $ref: '#/definitions/MyAssetsRequest'
          in: body
          name: body
      responses:
        '200':
          schema:
            $ref: '#/definitions/MyAssetsEnvelope'
          description: ''
        '400':
          description: Invalid `page`
        '404':
          description: '`krs_e_number` not found'
  /registry:
    post:
      summary: Wszystkie dane z rejestru
      consumes:
        - application/json;charset=utf-8
      produces:
        - application/json;charset=utf-8
      parameters:
        - name: X-Auth-Token
          in: header
          required: true
          type: string
          description: 'Nagłówek musi zawierac token uzyskany z usługi login'
        - required: true
          schema:
            $ref: '#/definitions/RegistryRequest'
          in: body
          name: body
      responses:
        '200':
          schema:
            $ref: '#/definitions/RegistryEnvelope'
          description: ''
        '400':
          description: Invalid `krsENumber` or `page`
  /shareholder:
    post:
      summary: Dane dotyczące akcjonariusza
      consumes:
        - application/json;charset=utf-8
      produces:
        - application/json;charset=utf-8
      parameters:
        - name: X-Auth-Token
          in: header
          required: true
          type: string
          description: 'Nagłówek musi zawierac token uzyskany z usługi login'
        - required: true
          schema:
            $ref: '#/definitions/ShareholderRequest'
          in: body
          name: body
      responses:
        '200':
          schema:
            $ref: '#/definitions/ShareholderEnvelope'
          description: ''
        '400':
          description: Invalid `page`
definitions:
  WalletURI:
    required:
      - wallet_address
    properties:
      wallet_address:
        type: string
    type: object
  Token:
    description: Klasa reprezentuje token tymczasowy uzyskany na etapie wnioskowania o challenge.
    required:
      - token
      - api_version
    properties:
      token:
        type: string
      challenge:
        type: string
      api_version:
        type: string
    type: object
  RegularToken:
    description: Klasa reprezentuje regularny token uzyskany na etapie uwierzytelnienia użytkownika, który potrzebny jest do autoryzacji dostępu do pozostałych endpointow.
    required:
      - token
      - api_version
    properties:
      token:
        type: string
      api_version:
        type: string
    type: object
  ChallengeVerification:
    required:
      - challenge
      - signature
    properties:
      challenge:
        type: string
      signature:
        description: Podpis za pomocą klucza prywatnego użytkownika
        type: string   
    type: object
  PeersEnvelope:
    required:
      - allowed_list
      - blocked_list
    properties:
      allowed_list:
        items:
          $ref: '#/definitions/Peer'
        type: array
      blocked_list:
        items:
          $ref: '#/definitions/Peer'
        type: array
    example:
      allowed_list:
        - api_version: v0.1.1
          url: 'https://exasmple.com/api'
      blocked_list:
        - api_version: v0.1.1
          url: 'https://exasmple.com/api'
    type: object
  Peer:
    description: Klasa reprezentuje adresy pozostałych API.
    required:
      - url
      - api_version
    properties:
      url:
        type: string
      api_version:
        type: string
    example:
      api_version: v0.1.1
      url: 'https://exasmple.com/api'
    type: object
  IssuersRequest:
    description: Umożliwia pobranie danych o spółkach, których akcje posiada akcjonariusz odpytujący API.
    required:
      - page
      - items_on_page
    properties:
      page:
        type: integer
      items_on_page:
        type: integer
  IssuerEnvelope:
    required:
      - api_version
      - data
      - page
      - items_on_page
    properties:
      api_version:
        type: string
      data:
        items:
          $ref: '#/definitions/Issuers'
        type: array
      page:
        maximum: 9223372036854776000
        minimum: -9223372036854776000
        type: integer
      page_total:
        maximum: 9223372036854776000
        minimum: -9223372036854776000
        type: integer
    example:
      api_version: v0.1.0
      data:
        - issuer_name: 'Firma'
          issuer_krs_number: 2233232
          issuer_registration_date : '2014-12-03'
          issuer_adress: 'ul. Puławska 15, 03-682 Warszawa'
          issuer_NIP: 5384354
          issuer_regon: 5384354
          number_of_my_assets: 340
          my_share_in_equity: 0.12
      page: 1
      items_on_page: 20
    type: object
  Issuers:
    description: Klasa reprezentuje dane na temat spółek, w których akcje posiada akcjonariusz odpytujący API.
    required:
      - issuer_name
      - issuer_krs_number
    properties:
      issuer_name:
        type: string
      issuer_krs_number:
        type: integer
      issuer_registration_date:
        $ref: '#/definitions/Day'
      issuer_adress:
        type: string
      issuer_regon:
        type: string
      number_of_my_assets:
        type: integer
      my_share_in_equity:
        format: float
        type: number
    example:
        issuer_name: 'Firma'
        issuer_krs_number: 2233232
        issuer_registration_date : '2014-12-03'
        issuer_adress: 'ul. Puławska 15, 03-682 Warszawa'
        issuer_NIP: 5384354
        issuer_regon: 5384354
        number_of_my_assets: 340
        my_share_in_equity: 0.12
  Day:
    example: '2016-07-22'
    format: date
    type: string
  MyAssetsRequest:
    description: Umożliwia pobranie informacji o aktywach danego akcjonariusza w danej spółce.
    required:
      - krs_e_number
      - page
      - items_on_page
    properties:
      page:
        type: integer
      items_on_page:
        type: integer
      krs_e_number:
        type: integer
  MyAssetsEnvelope:
    required:
      - api_version
      - data
      - page
      - item_on_page
    properties:
      api_version:
        type: string
      data:
        items:
          $ref: '#/definitions/MyAssets'
        type: array
      page:
        maximum: 9223372036854776000
        minimum: -9223372036854776000
        type: string
      page_total:
        maximum: 9223372036854776000
        minimum: -9223372036854776000
        type: integer
    example:
      api_version: v0.1.0
      data:
        - emission_date: '2014-12-03'
          series: 'A'
          paper_number_from: 123
          paper_number_to: 125
          isin: 'AXSD'
          paper_ISIN_number: 1200
          nominal_value: 100
          paper_type: 'akcje imienne'
          is_paid: true
          limitations: true
          special_authorizations: true
          addnotations: 'Uprawnienia: dwa głosy na jedną akcję,\nOgraniczenia: blokada komornicza, \nOpłacono 70/100, \nPozostałe: inny tekst'
      page: 1
      items_on_page: 20
  MyAssets:
    description: Klasa reprezentuje informacje o aktywach danego akcjonariusza w danej spółce.
    required:
      - emission_date
      - nominal_value
      - is_paid
    properties:
      emission_date:
        $ref: '#/definitions/Day'
      series:
        type: string
      paper_number_from:
        format: long
        type: number
      paper_number_to:
        format: long
        type: number
      isin:
        type: string
      paper_ISIN_number:
        format: long
        type: number
      nominal_value:
        format: float
        type: number
      paper_type:
        type: string
      is_paid:
        type: boolean
      limitations:
        type: boolean
      special_authorizations:
        type: boolean
      addnotations:
        type: string
    example:
      emission_date: '2014-12-03'
      series: 'A'
      paper_number_from: 123
      paper_number_to: 125
      isin: 'AXSD'
      paper_ISIN_number: 1200
      nominal_value: 100
      paper_type: 'akcje imienne'
      is_paid: true
      limitations: true
      special_authorizations: true
      addnotations: 'Uprawnienia: dwa głosy na jedną akcję,\nOgraniczenia: blokada komornicza, \nOpłacono 70/100, \nPozostałe: inny tekst'
  RegistryRequest:
    description: Umożliwia otrzymanie pełnego zestawu danych z rejestru akcjonariuszy.
    required:
      - page
      - items_on_page
      - krs_e_number
    properties:
      page:
        type: integer
      items_on_page:
        type: integer
      krs_e_number:
        type: integer
  RegistryEnvelope:
    required:
      - api_version
      - data
      - page
      - page_total
    properties:
      api_version:
        type: string
      data:
          $ref: '#/definitions/Registry'
      page:
        maximum: 9223372036854776000
        minimum: -9223372036854776000
        type: integer
      page_total:
        maximum: 9223372036854776000
        minimum: -9223372036854776000
        type: integer
    example:
      api_version: v0.1.0
      data: 
        issuer_name: 'Firma'
        issuer_company_registration_date: '2014-12-03'
        issuer_address: 'ul. Puławska 15, 03-682 Warszawa'
        issuer_nip: 5288294788
        issuer_regon: 438159307
        meta:
            - owner_company: 'Akcjonariusz S.A.'
              owner_name: 'Andrzej, Janusz'
              owner_surname: 'Saski'
              owner_email: 'anjasas@gmail.com'
              owner_adress: 'ul. Gazowana 43, 03-744, Warszawa'
              emission_date: '2014-01-01'
              paper_type: 'akcje imienne'
              series: 'A'
              paper_number_from: 1
              paper_number_to: 2
              ISIN: ZAS127
              paper_ISIN_number: 9892424
              nominal_value: 10.50
              is_paid: true
              limitations: false
              special_authorizations: true
              addnotations: 'Akcje opłacone'
      page: 1
      items_on_page: 20
    type: object
  Registry:
    description: Klasa reprezentuje pełny zestaw danych z rejestru akcjonariuszy.
    required:
      - issuer_name
      - issuer_company_registration_date
      - issuer_address
    properties:
      issuer_name:
        type: string
      issuer_company_registration_date:
        $ref: '#/definitions/Day'
      issuer_address:
        type: string
      issuer_nip:
        type: integer
      issuer_regon:
        type: integer
      meta:
        items:
          $ref: '#/definitions/MetaType'
        type: array
    example:
      issuer_name: 'Firma'
      issuer_company_registration_date: '2014-12-03'
      issuer_address: 'ul. Puławska 15, 03-682 Warszawa'
      issuer_nip: 5288294788
      issuer_regon: 438159307
      meta:
        - owner_company: 'Akcjonariusz S.A.'
          owner_name: 'Andrzej, Janusz'
          owner_surname: 'Saski'
          owner_email: 'anjasas@gmail.com'
          owner_adress: 'ul. Gazowana 43, 03-744, Warszawa'
          emission_date: '2014-01-01'
          paper_type: 'akcje imienne'
          series: 'A'
          paper_number_from: 1
          paper_number_to: 2
          ISIN: ZAS127
          paper_ISIN_number: 9892424
          nominal_value: 10.50
          is_paid: true
          limitations: false
          special_authorizations: true
          addnotations: 'Akcje opłacone'
  MetaType:
    description: Akcje
    required:
      - owner_name
      - owne_surname
      - owner_address
      - emission_date
      - paper_type
      - nominal_value
      - is_paid
      - limitations
      - special_authorizations
    properties:
      owner_company:
        type: string
      owner_name:
        type: string
      owner_surname:
        type: string
      owner_email:
        type: string
      owner_adress:
        type: string
      emission_date:
        $ref: '#/definitions/Day'
      paper_type:
        type: string
      series:
        type: string
      paper_number_from:
        format: long
        type: number
      paper_number_to: 
        format: long
        type: number
      ISIN:
        type: string
      paper_ISIN_number:
        format: long
        type: number
      nominal_value:
        format: float
        type: number
      is_paid:
        type: boolean
      limitations:
        type: boolean
      special_authorizations:
        type: boolean
      addnotations:
        type: string
  ShareholderRequest:
    description: Umożliwia otrzymane danych na temat akcjonariusza odpytującego API.
    required:
      - page
      - items_on_page
    properties:
      page:
        type: integer
      items_on_page:
        type: integer
  ShareholderEnvelope:
    required:
      - api_version
      - data
      - page
      - page_total
    properties:
      api_version:
        type: string
      data:
        $ref: '#/definitions/Shareholder'
      page:
        maximum: 9223372036854776000
        minimum: -9223372036854776000
        type: integer
      page_total:
        maximum: 9223372036854776000
        minimum: -9223372036854776000
        type: integer
    example:
      api_version: v0.1.0
      data:
        shr_company: 'Akcjonariusz S.A.'
        shr_name: 'Andrzej, Janusz'
        shr_surname: 'Saski'
        shr_email: 'anjasas@gmail.com'
        shr_adress: 'ul. Gazowana 43, 03-744, Warszawa'
      page: 1
      page_total: 1
    type: object
  Shareholder:
    description: Klasa reprezentuje dane dotyczace akcjonariusza odpytującego API.
    required:
      - shr_adress
    properties:
      shr_company:
        type: string
      shr_name:
        type: string
      shr_surname:
        type: string
      shr_email:
        type: string
      shr_adress:
        type: string
    example:
      shr_company: 'Akcjonariusz S.A.'
      shr_name: 'Andrzej, Janusz'
      shr_surname: 'Saski'
      shr_email: 'anjasas@gmail.com'
      shr_adress: 'ul. Gazowana 43, 03-744, Warszawa'