This repository has been archived by the owner on Oct 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a5a3386
commit c9648ba
Showing
3 changed files
with
166 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
name: PublishDocumentation | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
deploy_docs: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
name: Release | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
types: | ||
- closed | ||
|
||
permissions: | ||
contents: write | ||
pages: write | ||
id-token: write | ||
|
||
concurrency: | ||
group: ${{ github.ref }}-${{ github.workflow }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
docs: | ||
runs-on: macos-latest | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Publish Jazzy Docs | ||
uses: steven0351/publish-jazzy-docs@v1 | ||
with: | ||
personal_access_token: ${{ secrets.ACCESS_TOKEN }} | ||
branch: main | ||
|
||
release: | ||
if: github.event.pull_request.merged == true && startsWith(github.head_ref, 'release/') | ||
environment: Production | ||
outputs: | ||
tag: ${{ steps.semver.outputs.nextStrict }} | ||
runs-on: macos-latest | ||
steps: | ||
- name: Checkout TIKI SDK iOS | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Get Version | ||
id: semver | ||
uses: ietf-tools/semver-action@v1 | ||
with: | ||
token: ${{ github.token }} | ||
|
||
- name: Create a new tag | ||
run: | | ||
git tag ${{ steps.semver.outputs.nextStrict }} | ||
git push origin ${{ steps.semver.outputs.nextStrict }} | ||
- name: Deploy to Cocoapods | ||
run: | | ||
set -eo pipefail | ||
pod lib lint --allow-warnings | ||
pod trunk push TikiSdkDebug.podspec --allow-warnings | ||
pod trunk push TikiSdkRelease.podspec --allow-warnings | ||
env: | ||
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }} | ||
|
||
- name: Create a Release | ||
continue-on-error: true | ||
uses: ncipollo/release-action@v1 | ||
with: | ||
tag: ${{ steps.semver.outputs.nextStrict }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,96 +1,117 @@ | ||
# TIKI Client Library - iOS Specification | ||
# TIKI Client Library - iOS Usage Guide | ||
|
||
## Technologies Used | ||
The TIKI Client Library for iOS provides a set of APIs that developers can use to publish data to TIKI. This library simplifies the process of integrating your iOS application with TIKI by providing convenient methods for authorization, licensing, capture, and upload. | ||
|
||
1. **Language:** Swift | ||
2. **Networking:** URLSession for HTTP communication | ||
3. **Authentication:** AppAuth for OAuth2 | ||
4. **Encrypted Storage:** Keychain for secure storage | ||
5. **Storage:** UserDefaults for small non-sensitive key-value pairs and the filesystem for lengthy information, like the index of email IDs. | ||
6. **Camera Integration:** AVFoundation for receipt image capture | ||
7. **UI Components:** SwiftUI | ||
## Getting Started | ||
|
||
## Library Structure | ||
To get started, visit mytiki.com and apply for beta access. Our team will then set up the provider ID and public key for your project, which you'll use to configure the client. | ||
|
||
1. **TikiClient:** The primary entry point for the TIKI Client Library. | ||
## Installation | ||
|
||
2. **TikiClient.auth:** Handles authentication, token retrieval, revocation, and refresh. | ||
Include TikiClient in your `Podfile` | ||
|
||
3. **TikiClient.license:** Manages user licenses, including creation, retrieval, revocation, and verification. | ||
``` | ||
target 'YourApplication' do | ||
pod 'TikiClient' | ||
end | ||
``` | ||
|
||
4. **TikiClient.email:** Manages email-related operations such as adding, retrieving, and removing email accounts. | ||
## Configuration | ||
|
||
5. **TikiClient.capture:** Deals with capturing receipt images, downloading and publishing email receipt data, uploading receipt images, and checking publishing status. | ||
Before executing any commands with the TikiClient library, you need to configure it. This includes providing the Provider ID and Public Key obtained during Provider Registration, as well as company information for generating license terms. | ||
|
||
6. **TikiClient.clo:** Handles card-linked offers, including adding cards, retrieving offers, getting user rewards, and publishing transaction information. | ||
```swift | ||
let config = Config( | ||
providerId = "<PROVIDER-ID>", // Provided by TIKI | ||
publicKey = "<PUBLIC-KEY>", // Provided by TIKI | ||
companyName = "ACME Inc", | ||
companyJurisdiction = "Nashville, TN", | ||
tosUrl = "https://acme.inc/tos", | ||
privacyUrl = "https://acme.inc/privacy" | ||
) | ||
TikiClient.configure(config) | ||
``` | ||
|
||
## Implementation | ||
## How to Use | ||
|
||
### TikiClient | ||
The TikiClient is a singleton used as the main entry point for all functionalities of the library. The configuration sets the parameters used by all methods. | ||
|
||
- **Methods:** | ||
- `initialize(providerId: String, userId: String, company: CompanyInfo)`: Initializes the TikiClient with parameters. | ||
- `scan() -> String`: Initiates the process of scanning a physical receipt and returns the receipt ID. | ||
- `login(provider: EmailProviderEnum)`: Initiates the process of scraping receipts from emails. | ||
- `logout(email: String)`: Removes a previously added email account. | ||
- `accounts() -> [EmailAccount]`: Retrieves the list of connected email accounts. | ||
- `scrape()`: Initiates the process of scraping receipts from emails. | ||
- `card(last4: String, bin: String, issuer: String, network: String)`: Adds a card for card-linked offers. | ||
- `offers() -> [Offer]`: Retrieves card-linked offers for the user. | ||
- `transaction(transaction: Transaction)`: Submits a transaction for card-linked offer matching. | ||
- `rewards() -> [Reward]`: Retrieves information about the user's rewards. | ||
- `widget(theme: Theme?)`: Displays the widget for pre-built UIs with a custom theme. | ||
### Initialization | ||
|
||
### TikiClient.auth | ||
This method authenticates with the TIKI API and registers the user's device to publish data. It is an asynchronous method due to the necessary API calls. | ||
|
||
- **Methods:** | ||
- `authenticate() -> String`: Authenticates with TIKI and saves the auth and refresh tokens. | ||
- `token() -> String`: Retrieves the authentication token, refreshing if necessary. | ||
- `revoke()`: Revokes the authentication token. | ||
- `refresh() -> String`: Refreshes the authentication token. | ||
The user ID can be any arbitrary string that identifies the user in the application using the client library. It is not recommended to use personally identifiable information, such as emails. If necessary, use a hashed version of it. | ||
|
||
### TikiClient.license | ||
```swift | ||
TikiClient.initialize("<the-client-user-id>") | ||
``` | ||
|
||
- **Methods:** | ||
- `create() -> LicenseRecord`: Creates a new license for the user. | ||
- `get() -> License`: Retrieves the user's active license. | ||
- `revoke() -> License`: Revokes the user's existing license. | ||
- `verify() -> Bool`: Verifies the validity of the user's license. | ||
To switch the active user, call the `TikiClient.initialize` method again. | ||
|
||
### Data License | ||
|
||
- **Methods:** | ||
- `login(provider: EmailProvider)`: Authenticates with OAuth and adds an email account for scraping receipts. | ||
- `accounts() -> [EmailAccount]`: Retrieves the list of connected email accounts. | ||
- `logout(email: String)`: Removes a previously added email account. | ||
To successfully capture and upload receipt data to our platform, it is essential to establish a valid User Data License Agreement (UDLA). This agreement serves as a clear, explicit addendum to your standard app terms of service, delineating key aspects: | ||
|
||
### TikiClient.capture | ||
- User Ownership: It explicitly recognizes the user as the rightful owner of the data. | ||
- Usage Terms: It outlines the terms governing how the data will be licensed and used. | ||
- Compensation: It defines the compensation arrangements offered in exchange for the provided data. | ||
|
||
- **Methods:** | ||
- `camera() -> UIImage`: Captures an image of a receipt for processing. | ||
- `email(onPublish: (receiptId: String) -> Void)`: Downloads potential receipt data from known receipt email senders and publishes it. | ||
- `publish(data: ImageData) -> String`: Uploads receipt images or email data for receipt data extraction. | ||
- `status(receiptId: String) -> PublishingStatus`: Checks the publishing status of the data. | ||
Our Client Library streamlines this process by providing a pre-qualified agreement, filled with the company information provided in the library configuration. | ||
|
||
### TikiClient.clo | ||
Retrieve the formatted terms of the license, presented in Markdown, using the `TikiClient.terms()` method. This allows you to present users with a clear understanding of the terms before they agree to license their data. This agreement comes , ensuring a seamless integration into the license registry. | ||
|
||
- **Methods:** | ||
- `card(last4: String, bin: String, issuer: String, network: String)`: Adds a card to the user's account. | ||
- `offers() -> [Offer]`: Retrieves card-linked offers for the user. | ||
- `rewards() -> [Reward]`: Retrieves information about the user's rewards. | ||
- `transaction(transaction: Transaction)`: Sends transaction information to match card-linked offers. | ||
Upon user agreement, generate the license using the `TikiClient.createLicense` method. | ||
|
||
## Documentation | ||
```swift | ||
let license = TikiClient.createLicense() | ||
``` | ||
|
||
The library should provide comprehensive documentation including: | ||
This method needs to be invoked once for each device. Once executed, the license is registered in TIKI storage, eliminating the need to recreate it in the future. | ||
|
||
1. **Getting Started Guide:** Instructions on how to integrate the library into an iOS project. | ||
2. **API Reference:** Detailed documentation for each class, method, and parameter. | ||
3. **Sample Code:** Examples demonstrating how to use key functionalities of the library. | ||
4. **Configuration Guide:** Guidelines on setting up TIKI credentials and other necessary configurations. | ||
5. **Error Handling:** Information on handling errors and exceptions. | ||
6. **Example App** An example app with basic UI, for manual testing. | ||
### Data Capture | ||
|
||
## Non-Native Dependencies | ||
The Client Library offers an optional method for scanning physical receipts via the mobile device camera. | ||
|
||
- AppAuth for OAuth2. | ||
Use the `TikiClient.scan()` method to initiate the receipt scanning process. This method does not directly return the scanned receipt data. Instead, it provides the data through a callback function that you supply. | ||
|
||
Here's an example of how to use it: | ||
|
||
```swift | ||
TikiClient.scan() { image: UIImage -> | ||
// Handle the scanned bitmap here | ||
} | ||
``` | ||
|
||
In this example, `image` is the scanned receipt, and the code inside the callback function (i.e., `// Handle the scanned bitmap here`) is where you can process or use the scanned data. | ||
|
||
### Data Upload | ||
|
||
Utilize the `TikiClient.publish` method to upload receipt images to TIKI for processing. This method is versatile, as it can receive results from the `TikiClient.scan` method, or your application can implement a custom scan extraction method, sending the results to `TikiClient.publish`. | ||
|
||
The `publish` method accepts a bitmap image or an array of bitmap images, providing flexibility to capture and scan multiple images, ideal for processing lengthy receipts. | ||
|
||
```swift | ||
let data: UIImage = ... // The scanned receipt | ||
let result = TikiClient.publish(data) | ||
``` | ||
|
||
Upon execution, this method returns a `CompletableDeferred` object that will be completed when the data has been published. | ||
|
||
### Retrieve Results | ||
|
||
Once you've uploaded receipt images to TIKI for processing using the `TikiClient.publish` method, you can retrieve the extracted data associated with a specific receipt by calling the `TikiClient.receipt(receiptId)` method. | ||
|
||
```swift | ||
// Assuming you have the receiptId stored in a variable named 'receiptId' | ||
let receiptData = await TikiClient.receipt(receiptId); | ||
print(receiptData); | ||
``` | ||
|
||
**Note**: The data extraction from receipts is performed asynchronously by Amazon Textract. Processing typically takes a few seconds, but it can occasionally take up to a minute. It's important to note that making subsequent calls to `TikiClient.receipt(receiptId)` shortly after using `TikiClient.publish` might lead to unexpected results and false `404` errors from the API. We recommend allowing sufficient time for the extraction process to complete before attempting to retrieve the extracted data. | ||
|
||
|
||
## API Reference | ||
|
||
The central API interface in the library is the `TikiClient` object, designed to abstract the complexities of authorization and API requests. While serving as the primary entry point, it's important to note that all APIs within the library are public and accessible. | ||
|
||
For detailed usage instructions, please consult the TIKI Client API Documentation. This comprehensive resource provides direct insights into utilizing the various functionalities offered by the TIKI Client Library. |