Toggle menu

userLinking_userLinks

This API is intended only for use by GOSS developers as the first stage in user linking product development. It is liable to change and should not be incorporated into production environments with real users.

This API manages the links that can be created between users. All links are of a type created by userLinking_userLinkTypes.

When a userLink is created an ID is returned in the response. This ID is used in all other methods.

Authentication

All requests need the username and password of an iCM user. These can be provided directly or via an API key's "default credentials".

See End Point this Object for information about supplying an API key when calling a worker from an End Point, API Server Security for information about keys and default credentials, and the methods below for examples.

Logging

Creating, deleting and updating links is recorded in iCM's security log.

Methods

Note that all request parameters are passed to the method in a "payload" object. See the examples below.

userLinking_userLinks_create

Creates a userLink record.

Request Parameters

NameTypeDescription
fromUserIntegerRequired. The ID of the user to link from
toUserIntegerRequired. The ID of the user to link to
linkTypeIntegerRequired. The ID of a link type created by userLinking_userLinkTypes
commentStringOptional. An optional comment

function(params, credentials) {
    let userLink = this.callWorkerMethod("icmapi", "userLinking_userLinks_create", {
        payload: {
            fromUser: 69,
            toUser: 44,
            linkType: 8,
            comment: null
        }
    }, {
        options: {
            apiKey: "<Your API Key>"
        }
    });
    return userLink;
}

Response - Success

NameTypeDescription
idIntegerAn ID for the link
fromUserIntegerAs supplied
toUserIntegerAs supplied
linkTypeIntegerAs supplied
commentStringAs supplied

{
    "id": 83,
    "result": {
        "id": 47,
        "fromUser": 69,
        "toUser": 44,
        "linkType": 8,
        "created": "2022-11-30T14:01:43",
        "createdByUser": 74,
        "comment": null
    },
    "jsonrpc": "2.0"
}

Response - Error

MessageDescription
ConflictReturned when the link already exists or if the linkType conflicts with the cardinality rules of existing links (see userLinking_userLinkTypes for an explanation of the rules)
UnprocessableReturned if the fromUser, toUser or linkType don't exist

{
    "id": "_1",
    "error": {
        "code": -32602,
        "data": "Conflict",
        "message": "Conflict"
    },
    "jsonrpc": "2.0"
}

userLinking_userLinks_delete

Deletes a userLink.

Request Parameters

NameTypeDescription
idIntegerRequired. The ID of the userLink to delete

function(params, credentials) {
    let deleteLink = this.callWorkerMethod("icmapi", "userLinking_userLinks_delete", {
        payload: {
            id: 47
        }
    }, {
        "options": {
            apiKey: "<Your API Key>"
        }
    });
    return deleteLink;
}

Response - Success

None.

{
    "result": null,
    "id": "_1",
    "jsonrpc": "2.0"
}

Response - Error

Returned when the userLink couldn't be found.

{
    "id": "_1",
    "error": {
        "code": -32602,
        "data": "NotFound",
        "message": "NotFound"
    },
    "jsonrpc": "2.0"
}

userLinking_userLinks_get

Returns a single userLink by ID.

Request Parameters

NameTypeDescription
idIntegerRequired. The ID of the userLink

function(params, credentials) {
    let userLink = this.callWorkerMethod("icmapi", "userLinking_userLinks_get", {
        payload: {
            id: 45
        }
    }, {
        options: {
            apiKey: "<Your API Key>"
        }
    });
    return userLink;
}

Response - Success

The requested userLink.

NameTypeDescription
idIntegerThe link ID
fromUserIntegerThe ID of the user to linked from
toUserIntegerThe ID of the user to linked to
linkTypeIntegerThe ID of the link type created by userLinking_userLinkTypes
createdStringThe date and time the link was created
createdByUserIntegerThe ID of the iCM user who created this link - this will be the ID of the user supplied as default worker credentials if using an API key
commentStringThe comment added when the link was created

{
    "id": 236,
    "result": {
        "id": 45,
        "fromUser": 44,
        "toUser": 142,
        "linkType": 8,
        "created": "2022-11-30T13:36:17",
        "createdByUser": 74,
        "comment": null
    },
    "jsonrpc": "2.0"
}

userLinking_userLinks_getAll

Gets all userLinks that match the supplied filters and paging.

Request Parameters

NameTypeDescription
filtersObjectOptional. Not setting a filter (or providing an empty filter object) will return all userLinks
filters.fromUsersArray <integer>Returns all of the links from these users
filters.toUsersArray <integer>Returns all of the links to these users
filters.linkTypesArray <integer>Returns all of the links between users of this type
paginationObjectOptional. The start position and length of results to return
pagination.startIntegerThe start position (zero based)
pagination.lengthIntegerThe number to return

This example returns all of the links from the two users.

function(params, credentials) {
    let getAll = this.callWorkerMethod("icmapi", "userLinking_userLinks_getAll", {
        payload: {
            filters: {
                fromUsers: [142, 71]
            },
            pagination: {}
        }
    }, {
        options: {
            apiKey: "<Your API Key>"
        }
    });
    return getAll;
}

This example returns the first two userLinks of type 8.

function(params, credentials) {
    let getAll = this.callWorkerMethod("icmapi", "userLinking_userLinks_getAll", {
        payload: {
            filters: {
                linkTypes: [8]
            },
            pagination: {
                start: 0,
                length: 2
            }
        }
    }, {
        options: {
            apiKey: "<Your API Key>"
        }
    });
    return getAll;
}

Response - Success

An array of userLinks that match the filters and pagination, where each userLink has the following properties.

NameTypeDescription
idIntegerThe link ID
fromUserIntegerThe ID of the user to linked from
toUserIntegerThe ID of the user to linked to
linkTypeIntegerThe ID of the link type created by userLinking_userLinkTypes
createdStringThe date and time the link was created
createdByUserIntegerThe ID of the iCM user who created this link - this will be the ID of the user supplied as default worker credentials if using an API key
commentStringThe comment added when the link was created

{
    "id": 266,
    "result": [{
        "id": 43,
        "fromUser": 142,
        "toUser": 71,
        "linkType": 8,
        "created": "2022-11-30T13:32:13",
        "createdByUser": 74,
        "comment": null
    }, {
        "id": 44,
        "fromUser": 71,
        "toUser": 142,
        "linkType": 8,
        "created": "2022-11-30T13:32:34",
        "createdByUser": 74,
        "comment": null
    }],
    "jsonrpc": "2.0"
}

userLinking_userLinks_update

Updates an existing userLink. The payload is the same as that of create, with the addition of the ID of the userLink to update.

When updating, all existing links to and from the user are checked and the update will fail if the new link's cardinality would violate existing links.

Request Parameters

NameTypeDescription
idIntegerRequired. The ID of the userLink to update
fromUserIntegerRequired. The ID of the user to link from
toUserIntegerRequired. The ID of the user to link to
linkTypeIntegerRequired. The ID of a link type created by userLinking_userLinkTypes
commentStringOptional. An optional comment

function(params, credentials) {
    let userLink = this.callWorkerMethod("icmapi", "userLinking_userLinks_update", {
        payload: {
            "id": 43,
            "fromUser": 69,
            "toUser": 44,
            "linkType": 1,
            "comment": null
        }
    }, {
        options: {
            apiKey: "<Your API Key>"
        }
    });
    return userLink;
}

Response - Success

None.

{
    "result": null,
    "id": "_1",
    "jsonrpc": "2.0"
}

Response - Error

In this example the link didn't exist.

{
    "id": "_1",
    "error": {
        "code": -32602,
        "data": "Unprocessable",
        "message": "Unprocessable"
    },
    "jsonrpc": "2.0"
}

Last modified on November 21, 2023

Share this page

Facebook icon Twitter icon email icon

Print

print icon