Skip to content
This repository has been archived by the owner on May 29, 2021. It is now read-only.

Commit

Permalink
Drop http-status usage, Auth docs update (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedsakr authored Jan 29, 2021
1 parent 4124876 commit cbba8db
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 21 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ You just need node.js — and npm, obviously.

### Dependencies

The dependency list is tiny — **node-fetch**, **http-status**, and **source-map-support**. They will be automatically installed when you install `wstrade-api` through `npm`.
The dependency list is tiny — **node-fetch** and **source-map-support**. They will be automatically installed when you install `wstrade-api` through `npm`.

### Installing

Expand Down
4 changes: 2 additions & 2 deletions dist.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/auth/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ auth.login(email, password) -> Promise<void>
Attempts to login to the Wealthsimple Trade platform using the email and password combination.
If the login was successful, `auth.tokens` will be populated with the retrieved OAuth2.0 tokens and access token expiry time. Otherwise, the return promise is rejected with the appropriate error.

An OTP provider must be configured beforehand with the auth.`on` API for the `otp` event. If the `otp` event was registered with a string literal, it is assumed that you have already obtained the OTP manually and it will be passed along as-is. Otherwise, if you specified a function handler, it is assumed that your handler will automatically retrieve the OTP after we attempt a login without an OTP. See examples for practical explanation.
An OTP provider must be configured beforehand with the auth.`on` API for the `otp` event. If the `otp` event was registered with a string literal, it is assumed that you have already obtained the OTP somehow and it will be passed along as-is. Otherwise, if you specified a function handler, it is assumed that your handler will automatically retrieve the OTP after we attempt a login without an OTP. Your OTP function should return the OTP code as a string literal. See examples for practical explanation.

**Failure reasons**
* Incorrect email/password combination
Expand Down
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ declare namespace Trade {
};

// Supported exchanges
type Exchange = 'NYSE' | 'NASDAQ' | 'TSX' | 'TSX-V' | 'NEO';
type Exchange = 'NYSE' | 'NASDAQ' | 'TSX' | 'TSX-V' | 'NEO' | 'CC';

/**
* A ticker may be provided to the API as a string or an object with
Expand Down
7 changes: 1 addition & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"name": "wstrade-api",
"version": "1.3.0",
"version": "1.3.1",
"description": "Wealthsimple Trade API Wrapper",
"main": "dist.js",
"types": "index.d.ts",
"scripts": {
"bundle": "webpack",
"lint": "npx eslint --fix src/ --ignore-pattern __test__",
Expand Down Expand Up @@ -42,7 +43,6 @@
"webpack-cli": "^4.2.0"
},
"dependencies": {
"http-status": "^1.4.2",
"node-fetch": "^2.6.1",
"source-map-support": "^0.5.19"
}
Expand Down
5 changes: 3 additions & 2 deletions src/network/https.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import fetch, { Headers } from 'node-fetch';
import status from 'http-status';
import customHeaders from '../headers';
import auth from '../auth';
import { configEnabled } from '../config';
import implicitTokenRefresh from '../optional/implicit-token-refresh';

const [HTTP_OK, HTTP_CREATED] = [200, 201];

/*
* Complete the URL by filling the parameter placeholders with the
* data arguments.
Expand Down Expand Up @@ -80,7 +81,7 @@ export default async function handleRequest(endpoint, data) {
// Submit the HTTP request to the Wealthsimple Trade Servers
const response = await talk(endpoint, data);

if ([status.OK, status.CREATED].includes(response.status)) {
if ([HTTP_OK, HTTP_CREATED].includes(response.status)) {
return endpoint.onSuccess(response);
}

Expand Down
6 changes: 0 additions & 6 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ module.exports = {
amd: 'node-fetch',
root: '_',
},
"http-status": {
commonjs: 'http-status',
commonjs2: 'http-status',
amd: 'http-status',
root: '_',
},
"source-map-support": {
commonjs: 'source-map-support',
commonjs2: 'source-map-support',
Expand Down

0 comments on commit cbba8db

Please sign in to comment.