Skip to content

Swift framework for communicating with the Veryfi OCR API

Notifications You must be signed in to change notification settings

veryfi/veryfi-swift

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Swift 5.3 code coverage License: MIT

Installation

Install from Swift Package Manager, using this repository as the url.

Getting Started

Obtaining Client ID and user keys

If you don't have an account with Veryfi, please go ahead and register here: https://hub.veryfi.com/signup/api/.

Veryfi Swift Client Library

The veryfi library can be used to communicate with Veryfi API. All available functionality is described here.

Below is the sample Swift code using veryfi to OCR and extract data from a document:

Process a document

import UIKit
import VeryfiSDK

class ViewController: UIViewController {
    
    let clientId = "your_client_id"
    let clientSecret = "your_client_secret"
    let username = "your_username"
    let apiKey = "your_password"
    
    override func viewDidLoad() {
        super.viewDidLoad()
        let client = Client(clientId: clientId, clientSecret: clientSecret, username: username, apiKey: apiKey)
        let file = "receipt"
        let url = Bundle(for: Self.self).url(forResource: file, withExtension: "jpeg")!
        let fileData = try? Data(contentsOf: url)
        client.processDocument(fileName: file, fileData: fileData!) { result in
            switch result {
            case .success(let data):
                print("Succeded")
            case .failure(let error):
                print("Error")
            }
        }
    }
}

Update a document

import UIKit
import VeryfiSDK

class ViewController: UIViewController {
    
    let clientId = "your_client_id"
    let clientSecret = "your_client_secret"
    let username = "your_username"
    let apiKey = "your_password"
    
    override func viewDidLoad() {
        super.viewDidLoad()
        let client = Client(clientId: clientId, clientSecret: clientSecret, username: username, apiKey: apiKey)
        let documentId = "your_document_id"
        var parameters = [String : Any]()
        parameters["category"] = "Meals & Entertainment"
        parameters["total"] =  11.23
        client.updateDocument(documentId: documentId, params: parameters) { result in
            switch result {
            case .success(let data):
                print("Succeded")
            case .failure(let error):
                print("Error")
            }
        }
    }
}

Release

  1. Create new branch for your code
  2. Change version in Constants.swift
  3. Commit changes and push to Github
  4. Create PR pointing to master branch and add a Veryfi member as a reviewer
  5. Tag your commit with the new version
  6. The new version will be accesible through Swift Package Manager

Need help?

Visit https://docs.veryfi.com/ to access integration guides and usage notes in the Veryfi API Documentation Portal

If you run into any issue or need help installing or using the library, please contact [email protected].

If you found a bug in this library or would like new features added, then open an issue or pull requests against this repo!

To learn more about Veryfi visit https://www.veryfi.com/