@compeon/compeon-api-js

0.20.0 • Public • Published

compeon-api-js

Installation

yarn add @compeon/compeon-api-js

Usage

import { CompeonAPI } from '@compeon/compeon-api-js'

const client = new CompeonAPI({
  // the URL that the client will perform its requests against
  baseURL: 'https://api.staging.compeon.de',


  // skipAuthentication: false,
  // (optional) Set to true if you want to manage token fetch/refresh and logout yourself

  //skipLogout: false,
  // (optional) Set to true to skip the cookie-based automatic logout

  authConfig: {
    // the URL where the OAuth provider is configured at
    baseUrl: 'https://login.staging.compeon.de',

    // the client ID registered with COMPEON
    clientId: 'your-client-id',

    // configuration for the cookie used for global logout
    loggedInCookieDomain: '.staging.compeon.de',
    loggedInCookieName: 'compeon-logged-in-staging'
  }
})

All options will be passed to axios.create, so you may use transformRequest, transformResponse and all other options you are used to when using axios.

Do something after authentication

The client exposes a callback which is called after successful authentication. You may use this e.g. to bootstrap your application.

client
  .authPromise
  .then(render)

Remove OAuth2 URL Params

You might want to remove the URL params after authenticating. Depending on your setup, you want to alter the location, use a framework router or just truncate the query params

const removeAuthParams = () => {
  const cleanedUrl = new URL(window.location)
  const params = new URLSearchParams(cleanedUrl.search.substring(1))

  const paramsDefined = params.get('code') && params.get('state')
  if (!paramsDefined) return

  params.delete('code')
  params.delete('state')

  cleanedUrl.search = params

  window.history.replaceState({}, '', cleanedUrl)
}

client
  .authPromise
  .then(removeAuthParams)
  .then(...)

API

Table of Contents

AdminDocument

Extends LegacyDocumentResource

AdminDocument resource

allForInquiry

Get all admin documents for a specific inquiry

Parameters
  • config object

    • config.inquiryId string The Id of the inquiry to get all admin documents for
    • config.options object Options that are forwarded to the http client
allForTender

Get all admin documents for a specific tender

Parameters
  • config object

    • config.tenderId string The Id of the tender to get all admin documents for
    • config.options object Options that are forwarded to the http client

Attachment

Extends Resource

Attachment resource

find

Get a specific attachment

Parameters
  • config object

    • config.contextType string the context in which the attachment exists (e.g. inquiry)
    • config.contextId string Id of the specified context (e.g. inquiryId)
    • config.id string Id of the attachment
    • config.options object Options that are forwarded to the http client
all

Get all attachments for a specific context

Parameters
  • config object

    • config.contextType string the context in which the attachment exists (e.g. inquiry)
    • config.contextId string Id of the specified context
    • config.options object Options that are forwarded to the http client
create

Create an attachment in a specific context

Parameters
  • config object

    • config.contextType string the context in which the attachment exists (e.g. inquiry)
    • config.contextId string Id of the specified context
    • config.data object data of the attachment
    • config.options object Options that are forwarded to the http client
delete

Delete an attachment

Parameters
  • config object

    • config.contextType string the context in which the attachment exists (e.g. inquiry)
    • config.contextId string Id of the specified context
    • config.id string Id of the attachment
    • config.options object Options that are forwarded to the http client
update

Create an attachment in a specific context

Parameters
  • config object

    • config.contextType string the context in which the attachment exists (e.g. inquiry)
    • config.contextId string Id of the specified context
    • config.id string Id of the attachment
    • config.data object data to update
    • config.options object Options that are forwarded to the http client
getDocumentAccess

Get all accesses for a specific attachment

Parameters
  • config object

    • config.contextType string the context in which the attachment exists (e.g. inquiry)
    • config.contextId string Id of the specified context
    • config.attachmentId string Id of the attachment
    • config.bankId string id of the related bank
    • config.options object Options that are forwarded to the http client
createDocumentAccess

Create a document access for a specific attachment

Parameters
  • config object

    • config.contextType string the context in which the attachment exists (e.g. inquiry)
    • config.contextId string Id of the specified context
    • config.attachmentId string Id of the attachment
    • config.bankId string id of the related bank
    • config.options object Options that are forwarded to the http client
deleteDocumentAccess

Delete a document access for an attachment

Parameters
  • config object

    • config.contextType string the context in which the attachment exists (e.g. inquiry)
    • config.contextId string Id of the specified context
    • config.attachmentId string Id of the attachment
    • config.id string Id of the access to delete
    • config.options object Options that are forwarded to the http client

Authentication

Extends Resource

Authentication Resource

fetchTokens

fetch OAuth tokens using the authorizaton code

Parameters
  • config object

    • config.code string OAuth2 authorization code
refreshTokens

refresh OAuth tokens using the refresh code

Parameters
  • config object

    • config.refreshCode string OAuth2 refresh code
isSignedInWithCookie

check if the current user is signed in

getCookie

get the current cookie

Bank

Extends Resource

Bank resource

allEmployees

Get all employees for a specific bank

Parameters
  • config object

    • config.bankId string the bank to get the employees for
    • config.options object Options that are forwarded to the http client
inviteEmployee

Invite an employee to a specific bank

Parameters
  • config object

    • config.bankId string of the bank to invite the employee to
    • config.inviterId string id of the inviting user
    • config.data string attributes of the new employee
    • config.options object Options that are forwarded to the http client
deleteEmployee

Delete an employee of a specific bank

Parameters
  • config object

    • config.bankId string the bank to get the employees for
    • config.id string id of the employee
    • config.options object Options that are forwarded to the http client
updateEmployee

Update an employee of a specific bank

Parameters
  • config object

    • config.bankId string the bank to which the updated employee belongs to
    • config.data string The new attributes of the item
    • config.id string id of the employee
    • config.userId string id of the user
    • config.options object Options that are forwarded to the http client
allThatCanSeeTender

Get all banks that are able to see a specific tender

Parameters
  • config object

    • config.tenderId string id of the tender to get all banks for
    • config.options object Options that are forwarded to the http client
find

Get a bank

Parameters
  • config object

    • config.id string id of the bank
    • config.options object Options that are forwarded to the http client
update

Update a bank

Parameters
  • config object

    • config.id string id of the bank
    • config.data object updated data
    • config.options object Options that are forwarded to the http client
requestedDocuments

Get all requested documents of a bank

Parameters
  • config object

    • config.bankId string id of the bank
    • config.options

BankCode

Extends Resource

BankCode resource

all

Get all BankCodes

Parameters
  • config object (optional, default {})

    • config.options object Options that are forwarded to the http client

BankGroup

Extends Resource

BankGroup resource

all

Get all BankGroups

Parameters
  • config object (optional, default {})

    • config.options object Options that are forwarded to the http client

BankGroupCandidate

Extends Resource

BankGroupCandidate resource

BankInquiryNote

Extends Resource

BankInquiryNote resource

find

Get a specific bankInquiryNote

Parameters
  • config object

    • config.inquiryId string id of the inquiry that the note is attached to
    • config.id string Id of the note
    • config.options object Options that are forwarded to the http client
all

Get all notes for a specific inquiry

Parameters
  • config object

    • config.inquiryId string id of the inquiry to get all notes for
    • config.options object Options that are forwarded to the http client
create

Create a note for a specific inquiry

Parameters
  • config object

    • config.inquiryId string id of the inquiry to create a note for
    • config.data object data of the note
    • config.options object Options that are forwarded to the http client
delete

Delete a note

Parameters
  • config object

    • config.inquiryId string id of the inquiry to delete the note for
    • config.id string Id of the note
    • config.options object Options that are forwarded to the http client
update

Update a note

Parameters
  • config object

    • config.inquiryId string Id of the inquiry to udpate a note for
    • config.id string Id of the note
    • config.data object data to update
    • config.options object Options that are forwarded to the http client

BankTag

Extends Resource

BankTag resource

all

Get all BankTags

Parameters
  • config object (optional, default {})

    • config.options object Options that are forwarded to the http client

BankVisibility

Extends Resource

BankVisibility resource

all

Get all BankVisibilities

Parameters
  • config object (optional, default {})

    • config.options object Options that are forwarded to the http client

BankVisibilityParameterSet

Extends Resource

BankVisibilityParameterSet resource

all

Get all BankVisibilityParameterSets

Parameters
  • config object

    • config.bankId string bankId to fetch the parametersets for
    • config.options object Options that are forwarded to the http client

Questionnaire

Extends Resource

Questionnaire Resource

resourcePath

Returns string questionnaire resource path

serializer

Returns function questionnaire serializer

allItems

Get all items for a specific questionnaire

Parameters
  • config object

    • config.id string The Id of the questionnaire to get the items for
    • config.options object Options that are forwarded to the http client
createItem

Create an questionnaire item for a specific questionnaire

Parameters
  • config object

    • config.questionnaireId string The id of the questionnaire to create the item for
    • config.data string The attributes of the item
    • config.options object Options that are forwarded to the http client
updateItem

Update the item of an specific questionnaire

Parameters
  • config object

    • config.questionnaireId string The id of the questionnaire to which the item belongs
    • config.id string The id of the item to update
    • config.data string The new attributes of the item
    • config.options object Options that are forwarded to the http client
deleteItem

Delete the item of a specific questionnaire

Parameters
  • config object

    • config.questionnaireId string The id of the questionnaire to which the item belongs
    • config.id string The id of the item to delete
    • config.options object Options that are forwarded to the http client

Tender

Extends Resource

Tender resource

Readme

Keywords

none

Package Sidebar

Install

npm i @compeon/compeon-api-js

Weekly Downloads

6

Version

0.20.0

License

ISC

Unpacked Size

200 kB

Total Files

4

Last publish

Collaborators

  • apaessler
  • dlandry
  • lgreiving
  • janb
  • compeonnpm
  • bahrens
  • florian-compeon
  • dominikfischer86
  • jbelovs
  • stphnrdmr