Swiftpack.co - Package - pixyzehn/EsaKit

Notice: EsaKit is no longer being maintained/updated.

EsaKit MIT license

A Swift framework for the esa.io API

let client = EsaClient(token: "your_token", teamName: "your_team_name")
client.members()
  .startWithResult { result in
    switch result {
    case let .success(response, members):
      print("\(response)") // => Response(xRateLimitLimit: 75, XRateLimitRemaining: 71)
      print("\(members)")  // => Memberss(members: [EsaKit.MemberUser(name:...
    case let .failure(error):
      print("An error occured: \(error)")
    }
  }

client.teamName = "other_your_team_name"
client.posts()
  .startWithResult { result in
    switch result {
    case let .success(response, posts):
      print("\(response)") // => Response(xRateLimitLimit: 75, XRateLimitRemaining: 70)
      print("\(posts)")    // => Posts(posts: [EsaKit.Post(number: 11, name:...
    case let .failure(error):
      print("An error occured: \(error)")
    }
  }

EsaKit is build with ReactiveSwift and Sourcery.

Requirements

EsaKit requires / supports the following environments:

  • Swift 3.0 / Xcode 8.1
  • OS X 10.10 or later
  • iOS 9.0 or later

Installation

Carthage

  • Insert github "pixyzehn/EsaKit" to your Cartfile.
  • Run carthage update.
  • Link your app with EsaKit.framework, ReactiveSwift.framework and Result.framework in Carthage/Build.

CocoaPods

  • Insert pod 'EsaKit' to your Podfile.
  • Run pod install.

Swift Package Manager

  • Add EsaKit as a dependency of your package in Package.swift. .Package(url: "https://github.com/pixyzehn/EsaKit.git", majorVersion: 0, minor: 3)

Usage

Read the docs. Generated with jazzy.

// Initialization
let client = EsaClient(token: "your_token", teamName: "your_team_name")

// Team API
client.teams()
// #=> GET /v1/teams

client.team()
// #=> GET /v1/teams/[your_team_name]


// Stats API
client.stats()
// #=> GET /v1/teams/[your_team_name]/stats


// Member API
client.members()
// #=> GET /v1/teams/[your_team_name]/members


// Post API
client.posts()
// #=> GET /v1/teams/[your_team_name]/posts

client.posts(query: "in:help")
// #=> GET /v1/teams/[your_team_name]/posts?q=in%3Ahelp

client.post(postNumber: 1)
// #=> GET /v1/teams/[your_team_name]/posts/1

client.createPost(parameters: PostParameters(name: "title"))
// #=> POST /v1/teams/[your_team_name]/posts

client.updatePost(postNumber: 1, parameters: PostParameters(name: "other_title"))
// #=> PATCH /v1/teams/[your_team_name]/posts/1

client.deletePost(postNumber: 1)
// #=> DELETE /v1/teams/[your_team_name]/posts/1


// Comment API
client.comments(postNumber: 1)
// #=> GET /v1/teams/[your_team_name]/posts/1/comments

client.comment(commentId: 123)
// #=> GET /v1/teams/[your_team_name]/comments/123

client.createComment(postNumber, bodyMd: "baz")
// #=> POST /v1/teams/[your_team_name]/posts/1/comments

client.updateComment(commentId, bodyMd: "bazbaz")
// #=> PATCH /v1/teams/[your_team_name]/comments/123

client.delete_comment(commentId)
// #=> DELETE /v1/teams/[your_team_name]/comments/123


// Star API
client.stargazersInPost(postNumber: 1)
// #=> GET /v1/teams/[your_team_name]/posts/1/stargazers

client.addStarInPost(postNumber: 1)
// #=> POST /v1/teams/[your_team_name]/posts/1/star

client.removeStarInPost(postNumber: 1)
// #=> DELETE /v1/teams/[your_team_name]/posts/1/star

client.stargazersInComment(commentId: 123)
// #=> GET /v1/teams/[your_team_name]/comments/123/stargazers

client.addStarInComment(commentId: 123)
// #=> POST /v1/teams/[your_team_name]/comments/123/star

client.removeStarInComment(commentId: 123)
// #=> DELETE /v1/teams/[your_team_name]/comments/123/star


// Watch API
client.watchers(postNumber: 1)
// #=> GET /v1/teams/[your_team_name]/posts/1/watchers

client.addWatch(postNumber: 1)
// #=> POST /v1/teams/[your_team_name]/posts/1/watch

client.removeWatch(postNumber: 1)
// #=> DELETE /v1/teams/[your_team_name]/posts/1/watch


// Category API
client.batchMove(from: "/foo/bar/",to: "/baz/")
// #=> POST /v1/teams/[your_team_name]/categories/batch_move


// Authenticated User API
client.user()
// #=> GET /v1/user

Contributing

  1. Fork it ( https://github.com/pixyzehn/EsaKit )
  2. Create your feature branch (git checkout -b new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin new-feature)
  5. Create a new Pull Request

Github

link
Stars: 5
Help us keep the lights on

Used By

Total: 1

Releases

0.3.1 - May 28, 2017

  • Update dependency
  • Fix the violation of SwiftLint
  • Add Package.pins for SwiftPM

0.3.0 - Apr 22, 2017

  • Removed Himotoki dependency https://github.com/pixyzehn/EsaKit/pull/35
  • Added a simple decoding implementation
  • Updated other libraries version

0.2.3 - Apr 8, 2017

  • Add new X-RateLimit-Reset in response header. https://github.com/pixyzehn/EsaKit/pull/32

0.2.2 - Mar 5, 2017

  • Add new categories API.
  • Introduce Sourcery for AutoEquatable & AutoHashable.

0.2.1 - Feb 24, 2017

  • Update dependencies
  • Fix error handling