Swiftpack.co - Qase/RxGitLabKit as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by Qase.
Qase/RxGitLabKit 1.0.1
Swift Reactive GitLab API v4 client using RxSwift
⭐️ 8
🕓 4 years ago
.package(url: "https://github.com/Qase/RxGitLabKit.git", from: "1.0.1")

RxGitLabKit

Build Status codebeat badge Platform pod Carthage Swift Package Manager

Description

Swift Reactive GitLab API v4 client using RxSwift

This library currently supports these endpoint groups:

The HTML documentation generated using Jazzy can be found on GitHub pages here.

Before running the demo app or the tests, download the dependencies using:

$ carthage update

Usage

Authorization

Using a private/ OAuth token or login using username and password

import RxGitLabKit

// Host URL
let hostURL = URL(string: "http://example.gitlab.server.com")!
// Using private token
let client = RxGitLabAPIClient(with: hostURL, privateToken: "PRIVATE_TOKEN")

// Using an OAuth token
let client = RxGitLabAPIClient(with: hostURL, oAuthToken: "OAUTH_TOKEN")

// Authorize using username and password
let client = RxGitLabAPIClient(with: hostURL)
client.logIn(username: "USERNAME", password: "PASSWORD")

Basic usage

import RxGitLabKit

let hostURL = URL(string: "http://example.gitlab.server.com")!

let client = RxGitLabAPIClient(with: hostURL, privateToken: "PRIVATE_TOKEN")

// Get projects
let projects: Observable<[Project]> = client.users
  .getProjects(parameters: ["order_by" : "id", "sort" : "asc"],
    page: 2,
    perPage: 20)
projects.subscribe(onNext: { projects in
    // do something with projects
  },
  onError: { error in
    // Do something with the error
  }
)

Paginator

Some endpoints return a Paginator which handles the pagination of the objects. The paginator uses subscripts for loading the desired pages.

import RxGitLabKit

// Get the paginator
let projectsPaginator: Paginator<Project> = client.users
  .getProjects(parameters: ["order_by" : "id", "sort" : "asc"])

// Load page 2
projectsPaginator[2].subscribe(onNext: { projects in
    // do something with projects
  },
  onError: { error in
    // Do something with the error
  }
)

// Load page 2 to 5
projectsPaginator[2...5].subscribe(onNext: { projects in
    // do something with projects
  },
  onError: { error in
    // Do something with the error
  }
)

// Load all pages
projectsPaginator.loadAll().subscribe(onNext: { projects in
    // do something with projects
  },
  onError: { error in
    // Do something with the error
  }
)

Requirements

  • Xcode 10.0
  • Swift 4.2

Integration

CocoaPods

Tested with pod --version: 1.5.3

# Podfile
use_frameworks!

target 'YOUR_TARGET_NAME' do
  pod 'RxGitLabKit'
end
\end{minted}

Replace YOUR_TARGET_NAME and then run this command:

$ pod install

Carthage

Tested with carthage version: 0.31.2

Add this to Cartfile

  git "https://github.com/Qase/RxGitLabKit.git"

and run:

$ carthage update

Then link the built RxGitLabKit.framework it the "Linked Frameworks and Libraries" section of the target.

Swift Package Manager

Tested with swift build --version: Apple Swift Package Manager - Swift 4.2.0 (swiftpm-14460.2)

Create a Package.swift file.

// swift-tools-version:4.2
import PackageDescription

let package = Package(
  name: "YOUR_PROJECT_NAME",
  dependencies: [
    .package(url: "https://github.com/Qase/RxGitLabKit.git", from: "1.0.0")
  ],
  targets: [
    .target(name: "YOUR_PROJECT_NAME", dependencies: ["RxGitLabKit"], path: "SOURCE_PATH")
  ]
)

replace YOUR_PROJECT_NAME and SOURCE_PATH and run

$ swift build

and then

$ swift package generate-xcodeproj

Licence

MIT

GitHub

link
Stars: 8
Last commit: 4 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Dependencies

Release Notes

Travis
5 years ago

Travis Integration.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics