DetailedProductsKit
DetailedProductsKit
is a Swift library for iOS and macOS that manages all interaction with the the Franklin Templeton Detailed Product API.
Note
In order to use DetailedProductsKit
you first need to register, create an app, and obtain credentials on the Franklin Templeton Developer portal.
Features
- Authentication with the API
- Data download
- JSON decoding
- Error handling
- Response caching
- Get up and running three lines of code
Requirements
- iOS 12.1+
- Xcode 10.2+
- Swift 5.0+
Installation
DetailedProductsKit
is available through CocoaPods. To integrate DetailedProductsKit
into your project add the following line to your Podfile and then run pod install
:
pod 'DetailedProductsKit'
Basics
The functionality offered by DetailedProductsKit
is surfaced through the DetailedProductsAPI
class.
Configuration
Add the following import declaration to the class where you want to use the API:
import DetailedProductsKit
Create a constant:
let productsAPI = DetailedProductsAPI(key: <#CONSUMER_KEY#>, secret: <#CONSUMER_SECRET#>)
Usage
After productsAPI
is initialised, you can call any of the supported API endpoints. For example, to get the latest fund NAV data:
productsAPI.getFundNav(fundKey: "US8802081039", fundKeyType: .isin) { (result) in
DispatchQueue.main.async {
switch result {
case .success(let nav):
// Handle success
case .failure(let error):
// Handle error
}
}
}
Caching
DetailedProductsAPI
will cache responses to API requests by default.
If you wish to disable caching, you can do so at the point of initialisation:
let productsAPI = DetailedProductsAPI(key: <#CONSUMER_KEY#>, secret: <#CONSUMER_SECRET#>, shouldCacheResponses: false)
Alternatively, you can disable caching by setting the shouldCacheResponses
variable to false
:
productsAPI.shouldCacheResponses = false
If you need to remove cached responses call the following method:
productsAPI.removeAllCachedResponses()
Example App
An example app is included. Change this line in ViewController
to include your consumer key and secret:
let productsAPI = DetailedProductsAPI(key: "CONSUMER_KEY", secret: "CONSUMER_SECRET")
Then launch the app.
Author
Stuart Breckenridge
License
DetailedProductsKit is available under the MIT license. See the LICENSE file for more info.