<commit_before># EsaKit [![MIT license](https://img.shields.io/badge/license-MIT-lightgrey.svg)](https://raw.githubusercontent.com/pixyzehn/EsaKit/master/LICENSE.md)
A Swift framework for the esa.io API

```swift
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](https://github.com/ReactiveCocoa/ReactiveSwift) and [Himotoki](https://github.com/ikesyo/Himotoki).

## Requirements

EsaKit requires / supports the following environments:

- Swift 3.0 / Xcode 8.1
- OS X 10.10 or later
- iOS 8.0 or later

## Installation

#### [Carthage](https://github.com/Carthage/Carthage)

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

#### [CocoaPods](https://github.com/cocoapods/cocoapods)

- Insert `pod 'EsaKit'` to your Podfile.
- Run `pod install`.

## Usage

```swift
// Initialization
let client = EsaClient(token: "<PASSWORD>", 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)<commit_msg>Replace single quote with double quote<commit_after># EsaKit [![MIT license](https://img.shields.io/badge/license-MIT-lightgrey.svg)](https://raw.githubusercontent.com/pixyzehn/EsaKit/master/LICENSE.md)
A Swift framework for the esa.io API

```swift
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](https://github.com/ReactiveCocoa/ReactiveSwift) and [Himotoki](https://github.com/ikesyo/Himotoki).

## Requirements

EsaKit requires / supports the following environments:

- Swift 3.0 / Xcode 8.1
- OS X 10.10 or later
- iOS 8.0 or later

## Installation

#### [Carthage](https://github.com/Carthage/Carthage)

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

#### [CocoaPods](https://github.com/cocoapods/cocoapods)

- Insert `pod 'EsaKit'` to your Podfile.
- Run `pod install`.

## Usage

```swift
// Initialization
let client = EsaClient(token: "<PASSWORD>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)
{'fraction_non_alphanumeric': 0.17500731635937958, 'fraction_numerical': 0.018729880011706175, 'mean_word_length': 4.055473372781065, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 47, 'https://': 12, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '434740', 'n_tokens_mistral': 2644, 'n_tokens_neox': 2464, 'n_words': 448}