Swiftpack.co - veryfi/veryfi-swift as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by veryfi.
veryfi/veryfi-swift 1.2.0
Swift framework for communicating with the Veryfi OCR API
⭐️ 9
🕓 1 year ago
.package(url: "https://github.com/veryfi/veryfi-swift.git", from: "1.2.0")

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](https://raw.github.com/veryfi/veryfi-swift/master/)
        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/

GitHub

link
Stars: 9
Last commit: 24 weeks ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

1.2.0
1 year ago

Changes:

  • Added support for query items in get documents

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics