Skip to content

MLabs-code/Kra

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kra

Swift package for interacting with the KRA.sk cloud storage API.

Features

  • User Authentication (login/logout)
  • User Information retrieval
  • File operations (list, download, and more)
  • Folder operations (create, delete)

Requirements

  • iOS 15.0+ / tvOS 15 / macOS 12.00 / visonOS 1.0 / macCatalyst 15.0+
  • Swift 5.9+

Installation

Swift Package Manager

Add the following to your Package.swift file:

dependencies: [
    .package(url: "https://github.com/MLabs-code/Kra.git", from: "1.0.0")
]

Usage

Initialization

let kra = Kra()

Login

kra.login(username: "your_username", password: "your_password") { result in
    switch result {
    case .success(let sessionId):
        print("Successfully logged in with session ID: \(sessionId)")
    case .failure(let error):
        print("Login failed: \(error.localizedDescription)")
    }
}

Get User Info

kra.getUserInfo(sessionId: sessionId) { result in
    switch result {
    case .success(let userInfo):
        print("User: \(userInfo.data.username)")
        print("Email: \(userInfo.data.email)")
    case .failure(let error):
        print("Getting user info failed: \(error.localizedDescription)")
    }
}

List Files

kra.listFiles(sessionId: sessionId, folderIdent: nil) { result in
    switch result {
    case .success(let files):
        for file in files {
            print("File: \(file.data?.link ?? "")")
        }
    case .failure(let error):
        print("Listing files failed: \(error.localizedDescription)")
    }
}

Download File

kra.fileLink(sessionId: sessionId, fileIdent: "file_id") { result in
    switch result {
    case .success(let filePath):
        if let url = filePath.urlLink {
            // Download the file from the URL
            print("File URL: \(url)")
        }
    case .failure(let error):
        print("Getting file link failed: \(error.localizedDescription)")
    }
}

Logout

kra.logout(sessionId: sessionId) { result in
    switch result {
    case .success(_):
        print("Successfully logged out")
    case .failure(let error):
        print("Logout failed: \(error.localizedDescription)")
    }
}

License

This package is available under the MIT license. See the LICENSE file for more info.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages