blob: 504c870246af6d5b435b7d9b1b4b6337231a58d6 [file] [log] [blame]
{
"name": "AmbrosusSDK",
"version": "1.0.0",
"summary": "Fetches Assets and Events from the Ambrosus Network (AMB-NET) and makes it easy to build interfaces.",
"description": "# Ambrosus iOS SDK\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.0 and is compatible with Xcode 9.0+. Branches for newer versions of Swift will be added later on.\n\nSupports iOS 10+\nSupports Objective-C and Swift 4.0+\nSupports Xcode 9.0+\n\n* [Integration](#integration)\n* [Overview](#overview)\n* [Usage](#usage)\n* [Usage (Objective-C)](#usage-objective-c)\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\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```",
"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.0.0"
},
"platforms": {
"ios": "10.0"
},
"source_files": "AmbrosusSDK/**/*"
}