blob: 596ff0ef5e7dfa10651723bd7446f60aae010602 [file] [log] [blame]
{
"name": "AmbrosusSDK",
"version": "1.2.0",
"summary": "Fetches Assets and Events from the Ambrosus Network (AMB-NET) and makes it easy to build interfaces.",
"description": "# Ambrosus iOS SDK\n\n[![Version](https://img.shields.io/cocoapods/v/AmbrosusSDK.svg?style=flat)](http://cocoapods.org/pods/AmbrosusSDK)\n[![License](https://img.shields.io/cocoapods/l/AmbrosusSDK.svg?style=flat)](http://cocoapods.org/pods/AmbrosusSDK)\n[![Platform](https://img.shields.io/cocoapods/p/AmbrosusSDK.svg?style=flat)](http://cocoapods.org/pods/AmbrosusSDK)\n\nThe Ambrosus iOS SDK makes it easy for iOS App Developers to get back data from the [Ambrosus API](https://ambrosus.docs.apiary.io) (AMB-NET), and build their own interfaces for displaying Assets and Events.\n\nThe Ambrosus iOS SDK is written in Swift 4.2 and is compatible with Xcode 10.1+. Branches for newer versions of Swift will be added later on.\n\nSupports iOS 10+\nSupports Objective-C and Swift 4.2+\nSupports Xcode 10.1+\n\n* [Integration](#integration)\n* [Overview](#overview)\n* [Usage](#usage)\n* [Usage (Objective-C)](#usage-objective-c)\n* [Sample Application (Ambrosus Viewer)](#sample-application-ambrosus-viewer)\n* [Ambrosus Viewer Support](#ambrosus-viewer-support)\n* [Sample Symbologies](#sample-symbologies)\n\n## Integration\n\nTo start using the SDK you can add the following to your Podfile:\n\n```ruby\npod 'AmbrosusSDK'\n```\n\nYou can also download or clone this repository and import the AmbrosusSDK manually if not using Cocoapods, all of the code is contained in the top level \"AmbrosusSDK\" folder.\n\n## Overview\n\nThe SDK is composed of three main files all contained within the \"AmbrosusSDK\" folder:\n\n`AMBNetwork.swift` \n\nThe interface layer which makes network requests to the Ambrosus API such as fetching assets, events, and images associated with assets and Events\n\n`AMBDataStore.swift`\n\nA singleton caching layer, you can insert assets into it using `AMBDataStore.sharedInstance.assetStore.insert(:)` or events using `AMBDataStore.sharedInstance.eventsStore.insert(_:)`, saving assets and events in here will make them easy to fetch later, and also improve network performance when requesting already stored assets and events from AMBNetwork. It also will cache images downloaded using `AMBNetwork.requestImage(_:)` calls.\n\n`AMBModels.swift`\n\nDefines the two main data models, `AMBAsset` and `AMBEvent` these are the objects which Asset and Event details screens can be built with. To see an example of these structures being used see the AmbrosusViewer example project included with this repository.\n\n## Usage\n\nTo start using the Ambrosus SDK within a Swift file first import it:\n```swift\nimport AmbrosusSDK\n```\n\nTo get back an asset from the API you can make a call like the following:\n\n```swift\nAMBNetwork.requestAsset(fromId: \"0x602023f73ab25f0c95a3cf4e92c9cb2f4c9c09dbd3ca6e167d362de6e7f1eeae\", completion: { (asset) in\n guard let asset = asset else {\n NSLog(\"asset failed to unwrap\")\n return\n }\n // Use unwrapped Asset here\n}\n```\n\nA single Asset in the Ambrosus SDK has many events associated with it, to get back all events associated with an asset you can make a call like the following:\n\n```swift\nAMBNetwork.requestEvents(fromAssetId: \"0x602023f73ab25f0c95a3cf4e92c9cb2f4c9c09dbd3ca6e167d362de6e7f1eeae\") { (events) in\n guard let events = events else {\n NSLog(\"Failed to return events\")\n return\n }\n // Use unwrapped events here\n}\n```\n\nTo get back an asset along with all of its events, and store the information in the `AMBDataStore` this can be done as follows:\n\n```swift\nAMBNetwork.requestAsset(fromId: \"0x602023f73ab25f0c95a3cf4e92c9cb2f4c9c09dbd3ca6e167d362de6e7f1eeae\", completion: { (asset) in\n guard let asset = asset else {\n NSLog(\"asset failed to unwrap\")\n return\n }\n AMBDataStore.sharedInstance.assetStore.insert(asset)\n\n AMBNetwork.requestEvents(fromAssetId: asset.id, completion: { (events) in\n guard let events = events else {\n print(\"events failed to unwrap\")\n return\n }\n AMBDataStore.sharedInstance.eventStore.insert(events)\n })\n})\n```\n\nOnce the asset along with its events are stored in the `AMBDataStore` they can then be accessed like so:\n```swift\nlet assetId = \"0x602023f73ab25f0c95a3cf4e92c9cb2f4c9c09dbd3ca6e167d362de6e7f1eeae\"\nlet asset = AMBDataStore.sharedInstance.assetStore.fetch(withAssetId: assetId)\nlet events = AMBDataStore.sharedInstance.eventStore.fetchEvents(forAssetId: assetId)\n```\n\nTo create assets and events, you must have an Ambrosus account with the `create_entity` permission and know your public key and private key. Your private key will be used for client-side signing. Start by configuring the `AMBWeb3Manager` with your private key:\n\n```swift\nlet privateKey = \"[YOUR_PRIVATE_KEY]\"\nlet publicKey = \"[YOUR_PUBLIC_KEY]\"\nAMBWeb3Manager.sharedInstance.setAccount(withPrivateKey: privateKey)\n```\n\nOnce you have your private key set you can now create assets and events using `AMBNetwork`:\n```swift\nAMBNetwork.createAsset(createdBy: publicKey) { (asset, error) in\n guard let assetId = asset?.id else {\n NSLog(error ?? \"Error, no Asset created\")\n return\n }\n let eventData = [\n [\"type\": \"ambrosus.asset.info\",\n \"name\": \"Organic Figs ((Int(arc4random_uniform(300))) count)\",\n \"assetType\": \"ambrosus.assetTypes.batch\",\n \"images\": [\n \"default\": [\"url\": \"http://limitlessapps.net/images/AmberAssets/figs.png\"]\n ]\n ]\n ]\n\n AMBNetwork.createEvent(assetId: assetId, createdBy: publicKey, data: eventData) { (event, error) in\n guard let event = event else {\n NSLog(error ?? \"Error, no Event created\")\n return\n }\n\n // Do something with unwrapped event here\n print(event.description)\n }\n}\n```\n\n## Usage (Objective-C)\n\nThe Ambrosus SDK is also fully compatible with Objective-C, you can import the SDK by adding the following to the top of your implementation file:\n```objective-c\n@import AmbrosusSDK;\n```\n\nTo fetch an asset as well as its events in Objective-C and store the data in `AMBDataStore` you can do the following:\n\n```objective-c\nNSString *assetId = @\"0x602023f73ab25f0c95a3cf4e92c9cb2f4c9c09dbd3ca6e167d362de6e7f1eeae\";\n[AMBNetwork requestAssetFromId:assetId completion:^(AMBAsset * _Nullable asset) {\n if (!asset) {\n return;\n }\n [[[AMBDataStore sharedInstance] assetStore] insert:asset];\n\n [AMBNetwork requestEventsFromAssetId:assetId completion:^(NSArray<AMBEvent *> * _Nullable events) {\n if (!events) {\n return;\n }\n [[[AMBDataStore sharedInstance] eventStore] insert:events];\n }];\n}];\n```\n\n# Sample Application (Ambrosus Viewer)\n\nThe included example application, Ambrosus Viewer includes a scanner that is capable of scanning 1d and 2d codes and displaying details about an associated asset and its events from AMB-NET. It comes packaged with several sample assets and events as well. The app also contains Asset Details and Event Details screens which demonstrate using the SDK to build a fully featured iOS application for viewing data stored on AMB-NET.\n\n## Ambrosus Viewer Support\n\n* Supports iPhone 5S and above, iPad 5th Generation and above, iPod Touch 6th Generation and Above.\n* Minimum iOS Version 11\n* Requires Camera permission enabled in order to scan codes\n* Capable of scanning codes with the following symbologies:\n * UPCE, UPC12, EAN8, EAN13, CODE 39, CODE 128, ITF, QR, DATAMATRIX\n\n## Sample Symbologies\n\nTo see details about sample assets with the Ambrosus Viewer, scan any of the following codes from the app:\n\n|   EAN-8   |   EAN-13   |     QR     |\n| --------- | ---------------------------------- | ---------- |\n| &emsp;&emsp;![EAN-8 Sample](https://i.imgur.com/m7QZIaS.png) | &emsp;&emsp;![EAN-13 Sample](https://i.imgur.com/1HXwtPr.png) | &emsp;&emsp;![QR Sample](https://i.imgur.com/JfEUGo8.png)&emsp;&emsp;\n| <a href=\"https://gateway-test.ambrosus.com/events?data[type]=ambrosus.asset.identifier&data[identifiers.ean8]=96385074\" target=\"_blank\">Generic Asset</a>&emsp; | <a href=\"https://gateway-test.ambrosus.com/events?data[type]=ambrosus.asset.identifier&data[identifiers.ean13]=6942507312009\" target=\"_blank\">Guernsey Cow</a>&emsp;&emsp; | &emsp;&emsp;&emsp;&emsp;<a href=\"https://gateway-test.ambrosus.com/assets/0x4c289b68b5bb1a098a4aa622b84d6f523e02fc9346a3a0a99efdfd8a96ba56df\" target=\"_blank\">Ibuprofen Batch 200mg</a>&emsp;&emsp;\n```",
"homepage": "https://github.com/ambrosus/sdk-ios",
"license": {
"type": "MIT",
"file": "LICENSE"
},
"authors": {
"ambrosus": "tech@ambrosus.com"
},
"source": {
"git": "https://github.com/ambrosus/sdk-ios.git",
"tag": "1.2.0"
},
"platforms": {
"ios": "10.0"
},
"source_files": "AmbrosusSDK/**/*"
}