Latest 0.3.1
Homepage https://github.com/pixyzehn/EsaKit
License MIT
Platforms ios 9.0, osx 10.10, requires ARC
Dependencies ReactiveSwift
Authors

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

Latest podspec

{
    "name": "EsaKit",
    "version": "0.3.1",
    "summary": "A Swift framework for the esa.io API.",
    "homepage": "https://github.com/pixyzehn/EsaKit",
    "license": "MIT",
    "authors": {
        "Nagasawa Hiroki": "[email protected]"
    },
    "social_media_url": "http://twitter.com/pixyzehn",
    "platforms": {
        "ios": "9.0",
        "osx": "10.10"
    },
    "source": {
        "git": "https://github.com/pixyzehn/EsaKit.git",
        "tag": "0.3.1"
    },
    "source_files": "Sources/**/*.{swift,h,m}",
    "requires_arc": true,
    "dependencies": {
        "ReactiveSwift": [
            "~> 1.0"
        ]
    },
    "pushed_with_swift_version": "3.1"
}

Pin It on Pinterest

Share This