Git Product home page Git Product logo

github.swift's Introduction

Github.swift

❤️ Support my apps ❤️

❤️❤️😇😍🤘❤️❤️

CI Status Version Carthage Compatible License Platform

Description

Usage

Client

  • User: identify a user
  • Server: identify server (Github or Github Enterprise)
  • Client: make request. If associated with a valid token, it is considered authenticated client
let _ =
  Client.signInUsingWebBrowser(Server.dotComServer, scopes: [.Repository])
    .flatMap { client in
      return client.fetchUserRepositories()
    }.subscribeNext { repositories in
      repositories.forEach { print($0.name)
    }
  }

Request Descriptor

Make your own request using RequestDescriptor, using syntax from Construction

let requestDescriptor: RequestDescriptor = construct {
  $0.path = "repos/\(owner)/\(name)"
  $0.etag = "12345"
  $0.offset = 2
  $0.perPage = 50
  $0.parameters["param"] = "value"
  $0.headers["header"] = "value"
  $0.method = .PUT  
}

return enqueue(requestDescriptor).map {
  return Parser.one($0)
}

Pagination

  • The subscribe gets called many times if there is pagination
client
.fetchUserRepositories()
.subscribeNext { repositories in
  // This gets called many times depending pagination
  repositories.forEach { print($0.name)
}
  • Use toArray if we want subscribe to be called once with all the values collected
client
.fetchUserRepositories()
.toArray()
.subscribeNext { repositories: [[Repository]] in
  repositories.flatMap({$0}).forEach { print($0.name)
}

Features

Metadata

  • Fetch server metadata

Sign in

  • Native flow
  • OAuth flow

User

  • Follow
  • Unfollow
  • Fetch user info

Repository

  • Fetch repositories
  • Create repository
  • Fetch commits
  • Fetch pull requests
  • Fetch issues
  • Watch

Pull request

  • Make pull requests

Issue

  • Create issue
  • Fetch issues

Organization

  • Fetch organizations
  • Fetch teams

Search

  • Search repositories

Event

  • Fetch user events

Gists

  • Fetch gists

Git

  • Create tree
  • Create blob
  • Create commit

Activity

  • Star
  • Unstar

Notification

  • Fetch notifications

Installation

GithubSwift is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'GithubSwift'

GithubSwift is also available through Carthage. To install just write into your Cartfile:

github "onmyway133/Github.swift"

Author

Khoa Pham, [email protected]

Contributing

We would love you to contribute to GithubSwift, check the CONTRIBUTING file for more info.

License

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

github.swift's People

Contributors

onmyway133 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

github.swift's Issues

The 'Event' name

I was try to do something like this in my viewModel:

struct UserEventModel {

  let events: Observable<[Event]>

}

It seems the name Event conflict with the Event in RxSwift.

: (

About the etag in `fetchUserEvents`

Sorry to bother you again @onmyway133 😓
This method is return an Observable<[Events]> (transform from Observable<Response>)

  public func fetchUserEvents(etag: String? = nil,
                              offset: Int = 0, perPage: Int = Constant.defaultPerPage) -> Observable<[Event]> {
    if !isAuthenticated {
      return Observable<[Event]>.error(Error.authenticationRequiredError())
    }

    let requestDescriptor: RequestDescriptor = construct {
      $0.path = "users/\(user?.login ?? "")/received_events"
      $0.offset = offset
      $0.perPage = perPage
      $0.etag = etag
    }

    return enqueue(requestDescriptor).map {
      return Parser.all($0)
    }
  }

So how can I fetch the etag .....

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.