1.7.0 • Published 10 months ago

@goparrot/square-connect-plus v1.7.0

Weekly downloads
94
License
MIT
Repository
github
Last release
10 months ago

Build Status Coverage Status NPM version Greenkeeper badge Commitizen friendly Conventional Commits

Square Connect Plus

Square Connect Plus is a Typescript library which extends the official Square Connect APIs library with additional functionality

Installation

$ npm i @goparrot/square-connect-plus square-connect

Usage

Simple example

import { SquareClient } from '@goparrot/square-connect-plus'; 
import { ListLocationsResponse } from 'square-connect';

const accessToken: string = `${process.env.SQUARE_ACCESS_TOKEN}`;
const squareClient: SquareClient = new SquareClient(accessToken);

(async () => {
    try {
        const listLocationsResponse: ListLocationsResponse = await squareClient.getLocationsApi().listLocations();
        if (listLocationsResponse.errors) {
            throw new Error(`cant fetch locations`);
        }

        console.info('locations', listLocationsResponse.locations);
    } catch (err) {
        console.error(err);
    }
})();

Advanced example

import { SquareClient, exponentialDelay, ILogger } from '@goparrot/square-connect-plus'; 
import { ListLocationsResponse } from 'square-connect';

const accessToken: string = `${process.env.SQUARE_ACCESS_TOKEN}`;
const squareClient: SquareClient = new SquareClient(accessToken, {
    retry: {
        maxRetries: 6, 
        retryDelay: exponentialDelay,
    },
    originClient: {
        timeout: 10000,
    },
    logger: console,
});

Available Options

retry Options

NameTypeDefaultDescription
maxRetriesNumber3The number of times to retry before failing.
retryDelayFunctionexponentialDelayA callback to further control the delay between retried requests. By default, the built-in exponentialDelay function is used (Exponential Backoff). The function is passed retryCount and error.

originClient Options

A set of possible settings for the original library.

| --- | --- | --- | --- | | basePath | String | https://connect.squareup.com | The base URL against which to resolve every API call's (relative) path. | | defaultHeaders | Array | { 'User-Agent': 'Square-Connect-Javascript/2.20191217.0' } | The default HTTP headers to be included for all API calls. | | timeout | Number | 15000 | The default HTTP timeout for all API calls. | | cache | Boolean | true | If set to false an additional timestamp parameter is added to all API GET calls to prevent browser caching. | | enableCookies | Boolean | false | If set to true, the client will save the cookies from each server response, and return them in the next request. |

logger Option

By default, the built-in NullLogger class is used. You can use any logger that fits the built-in ILogger interface

Versioning

Square Connect Plus follows Semantic Versioning.

Contributing

See CONTRIBUTING file.

Unit Tests

In order to run the test suite, install the development dependencies:

$ npm i

Then, run the following command:

$ npm run coverage

License

Square Connect Plus is MIT licensed.

1.8.0-dev.gc-3830.0

10 months ago

1.7.0

1 year ago

1.6.0-dev.7277.2

2 years ago

1.6.1

2 years ago

1.2.0

2 years ago

1.5.2-dev-7252.0

2 years ago

1.6.0

2 years ago

1.4.0

2 years ago

1.3.0-dev.7073.0

2 years ago

1.5.2

2 years ago

1.5.1

2 years ago

1.2.0-dev-7201.3

2 years ago

1.5.0

2 years ago

1.2.0-dev-7201.1

2 years ago

1.3.0

2 years ago

1.2.0-dev-7201.0

2 years ago

1.1.0-dev.7073.0

2 years ago

1.1.0-dev.gc.0

2 years ago

1.1.0-dev.gc.1

2 years ago

1.1.0

2 years ago

1.0.0-dev.6755.0

2 years ago

1.0.0

2 years ago

0.4.0-dev-6205.0

2 years ago

0.4.0-dev-6205.1

2 years ago

0.5.0-dev-6619.2

2 years ago

0.5.0-dev-6619.3

2 years ago

0.5.0-dev-6619.4

2 years ago

0.5.0-dev-6619.5

2 years ago

0.5.0-dev-6619.6

2 years ago

0.5.0-dev-6619.7

2 years ago

0.5.0-dev-6619.8

2 years ago

0.5.0-dev-6619.0

2 years ago

0.5.0-dev-6619.1

2 years ago

0.4.0

3 years ago

0.3.1

3 years ago

0.2.0-dev-5420.0

3 years ago

0.3.0

3 years ago

0.2.0

3 years ago

0.1.0-dev-4397.5

3 years ago

0.1.0-dev-4397.4

3 years ago

0.1.0-dev-4397.2

3 years ago

0.1.0-dev-3201.1

3 years ago

0.1.0-dev-3201.0

3 years ago

0.1.0

3 years ago

0.1.0-dev.0

3 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago

0.0.1-dev.4

4 years ago

0.0.1-dev.3

4 years ago

0.0.1-dev.2

4 years ago

0.0.1-dev.1

4 years ago

0.0.1-dev.0

4 years ago