onfido

package module
v0.0.0-...-16b55eb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 6, 2019 License: MIT Imports: 13 Imported by: 0

README

onfido

A simple Go package for interacting with Onfido. See the godoc documentation for more info.

This package is nowhere near as complete as I would like it to be. Time constraints have forced me to write only the things that I needed immediately.

Eventually, all functionality will be complete, a proper README will be created and it will be very nice.

For now, if it is missing functionality you need, please submit a PR to add it. For any issues you encounter, please submit an issue.

Thanks!

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CheckType = struct {
	Express  string
	Standard string
}{
	Express:  "express",
	Standard: "standard",
}
View Source
var (
	ErrBadSignature = newError("webhook signature validation failed")
)
View Source
var EventType = struct {
	Completion string
	Withdrawal string
	InProgress string
}{
	Completion: "completion",
	Withdrawal: "withdrawal",
	InProgress: "in_progress",
}
View Source
var IDNumberType = struct {
	Nino           string
	SSN            string
	DrivingLicense string
}{
	Nino:           "nino",
	SSN:            "ssn",
	DrivingLicense: "driving_license",
}
View Source
var ReportStatus = struct {
	Pending  string
	Complete string
}{
	Pending:  "pending",
	Complete: "complete",
}
View Source
var ReportType = struct {
	GBR struct {
		Identity            string
		Document            string
		Employment          string
		Education           string
		NegativeMedia       string
		Directorship        string
		CriminalHistory     string
		Watchlist           string
		AntiMoneyLaundering string
		StreetLevel         string
	}
	USA struct {
		Identity         string
		Document         string
		SexOffender      string
		Watchlist        string
		NationalCriminal string
		Eviction         string
		CountyCriminal   string
		DrivingRecord    string
	}
	Europe struct {
		Identity        string
		Document        string
		CriminalHistory string
	}
}{
	GBR: struct {
		Identity            string
		Document            string
		Employment          string
		Education           string
		NegativeMedia       string
		Directorship        string
		CriminalHistory     string
		Watchlist           string
		AntiMoneyLaundering string
		StreetLevel         string
	}{
		Identity:            "identity",
		Document:            "document",
		Employment:          "employment",
		Education:           "education",
		NegativeMedia:       "negative_media",
		Directorship:        "directorship",
		CriminalHistory:     "criminal_history",
		Watchlist:           "watchlist",
		AntiMoneyLaundering: "anti_money_laundering",
		StreetLevel:         "street_level",
	},
	USA: struct {
		Identity         string
		Document         string
		SexOffender      string
		Watchlist        string
		NationalCriminal string
		Eviction         string
		CountyCriminal   string
		DrivingRecord    string
	}{
		Identity:         "identity",
		Document:         "document",
		SexOffender:      "sex_offender",
		Watchlist:        "watchlist",
		NationalCriminal: "national_criminal",
		Eviction:         "eviction",
		CountyCriminal:   "county_criminal",
		DrivingRecord:    "driving_record",
	},
	Europe: struct {
		Identity        string
		Document        string
		CriminalHistory string
	}{
		Identity:        "identity",
		Document:        "document",
		CriminalHistory: "criminal_history",
	},
}
View Source
var ResourceType = struct {
	Report string
	Check  string
}{
	Report: "report",
	Check:  "check",
}
View Source
var ResultKind = struct {
	Clear        string
	Consider     string
	Fail         string
	Unidentified string
	None         string
}{
	Clear:        "clear",
	Consider:     "consider",
	Fail:         "fail",
	Unidentified: "unidentified",
	None:         "none",
}

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Err struct {
		ID      string                 `json:"id"`
		Fields  map[string]interface{} `json:"fields"`
		Message string                 `json:"message"`
		Type    string                 `json:"type"`
	} `json:"error"`
}

func (*APIError) Error

func (a *APIError) Error() string

type Address

type Address struct {
	BuildingName   string `json:"building_name,omitempty"`
	BuildingNumber string `json:"building_number,omitempty"`
	FlatNumber     string `json:"flat_number,omitempty"`
	Street         string `json:"street"`
	SubStreet      string `json:"sub_street,omitempty"`
	Town           string `json:"town"`
	State          string `json:"state,omitempty"`
	Postcode       string `json:"postcode"`
	Country        string `json:"country"`
	StartDate      *Date  `json:"start_date"`
	EndDate        *Date  `json:"end_date,omitempty"`
}

type Applicant

type Applicant struct {
	ID         string     `json:"id,omitempty"`
	Title      string     `json:"title,omitempty"`
	FirstName  string     `json:"first_name"`
	LastName   string     `json:"last_name"`
	MiddleName string     `json:"middle_name,omitempty"`
	Email      string     `json:"email,omitempty"`
	Gender     string     `json:"gender,omitempty"`
	Dob        *Date      `json:"dob,omitempty"`
	Country    string     `json:"country,omitempty"`
	Mobile     string     `json:"mobile,omitempty"`
	Telephone  string     `json:"telephone,omitempty"`
	IDNumbers  []IDNumber `json:"id_numbers,omitempty"`
	Addresses  []Address  `json:"addresses,omitempty"`

	Href      string     `json:"href,omitempty"`
	CreatedAt *time.Time `json:"created_at,omitempty"`
}

type Callback

type Callback struct {
	Payload CallbackPayload `json:"payload"`
}

type CallbackPayload

type CallbackPayload struct {
	Action       string `json:"action"`
	ResourceType string `json:"resource_type"`
	Object       struct {
		Href   string `json:"href"`
		ID     string `json:"id"`
		Status string `json:"status"`
	} `json:"object"`
}

type Check

type Check struct {
	ID        string    `json:"id"`
	Result    string    `json:"result"`
	Status    string    `json:"status"`
	Type      string    `json:"type"`
	Href      string    `json:"href"`
	Reports   []*Report `json:"reports"`
	CreatedAt time.Time `json:"created_at"`
}

func (*Check) ReportForName

func (c *Check) ReportForName(name string) *Report

type CheckRequest

type CheckRequest struct {
	Type    string          `json:"type"`
	Reports []ReportRequest `json:"reports"`
	Tags    []string        `json:"tags"`
}

func NewCheckRequest

func NewCheckRequest(checkType string, reports ...string) *CheckRequest

type Client

type Client struct {
	WebhookToken string
	// contains filtered or unexported fields
}

Client provides methods for interacting with the onfido API

func New

func New(apiToken string) *Client

func (*Client) CreateApplicant

func (c *Client) CreateApplicant(a *Applicant) (*Applicant, error)

func (*Client) CreateCheck

func (c *Client) CreateCheck(appID string, cr *CheckRequest) (*Check, error)

func (*Client) GetDocuments

func (c *Client) GetDocuments(appID string) ([]Document, error)

func (*Client) GetFile

func (c *Client) GetFile(url string) (b []byte, err error)

func (*Client) GetLivePhotos

func (c *Client) GetLivePhotos(appID string) ([]LivePhoto, error)

func (*Client) ReadApplicant

func (c *Client) ReadApplicant(id string) (*Applicant, error)

func (*Client) ReadApplicants

func (c *Client) ReadApplicants() ([]*Applicant, error)

func (*Client) ReadCheck

func (c *Client) ReadCheck(appID, checkID string) (*Check, error)

func (*Client) ReadChecks

func (c *Client) ReadChecks(appID string) ([]*Check, error)

func (*Client) ReadReport

func (c *Client) ReadReport(url string) (*Report, error)

func (*Client) SDKToken

func (c *Client) SDKToken(appID, referrer string) (SDKToken, error)

func (*Client) UnmarshalEvent

func (c *Client) UnmarshalEvent(r *http.Request) (*Event, error)

type Date

type Date time.Time

func (*Date) MarshalJSON

func (d *Date) MarshalJSON() ([]byte, error)

func (*Date) UnmarshalJSON

func (d *Date) UnmarshalJSON(data []byte) error

type Document

type Document struct {
	ID                 string    `bson:"id" json:"id"`
	CreatedAt          time.Time `bson:"created_at" json:"created_at"`
	Type               string    `bson:"type" json:"type"`
	Side               string    `bson:"side" json:"side"`
	Href               string    `bson:"href" json:"href"`
	OnfidoDownloadHref string    `json:"download_href"`
}

type Event

type Event struct {
	Payload struct {
		ResourceType string `json:"resource_type"`
		Action       string `json:"action"`
		Object       Object `json:"object"`
	} `json:"payload"`
}

type EventTime

type EventTime time.Time

func (*EventTime) UnmarshalJSON

func (et *EventTime) UnmarshalJSON(data []byte) error

type IDNumber

type IDNumber struct {
	Type      string `json:"type"`
	Value     string `json:"value"`
	StateCode string `json:"state_code,omitempty"`
}

type LivePhoto

type LivePhoto struct {
	ID                 string    `bson:"id" json:"id"`
	CreatedAt          time.Time `bson:"created_at" json:"created_at"`
	Href               string    `bson:"href" json:"href"`
	OnfidoDownloadHref string    `json:"download_href"`
}

type Object

type Object struct {
	ID          string    `json:"id"`
	Status      string    `json:"status"`
	CompletedAt EventTime `json:"completed_at"`
	Href        string    `json:"href"`
}

type Report

type Report struct {
	ID         string                 `json:"id"`
	Href       string                 `json:"href"`
	Name       string                 `json:"name"`
	Result     string                 `json:"result"`
	Status     string                 `json:"status"`
	Breakdown  map[string]interface{} `json:"breakdown"`
	Properties map[string]interface{} `json:"properties"`
	CreatedAt  time.Time              `json:"created_at"`
}

type ReportRequest

type ReportRequest struct {
	Name string `json:"name"`
}

type SDKToken

type SDKToken struct {
	Token string `json:"token"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL