OrganizationApi

This class implements BaseApi.

You need the organization:manage scope to access this API.

This is a JavaScript implementation of the Organization API.

For ease of use we recommend using the User object for interaction instead.

Interfaces

RoleReference

interface RoleReference {
    name: string,
    id: string
}

MembershipInfo

interface MembershipInfo {
    roles: RoleReference[],
    firstName: string,
    lastName: string,
    email: string,
    organizationId: number,
    membershipId: string,
    userId: string
}

OrganizationCreateDetails

interface OrganizationCreateDetails {
    name: string,
    website: string,
    address: string,
    uniqueId: string,
    taxNumber: string,
    city: string,
    countryCode: string,
    zipCode: string,
    state?: string
}

OrganizationUpdateDetails

interface OrganizationUpdateDetails {
    name?: string,
    website?: string,
    address?: string,
    uniqueId?: string,
    taxNumber?: string,
    city?: string,
    countryCode?: string,
    zipCode?: string,
    state?: string
}

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

interface OrganizationMembershipReference {
    organizationId: number,
    membershipId: string,
    userId: string
}

Methods

constructor(user, endpoint)

Create an Organization API object.

  • user should be an instance of the User object.

  • endpoint should be the Vulos Identity endpoint.

const organizationApi = new OrganizationApi(user, endpoint)

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.

This method's response has the organization:list cache prefix.

for (const membership of await organizationApi.organizationList()) {
    // do something with the membership
}

async organizationInfo(id)

Get information of an organization by the organization's ID.

The result implements the OrganizationInfo interface.

This method's response has the organization:info cache prefix.

const info = await organizationApi.organizationInfo(organizationId)

async organizationUpdate(id, details)

Update an organization's details.

The details object implements the OrganizationUpdateDetails interface.

The result implements the SuccessResponse interface.

This method's response has the organization:update cache prefix.

const response = await organizationApi.organizationUpdate(organizationId, {name: 'New Organization Name'})
if (response.success) {
    // the organization's name was updated successfully
}

async organizationDelete(id)

Delete an organization.

The result implements the SuccessResponse interface.

This method's response has the organization:delete cache prefix.

const response = await organizationApi.organizationDelete(organizationId)
if (response.success) {
    // successfully deleted the organization
}

async organizationCreate(details)

Create a new organization.

The details object implements the OrganizationCreateDetails interface.

The result implements the OrganizationMembershipReference interface.

This method's response has the organization:create cache prefix.

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)

Get information about a specific member.

  • id is the organization id;

  • member is the membership id;

The result implements the MembershipInfo interface.

This method's response has the organization:member:info cache prefix.

const memberInfo = await organizationApi.memberInfo(organizationId, membershipId)

async memberDelete(id, member)

Remove a member from an organization.

The result implements the SuccessResponse interface.

This method's response has the organization:member:delete cache prefix.

const response = await organizationApi.memberDelete(organizationId, membershipId)
if (response.success) {
    // successfully deleted the membership
}

async memberInvite(id, email)

Invite a user to an organization by email.

The result implements the SuccessResponse interface.

This method's response has the organization:member:invite cache prefix.

const response = await organizationApi.memberInvite(organizationId, email)
if (response.success) {
    // successfully invited the member
}

async roleList(id, member)

Get all the roles for a member.

The result is an array of objects that implement the RoleReference interface.

This method's response has the organization:role:list cache prefix.

const roles = await organizationApi.roleList(organizationId, membershipId)
for(const role of roles) {
    // do something with the role
}

async roleCreate(id, member, name)

Add a new role to a user.

The result implements the RoleReference interface.

This method's response has the organization:role:create cache prefix.

const role = await organizationApi.roleCreate(organizationId, membershipId, "Admin")

async roleDelete(id, member, role)

Remove a role from a member.

  • role is the role id;

The result implements the SuccessResponse interface.

This method's response has the organization:role:delete cache prefix.

const response = await organizationApi.roleDelete(organizationId, membershipId, roleId)
if (response.success) { 
    // successfully deleted the role
}

Last updated