Documentation ¶
Index ¶
- Constants
- Variables
- type Address
- type Applicant
- type Client
- func (c *Client) Close()
- func (c *Client) CreateApplicant(ctx context.Context, payload CreateApplicantPayload) (*Applicant, error)
- func (c *Client) CreateWorkflowRun(ctx context.Context, payload CreateWorkflowRunPayload) (*WorkflowRun, error)
- func (c *Client) DeleteApplicant(ctx context.Context, applicantId string) error
- func (c *Client) DownloadDocument(ctx context.Context, documentId string) ([]byte, error)
- func (c *Client) DownloadDocumentNFCFace(ctx context.Context, documentId string) ([]byte, error)
- func (c *Client) DownloadDocumentVideo(ctx context.Context, documentId string) ([]byte, error)
- func (c *Client) ListApplicants(ctx context.Context, opts ...IsListApplicantOption) ([]Applicant, *PageDetails, error)
- func (c *Client) ListDocuments(ctx context.Context, applicantId string) ([]Document, *PageDetails, error)
- func (c *Client) ListWorkflowRuns(ctx context.Context, opts ...IsListWorkflowRunOption) ([]WorkflowRun, *PageDetails, error)
- func (c *Client) RestoreApplicant(ctx context.Context, applicantId string) error
- func (c *Client) RetrieveApplicant(ctx context.Context, applicantId string) (*Applicant, error)
- func (c *Client) RetrieveDocument(ctx context.Context, documentId string) (*Document, error)
- func (c *Client) RetrieveWorkflowRun(ctx context.Context, workflowRunID string) (*WorkflowRun, error)
- func (c *Client) RetrieveWorkflowRunEvidenceSummaryFile(ctx context.Context, workflowRunID string) (*WorkflowRunEvidenceSummary, error)
- func (c *Client) UpdateApplicant(ctx context.Context, applicantId string, payload CreateApplicantPayload) (*Applicant, error)
- func (c *Client) UploadDocument(ctx context.Context, payload UploadDocumentPayload) (*Document, error)
- type ClientOption
- type Consent
- type CreateApplicantPayload
- type CreateWorkflowRunLink
- type CreateWorkflowRunPayload
- type Document
- type DocumentSide
- type DocumentType
- type IdNumber
- type IsListApplicantOption
- type IsListWorkflowRunOption
- type LimitPaginationOption
- type ListApplicantsOption
- type ListWorkflowRunOption
- func WithWorkflowRunCreatedAfter(date time.Time) ListWorkflowRunOption
- func WithWorkflowRunCreatedBefore(date time.Time) ListWorkflowRunOption
- func WithWorkflowRunSort(sort sortDirection) ListWorkflowRunOption
- func WithWorkflowRunStatus(status WorkflowRunStatus) ListWorkflowRunOption
- func WithWorkflowRunTags(tags ...string) ListWorkflowRunOption
- type Location
- type OnfidoError
- type PageDetails
- type PaginationOption
- type UploadDocumentPayload
- type WorkflowRun
- type WorkflowRunEvidenceSummary
- type WorkflowRunLink
- type WorkflowRunStatus
Constants ¶
const ( // CURRENT_CLIENT_VERSION is the current version of the Go-Onfido client CURRENT_CLIENT_VERSION = "1.0.0" // LATEST_API_VERSION is the latest version of the Onfido API LATEST_API_VERSION = "v3.6" // DEFAULT_API_REGION is the default region for the Onfido API DEFAULT_API_REGION = API_REGION_EU )
const ( // API_REGION_EU is the EU region for the Onfido API API_REGION_EU apiRegion = "eu" // API_REGION_US is the US region for the Onfido API API_REGION_US apiRegion = "us" // API_REGION_CA is the CA region for the Onfido API API_REGION_CA apiRegion = "ca" )
const ( // SortAsc is the ascending sort direction SortAsc sortDirection = "asc" // SortDesc is the descending sort direction SortDesc sortDirection = "desc" )
Variables ¶
var ErrInvalidId = &OnfidoError{Type: "validation_error", Message: "id is required"}
Functions ¶
This section is empty.
Types ¶
type Address ¶
type Address struct { Country string `json:"country,omitempty"` Postcode string `json:"postcode,omitempty"` FlatNumber string `json:"flat_number,omitempty"` BuildingNumber string `json:"building_number,omitempty"` BuildingName string `json:"building_name,omitempty"` Street string `json:"street,omitempty"` SubStreet string `json:"sub_street,omitempty"` Town string `json:"town,omitempty"` State string `json:"state,omitempty"` Line1 string `json:"line1,omitempty"` Line2 string `json:"line2,omitempty"` Line3 string `json:"line3,omitempty"` }
type Applicant ¶
type Applicant struct { ID string `json:"id,omitempty"` Email string `json:"email,omitempty"` Dob string `json:"dob,omitempty"` IdNumbers []IdNumber `json:"id_numbers,omitempty"` PhoneNumber string `json:"phone_number,omitempty"` FirstName string `json:"first_name,omitempty"` LastName string `json:"last_name,omitempty"` CreatedAt *time.Time `json:"created_at,omitempty"` UpdatedAt *time.Time `json:"updated_at,omitempty"` Href string `json:"href,omitempty"` Sandbox bool `json:"sandbox,omitempty"` Address *Address `json:"address,omitempty"` Location *Location `json:"location,omitempty"` }
Applicant represents an applicant in the Onfido API
type Client ¶
type Client struct { Endpoint string Retries int RetryWait time.Duration // contains filtered or unexported fields }
Client is a client for the Onfido API
func NewClient ¶
func NewClient(apiToken string, opts ...ClientOption) (*Client, error)
NewClient creates a new Client
func (*Client) Close ¶
func (c *Client) Close()
Close closes the idle connections of the underlying HTTP client.
The client can be reused after closing as per the http.Client documentation.
func (*Client) CreateApplicant ¶
func (c *Client) CreateApplicant(ctx context.Context, payload CreateApplicantPayload) (*Applicant, error)
CreateApplicant creates a new applicant in the Onfido API
func (*Client) CreateWorkflowRun ¶
func (c *Client) CreateWorkflowRun(ctx context.Context, payload CreateWorkflowRunPayload) (*WorkflowRun, error)
CreateWorkflowRun creates a new workflow run in the Onfido API
func (*Client) DeleteApplicant ¶
DeleteApplicant deletes an applicant from the Onfido API
func (*Client) DownloadDocument ¶
func (*Client) DownloadDocumentNFCFace ¶
func (*Client) DownloadDocumentVideo ¶
func (*Client) ListApplicants ¶
func (c *Client) ListApplicants(ctx context.Context, opts ...IsListApplicantOption) ([]Applicant, *PageDetails, error)
ListApplicants retrieves all applicants from the Onfido API
func (*Client) ListDocuments ¶
func (c *Client) ListDocuments(ctx context.Context, applicantId string) ([]Document, *PageDetails, error)
ListDocuments retrieves a list of documents from the Onfido API
func (*Client) ListWorkflowRuns ¶
func (c *Client) ListWorkflowRuns(ctx context.Context, opts ...IsListWorkflowRunOption) ([]WorkflowRun, *PageDetails, error)
ListWorkflowRuns retrieves a list of workflow runs from the Onfido API
func (*Client) RestoreApplicant ¶
RestoreApplicant restores a deleted applicant in the Onfido API
func (*Client) RetrieveApplicant ¶
RetrieveApplicant retrieves an applicant from the Onfido API
func (*Client) RetrieveDocument ¶
RetrieveDocument retrieves a document from the Onfido API
func (*Client) RetrieveWorkflowRun ¶
func (c *Client) RetrieveWorkflowRun(ctx context.Context, workflowRunID string) (*WorkflowRun, error)
RetrieveWorkflowRun retrieves a workflow run from the Onfido API
func (*Client) RetrieveWorkflowRunEvidenceSummaryFile ¶
func (c *Client) RetrieveWorkflowRunEvidenceSummaryFile(ctx context.Context, workflowRunID string) (*WorkflowRunEvidenceSummary, error)
RetrieveWorkflowRunEvidenceSummaryFile retrieves the signed evidence file for a workflow run
func (*Client) UpdateApplicant ¶
func (c *Client) UpdateApplicant(ctx context.Context, applicantId string, payload CreateApplicantPayload) (*Applicant, error)
UpdateApplicant updates an existing applicant in the Onfido API
func (*Client) UploadDocument ¶
func (c *Client) UploadDocument(ctx context.Context, payload UploadDocumentPayload) (*Document, error)
UploadDocument uploads a document to the Onfido API
type ClientOption ¶
type ClientOption func(*clientOptions)
func WithRegion ¶
func WithRegion(region apiRegion) ClientOption
func WithRetries ¶
func WithRetries(retries int, wait time.Duration) ClientOption
type CreateApplicantPayload ¶
type CreateApplicantPayload struct { // FirstName is the first name of the applicant, required FirstName string `json:"first_name,omitempty"` // LastName is the last name of the applicant, required LastName string `json:"last_name,omitempty"` Email string `json:"email,omitempty"` Dob time.Time `json:"dob,omitempty"` IdNumbers []IdNumber `json:"id_numbers,omitempty"` PhoneNumber string `json:"phone_number,omitempty"` Consents []Consent `json:"consents,omitempty"` Address *Address `json:"address,omitempty"` Location *Location `json:"location,omitempty"` }
type CreateWorkflowRunLink ¶
type CreateWorkflowRunPayload ¶
type CreateWorkflowRunPayload struct { ApplicantID string `json:"applicant_id,omitempty"` WorkflowID string `json:"workflow_id,omitempty"` Tags []string `json:"tags,omitempty"` CustomerUserID string `json:"customer_user_id,omitempty"` Link *CreateWorkflowRunLink `json:"link,omitempty"` CustomData map[string]any `json:"custom_data,omitempty"` }
type Document ¶
type Document struct { ID string `json:"id,omitempty"` FileType string `json:"file_type,omitempty"` Type DocumentType `json:"type,omitempty"` Side string `json:"side,omitempty"` IssuingCountry string `json:"issuing_country,omitempty"` ApplicantID string `json:"applicant_id,omitempty"` CreatedAt time.Time `json:"created_at,omitempty"` Href string `json:"href,omitempty"` DownloadHref string `json:"download_href,omitempty"` FileName string `json:"file_name,omitempty"` FileSize int `json:"file_size,omitempty"` }
Document represents a document in the Onfido API
type DocumentSide ¶
type DocumentSide string
const ( DocumentSideFront DocumentSide = "front" DocumentSideBack DocumentSide = "back" )
type DocumentType ¶
type DocumentType string
DocumentType represents the type of document
- The document types declared here are not exhaustive, the API may support more types
const ( DocumentTypeUnknown DocumentType = "unknown" DocumentTypePassport DocumentType = "passport" DocumentTypeDrivingLicence DocumentType = "driving_licence" DocumentTypeNationalIdentityCard DocumentType = "national_identity_card" DocumentTypeResidencePermit DocumentType = "residence_permit" DocumentTypeWorkPermit DocumentType = "work_permit" DocumentTypeVoterID DocumentType = "voter_id" DocumentTypeTaxID DocumentType = "tax_id" )
type IsListApplicantOption ¶
type IsListApplicantOption interface {
// contains filtered or unexported methods
}
type IsListWorkflowRunOption ¶
type IsListWorkflowRunOption interface {
// contains filtered or unexported methods
}
type LimitPaginationOption ¶
type LimitPaginationOption func(*limitPaginationOption)
func WithPageLimit ¶
func WithPageLimit(limit int) LimitPaginationOption
type ListApplicantsOption ¶
type ListApplicantsOption func(*listApplicantsOptions)
func WithIncludeDeletedApplicants ¶
func WithIncludeDeletedApplicants() ListApplicantsOption
type ListWorkflowRunOption ¶
type ListWorkflowRunOption func(*listWorkflowRunOptions)
func WithWorkflowRunCreatedAfter ¶
func WithWorkflowRunCreatedAfter(date time.Time) ListWorkflowRunOption
WithWorkflowRunCreatedAfter filters the list of workflow runs to those created after the specified date.
The hour, minute, second and timezone of the date are ignored, onfido throws an error for any other format.
func WithWorkflowRunCreatedBefore ¶
func WithWorkflowRunCreatedBefore(date time.Time) ListWorkflowRunOption
WithWorkflowRunCreatedBefore filters the list of workflow runs to those created before the specified date.
The hour, minute, second and timezone of the date are ignored, onfido throws an error for any other format.
func WithWorkflowRunSort ¶
func WithWorkflowRunSort(sort sortDirection) ListWorkflowRunOption
func WithWorkflowRunStatus ¶
func WithWorkflowRunStatus(status WorkflowRunStatus) ListWorkflowRunOption
func WithWorkflowRunTags ¶
func WithWorkflowRunTags(tags ...string) ListWorkflowRunOption
type OnfidoError ¶
type OnfidoError struct { Type string `json:"type,omitempty"` Message string `json:"message,omitempty"` Fields map[string]any `json:"fields,omitempty"` }
func (OnfidoError) Error ¶
func (e OnfidoError) Error() string
type PageDetails ¶
type PaginationOption ¶
type PaginationOption func(*paginationOption)
func WithPage ¶
func WithPage(page int) PaginationOption
type UploadDocumentPayload ¶
type UploadDocumentPayload struct { ApplicantID string `json:"applicant_id,omitempty"` File *os.File `json:"file,omitempty"` FileType string `json:"file_type,omitempty"` Type DocumentType `json:"type,omitempty"` Side DocumentSide `json:"side,omitempty"` IssuingCountry string `json:"issuing_country,omitempty"` Location *Location `json:"location,omitempty"` ValidateImageQuality bool `json:"validate_image_quality,omitempty"` }
type WorkflowRun ¶
type WorkflowRun struct { ID string `json:"id,omitempty"` ApplicantID string `json:"applicant_id,omitempty"` WorkflowID string `json:"workflow_id,omitempty"` WorkflowVersionID uint `json:"workflow_version_id"` DashboardURL string `json:"dashboard_url,omitempty"` Status WorkflowRunStatus `json:"status,omitempty"` Tags []string `json:"tags,omitempty"` CustomerUserID string `json:"customer_user_id,omitempty"` Output map[string]any `json:"output,omitempty"` Reasons []string `json:"reasons,omitempty"` Error *OnfidoError `json:"error,omitempty"` SDKToken string `json:"sdk_token,omitempty"` Link *WorkflowRunLink `json:"link,omitempty"` CreatedAt *time.Time `json:"created_at,omitempty"` UpdatedAt *time.Time `json:"updated_at,omitempty"` }
WorkflowRun represents a workflow run in the Onfido API
type WorkflowRunEvidenceSummary ¶
type WorkflowRunEvidenceSummary struct {
URL string `json:"url,omitempty"`
}
WorkflowRunEvidenceSummary represents the evidence summary file response
type WorkflowRunLink ¶
type WorkflowRunLink struct { URL string `json:"url,omitempty"` CreateWorkflowRunLink `json:",inline"` }
type WorkflowRunStatus ¶
type WorkflowRunStatus string
WorkflowRunStatus represents the status of a workflow run
const ( WorkflowRunStatusProcessing WorkflowRunStatus = "processing" WorkflowRunStatusAwaitingInput WorkflowRunStatus = "awaiting_input" WorkflowRunStatusApproved WorkflowRunStatus = "approved" WorkflowRunStatusDeclined WorkflowRunStatus = "declined" WorkflowRunStatusReview WorkflowRunStatus = "review" WorkflowRunStatusAbandoned WorkflowRunStatus = "abandoned" WorkflowRunStatusError WorkflowRunStatus = "error" )