GithubHelp home page GithubHelp logo

go-onfido's Introduction

go-onfido CircleCI Go Report Card

Client for the Onfido API

go-doc

This library was built for Utility Warehouse internal projects, so priority was given to supporting the features we needed. If the library is missing a feature from the API, raise an issue or ideally open a PR.

Installation

To install go-onfido, use go get:

go get github.com/uw-labs/go-onfido

Usage

First you're going to need to instantiate a client (grab your sandbox API key)

client := onfido.NewClient("test_123")

Or you can instantiate usign the env variable ONFIDO_TOKEN

client, err := onfido.NewClientFromEnv()

Now checkout some of the examples

go-onfido's People

Contributors

cpick avatar hsyed avatar marksonghurst avatar rcrowe avatar realdave avatar speedycoder avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

go-onfido's Issues

Pre-PR: webhook creation support

I've been working on expanding webhook support. That branch has CreateWebhook and ListWebhooks which are already functional.
If this looks like it would be useful in the main project I'd be happy to open a PR.

(I'm not completely happy withe the WebhookRef type name that I've been using and would very much appreciate any alternative suggestions.)

Error marshalling issue

internally we are creating an applicant with the following data:

 "applicant": {
    "first_name": "Df",
    "last_name": "Df",
    "email": "[email protected]",
    "dob": "1990-12-12",
    "country": "GBR",
    "addresses": [
      {
        "flat_number": "",
        "building_number": "",
        "building_name": "",
        "street": "Prime Minister & First Lord of the Treasury",
        "sub_street": "",
        "town": "",
        "state": "",
        "postcode": "SW1A 2AA",
        "country": "GBR"
      }
    ]
  },

Hacking some debug code in we can see Onfido send the following error body:

{"error":{"type":"validation_error","message":"There was a validation error on this request","fields":{"addresses":[{"street":["can't be longer than 32 characters"]}]}}}

Demarshalling this leads to an error as this type:

type ErrorFields map[string][]string

should actually be

type ErrorFields map[string][]interface{}

Codify document options

We just heard from Onfido that the document check can return address information if the document contained it (driving license). This need to enabled in options as follows:

{
	"type": "express",
	"asynchronous": true,
	"reports": [{
		"name": "document",
		"options": [
        {
          "name": "document_address_information"
        }
      ]
	}]
}

Since a lot of the fields are type-safe (ish) is there a nice way to encode this ? At the moment the options field is map[string]interface{}.

Add parameter to expand reports when retrieving checks

The get requests contain a query param to expand the check. When a check has the consider status the reports need to be expanded to make decisions.

The signature of GetCheck will need to be changed it should probably be updated to take a request object. Will you accept a PR for this ?

Converting DOB to time.Time

Expected Behavior

As a user of the library it would be nice for date of birth to be of type time.Time and have the library deal with the parsing to and from the string type/

Actual Behavior

Date of birth is of type string

Concurrency Question

Thank you for a great Go package. My API is Go based and I have a need to interface it with Onfido. Finding your well documented package has saved me many days of development effort.

Are you able to confirm please, that the package (go-onfido.Client in particular) is safe for concurrent use by multiple Go routines?

Have you considered adding it here: https://documentation.onfido.com/#client-libraries

Thanks again.
Mark

Fix CI failures due to rate limiting

When running the build for multiple versions of go, at least one seems to fail with the following error
integration_test.go:173: Rate limit exceeded. Please try again later.

The tests should be made more resilient to not fail when this happens, or we should run integration tests for fewer go versions.

Onfido Error JSON Structure

It seems that Onfido have deviated from their documented Error JSON structure:

{
  "error": {
    "id": "544f95539648607d03001542",
    "type": "validation_error",
    "message": "",
    "fields": {
      "email": {
        "messages": [
          "invalid format"
        ]
      },
      "name": {
        "messages": [
          "can't be blank"
        ]
      }
    }
  }
}

I am receiving from them the following Error object when I create a new Applicant:

{
    "error": {
        "type": "validation_error",
        "message": "There was a validation error on this request",
        "fields": {
            "addresses": [
                {
                    "country": [
                        "can't be blank"
                    ]
                }
            ]
        }
    }
}

This causes a json.Unmarshal error within this package's onfido.go file:

json: cannot unmarshal array into Go struct field .fields of type struct { Messages []string }

This unmarshallng error then masks the actual Onfido error.
My solution was to update the Error structure type in onfido.go with the following:

// Error represents an Onfido API error response
type Error struct {
	Resp *http.Response
	Err  struct {
		ID     string      `json:"id"`
		Type   string      `json:"type"`
		Msg    string      `json:"message"`
		Fields ErrorFields `json:"fields"`
	} `json:"error"`
}

type ErrorFields map[string]interface{}

I am using Go 1.11.4 linux/amd64

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.