Swift SDK for Bynder
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
Sample
Source
Tests
bynder-swift-sdk.xcodeproj
bynder-swift-sdk.xcworkspace
.gitignore
.swift-version
BynderSDK.podspec
LICENSE
Podfile
README.md

README.md

Bynder Swift SDK

The main goal of this SDK is to speed up the integration of Bynder customers who use Objective-C and Swift; making it easier to connect to the Bynder API (http://docs.bynder.apiary.io/) and executing requests on it.

Requirements

  • iOS 8.0+ / macOS 10.10+

BynderClient

public var sessionManager: BynderSessionManager { get }

public required init(configuration: Configuration)

public func authoriseCalls(accessToken: String, accessSecret: String)

public func removeUserSession()

public func userSessionAcquired() -> Bool

public var userController: UserController { get }

public var brandController: BrandController { get }

public var categoryController: CategoryController { get }

public var collectionController: CollectionController { get }

public var assetBankController: AssetBankController { get }

public var metapropertyController: MetapropertyController { get }

public var tagController: TagController { get }

public var uploadController: UploadController { get }

open func uploadController(maxConcurrentOperationCount: Int, qualityOfService: QualityOfService) -> UploadController

public var downloadController: DownloadController { get }

UserController

open func retrieveRequestToken(_ completed: @escaping ((_ oauthToken: String, _ oauthTokenSecret: String) -> Void), failed: ControllerFailedClosure?) -> DataRequest?

open func retrieveAuthorizeURL(requestToken: String, callBackURL: String?) throws -> URLRequest?

open func retrieveAccessToken(_ requestToken: String, requestSecret: String, completed: ((_ accessToken: String, _ accessSecret: String) -> Void)?, failed: ControllerFailedClosure?) -> DataRequest?

open func retrieveCurrentUser(_ completed: ((UserProfile) -> Void)?, failed: ControllerFailedClosure?) -> DataRequest?

open func retrieveAccount(_ completed: ((Account?) -> Void)?, failed: ControllerFailedClosure?) -> DataRequest?

open func retrieveSecurityProfiles(_ completed: (([SecurityProfile]) -> Void)?, failed: ControllerFailedClosure?) -> DataRequest?

open func retrieveCurrentSecurityProfile(user: UserProfile!, completed: ((SecurityProfile) -> Void)?, failed: ControllerFailedClosure?) -> DataRequest?

open func retrieveDomainUsers(includeInActive: Bool = default, completed: ((_ users: [UserProfile]) -> Void)?, failed: ControllerFailedClosure?) -> DataRequest?

open func modifyLoginTermsAccepted(user: UserProfile, completed: @escaping (() -> Void), failed: ControllerFailedClosure?) -> DataRequest?

AssetBankController

open func generalAssetResponseClosure(_ completed: @escaping (([Asset]) -> Void), failed: ControllerFailedClosure?) -> ((DataResponse<Any>) -> Void)

open func retrieveAssetCount(settings: AssetFilterQuery, completed: @escaping ((AssetCount) -> Void), failed: ControllerFailedClosure?) -> DataRequest

open func retrieveAssetCount(params: [String : Any], completed: @escaping ((AssetCount) -> Void), failed: ControllerFailedClosure?) -> DataRequest

open func retrieveAssets(settings: AssetFilterQuery, completed: @escaping (([Asset]) -> Void), failed: ControllerFailedClosure?) -> DataRequest

open func retrieveAssets(params: [String : Any]?, completed: @escaping (([Asset]) -> Void), failed: ControllerFailedClosure?) -> DataRequest

open func retrieveAssetInfo(id: String, versions: Bool = default, completed: @escaping (([Asset]) -> Void), failed: ControllerFailedClosure?) -> DataRequest?

open func retrieveAssets(ids: [String], completed: @escaping (([Asset]) -> Void), failed: ControllerFailedClosure?) -> DataRequest?

open func retrieveAssetDownloadURL(assetId: String, type: DownloadType, completed: @escaping ((DownloadInfo) -> Void), failed: ControllerFailedClosure?) -> DataRequest?

open func modifyAsset(assetId: String, updateInfo: AssetUpdateQuery, completed: @escaping (() -> Void), failed: ControllerFailedClosure?) -> DataRequest?

open func deleteAsset(assetId: String, completed: @escaping (() -> Void), failed: ControllerFailedClosure?) -> DataRequest?

CollectionController

open func retrieveCollectionCount(settings: CollectionFilterQuery, completed: @escaping (([Collection], Int) -> Void), failed: ControllerFailedClosure?) -> DataRequest

open func retrieveCollectionCount(params: [String : Any], completed: @escaping (([Collection], Int) -> Void), failed: ControllerFailedClosure?) -> DataRequest

open func retrieveCollections(settings: CollectionFilterQuery, completed: @escaping (([Collection]) -> Void), failed: ControllerFailedClosure?) -> DataRequest

open func retrieveCollections(params: [String : Any]?, completed: @escaping (([Collection]) -> Void), failed: ControllerFailedClosure?) -> DataRequest

open func createCollection(name: String, description: String?, completed: ((Collection) -> Void)?, failed: ControllerFailedClosure?) -> DataRequest?

open func addAssets(assetIds: [String], toCollectionId collectionId: String, completed: @escaping (() -> Void), failed: ControllerFailedClosure?)

open func shareCollection(_ collection: Collection, shareInfo: ShareCollectionQuery, completed: @escaping (() -> Void), failed: ControllerFailedClosure?) -> DataRequest?

open func removeAssets(assets: [Asset], fromCollection collection: Collection, completed: (() -> Void)?, failed: ControllerFailedClosure?) -> DataRequest?

open func deleteCollection(_ collection: Collection, completed: ((Collection) -> Void)?, failed: ((Collection, Error) -> Void)?) -> DataRequest?

open func modifyCollection(_ collection: Collection, completed: @escaping (() -> Void), failed: ControllerFailedClosure?) -> DataRequest?

open func modifyCollection(id: String, name: String?, description: String?, completed: @escaping (() -> Void), failed: ControllerFailedClosure?) -> DataRequest?

open func modifyCollection(id: String, params: [String : Any], completed: @escaping (() -> Void), failed: ControllerFailedClosure?) -> DataRequest?

BrandController

open func retrieveBrands(_ completed: @escaping (([Brand]) -> Void), failed: ControllerFailedClosure?) -> DataRequest?

CategoryController

open func retrieveCategories(_ completed: @escaping ((_ users: [Category]) -> Void), failed: ControllerFailedClosure?) -> DataRequest?

MetapropertyController

open func retrieveMetaproperties(_ completed: @escaping (([Metaproperty]) -> Void), failed: ControllerFailedClosure?) -> DataRequest?

TagController

open func retrieveTags(settings: TagFilterQuery, completed: @escaping (([Tag]) -> Void), failed: ControllerFailedClosure?) -> DataRequest

open func retrieveTags(params: [String : Any]?, completed: @escaping (([Tag]) -> Void), failed: ControllerFailedClosure?) -> DataRequest

UploadController

internal let uploadOpQueue: OperationQueue

public required init(sessionManager: BynderSessionManager)

public init(sessionManager: BynderSessionManager, maxConcurrentOperationCount: Int, qualityOfService: QualityOfService)

open func cancelAllOperations()

open func setMaxConcurrentOperationCount(_ max: Int)

open func setQualityOfService(_ service: QualityOfService)

open func generalUploadCompletionClosure(completed: UploadSaveCompletionClosure?) -> UploadSaveCompletionClosure

open func uploadNewAsset(securityProfile: SecurityProfile, filePath: String, uploadInfo: UploadInfoQuery, progress: UploadFileProgressClosure?, completed: UploadSaveCompletionClosure?) -> UploadAssetOperation?

open func uploadAssetVersion(securityProfile: SecurityProfile, filePath: String, assetId: String, uploadInfo: UploadInfoQuery, progress: UploadFileProgressClosure?, completed: UploadSaveCompletionClosure?) -> UploadAssetVersionOperation?

open func uploadAdditionalAsset(securityProfile: SecurityProfile, filePath: String, assetId: String, uploadInfo: UploadInfoQuery, progress: UploadFileProgressClosure?, completed: UploadSaveCompletionClosure?) -> UploadAssetAdditionalOperation?

internal func startNewOperation(_ newOp: UploadSaveOperation)

internal func isValidFilePath(_ path: String) -> Bool

open func updateNumberOfUploads()

open func isUploading() -> Bool

DownloadController

internal var locationHTTPOperationManager: Alamofire.SessionManager?

internal var downloadHTTPOperationManager: Alamofire.SessionManager?

public let downloadBatchOperationQueue: OperationQueue

public required init(sessionManager: BynderSessionManager)

public init(sessionManager: BynderSessionManager, maxConcurrentLocationRequests: Int, maxConcurrentDownloadRequests: Int)

public func createHTTPOperationManagers(maxConcurrentLocationRequests: Int, maxConcurrentDownloadRequests: Int)

open func download(tasks: [DownloadTask], disclaimer: @escaping DisclaimerClosure, progress: DownloadProgressClosure?, completed: @escaping DownloadCompletionClosure) -> DownloadBatchOperation

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install BynderSDK

CocoaPods 1.1+ is required to build BynderSDK.

To integrate BynderSDK into your Xcode project using CocoaPods, specify it in your Podfile:

platform :ios, '10.0'
use_frameworks!

target '<Your Target Name>' do
    pod 'BynderSDK'
end

Then, run the following command:

$ pod install

Manually

If you prefer not to use any of the aforementioned dependency managers, you can integrate BynderSDK into your project manually.

Usage

Retrieve assets

import UIKit
import BynderSDK

class ViewController: UIViewController {
    var client: BynderClient?
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        
        // Create configuration instance
        var configuration: Configuration? = nil
        
        do {
            configuration = try Configuration(consumerToken: "_CONSUMER_KEY_",
                                              consumerSecret: "_CONSUMER_SECRET_",
                                              accessToken: "_ACCESS_TOKEN_",
                                              accessSecret: "_ACCESS_SECRET_",
                                              baseURL: URL(string: "example.getbynder.com")!)
        } catch {
            print("ERROR: %@", error)
        }
        
        // Create client using your configuration
        client = BynderClient(configuration: configuration!)
        
        // Retrieve assets
        let query = AssetFilterQuery()
        query.limit = 5
        
        client!.assetBankController.retrieveAssets(settings: query, completed: { (assets) in
            for asset in assets {
                loggingPrint(asset.name)
            }
        }) { (error) -> (Void) in
            loggingPrint("Error: \(error)")
        }
    }
}