/api/administrator/organizations/invitations-count (GET)
await global.api.administrator.organizations.InvitationsCount.get(req) Located in Organizations module API
Returns integer
Exceptions
These exceptions are thrown (NodeJS) or returned as JSON (HTTP) if you provide incorrect data or do not meet the requirements:
Exception | Circumstances |
---|
NodeJS source (edit on github)
If you see a problem with the source submit a pull request on Github.
const organizations = require('../../../../../index.js')
module.exports = {
get: async (req) => {
let index
if (req.query) {
if (req.query.accountid) {
index = `${req.appid}/account/invitations/${req.query.accountid}`
} else if (req.query.organizationid) {
index = `${req.appid}/organization/invitations/${req.query.organizationid}`
}
}
index = index || `${req.appid}/invitations`
return organizations.StorageList.count(index)
}
}
Test source (edit on github)
Tests perform real HTTP requests against a running Dashboard server.
/* eslint-env mocha */
const assert = require('assert')
const TestHelper = require('../../../../../test-helper.js')
describe('/api/administrator/organizations/invitations-count', () => {
describe('returns', () => {
it('integer', async () => {
const administrator = await TestHelper.createOwner()
for (let i = 0, len = global.pageSize + 1; i < len; i++) {
const owner = await TestHelper.createUser()
global.userProfileFields = ['display-name', 'display-email']
await TestHelper.createProfile(owner, {
'display-name': owner.profile.firstName,
'display-email': owner.profile.contactEmail
})
await TestHelper.createOrganization(owner, {
email: owner.profile.displayEmail,
name: 'My organization',
profileid: owner.profile.profileid
})
await TestHelper.createInvitation(owner)
}
const req = TestHelper.createRequest('/api/administrator/organizations/invitations-count')
req.account = administrator.account
req.session = administrator.session
req.filename = __filename
req.saveResponse = true
const result = await req.get()
assert.strictEqual(result, global.pageSize + 1)
})
})
})