Socket
Socket
Sign inDemoInstall

nordnet-next-api

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nordnet-next-api - npm Package Compare versions

Comparing version 1.0.3 to 2.0.0

2

examples/client/src/components/Status.jsx

@@ -8,3 +8,3 @@ import React from 'react';

get('/next/2/')
.then(response => this.setState({ status: response }));
.then(({ data }) => this.setState({ status: data }));
}

@@ -11,0 +11,0 @@

@@ -154,25 +154,45 @@ 'use strict';

describe('get', function () {
beforeEach(settle(_index.get, '/next/2/accounts/{accno}', { accno: 123 }, { 'Accept-Language': 'sv' }));
describe('accounts', function () {
beforeEach(settle(_index.get, '/next/2/accounts/{accno}', { accno: 123 }, { 'Accept-Language': 'sv' }));
it('should set expected headers', function () {
return expectHeaders({ Accept: 'application/json', 'Accept-Language': 'sv' });
it('should set expected headers', function () {
return expectHeaders({ Accept: 'application/json', 'Accept-Language': 'sv' });
});
it('should set method \'get\'', function () {
return (0, _chai.expect)(fetchSpy.args[0][1].method).to.equal('get');
});
it('should include credentials', function () {
return (0, _chai.expect)(fetchSpy.args[0][1].credentials).to.equal('include');
});
it('should not set body', function () {
return (0, _chai.expect)(fetchSpy.args[0][1].body).to.be.undefined;
});
it('should return expected status', function () {
return (0, _chai.expect)(response.status).to.equal(200);
});
it('should return expected response data', function () {
return (0, _chai.expect)(response.data).to.deep.equal({ accno: 123 });
});
});
it('should set method \'get\'', function () {
return (0, _chai.expect)(fetchSpy.args[0][1].method).to.equal('get');
describe('news', function () {
beforeEach(settle(_index.get, '/next/2/news?days={days}', { days: 0 }));
it('should return expected status', function () {
return (0, _chai.expect)(response.status).to.equal(200);
});
it('should return expected response data', function () {
return (0, _chai.expect)(response.data).to.deep.equal([{ news_id: 1 }]);
});
});
it('should include credentials', function () {
return (0, _chai.expect)(fetchSpy.args[0][1].credentials).to.equal('include');
});
it('should not set body', function () {
return (0, _chai.expect)(fetchSpy.args[0][1].body).to.be.undefined;
});
it('should return expected response', function () {
return (0, _chai.expect)(response).to.deep.equal({ accno: 123 });
});
});
describe('get with query params', function () {
beforeEach(settle(_index.get, '/next/2/news?days={days}', { days: 0 }));
it('should return expected response', function () {
return (0, _chai.expect)(response).to.deep.equal([{ news_id: 1 }]);
describe('settings', function () {
beforeEach(settle(_index.get, '/next/2/user/settings/{foo}', { foo: 'foo' }));
it('should return expected status', function () {
return (0, _chai.expect)(response.status).to.equal(204);
});
it('should return expected response data', function () {
return (0, _chai.expect)(response.data).to.be.undefined;
});
});

@@ -179,0 +199,0 @@ });

@@ -138,3 +138,9 @@ 'use strict';

function toJSON(response) {
return response.json();
if (response.status === 204) {
return { status: response.status };
}
return response.json().then(function (json) {
return { status: response.status, data: json };
});
}

@@ -141,0 +147,0 @@

{
"name": "nordnet-next-api",
"version": "1.0.3",
"version": "2.0.0",
"description": "Nordnet nExt API Javascript client",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -27,3 +27,3 @@ # Nordnet nExt API Javascript client

.get('https://api.test.nordnet.se/next/2')
.then(response => console.log(response));
.then(({ status, data }) => console.log(status, data));
```

@@ -52,22 +52,34 @@

api.get('https://api.test.nordnet.se/next/2/accounts/{accno}', { accno: 123456789 })
.then(response => console.log(response));
api
.get('https://api.test.nordnet.se/next/2/accounts/{accno}', { accno: 123456789 })
.then(({ status, data }) => console.log(status, data));
```
Returned response contains status (HTTP response status) and data (JSON parsed response).
### Passing path parameters
```js
import api from 'nordnet-next-api';
import { get } from 'nordnet-next-api';
api.get('https://api.test.nordnet.se/next/2/accounts/{accno}', { accno: 123456789 })
.then(response => console.log(response));
get('https://api.test.nordnet.se/next/2/accounts/{accno}', { accno: 123456789 })
.then(({ status, data }) => console.log(status, data));
```
### Passing query parameters
```js
import { get } from 'nordnet-next-api';
get('https://api.test.nordnet.se/next/2/news?days={days}', { days: 0 })
.then(({ status, data }) => console.log(status, data));
```
### Passing POST parameters
```js
import api from 'nordnet-next-api';
import { post } from 'nordnet-next-api';
api.get('https://api.test.nordnet.se/next/2/user/{key}', { key: 'foo', value: { bar: 'bar' }})
.then(response => console.log(response));
post('https://api.test.nordnet.se/next/2/user/{key}', { key: 'foo', value: { bar: 'bar' }})
.then(({ status, data }) => console.log(status, data));
```

@@ -78,6 +90,6 @@

```js
import api from 'nordnet-next-api';
import { get } from 'nordnet-next-api';
api.get('https://api.test.nordnet.se/next/2/markets/{market_id}', { market_id: 80 }, { 'Accept-Language': 'sv' })
.then(response => console.log(response));
get('https://api.test.nordnet.se/next/2/markets/{market_id}', { market_id: 11 }, { 'Accept-Language': 'sv' })
.then(({ status, data }) => console.log(status, data));
```

@@ -84,0 +96,0 @@

@@ -140,14 +140,26 @@ import 'test-helper';

describe('get', () => {
beforeEach(settle(get, '/next/2/accounts/{accno}', { accno: 123 }, { 'Accept-Language': 'sv' }));
describe('accounts', () => {
beforeEach(settle(get, '/next/2/accounts/{accno}', { accno: 123 }, { 'Accept-Language': 'sv' }));
it('should set expected headers', () => expectHeaders({ Accept: 'application/json', 'Accept-Language': 'sv' }));
it('should set method \'get\'', () => expect(fetchSpy.args[0][1].method).to.equal('get'));
it('should include credentials', () => expect(fetchSpy.args[0][1].credentials).to.equal('include'));
it('should not set body', () => expect(fetchSpy.args[0][1].body).to.be.undefined);
it('should return expected response', () => expect(response).to.deep.equal({ accno: 123 }));
});
it('should set expected headers', () => expectHeaders({ Accept: 'application/json', 'Accept-Language': 'sv' }));
it('should set method \'get\'', () => expect(fetchSpy.args[0][1].method).to.equal('get'));
it('should include credentials', () => expect(fetchSpy.args[0][1].credentials).to.equal('include'));
it('should not set body', () => expect(fetchSpy.args[0][1].body).to.be.undefined);
it('should return expected status', () => expect(response.status).to.equal(200));
it('should return expected response data', () => expect(response.data).to.deep.equal({ accno: 123 }));
});
describe('get with query params', () => {
beforeEach(settle(get, '/next/2/news?days={days}', { days: 0 }));
it('should return expected response', () => expect(response).to.deep.equal([{ news_id: 1 }]));
describe('news', () => {
beforeEach(settle(get, '/next/2/news?days={days}', { days: 0 }));
it('should return expected status', () => expect(response.status).to.equal(200));
it('should return expected response data', () => expect(response.data).to.deep.equal([{ news_id: 1 }]));
});
describe('settings', () => {
beforeEach(settle(get, '/next/2/user/settings/{foo}', { foo: 'foo' }));
it('should return expected status', () => expect(response.status).to.equal(204));
it('should return expected response data', () => expect(response.data).to.be.undefined);
});
});

@@ -154,0 +166,0 @@

@@ -112,3 +112,9 @@ import es6Promise from 'es6-promise';

function toJSON(response) {
return response.json();
if (response.status === 204) {
return { status: response.status };
}
return response.json().then(json => {
return { status: response.status, data: json };
});
}

@@ -115,0 +121,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc