bizprint-api

HTTP Print Backend API docs


General request info:

When making GET or DELETE request, along the way we are passing next query parameters:

We are getting hash and time from next function:

const hashData = (queryArgs, secretKey) => {
    return createHash('sha256').update(`${queryArgs.toString()}:${secretKey}`).digest('hex');
};

export const signGetData = (queryArgs, publicKey, secretKey) => {
    queryArgs = new URLSearchParams(queryArgs);
    const time = `${Math.floor(Date.now() / 1000)}`;

    queryArgs.set('publicKey', publicKey);
    queryArgs.set('time', time);

    const hash = hashData(queryArgs.toString(), secretKey);
    queryArgs.set('hash', hash);

    return queryArgs;
};

When making PATCH, POST or PUT request, along the way we are adding next body properties:

And it is also required to pass along in Header:

We are getting hash and time from next function:

const hashData = (data, secretKey) => {
    const json = JSON.stringify(data);

    return createHash('sha256').update(`${json}:${secretKey}`).digest('hex');
};

export const signPostData = (data, publicKey, secretKey) => {
    const time = Math.floor(Date.now() / 1000);

    const dataToSign = {
        ...data,
        publicKey,
        time
    };
    const hash = hashData(dataToSign, secretKey);
    return { ...dataToSign, hash };
};

Job object

Properties


Creating a job

Creates a job for a printer with passed parameters.

HTTP Request

POST https://print.bizswoop.app/api/connect-application/v1/jobs

JSON Body

An object with following properties: 

Returns

Returns JSON object with following properties:

Possible errors

ERR_INVALID_REQUEST:

{
	"errorCode": 'ERR_INVALID_REQUEST',
    "message": "Invalid request fields: url, description",
    "errors": {
        "url": ["Url must be a valid URL"],
        "description":["Description is a required field"]
    }
}

ERR_JOB_CREATING_PRINT_JOB_LIMIT:

ERR_JOB_CREATING_INVALID_PRINTER_ID:

ERR_SOMETHING_WRONG:


Retrieve a Job

Retrieves a job with a given ID.

HTTP Request

GET https://print.bizswoop.app/api/connect-application/v1/jobs/${ID}

Parameters

Returns

Returns JSON object with following properties:

Possible errors

ERR_ACCESS_FORBIDDEN:

ERR_NOT_FOUND:

ERR_SOMETHING_WRONG:


List Jobs

Return a list of jobs.

HTTP Request

GET https://print.bizswoop.app/api/connect-application/v1/jobs?perPage=10&page=3

Query Parameters

Returns

Returns JSON object with following properties:

In header we are passing as well next properties:

Possible errors

ERR_INVALID_REQUEST:

{
    "errorCode": "ERR_INVALID_REQUEST",
    "message": "Invalid request fields: page, perPage",
    "errors": {
        "page": ["Page must be greater than or equal to 1"],
        "perPage":["Per Page must be less than or equal to 100"]
    }
}

ERR_SOMETHING_WRONG:


Station object

Properties


Retrieve a Station

Retrieves a station with a given ID.

HTTP Request

GET https://print.bizswoop.app/api/connect-application/v1/stations/${ID}

Parameters

Returns

Returns JSON object with following properties:

Possible errors

ERR_ACCESS_FORBIDDEN:

ERR_NOT_FOUND:

ERR_SOMETHING_WRONG:


List Stations

Return a list of stations.

HTTP Request

GET https://print.bizswoop.app/api/connect-application/v1/stations?perPage=1

Query Parameters

Returns

Returns JSON object with following properties:

In header we are passing as well next properties:

Possible errors

ERR_INVALID_REQUEST:

{
    "errorCode": "ERR_INVALID_REQUEST",
    "message": "Invalid request fields: page",
    "errors": {
        "page": ["Must be a number"]
    }
}

ERR_SOMETHING_WRONG:


Printer object

Properties


Retrieve a Printer

Retrieves a printer with a given ID.

HTTP Request

GET https://print.bizswoop.app/api/connect-application/v1/printers/${ID}

Parameters

Returns

Returns JSON object with following properties:

Possible errors

ERR_ACCESS_FORBIDDEN:

ERR_NOT_FOUND:

ERR_SOMETHING_WRONG:


List Printers

Return a list of printers.

HTTP Request

GET https://print.bizswoop.app/api/connect-application/v1/printers?perPage=5&page=1

Query Parameters

Returns

Returns JSON object with following properties:

In header we are passing as well next properties:

Possible errors

ERR_INVALID_REQUEST

{
    "errorCode": "ERR_INVALID_REQUEST",
    "message": "Invalid request fields: perPage",
    "errors": {
        "perPage": ["Must be a number"]
    }
}

ERR_SOMETHING_WRONG :


General errors

Typical structure of any error response will be like following:

interface BaseErrorResponse {
	errorCode: string;
	message: string;
}

Errors codes that might occur for any request: