Class Api

Creates new Api instance.

Param

An object with the following keys:

Hierarchy

  • Api

Constructors

Properties

_httpOptions: IHttpOptions
_uriGenerationMode: boolean
serverAcceptsJSON: boolean
Methods: {
    DELETE: string;
    GET: string;
    POST: string;
    PUT: string;
} = ...

Type declaration

  • DELETE: string
  • GET: string
  • POST: string
  • PUT: string

Methods

  • Performs batch call to the API.

    Member Of

    Api

    Parameters

    • uriCollector: ((batchApi) => string[])

      A function which will be invoked with api instance. This instance is special, as all methods there return a url string instead of making a backend call. uriCollector should return an array of uris to be executed in batch. So, for example, one may return [batchApi.metadata(), batchApi.count(...)] from uriCollector. That will mean call metadata() method and then call count() method.

        • (batchApi): string[]
        • Parameters

          Returns string[]

    • Optional isAtomic: false

      Pass true if you want all operations to happen in the same transaction. There is a limitation, however. Atomic batch operations can only return success or error.

    • Optional isConcurrent: boolean

      Requests to the DB are made asynchronously.

    Returns Promise<any[]>

  • Parameters

    • uriCollector: ((batchApi) => string[])
        • (batchApi): string[]
        • Parameters

          Returns string[]

    • Optional isAtomic: true
    • Optional isConcurrent: boolean

    Returns Promise<void>

  • Invalidates the current API key. Call this to be able to retrieve a new one using getApiKey().

    Member Of

    Api

    Returns Promise<void>

    A promise which will resolved if everything went ok and rejected otherwise

  • Copies an existing object with making changes on a copy. Copying is supported only for some objects. The API Explorer page displays which objects support the Copy action.

    Member Of

    Api

    Parameters

    • objCode: string

      One of object codes from API Explorer

    • objID: string

      ID of object to copy

    • updates: object

      Which fields to set on copied object. See API Explorer for the list of available fields for the given objCode.

    • Optional fields: TFields

      Which fields to return. See API Explorer for the list of available fields for the given objCode.

    • Optional options: string[]

      A list of options that are attached to the copy request (object specific)

    Returns Promise<any>

    A promise which will resolved with results if everything went ok and rejected otherwise

  • Used to retrieve number of objects matching given search criteria

    Member Of

    Api

    Parameters

    • objCode: string
    • Optional query: object

      An object with search criteria

    Returns Promise<number>

  • Creates a new object.

    Member Of

    Api

    Parameters

    • objCode: string

      One of object codes from API Explorer

    • params: any

      Values of fields to be set for the new object. See API Explorer for the list of available fields for the given objCode.

    • Optional fields: TFields

      Which fields of newly created object to return. See API Explorer for the list of available fields for the given objCode.

    Returns Promise<any>

    A promise which will resolved with the ID and any other specified fields of newly created object

  • Edits an existing object

    Member Of

    Api

    Parameters

    • objCode: string

      One of object codes from API Explorer

    • objID: string

      ID of object to modify

    • updates: any

      Which fields to set. See API Explorer for the list of available fields for the given objCode.

    • Optional fields: TFields

      Which fields to return. See API Explorer for the list of available fields for the given objCode.

    Returns Promise<any>

    A promise which will resolved with results if everything went ok and rejected otherwise

  • Edit multiple existing objects

    Member Of

    Api

    Parameters

    • objCode: string

      One of object codes from API Explorer

    • updates: any[]

      Array of fields for each object to be edited. See API Explorer for the list of available fields for the given objCode.

    • Optional fields: TFields

      Which fields to return. See API Explorer for the list of available fields for the given objCode.

    Returns Promise<any>

    A promise which will resolved with results if everything went ok and rejected otherwise

  • Executes an action for the given object

    Member Of

    Api

    Parameters

    • objCode: string

      One of object codes from API Explorer

    • objID: string

      ID of object. Optional, pass null or undefined to omit

    • action: string

      An action to execute. A list of allowed actions are available within the API Explorer under "actions" for each object.

    • Optional actionArgs: object

      Optional. Arguments for the action. See API Explorer for the list of valid arguments

    Returns Promise<any>

    A promise which will resolved if everything went ok and rejected otherwise

  • Used for retrieve an object or multiple objects.

    Member Of

    Api

    Parameters

    • objCode: string

      One of object codes from API Explorer

    • objIDs: string | string[]

      Either one or multiple object ids

    • Optional fields: TFields

      Which fields to return. See API Explorer for the list of available fields for the given objCode.

    Returns Promise<any>

    A promise which will resolved with results if everything went ok and rejected otherwise

  • Used to obtain an API key

    Member Of

    Api

    Parameters

    • username: string

      A username in Workfront

    • password: string

      Password to use

    • Optional subdomain: string

      Sub-domain to use

    Returns Promise<string>

    A promise which will resolved with API key if everything went ok and rejected otherwise

  • Returns Headers

  • Logs in into Workfront. Should be a first call to Workfront API. Other calls should be made after this one will be completed.

    Member Of

    Api

    Parameters

    • username: string

      A username in Workfront

    • password: string

      Password to use

    • Optional subdomain: string

      Sub-domain to use

    Returns Promise<any>

    A promise which will resolved with logged in user data if everything went ok and rejected otherwise

  • Logs out from Workfront

    Member Of

    Api

    Returns Promise<void>

    A promise which will resolved if everything went ok and rejected otherwise

  • Retrieves API metadata for an object.

    Member Of

    Api

    Parameters

    • Optional objCode: string

      One of object codes from API Explorer. If omitted will return list of objects available in API.

    • Optional fields: TFields

      Which fields to return.

    Returns Promise<any>

    A promise which will resolved with object metadata if everything went ok and rejected otherwise

  • Executes a named query for the given obj code

    Member Of

    Api

    Parameters

    • objCode: string

      One of object codes from API Explorer

    • query: string

      A query to execute. A list of allowed named queries are available within the API Explorer under "actions" for each object.

    • Optional queryArgs: object

      Optional. Arguments for the action. See API Explorer for the list of valid arguments

    • Optional fields: TFields

      Which fields to return. See API Explorer for the list of available fields for the given objCode.

    Returns Promise<any>

    A promise which will resolved with received data if everything went ok and rejected with error info otherwise

  • Deletes an object

    Member Of

    Api

    Parameters

    • objCode: string

      One of object codes from API Explorer

    • objID: string

      ID of object

    • Optional bForce: boolean

      Pass true to cause the server to remove the specified data and its dependants

    Returns Promise<void>

    A promise which will resolved if everything went ok and rejected otherwise

  • Performs report request, where only the aggregate of some field is desired, with one or more groupings.

    Member Of

    Api

    Parameters

    • objCode: string

      One of object codes from API Explorer

    • query: object

      An object with search criteria and aggregate functions

    • Optional useHttpPost: boolean = false

      Whenever to use POST to send query params

    Returns Promise<any>

    A promise which will resolved with results if everything went ok and rejected otherwise

  • Do the request using Fetch API.

    Member Of

    Api

    Parameters

    • path: string

      URI path where the request calls

    • params: any

      An object with params

    • Optional fields: TFields = []

      Fields to query for the request

    • Optional method: string = Api.Methods.GET

      The method which the request will do (GET|POST|PUT|DELETE)

    Returns Promise<any>

    A promise which will resolved with results if everything went ok and rejected otherwise

  • Used for object retrieval by multiple search criteria.

    Member Of

    Api

    Parameters

    • objCode: string

      One of object codes from API Explorer

    • Optional query: object

      An object with search criteria

    • Optional fields: TFields

      Which fields to return. See API Explorer for the list of available fields for the given objCode.

    • Optional useHttpPost: boolean = false

      Whenever to use POST to send query params

    Returns Promise<any>

    A promise which will resolved with search results if everything went ok and rejected otherwise

  • Sets a current API key for future requests

    Member Of

    Api

    Parameters

    • apiKey: any

    Returns any

    returns the given api key value

  • Sets a sessionID in the headers or removes sessionID if passed argument is undefined

    Member Of

    Api

    Parameters

    • sessionID: any

      sessionID to set

    Returns void

  • Sets a 'X-XSRF-TOKEN' in the headers or removes 'X-XSRF-TOKEN' if passed argument is undefined

    Member Of

    Api

    Parameters

    • Optional xsrfToken: string

      X-XSRF-TOKEN to set

    Returns void

  • Parameters

    • fileContent: any
    • filename: string

    Returns Promise<any>

Generated using TypeDoc