Share Groups

A ShareGroup is a way for you to store and name groups of email contacts to be used for sending share and inbox invitations.

List Share Groups

SDK Method

ShareGroup.list()

Return Object

ShareGroup[]

Authorization Requirement

Available to all authenticated keys or sessions.

Method Arguments

ArgumentDescription
user_id
int64
User ID. Provide a value of 0 to operate the current session's user.

Additional Arguments

Example Request

import ShareGroup from 'files.com/lib/models/ShareGroup';
import * as FilesErrors from 'files.com/lib/Errors';

try {
  const shareGroups = await ShareGroup.list({
    user_id: 1,
  });
  for (const shareGroup of shareGroups) {
    // Operate on shareGroup
  }
} catch (err) {
  if (err instanceof FilesErrors.NotAuthenticatedError) {
    console.error(`Authentication Error Occurred (${err.constructor.name}): ${err.error}`);
  } else if (err instanceof FilesErrors.FilesError) {
    console.error(`Unknown Error Occurred (${err.constructor.name}): ${err.error}`);
  } else {
    throw err;
  }
}

Show Share Group

SDK Method

ShareGroup.find()

Return Object

ShareGroup

Authorization Requirement

Available to all authenticated keys or sessions.

Method Arguments

ArgumentDescription
id
int64
Required
Share Group ID.

Example Request

import ShareGroup from 'files.com/lib/models/ShareGroup';
import * as FilesErrors from 'files.com/lib/Errors';

try {
  const shareGroup = await ShareGroup.find(id);
  // Operate on shareGroup
} catch (err) {
  if (err instanceof FilesErrors.NotAuthenticatedError) {
    console.error(`Authentication Error Occurred (${err.constructor.name}): ${err.error}`);
  } else if (err instanceof FilesErrors.FilesError) {
    console.error(`Unknown Error Occurred (${err.constructor.name}): ${err.error}`);
  } else {
    throw err;
  }
}

Create Share Group

SDK Method

ShareGroup.create()

Return Object

ShareGroup

Authorization Requirement

Available to all authenticated keys or sessions.

Method Arguments

ArgumentDescription
user_id
int64
User ID. Provide a value of 0 to operate the current session's user.
notes
string
Additional notes of the share group
name
string
Required
Name of the share group
members
array(object)
Required
A list of share group members.

Example Request

import ShareGroup from 'files.com/lib/models/ShareGroup';
import * as FilesErrors from 'files.com/lib/Errors';

try {
  const shareGroup = await ShareGroup.create({
    name: "Test group 1",
    members: [{"name":"John Doe","company":"Acme Ltd","email":"johndoe@gmail.com"}],
  });
  // Operate on shareGroup
} catch (err) {
  if (err instanceof FilesErrors.NotAuthenticatedError) {
    console.error(`Authentication Error Occurred (${err.constructor.name}): ${err.error}`);
  } else if (err instanceof FilesErrors.FilesError) {
    console.error(`Unknown Error Occurred (${err.constructor.name}): ${err.error}`);
  } else {
    throw err;
  }
}

Update Share Group

SDK Method

shareGroup.update()

Return Object

ShareGroup

Authorization Requirement

Available to all authenticated keys or sessions.

Method Arguments

ArgumentDescription
notes
string
Additional notes of the share group
name
string
Name of the share group
members
array(object)
A list of share group members.

Example Request

import ShareGroup from 'files.com/lib/models/ShareGroup';
import * as FilesErrors from 'files.com/lib/Errors';

try {
  // Find the shareGroup object by its id.
  const shareGroup = await ShareGroup.find(id);
  await shareGroup.update({
    notes: "This group is defined for testing purposes",
  });
} catch (err) {
  if (err instanceof FilesErrors.NotAuthenticatedError) {
    console.error(`Authentication Error Occurred (${err.constructor.name}): ${err.error}`);
  } else if (err instanceof FilesErrors.FilesError) {
    console.error(`Unknown Error Occurred (${err.constructor.name}): ${err.error}`);
  } else {
    throw err;
  }
}

Delete Share Group

SDK Method

shareGroup.delete()

Return Object

No return value.

Authorization Requirement

Available to all authenticated keys or sessions.

Example Request

import ShareGroup from 'files.com/lib/models/ShareGroup';
import * as FilesErrors from 'files.com/lib/Errors';

try {
  // Find the shareGroup object by its id.
  const shareGroup = await ShareGroup.find(id);
  await shareGroup.delete();
} catch (err) {
  if (err instanceof FilesErrors.NotAuthenticatedError) {
    console.error(`Authentication Error Occurred (${err.constructor.name}): ${err.error}`);
  } else if (err instanceof FilesErrors.FilesError) {
    console.error(`Unknown Error Occurred (${err.constructor.name}): ${err.error}`);
  } else {
    throw err;
  }
}

The ShareGroup Object

Some of the methods above return a ShareGroup object. The attributes of this object are listed below.

AttributeDescription
id
int64
Share Group ID
name
string
Name of the share group
notes
string
Additional notes of the share group
user_id
int64
Owner User ID
members
array(object)
A list of share group members