@useshortcut/client 1.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,80 @@
1
+ <p align="center">
2
+ <img height="60" src="https://user-images.githubusercontent.com/7189823/133838642-9a05e1ec-9a79-46ae-b22e-a8b931caf233.png" alt="Shortcut logo">
3
+ </p>
4
+
5
+ <h3 align="center">
6
+ @useshortcut/client
7
+ </h3>
8
+
9
+ <p align="center">
10
+ A library for interacting with the Shortcut (formerly Clubhouse) REST API
11
+ </p>
12
+
13
+ <p align="center">
14
+ <a href="https://www.npmjs.org/package/clubhouse-lib">
15
+ <img src="https://badge.fury.io/js/clubhouse-lib.svg" alt="Current npm package version." />
16
+ </a>
17
+ <a href="https://circleci.com/gh/useshortcut/clubhouse-lib">
18
+ <img src="https://circleci.com/gh/useshortcut/clubhouse-lib.svg?style=shield" alt="Current CircleCI build status." />
19
+ </a>
20
+ <a href="https://circleci.com/gh/useshortcut/clubhouse-lib">
21
+ <img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg" alt="PRs welcome!" />
22
+ </a>
23
+ <a href="https://twitter.com/intent/follow?screen_name=useshortcut">
24
+ <img src="https://img.shields.io/twitter/follow/useshortcut.svg?label=Follow%20@useshortcut" alt="Follow @useshortcut" />
25
+ </a>
26
+ </p>
27
+
28
+ <br>
29
+
30
+ ## Getting Started
31
+
32
+ ### Installation
33
+
34
+ You can install `@useshortcut/client` with [NPM](https://www.npmjs.com/) or [Yarn](https://yarnpkg.com).
35
+
36
+ ```shell
37
+ npm install --save @useshortcut/client
38
+ ```
39
+
40
+ or
41
+
42
+ ```shell
43
+ yarn add @useshortcut/client
44
+ ```
45
+
46
+ ### How to Get an API Token
47
+
48
+ The Shortcut API uses token-based authentication, you will need one to use this library.
49
+
50
+ To generate an API token, go to https://app.shortcut.com/settings/account/api-tokens. To make it easier to explore our API, we recommend saving this token as an environment variable in your local dev environment:
51
+
52
+ ```bash
53
+ export SHORTCUT_API_TOKEN="YOUR API TOKEN HERE"
54
+ ```
55
+
56
+ This will allow you to copy and paste many examples in the documentation to try them out.
57
+
58
+ Requests made with a missing or invalid token will get a `401 Unauthorized` response. All requests must be made over HTTPS. Tokens provide complete access to your Shortcut account, **so keep them secure**. Don’t paste them into your source code, use an environment variable instead. For security reasons, we will immediately invalidate any tokens we find have been made public.
59
+
60
+ ## Usage
61
+
62
+ ```javascript
63
+ import { ShortcutApi } from './';
64
+
65
+ const shortcut = new ShortcutApi('YOUR_API_TOKEN'); // See https://github.com/useshortcut/clubhouse-lib#how-to-get-an-api-token
66
+
67
+ shortcut.getCurrentMemberInfo().then((response) => console.log(response?.data));
68
+
69
+ shortcut.listProjects().then((response) => console.log(response?.data));
70
+ ```
71
+
72
+ ## Play with It
73
+
74
+ You can play with it in your web browser with this live playground:
75
+
76
+ - [CodeSandbox](https://codesandbox.io/s/clubhouse-lib-playground-r447i)
77
+
78
+ ## Documentation
79
+
80
+ [Documentation for the REST API](https://shortcut.com/api/rest).
@@ -0,0 +1,5 @@
1
+ import { Api } from './generated/Api';
2
+ import type { ApiConfig } from './generated/http-client';
3
+ export declare class ShortcutApi<SecurityDataType = unknown> extends Api<SecurityDataType> {
4
+ constructor(apiToken: string, config?: ApiConfig<SecurityDataType>);
5
+ }
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __assign = (this && this.__assign) || function () {
18
+ __assign = Object.assign || function(t) {
19
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
20
+ s = arguments[i];
21
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
+ t[p] = s[p];
23
+ }
24
+ return t;
25
+ };
26
+ return __assign.apply(this, arguments);
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.ShortcutApi = void 0;
30
+ var Api_1 = require("./generated/Api");
31
+ var ShortcutApi = /** @class */ (function (_super) {
32
+ __extends(ShortcutApi, _super);
33
+ function ShortcutApi(apiToken, config) {
34
+ if (config === void 0) { config = {}; }
35
+ var _this = this;
36
+ if (apiToken == null || typeof apiToken !== 'string') {
37
+ // eslint-disable-next-line no-console
38
+ console.error('You need to supply an API Token.');
39
+ }
40
+ _this = _super.call(this, __assign({ headers: __assign({ 'Shortcut-Token': apiToken }, config.headers) }, config)) || this;
41
+ return _this;
42
+ }
43
+ return ShortcutApi;
44
+ }(Api_1.Api));
45
+ exports.ShortcutApi = ShortcutApi;