Latest 1.0.3
Homepage https://github.com/dracoon/dracoon-swift-sdk
License Apache 2.0
Platforms ios 9.3
Dependencies Alamofire, DRACOON-Crypto-SDK
Authors

DRACOON Swift SDK

A library to access DRACOON REST API

Setup

Minimum Requirements

Xcode 7.3.1 or newer

Carthage

Add the SDK and its dependencies to your Cartfile:

github "dracoon/dracoon-swift-sdk.git" ~> 1.0.3
github "Alamofire/Alamofire" ~> 4.7.3
github "dracoon/dracoon-swift-crypto-sdk.git" ~> 1.0.2

Then run

carthage update --platform iOS --cache-builds

To add the frameworks to your project, open it in Xcode, choose the "General" tab in targets settings and add it to "Linked Frameworks and Libraries".

CocoaPods

Add to your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.3'
use_frameworks!

target '<Your Target Name>' do
pod 'DRACOON-SDK', '~> 1.0.3'
end

Then run

pod install

Build examples

The example app in /Example/oauth2.example shows a possible setup for Carthage or CocoaPods.
Run sh setupCarthage.sh and sh setupCocoaPods.sh.
The run sh regenerateProjects to generate both the example projects.

To run the Carthage project open oauth2.carthage.example.xcodeproj
To run the CocoaPods project open oauth2.cocoapods.example.xcworkspace

Example

Too see how OAuth Code Grant flow works with DRACOON SDK, check out the example app in /Example/oauth2.example.
Build it with carthage and make sure to store your configuration to /Example/oauth2.example/oauth2.example/OAuthConfig.swift first.


// Create authMode

// Use this mode the first time initializing your DracoonClient. authCode is the code from your OAuth2 code flow authorization response.
let authMode = DracoonAuthMode.authorizationCode(clientId: clientId, clientSecret: clientSecret, authorizationCode: authCode)

// If you received your access and refresh tokens use this mode to initialize your DracoonClient.
let token = DracoonTokens(refreshToken: "refreshToken", accessToken: "accessToken", timestamp: Date(), accessTokenValidity: 3600)
let authMode2 = DracoonAuthMode.accessRefreshToken(clientId: "clientId", clientSecret: "clientSecret", tokens: token)

// Create client

let client = DracoonClientImpl(serverUrl: serverUrl, authMode: authMode, getEncryptionPassword: getEncryptionPassword)

// -- Example Requests --

// Nodes

client.nodes.getNodes(parentNodeId: nodeId, limit: nil, offset: nil, completion: { result in
  switch result {
    case .value(let nodeList):
          // ...
    case .error(let error):
          // ...
  }
})

client.nodes.deleteNodes(request: deleteRequest, completion: { result in
  if let error = result.error {
    // ...
  } else {
    // ...
  }
})

// Account

client.account.getUserAccount(completion: { result in
   switch result {
     case .error(let error):
            // ...
     case .value(let user):
            // ...
    }
 })

client.account.setUserKeyPair(password: password, completion: { result in
  switch result {
    case .error(let error):
        // ...
    case .value(let keyPair):
        // ...
    }
})

// Download
client.nodes.downloadFile(nodeId: nodeId, targetUrl: url, callback: callback)

// Upload
client.nodes.uploadFile(uploadId: uploadId, request: createRequest, filePath: filePath, callback: callback, resolutionStrategy: .autorename)

// Shares

client.shares.createDownloadShare(nodeId: idToShare, password: sharePassword, completion: { result in
  switch result {
    case .error(let error):
        // ...
    case .value(let share):
        // ...
    }
})

let request = CreateUploadShareRequest(targetId: self.nodeId, name: self.containerName){$0.expiration = expiration; $0.password = password; $0.notes = notes}
client.shares.requestCreateUploadShare(request: createRequest, completion: { result in
  switch result {
    case .error(let error):
        // ...
    case .value(let share):
        // ...
  }
})

Copyright and License

See LICENSE

Latest podspec

{
    "name": "DRACOON-SDK",
    "version": "1.0.3",
    "summary": "Official DRACOON SDK",
    "description": "This SDK implements access to DRACOON API.",
    "homepage": "https://github.com/dracoon/dracoon-swift-sdk",
    "license": {
        "type": "Apache 2.0",
        "file": "LICENSE"
    },
    "authors": {
        "Mathias Schreiner": "[email protected]"
    },
    "source": {
        "git": "https://github.com/dracoon/dracoon-swift-sdk.git",
        "tag": "v1.0.3"
    },
    "module_name": "dracoon_sdk",
    "platforms": {
        "ios": "9.3"
    },
    "swift_version": "4.2",
    "source_files": "dracoon-sdk/**/*",
    "dependencies": {
        "Alamofire": [
            "~> 4.7.3"
        ],
        "DRACOON-Crypto-SDK": [
            "~> 1.0.2"
        ]
    }
}

Pin It on Pinterest

Share This