Skip to content
Swift Reactive GitLab API v4 client using RxSwift
Swift Ruby Objective-C
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
RxGitLabKit.xcodeproj
RxGitLabKit.xcworkspace
RxGitLabKitDemoApp
Sources
Tests
docs
.gitignore GIT: QTI-912 Cartfile.resolved added. gitignore updated. Feb 27, 2019
.gitlab-ci.yml
.travis.yml
Cartfile
Cartfile.resolved GIT: QTI-912 Cartfile.resolved added. gitignore updated. Feb 27, 2019
LICENSE
Package.swift SPM support. Readme update. Dec 24, 2018
README.md
RxGitLabKit.podspec

README.md

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

You can’t perform that action at this time.