@compeon/compeon-api-js
v0.20.0
Published
A JS client for the COMPEON API.
Downloads
185
Maintainers
Keywords
Readme
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
- Attachment
- Authentication
- Bank
- BankCode
- BankGroup
- BankGroupCandidate
- BankInquiryNote
- BankTag
- BankVisibility
- BankVisibilityParameterSet
- Questionnaire
- Tender
AdminDocument
Extends LegacyDocumentResource
AdminDocument resource
allForInquiry
Get all admin documents for a specific inquiry
Parameters
config
object
allForTender
Get all admin documents for a specific tender
Parameters
config
object
Attachment
Extends Resource
Attachment resource
find
Get a specific attachment
Parameters
config
object
all
Get all attachments for a specific context
Parameters
config
object
create
Create an attachment in a specific context
Parameters
config
object
delete
Delete an attachment
Parameters
config
object
update
Create an attachment in a specific context
Parameters
config
object
getDocumentAccess
Get all accesses for a specific attachment
Parameters
config
object
createDocumentAccess
Create a document access for a specific attachment
Parameters
config
object
deleteDocumentAccess
Delete a document access for an attachment
Parameters
config
object
Authentication
Extends Resource
Authentication Resource
fetchTokens
fetch OAuth tokens using the authorizaton code
Parameters
refreshTokens
refresh OAuth tokens using the refresh code
Parameters
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
inviteEmployee
Invite an employee to a specific bank
Parameters
config
object
deleteEmployee
Delete an employee of a specific bank
Parameters
config
object
updateEmployee
Update an employee of a specific bank
Parameters
config
object
allThatCanSeeTender
Get all banks that are able to see a specific tender
Parameters
config
object
find
Get a bank
Parameters
config
object
update
Update a bank
Parameters
config
object
requestedDocuments
Get all requested documents of a bank
Parameters
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
all
Get all notes for a specific inquiry
Parameters
config
object
create
Create a note for a specific inquiry
Parameters
config
object
delete
Delete a note
Parameters
config
object
update
Update a note
Parameters
config
object
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
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
createItem
Create an questionnaire item for a specific questionnaire
Parameters
config
object
updateItem
Update the item of an specific questionnaire
Parameters
config
object
deleteItem
Delete the item of a specific questionnaire
Parameters
config
object
Tender
Extends Resource
Tender resource