OrganizationApi
You need the organization:manage
scope to access this API.
For ease of use we recommend using the User
object for interaction instead.
Interfaces
RoleReference
RoleReference
interface RoleReference {
name: string,
id: string
}
MembershipInfo
MembershipInfo
interface MembershipInfo {
roles: RoleReference[],
firstName: string,
lastName: string,
email: string,
organizationId: number,
membershipId: string,
userId: string
}
OrganizationCreateDetails
OrganizationCreateDetails
interface OrganizationCreateDetails {
name: string,
website: string,
address: string,
uniqueId: string,
taxNumber: string,
city: string,
countryCode: string,
zipCode: string,
state?: string
}
OrganizationUpdateDetails
OrganizationUpdateDetails
interface OrganizationUpdateDetails {
name?: string,
website?: string,
address?: string,
uniqueId?: string,
taxNumber?: string,
city?: string,
countryCode?: string,
zipCode?: string,
state?: string
}
OrganizationInfo
OrganizationInfo
interface OrganizationInfo {
memberships: OrganizationMembershipReference[],
id: number,
name: string,
website: string,
address: string,
uniqueId?: string,
taxNumber: string,
city: string,
country: {
alpha2: string,
name: string
},
zipCode: string,
state: string,
verified: boolean,
created: number
}
OrganizationMembershipReference
OrganizationMembershipReference
interface OrganizationMembershipReference {
organizationId: number,
membershipId: string,
userId: string
}
Methods
constructor(user, endpoint)
constructor(user, endpoint)
Create an Organization API object.
user
should be an instance of theUser
object.endpoint
should be the Vulos Identity endpoint.
const organizationApi = new OrganizationApi(user, endpoint)
async organizationList()
async organizationList()
Get a list of all the organizations that the user is in.
The result is an array of objects that implement the OrganizationMembershipReference
.
for (const membership of await organizationApi.organizationList()) {
// do something with the membership
}
async organizationInfo(id)
async organizationInfo(id)
Get information of an organization by the organization's ID.
The result implements the OrganizationInfo
interface.
const info = await organizationApi.organizationInfo(organizationId)
async organizationUpdate(id, details)
async organizationUpdate(id, details)
Update an organization's details.
The details
object implements the OrganizationUpdateDetails
interface.
The result implements the SuccessResponse
interface.
const response = await organizationApi.organizationUpdate(organizationId, {name: 'New Organization Name'})
if (response.success) {
// the organization's name was updated successfully
}
async organizationDelete(id)
async organizationDelete(id)
Delete an organization.
The result implements the SuccessResponse
interface.
const response = await organizationApi.organizationDelete(organizationId)
if (response.success) {
// successfully deleted the organization
}
async organizationCreate(details)
async organizationCreate(details)
Create a new organization.
The details
object implements the OrganizationCreateDetails
interface.
The result implements the OrganizationMembershipReference
interface.
const membership = await organizationApi.organizationCreate({
name: 'My Organization',
website: 'https://example.com',
address: 'Example St. 1234',
uniqueId: '1234-567-89',
city: 'Example City',
countryCode: 'AQ',
zipCode: '1234',
// state: 'Optional State'
})
async memberInfo(id, member)
async memberInfo(id, member)
Get information about a specific member.
id
is the organization id;member
is the membership id;
The result implements the MembershipInfo
interface.
const memberInfo = await organizationApi.memberInfo(organizationId, membershipId)
async memberDelete(id, member)
async memberDelete(id, member)
Remove a member from an organization.
The result implements the SuccessResponse
interface.
const response = await organizationApi.memberDelete(organizationId, membershipId)
if (response.success) {
// successfully deleted the membership
}
async memberInvite(id, email)
async memberInvite(id, email)
Invite a user to an organization by email.
The result implements the SuccessResponse
interface.
const response = await organizationApi.memberInvite(organizationId, email)
if (response.success) {
// successfully invited the member
}
async roleList(id, member)
async roleList(id, member)
Get all the roles for a member.
The result is an array of objects that implement the RoleReference
interface.
const roles = await organizationApi.roleList(organizationId, membershipId)
for(const role of roles) {
// do something with the role
}
async roleCreate(id, member, name)
async roleCreate(id, member, name)
Add a new role to a user.
The result implements the RoleReference
interface.
const role = await organizationApi.roleCreate(organizationId, membershipId, "Admin")
async roleDelete(id, member, role)
async roleDelete(id, member, role)
Remove a role from a member.
role
is the role id;
The result implements the SuccessResponse
interface.
const response = await organizationApi.roleDelete(organizationId, membershipId, roleId)
if (response.success) {
// successfully deleted the role
}
Last updated