Git Product home page Git Product logo

starling-developer-sdk's Introduction

Starling Javascript SDK

JavaScript Standard Style NPM Package Version Bundle size

Documentation

The documentation for our SDK can be found here.

Installation

npm install starling-developer-sdk

Usage

const Starling = require('starling-developer-sdk')
// or
import Starling from 'starling-developer-sdk'

const client = new Starling({
  // apiUrl: 'https://api-sandbox.starlingbank.com',
  accessToken: '<oauth access token>'
})

client.account.getAccounts()
  .then(({ data }) => console.log(data))
  .catch(err => console.log(err))

starling-developer-sdk's People

Contributors

amyjot avatar atwright147 avatar beresfordt avatar danosborne avatar dependabot[bot] avatar digitalpardoe avatar domdomegg avatar jakenvac avatar nottheusual avatar pettomartino avatar shubb avatar stephan5 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

starling-developer-sdk's Issues

:bug: in web SDK the get OAuthToken uses GET instead of POST method

in OAuth.js file the GetOAuthToken method uses a GET method instead of a POST (as per the instructions (https://jsapi.apiary.io/apis/starlingbankapi/introduction/authentication/5.-exchange-for-an-access-token.html). This is causing both the get original token and refresh token methods to return an error HTML page rather than the required response.

I have tested this using postman (using GET and POST) to verify that this is the issue and that the request should be a POST

OAuth URL correct?

Firstly, thanks for the sdk.

Feel like I'm going nuts; The getOAuthToken method in the OAuth class references:

const url = `${this.options.oauthUrl}/oauth/access-token`;

Which is getting the domain from the constructor defaults:

oauthUrl: 'https://oauth.starlingbank.com',

However the developer docs say:
"To exchange the authorisation code, POST as application/x-www-form-urlencoded from parameters, to https://api.starlingbank.com/oauth/access-token"

Either way though I am struggling to authenticate, getting "authorization_code could not be verified, it could be invalid, expired or revoked" from the sandbox :/

Failing tests on master

Hey,

I am finding that there are currently 4 failing tests on master. Is this just on my Win10 machine or is it a mistake in the repo?

> npm t

> [email protected] test
> jest test

 PASS  test/entities/feedItem.spec.js
 PASS  test/entities/accountHolder.spec.js
 FAIL  test/entities/account.spec.js
  ● Account › should download CSV statement for period

    expect(received).toBe(expected) // Object.is equality

    Expected: "Date,Counter Party,Reference,Type,Amount (GBP),Balance (GBP),Spending Category"
    "eceived: "Date,Counter Party,Reference,Type,Amount (GBP),Balance (GBP),Spending Category

      154 |
      155 |         expect(lines).toHaveLength(4)
    > 156 |         expect(lines[0]).toBe('Date,Counter Party,Reference,Type,Amount (GBP),Balance (GBP),Spending Category')
          |                          ^
      157 |         expect(lines[1]).toBe('01/10/2019,An Employer,SALARY,FASTER PAYMENT,1500.00,5500.00,INCOME')
      158 |         expect(lines[2]).toBe('02/10/2019,Landlord,Rent,FASTER PAYMENT,-1000.00,4500.00,PAYMENTS')
      159 |         expect(lines[3]).toBe('')

      at test/entities/account.spec.js:156:26

  ● Account › should download CSV statement for period with optional parameters removed

    expect(received).toBe(expected) // Object.is equality

    Expected: "Date,Counter Party,Reference,Type,Amount (GBP),Balance (GBP),Spending Category"
    "eceived: "Date,Counter Party,Reference,Type,Amount (GBP),Balance (GBP),Spending Category

      172 |
      173 |         expect(lines).toHaveLength(4)
    > 174 |         expect(lines[0]).toBe('Date,Counter Party,Reference,Type,Amount (GBP),Balance (GBP),Spending Category')
          |                          ^
      175 |         expect(lines[1]).toBe('01/10/2019,An Employer,SALARY,FASTER PAYMENT,1500.00,5500.00,INCOME')
      176 |         expect(lines[2]).toBe('02/10/2019,Landlord,Rent,FASTER PAYMENT,-1000.00,4500.00,PAYMENTS')
      177 |         expect(lines[3]).toBe('')

      at test/entities/account.spec.js:174:26

  ● Account › should download CSV statement for range

    expect(received).toBe(expected) // Object.is equality

    Expected: "Date,Counter Party,Reference,Type,Amount (GBP),Balance (GBP),Spending Category"
    "eceived: "Date,Counter Party,Reference,Type,Amount (GBP),Balance (GBP),Spending Category

      190 |
      191 |         expect(lines).toHaveLength(4)
    > 192 |         expect(lines[0]).toBe('Date,Counter Party,Reference,Type,Amount (GBP),Balance (GBP),Spending Category')
          |                          ^
      193 |         expect(lines[1]).toBe('01/10/2019,An Employer,SALARY,FASTER PAYMENT,1500.00,5500.00,INCOME')
      194 |         expect(lines[2]).toBe('02/10/2019,Landlord,Rent,FASTER PAYMENT,-1000.00,4500.00,PAYMENTS')
      195 |         expect(lines[3]).toBe('')

      at test/entities/account.spec.js:192:26

  ● Account › should download CSV statement for range with optional parameters removed

    expect(received).toBe(expected) // Object.is equality

    Expected: "Date,Counter Party,Reference,Type,Amount (GBP),Balance (GBP),Spending Category"
    "eceived: "Date,Counter Party,Reference,Type,Amount (GBP),Balance (GBP),Spending Category

      208 |
      209 |         expect(lines).toHaveLength(4)
    > 210 |         expect(lines[0]).toBe('Date,Counter Party,Reference,Type,Amount (GBP),Balance (GBP),Spending Category')
          |                          ^
      211 |         expect(lines[1]).toBe('01/10/2019,An Employer,SALARY,FASTER PAYMENT,1500.00,5500.00,INCOME')
      212 |         expect(lines[2]).toBe('02/10/2019,Landlord,Rent,FASTER PAYMENT,-1000.00,4500.00,PAYMENTS')
      213 |         expect(lines[3]).toBe('')

      at test/entities/account.spec.js:210:26

 PASS  test/entities/savingsGoals.spec.js
 PASS  test/entities/card.spec.js
 PASS  test/entities/payee.spec.js
 PASS  test/entities/payment.spec.js
 PASS  test/oauth.spec.js
 PASS  test/entities/identity.spec.js
 PASS  test/entities/address.spec.js
 PASS  test/utils/validator.spec.js
 PASS  test/entities/mandate.spec.js
 PASS  test/starling.spec.js

Test Suites: 1 failed, 12 passed, 13 total
Tests:       4 failed, 64 passed, 68 total
Snapshots:   0 total
Time:        6.472 s
Ran all test suites matching /test/i.

Thank you for your time :)

Optional argument suggestions

Hello guys,

First of all, thanks for this SDK, it's really handy.

I'd like to make a suggestion for those Starling methods signature, IMHO, it's a bit strange to have the first argument optional. Let's get as example the getTransaction method:

getTransaction (accessToken = this.config.accessToken, transactionId, source)

If I want to use this method as I suppose most of the use cases are going to be by using the accessToken from the construtor I must use like this:

starlingInstance.getTransaction(undefined, '12334-123123-12313-123123')

Although It's a bit Java way, I'd rather a setAccessToken() method and then ditch the accessToken argument from all methods signature(inside Starling class of course), using it straight from this.config.accessToken

Another suggestion, which I more Javascriptish is using a single object as argument, since there's that typeValidation function what helps validate the methods arguments that wouldn't be that tricky.

Responses inconsistent in documentation, test and production

For instance, api/v1/transactions is documented to respond with

{
  "transactions": [
    {
      "id": "6f03a23a-bbfc-4479-8d4d-abb6a9119d27",
      "currency": "GBP",
      "amount": -23.45,
      "direction": "OUTBOUND",
      "created": "2017-07-05T18:27:02.335Z",
      "narrative": "Borough Barista",
      "source": "MASTER_CARD",
      "balance": 254.12
    }
  ]
}

But actually returns in production:

{
  "_links": {
    "nextPage": {
      "href": "NOT_YET_IMPLEMENTED"
     }
  },
  "_embedded": {
    "transactions": [
      {
        "_links": {
          "detail": {
            "href": "...",
            "templated": false
          }
        },
        "id": "6f03a23a-bbfc-4479-8d4d-abb6a9119d27",
        "currency": "GBP",
        "amount": -23.45,
        "direction": "OUTBOUND",
        "created": "2017-07-05T18:27:02.335Z",
        "narrative": "Borough Barista",
        "source": "MASTER_CARD",
        "balance": 254.12
      }
    ]
  }
}

Tests are more similar to production but use "reference" instead of "narative".

I haven't looked at other responses yet, there may be other inconsistencies.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.