0.0.1 • Published 4 years ago

clik v0.0.1

Weekly downloads
6
License
MIT
Repository
github
Last release
4 years ago

clik build status codecov

WIP

Install

$ npm install --save clik

Usage

import * as clik from 'clik';

// setup client
const client = clik.setup('<insert apikey secret>', 'ApiKey');

// interact w/ API, passing client

await clik.exists(client, 'foobar');
//=> true | false

await clik.create(client, 'https://...');
//=> { uid: "<generated>", href: "https://...", ... }

await clik.create(client, 'https://...', 'desired');
//=> { uid: "desired", href: "https://...", ... }

await clik.update(client, 'desired', 'https://<new link>');
//=> { uid: "desired", href: "https://<new link>", ... }

const links = await clik.list(client);
//=> [{ uid: "desired", ...}, { uid: "<generated>", ...}]

API

clik.setup(token, type?)

Returns: ClikIO.Client

The HTTP client prepared to interact with the Clik.io API.

token

Type: string

The value of your Bearer or ApiKey token.

Important: Keep this value secret!

type

Type: Enum Default: Bearer Values: Bearer or ApiKey

The kind of token you are providing.

Please note that Bearer tokens have an expiration date, thus making them more secure. You should use an ApiKey token for long-lived albeit less secure access.

clik.exists(client, uid)

Returns: Promise<boolean>

Checks if a ClikIO.Link already exists using the uid value.

client

Type: ClikIO.Client

The prepared client via clik.setup.

uid

Type: string

The desired uid value to check.

clik.list(client)

Returns: Promise<ClikIO.Link[]>

Returns a list of ClikIO.Links that belong to the authenticated user.

client

Type: ClikIO.Client

The prepared client via clik.setup.

clik.create(client, href, uid?)

Returns: Promise<ClikIO.Link>

Creates a new ClikIO.Link with the target href destination.

client

Type: ClikIO.Client

The prepared client via clik.setup.

href

Type: string

The target destination.

uid

Type: string Optional: true

The desired uid value to reserve.

Note: When an undefined, a unique uid value will be generated.

clik.update(client, uid, href)

Returns: Promise<ClikIO.Link>

Updates the href property of an existing ClikIO.Link – but only if the authenticated user owns it!

client

Type: ClikIO.Client

The prepared client via clik.setup.

uid

Type: string

The uid value of an existing ClikIO.Link.

href

Type: string

The updated target destination.

License

MIT © Luke Edwards

0.0.1

4 years ago

0.0.0

5 years ago