Swiftpack.co - Enchan1207/Swiita as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by Enchan1207.
Enchan1207/Swiita 1.2.0
Simple iOS Framework for Qiita API written in Swift.
⭐️ 0
🕓 3 years ago
iOS
.package(url: "https://github.com/Enchan1207/Swiita.git", from: "1.2.0")

latest release GitHub Actions CI licence Carthage compatible SPM Compatible

Simple iOS Framework for Qiita API written in Swift.

Installation

Currently, Swiita supports some way to installation shown below:

  • Carthage
  • Swift Package Manager

Usage

Application regist

First, go Register the application - Qiita to regist your Application.
In "Callback URL", set the custom URL scheme for launching your application.(e.g. swiita-testapplication)

(If you aren't set custom URL scheme yet on your project, add it in Info.plist)
additional info.plist

Account authentication

To authenticate account, you need to add it in SceneDelegate.swift:

func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
    Swiita.handleCallback(URLContexts: URLContexts, callBack: URL(string: "{Callback URL}")!)
}

Then add this to the part that performs the authenticate function.

swiita.authorize(presentViewController: self, authority: [.read], success: { (token) in
    // access token
    print(token)
}) { (error) in
    // Error handling
}

In "authority", you can set access tokens authority.
It only accepts value of type QiitaAPIAuthority.

Instance initialization

To initialize instance, you need those params.

  • clientid: Qiita APIs application client ID.
  • clientsecret: Qiita APIs application client secret key.
  • token(Optional): Access token(if you generated beforehand, you can set it.)
/// Generate Instance.
/// - Parameters:
///     - clientid: Qiita API client ID
///     - clientsecret: Qiita API client secret
///     - apihost: Qiita API hostname
///     - token: Access token string
Swiita(clientid: "{client id}", clientsecret: "{client secret}", apihost: "{api host}", token: "{access token}")

NOTE: about parameter apihost: Using Qiita API as general user, you don't have to set it.
But if you use it as Qiita Team, you need set this parameter to {team name}.qiita.com.
Qiita Team APIs authentication needs other API endpoint. It may be supported, but it's currently unavailable.

API Request / Response

Being finished api requests without any errors, the callback function success(HTTPStatusType, JSONObject) will be performed.

HTTPStatusType is enum which has response type of API request(e.g. Successful).
JSONObject is parsed JSON object from API response.

Pagination

Some Qiita API accepts parameter "page" and "per_page".
and those responses header includes informations about paging, but currently version can't check this value.

About Qiita Team

Now, this framework doesn't support "Qiita Team"s APIs.
(Not belonging any qiita team, so I can't implement and debug those.)

GitHub

link
Stars: 0
Last commit: 3 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

SPM (Swift package manager) Compatible
3 years ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics