Home Manual Reference Source
import VisWiz from 'viswiz-sdk/dist/sdk.js'
public class | source

VisWiz

Constructor Summary

Public Constructor
public

constructor(apiKey: string, options: object)

Member Summary

Public Members
public

apiKey: *

public

server: *

Method Summary

Public Methods
public

async buildFolder(build: object, folderPath: string, progressCallback: function, concurrency: number): Promise

Creates a new build and uploads all images (*.png) found in a folder (scanned recursively)

public

buildWithImages(build: *, folderPath: *, progressCallback: *, concurrency: *): *

Alias for buildFolder

public

createBuild(build: object): Promise

Create a new build for a project.

public

createImage(buildID: string, name: string, filePath: string): Promise

Upload a new image for a build.

public

createProject(params: object): Promise

Create a new project for the account.

public

createWebhook(params: object): Promise

When a build comparison is finished a POST HTTP request will be triggered towards all webhooks configured for the account.

public

finishBuild(buildID: string): Promise

Finish a build when all images have been created.

public

getAccount(): Promise

Get the current account information

public

getBuildResults(buildID: string): Promise

Get the results for a build which has been compared to another build.

public

getBuilds(projectID: string): Promise

Get a list of all the builds for a project.

public

getImages(buildID: string): Promise

Get a list of all images for a build.

public

getProject(projectID: string): Promise

Get a list of all the projects for the account.

public

getProjectNotifications(projectID: string): Promise

Get the notifications settings for a project.

public

getProjects(): Promise

Get a list of all the projects for the account.

public

getWebhooks(): Promise

Get the list of webhooks configured for the account.

public

updateProjectNotifications(projectID: string, params: object): Promise

Update the notifications settings for a project.

Public Constructors

public constructor(apiKey: string, options: object) source

Params:

NameTypeAttributeDescription
apiKey string
  • optional

The API Key value for a VisWiz.io account

If omitted, the environment variable VISWIZ_API_KEY will be used

options object
  • optional
options.server string
  • optional
  • default: https://api.viswiz.io

The server URL prefix for all requests

Example:

const client = new VisWiz('your-unique-api-key-here');

// Assuming environment variable VISWIZ_API_KEY is set
const client = new VisWiz();

Public Members

public apiKey: * source

public server: * source

Public Methods

public async buildFolder(build: object, folderPath: string, progressCallback: function, concurrency: number): Promise source

Creates a new build and uploads all images (*.png) found in a folder (scanned recursively)

Params:

NameTypeAttributeDescription
build object
build.branch string

The branch name for this build

build.projectID string

The requested project ID

build.name string

The commit name for this build

build.revision string

The revision for this build

folderPath string
progressCallback function
  • optional

called with parameters: (current, total)

concurrency number
  • optional

The amount of concurrent images to upload (defaults to 4)

Return:

Promise

Example:

await client.buildFolder({
  branch: 'master',
  projectID: 'mwwuciQG7ETAmKoyRHgkGg',
  name: 'New amazing changes',
  revision: '62388d1e81be184d4f255ca2354efef1e80fbfb8'
}, '/path/to/folder/with/images');

public buildWithImages(build: *, folderPath: *, progressCallback: *, concurrency: *): * source

Alias for buildFolder

Params:

NameTypeAttributeDescription
build *
folderPath *
progressCallback *
concurrency *

Return:

*

public createBuild(build: object): Promise source

Create a new build for a project.

Params:

NameTypeAttributeDescription
build object
build.branch string

The branch name for this build

build.projectID string

The requested project ID

build.name string

The commit name for this build

build.revision string

The revision for this build

Return:

Promise

Example:

const build = await client.createBuild({
  branch: 'master',
  projectID: 'mwwuciQG7ETAmKoyRHgkGg',
  name: 'New amazing changes',
  revision: '62388d1e81be184d4f255ca2354efef1e80fbfb8'
});

public createImage(buildID: string, name: string, filePath: string): Promise source

Upload a new image for a build. This endpoint accepts only one PNG image per request.

Params:

NameTypeAttributeDescription
buildID string

The requested build ID

name string

The image name

filePath string

The image file path

Return:

Promise

Example:

const image = await client.createImage('gjVgsiWeh4TYVseqJsU6ev', 'image-name', '/path/to/image.png');

public createProject(params: object): Promise source

Create a new project for the account.

Params:

NameTypeAttributeDescription
params object

Return:

Promise

Example:

const project = await client.createProject({
  baselineBranch: 'master',
  name: 'My Amazing Project',
  url: 'http://github.com/amaze/project'
});

public createWebhook(params: object): Promise source

When a build comparison is finished a POST HTTP request will be triggered towards all webhooks configured for the account.

Params:

NameTypeAttributeDescription
params object

Return:

Promise

Example:

const webhook = await client.createWebhook({
  name: 'My first webhook',
  url: 'http://amazing.com/webhook-handler'
});

public finishBuild(buildID: string): Promise source

Finish a build when all images have been created. This triggers the actual build comparison to execute.

Params:

NameTypeAttributeDescription
buildID string

The requested build ID

Return:

Promise

Example:

await client.finishBuild('gjVgsiWeh4TYVseqJsU6ev');

public getAccount(): Promise source

Get the current account information

Return:

Promise

Example:

const account = await client.getAccount();

public getBuildResults(buildID: string): Promise source

Get the results for a build which has been compared to another build.

Params:

NameTypeAttributeDescription
buildID string

The requested build ID

Return:

Promise

Example:

const buildResults = await client.getBuildResults('gjVgsiWeh4TYVseqJsU6ev');

public getBuilds(projectID: string): Promise source

Get a list of all the builds for a project.

Params:

NameTypeAttributeDescription
projectID string

The requested project ID

Return:

Promise

Example:

const builds = await client.getBuilds('mwwuciQG7ETAmKoyRHgkGg');

public getImages(buildID: string): Promise source

Get a list of all images for a build.

Params:

NameTypeAttributeDescription
buildID string

The requested build ID

Return:

Promise

Example:

const images = await client.getImages('gjVgsiWeh4TYVseqJsU6ev');

public getProject(projectID: string): Promise source

Get a list of all the projects for the account.

Params:

NameTypeAttributeDescription
projectID string

The requested project ID

Return:

Promise

Example:

const project = await client.getProject(projectID);

public getProjectNotifications(projectID: string): Promise source

Get the notifications settings for a project.

Params:

NameTypeAttributeDescription
projectID string

The requested project ID

Return:

Promise

Example:

const notifications = await client.getProjectNotifications('mwwuciQG7ETAmKoyRHgkGg');

public getProjects(): Promise source

Get a list of all the projects for the account.

Return:

Promise

Example:

const projects = await client.getProjects();

public getWebhooks(): Promise source

Get the list of webhooks configured for the account.

Return:

Promise

Example:

const webhooks = await client.getWebhooks();

public updateProjectNotifications(projectID: string, params: object): Promise source

Update the notifications settings for a project.

Params:

NameTypeAttributeDescription
projectID string

The requested project ID

params object
params.emailEnabled string
  • optional

Controls if email reports are sent on new builds

params.slackEnabled string
  • optional

Controls if Slack notifications are sent on new builds

params.slackURL string
  • optional

The Slack webhook URL to use for sending notifications

Return:

Promise

Example:

const build = await client.updateProjectNotifications('mwwuciQG7ETAmKoyRHgkGg', {
  emailEnabled: false,
  slackEnabled: true,
  slackURL: 'https://hooks.slack.com/services/FOO/BAR/A18759GACAsgawg351ac',
});